diff options
author | Rob Landley <rob@landley.net> | 2022-04-12 17:22:18 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2022-04-12 17:22:18 -0500 |
commit | cecd169cde3ccb072dbbcf1cbbf76c5e19145371 (patch) | |
tree | daf39c57c53ddae7b656f9059f3cd495fc7a534a | |
parent | c37196772962b8ea1c5b06a0e2ae24f29f3a206a (diff) | |
download | toybox-cecd169cde3ccb072dbbcf1cbbf76c5e19145371.tar.gz |
Collate ASAN setup, move generated/instlist into generated/unstripped,
use $UNSTRIPPED variable in more places and move definition to ./configure.
-rwxr-xr-x | configure | 6 | ||||
-rwxr-xr-x | scripts/change.sh | 4 | ||||
-rwxr-xr-x | scripts/install.sh | 6 | ||||
-rwxr-xr-x | scripts/make.sh | 2 | ||||
-rw-r--r-- | scripts/portability.sh | 7 |
5 files changed, 10 insertions, 15 deletions
@@ -16,17 +16,13 @@ CFLAGS="$CFLAGS -Wall -Wundef -Wno-char-subscripts -Werror=implicit-function-dec # Set default values if variable not already set : ${CC:=cc} ${HOSTCC:=cc} ${GENDIR:=generated} ${KCONFIG_CONFIG:=.config} -: ${OUTNAME:=toybox${TARGET:+-$TARGET}} +: ${UNSTRIPPED:=$GENDIR/unstripped} ${OUTNAME:=toybox${TARGET:+-$TARGET}} : ${OPTIMIZE:=-Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing} -# set ASAN=1 to enable "address sanitizer" and debuggable backtraces -[ -z "$ASAN" ] || { CFLAGS="$CFLAGS -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address"; NOSTRIP=1; } - # We accept LDFLAGS, but by default don't have anything in it if [ "$(uname)" == "Darwin" ] then : ${LDOPTIMIZE:=-Wl,-dead_strip} ${STRIP:=strip} else : ${LDOPTIMIZE:=-Wl,--gc-sections -Wl,--as-needed} ${STRIP:=strip -s -R .note* -R .comment} -# LDASNEEDED="-Wl,--as-needed" # must go at end of compiler command line fi diff --git a/scripts/change.sh b/scripts/change.sh index 99dcfde9..ad01ba24 100755 --- a/scripts/change.sh +++ b/scripts/change.sh @@ -3,7 +3,7 @@ # build each command as a standalone executable NOBUILD=1 scripts/make.sh > /dev/null && -${HOSTCC:-cc} -I . scripts/install.c -o generated/instlist && +${HOSTCC:-cc} -I . scripts/install.c -o "$UNSTRIPPED"/instlist && export PREFIX=${PREFIX:-change/} && mkdir -p "$PREFIX" || exit 1 @@ -12,7 +12,7 @@ mkdir -p "$PREFIX" || exit 1 # sh - shell builtins like "cd" and "exit" need the multiplexer # help - needs to know what other commands are enabled (use command --help) -for i in $(generated/instlist | egrep -vw "sh|help") +for i in $("$UNSTRIPPED"/instlist | egrep -vw "sh|help") do echo -n " $i" && scripts/single.sh $i > /dev/null 2>$PREFIX/${i}.bad && diff --git a/scripts/install.sh b/scripts/install.sh index 56213ade..842ff9b0 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,7 +2,7 @@ # Grab default values for $CFLAGS and such. -source ./configure +source scripts/portability.sh [ -z "$PREFIX" ] && PREFIX="$PWD/install" @@ -32,8 +32,8 @@ done echo "Compile instlist..." NOBUILD=1 scripts/make.sh -$DEBUG $HOSTCC -I . scripts/install.c -o generated/instlist || exit 1 -COMMANDS="$(generated/instlist $LONG_PATH)" +$DEBUG $HOSTCC -I . scripts/install.c -o "$UNSTRIPPED"/instlist || exit 1 +COMMANDS="$("$UNSTRIPPED"/instlist $LONG_PATH)" echo "${UNINSTALL:-Install} commands..." diff --git a/scripts/make.sh b/scripts/make.sh index d850cd61..b7bb6930 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -26,7 +26,7 @@ isnewer() echo "Generate headers from toys/*/*.c..." -mkdir -p "${UNSTRIPPED:=$GENDIR/unstripped}" +mkdir -p "$UNSTRIPPED" if isnewer "$GENDIR"/Config.in toys || isnewer "$GENDIR"/Config.in Config.in then diff --git a/scripts/portability.sh b/scripts/portability.sh index 50793ade..3e86c36c 100644 --- a/scripts/portability.sh +++ b/scripts/portability.sh @@ -13,15 +13,14 @@ then [ ! -z "$(command -v gsed 2>/dev/null)" ] && SED=gsed || SED=sed fi -# Extra debug plumbing the Android guys want +# Address Sanitizer if [ ! -z "$ASAN" ]; then - echo "Enabling ASan..." # Turn ASan on and disable most optimization to get more readable backtraces. # (Technically ASAN is just "-fsanitize=address" and the rest is optional.) ASAN_FLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls" - CFLAGS="$ASAN_FLAGS $CFLAGS" - # Run this nonsense against temporary build tools that don't ship too + CFLAGS="$CFLAGS $ASAN_FLAGS" HOSTCC="$HOSTCC $ASAN_FLAGS" + NOSTRIP=1 # Ignore leaks on exit. TODO export ASAN_OPTIONS="detect_leaks=0" fi |