Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: improve inference of compiler flags for pb builds #829

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions BUILDING
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ type of build and the installation location. For example,
specifies the installation root. Run `./configure --help` for
information on the supported options.

For platforms without support for native-code compilation in Chez
Scheme, use a machine specification like `-m=tpb64l`, which is a
threaded, 64-bit, little-endian build. The "configure" script will
still attept to infer compilation and linking flags for the kernel; if
you need to give it a hint, you can use the `--os` flag with something
like `--os=tXle`, which indicates a threaded configuration (due to the
leading "t") on Linux (due to the trailing "le").

The generated makefile mostly just ensures that a `zuo` executable is
built in a `bin` directory, and then it defers the actual build work
to `zuo`, which uses the "main.zuo" file. If you have `zuo` installed,
Expand Down
6 changes: 3 additions & 3 deletions c/build.zuo
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
kernel-srcs))

(define kernel-asm-files
(if (glob-match? "*nt" (or (lookup 'defaultm) m))
(if (glob-match? "*nt" (or (lookup 'flagsm) m))
(cond
[(and msvc?
(string=? arch "a6"))
Expand Down Expand Up @@ -510,7 +510,7 @@
[config (hash-set config 'LDFLAGS (if (as-runtime-dll? config) "/MD" "/MT"))]
[config (hash-set config 'LIBS "rpcrt4.lib ole32.lib advapi32.lib User32.lib")])
config)]
[(and (glob-match? "*nt" (hash-ref config 'defaultm ""))
[(and (glob-match? "*nt" (hash-ref config 'flagsm ""))
(glob-match? "pb*" (m->arch (hash-ref config 'm))))
(config-merge config 'CFLAGS "-DFEATURE_WINDOWS")]
[else config]))
Expand Down Expand Up @@ -554,7 +554,7 @@
(define (for-windows? config)
(or (is-msvc? config)
(glob-match? "*nt" (hash-ref config 'm))
(glob-match? "*nt" (or (hash-ref config 'defaultm #f) ""))))
(glob-match? "*nt" (or (hash-ref config 'flagsm #f) ""))))

(define (lib-build-suffix config)
(if (is-msvc? config)
Expand Down
72 changes: 52 additions & 20 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,21 @@ else
cflagsset=no
fi

# Machine type to build:
m=""

# Working directory, defaults to $m
w=""

# Machine describing the OS that the kernel runs on, so it determines
# default compiler and linker flags; when $m is a pb variant, then
# this OS is inferred if not specified with `--osmachine=`
flagsm=""

# Used to select a default $m, but in the end corresponds to
# the target machine for boot files when built via pb
defaultm=""

pb=no
pbarch=no
threads=yes
Expand Down Expand Up @@ -257,6 +270,9 @@ while [ $# != 0 ] ; do
--machine=*)
m=`echo $1 | sed -e 's/^--machine=//'`
;;
--os=*)
flagsm=`echo $1 | sed -e 's/^--os=//'`
;;
--boot=*)
mboot=`echo $1 | sed -e 's/^--boot=//'`
;;
Expand Down Expand Up @@ -477,15 +493,6 @@ if [ $emscripten = yes ] ; then
tm32=tpb32l
fi

case "$m" in
pb)
echo "Don't select pb using -m or --machine, because pb prefers to use the"
echo " machine as the kernel host machine. Instead, use --pb or --pbarch"
echo " to select a pb (portable bytecode) build."
exit 1
;;
esac

if [ "$bits" = "" ] ; then
# infer default bits; this will be irrelevant if a machine is specified
if [ "$unamebits" != "" ] ; then
Expand All @@ -506,7 +513,14 @@ fi
# to the host platform's threadedness, and we want that to default
# the same way as when `--pb` is not used
if [ "$threads" = "" ] ; then
defaultthreads=yes
case "$m" in
pb*)
defaultthreads=no
;;
*)
defaultthreads=yes
;;
esac
else
defaultthreads=$threads
fi
Expand Down Expand Up @@ -542,36 +556,48 @@ if [ "$m" = "" ] ; then
machine_supplied=no
if [ $pb = yes ] ; then
m=pb
if [ "$threads" = yes ] ; then m=t$m ; fi
if [ $bits = 64 ] ; then mpbhost=$m64 ; else mpbhost=$m32 ; fi
flagsm=$mpbhost
if [ "$mpbhost" = "" ] ; then
flagsm=unknown
if [ $bits = 64 ] ; then defaultflagsm=$m64 ; else defaultflagsm=$m32 ; fi
if [ "$defaultflagsm" = "" ] ; then
defaultflagsm=unknown
fi
if [ "$threads" = yes ] ; then
m=t$m
defaultflagsm=t$defaultflagsm
fi
else
if [ "$unknownm" != "yes" ] ; then
m=$defaultm
fi
flagsm=$defaultm
# note that m (and flagsm) could still be "" at this point, in which
defaultflagsm=$defaultm
# note that m (and defaultflagsm) could still be "" at this point, in which
# case "No suitable machine type" will be reported further below
fi
elif [ $pb = yes ] ; then
mpbhost=$m
flagsm=$m
defaultflagsm=$m
m=pb
else
flagsm=$m
case "${m}" in
pb*|tpb*)
defaultflagsm=$defaultm
;;
*)
defaultflagsm=$m
esac
defaultm=$m
fi

if [ $pbarch = yes ] ; then
m=pb$bits$pbendian
if [ "$defaultthreads" = yes ] ; then
m=t$m
defaultflagsm=t$defaultflagsm
fi
fi

if [ "$flagsm" = "" ] ; then
flagsm=$defaultflagsm
fi

if [ "$mboot" = "" ] ; then
mboot="$m"
else
Expand Down Expand Up @@ -623,6 +649,7 @@ if [ "$help" = "yes" ]; then
echo "Options (defaults shown in parens):"
echo " --machine=<machine type> explicitly specify machine type ($m)"
echo " -m=<machine type> same as --machine=<machine type> ($m)"
echo " --os=<machine type> specify OS as a machine type ($flagsm)"
echo " --threads specify threaded version ($threads)"
echo " --nothreads specify non-threaded version ($nothreads)"
echo " --32|--64 specify 32/64-bit version ($bits)"
Expand Down Expand Up @@ -1042,6 +1069,10 @@ else
configuringin=" in $w"
fi

if [ "$flagsm" != "$m" ] ; then
configuringin="$configuringin to run on $flagsm"
fi

if [ "$m" = "" ] ; then
enableFrompb=no
forceworkarea=no
Expand Down Expand Up @@ -1113,6 +1144,7 @@ srcdir=$srcdir
upsrcdir=$upsrcdir
m=$m
defaultm=$defaultm
flagsm=$flagsm
mboot=$mboot
buildKernelOnly=$buildKernelOnly
enableFrompb=$enableFrompb
Expand Down