mirror of
https://codeberg.org/landley/toybox.git
synced 2026-01-26 14:13:25 +00:00
Collate ASAN setup, move generated/instlist into generated/unstripped,
use $UNSTRIPPED variable in more places and move definition to ./configure.
This commit is contained in:
parent
c371967729
commit
cecd169cde
6
configure
vendored
6
configure
vendored
@ -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
|
||||
|
||||
@ -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 &&
|
||||
|
||||
@ -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..."
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user