From 4cfe49aebb224ba49f153ee3cd6c5994bb5d880c Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Mon, 18 Jan 2021 03:48:06 +0000 Subject: [PATCH] package: involve $CCFLAGS when determing 64-bit arch (re: 9a48ba15) bin/package, src/cmd/INIT/package.sh: - It can depend on the compiler flags passed whether the compiler produces code for a 64-bit architecture, so pass $CCFLAGS to the compiler when testing whether it creates 64-bit object code. README.md: - Copy-edit of build instructions. --- README.md | 20 ++++++++++++++++---- bin/package | 2 +- src/cmd/INIT/package.sh | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 158f93e60..508272924 100644 --- a/README.md +++ b/README.md @@ -55,15 +55,27 @@ improved release out there. ## Build -After cloning this repo, cd to the top directory of it and run: +After downloading a release or cloning the ksh git repository, cd to the top +directory of it and run: ```sh bin/package make ``` If you have trouble or want to tune the binaries, you may pass additional -compiler and linker flags by appending it to the command shown above. E.g.: +compiler and linker flags. It is usually best to export these as environment +variables *before* running `bin/package` as they could change the name of +the build subdirectory of the `arch` directory, so exporting them is a +convenient way to keep them consistent between build and test commands. +**Note that this system uses `CCFLAGS` instead of the usual `CFLAGS`.** +An example that makes Solaris Studio cc produce a 64-bit binary: ```sh -bin/package make \ - SHELL=/bin/bash CCFLAGS="-xc99 -D_XPG6 -m64 -xO4" LDFLAGS="-m64" +export CCFLAGS="-xc99 -m64 -O2" LDFLAGS="-m64" +bin/package make +``` +Alternatively you can append these to the command, and they will only be +used for that command. You can also specify an alternative shell in which +to run the build scripts this way. For example: +```sh +bin/package make SHELL=/bin/bash CCFLAGS="-O2 -I/opt/local/include" LDFLAGS="-L/opt/local/lib" ``` For more information run ```sh diff --git a/bin/package b/bin/package index d0fe93525..a96774a77 100755 --- a/bin/package +++ b/bin/package @@ -2529,7 +2529,7 @@ int b() { return 0; } tmp=hi$$ trap 'rm -f $tmp.*' 0 1 2 echo 'int main() { return 0; }' > $tmp.a.c - $cc -o $tmp.a.exe $tmp.a.c /dev/null 2>&1 + $cc $CCFLAGS -o $tmp.a.exe $tmp.a.c /dev/null 2>&1 file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g" ` case $bits in *64*) bits=64 ;; diff --git a/src/cmd/INIT/package.sh b/src/cmd/INIT/package.sh index ba9455571..d1dbf990b 100644 --- a/src/cmd/INIT/package.sh +++ b/src/cmd/INIT/package.sh @@ -2528,7 +2528,7 @@ int b() { return 0; } tmp=hi$$ trap 'rm -f $tmp.*' 0 1 2 echo 'int main() { return 0; }' > $tmp.a.c - $cc -o $tmp.a.exe $tmp.a.c /dev/null 2>&1 + $cc $CCFLAGS -o $tmp.a.exe $tmp.a.c /dev/null 2>&1 file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g" ` case $bits in *64*) bits=64 ;;