2019-01-19 14:58:04 -08:00
|
|
|
# sourced to find alternate names for things
|
|
|
|
|
2021-11-20 00:54:13 -08:00
|
|
|
source ./configure
|
2019-03-21 13:53:18 -07:00
|
|
|
|
2022-11-21 20:48:12 -08:00
|
|
|
if [ -z "$(command -v "$CROSS_COMPILE$CC")" ]
|
2019-03-21 13:53:18 -07:00
|
|
|
then
|
2022-11-21 20:48:12 -08:00
|
|
|
echo "No $CROSS_COMPILE$CC found" >&2
|
2019-03-21 13:53:18 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-01-19 14:58:04 -08:00
|
|
|
if [ -z "$SED" ]
|
|
|
|
then
|
2019-06-29 05:52:00 -07:00
|
|
|
[ ! -z "$(command -v gsed 2>/dev/null)" ] && SED=gsed || SED=sed
|
2019-01-19 14:58:04 -08:00
|
|
|
fi
|
2022-02-12 00:45:22 -08:00
|
|
|
|
2022-04-12 15:25:51 -07:00
|
|
|
# Tell linker to do dead code elimination at function level
|
|
|
|
if [ "$(uname)" == "Darwin" ]
|
|
|
|
then
|
2022-05-16 13:45:43 -07:00
|
|
|
CFLAGS+=" -Wno-deprecated-declarations"
|
2022-04-12 15:25:51 -07:00
|
|
|
: ${LDOPTIMIZE:=-Wl,-dead_strip} ${STRIP:=strip}
|
|
|
|
else
|
|
|
|
: ${LDOPTIMIZE:=-Wl,--gc-sections -Wl,--as-needed} ${STRIP:=strip -s -R .note* -R .comment}
|
|
|
|
fi
|
|
|
|
|
2023-12-29 14:46:41 -08:00
|
|
|
# Disable pointless warnings only clang produces
|
2022-11-21 20:48:12 -08:00
|
|
|
[ -n "$("$CROSS_COMPILE$CC" --version | grep -w clang)" ] &&
|
2023-12-29 14:46:41 -08:00
|
|
|
CFLAGS+=" -Wno-string-plus-int -Wno-invalid-source-encoding" ||
|
|
|
|
# And ones only gcc produces
|
|
|
|
CFLAGS+=" -Wno-restrict -Wno-format-overflow"
|
2022-09-14 00:43:39 -07:00
|
|
|
|
2022-04-12 15:22:18 -07:00
|
|
|
# Address Sanitizer
|
2022-11-21 20:48:12 -08:00
|
|
|
if [ -n "$ASAN" ]; then
|
2022-02-12 00:45:22 -08:00
|
|
|
# Turn ASan on and disable most optimization to get more readable backtraces.
|
|
|
|
# (Technically ASAN is just "-fsanitize=address" and the rest is optional.)
|
2024-07-10 17:49:54 -07:00
|
|
|
export CFLAGS="$CFLAGS -fsanitize=address -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls -static-libasan"
|
2022-11-21 21:14:40 -08:00
|
|
|
export NOSTRIP=1
|
2022-02-12 00:45:22 -08:00
|
|
|
# Ignore leaks on exit. TODO
|
|
|
|
export ASAN_OPTIONS="detect_leaks=0"
|
2022-11-21 21:14:40 -08:00
|
|
|
# only do this once
|
2022-04-12 16:09:47 -07:00
|
|
|
unset ASAN
|
2022-02-12 00:45:22 -08:00
|
|
|
fi
|
|
|
|
|
2022-05-15 17:39:27 -07:00
|
|
|
# Probe number of available processors, and add one.
|
|
|
|
: ${CPUS:=$(($(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)+1))}
|
|
|
|
|
2022-02-12 00:45:22 -08:00
|
|
|
# If the build is using gnu tools, make them behave less randomly.
|
|
|
|
export LANG=c
|
|
|
|
export LC_ALL=C
|