aboutsummaryrefslogtreecommitdiff
path: root/scripts/portability.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/portability.sh')
-rw-r--r--scripts/portability.sh22
1 files changed, 13 insertions, 9 deletions
diff --git a/scripts/portability.sh b/scripts/portability.sh
index 3af2be5f..4241916a 100644
--- a/scripts/portability.sh
+++ b/scripts/portability.sh
@@ -2,9 +2,9 @@
source ./configure
-if [ -z "$(command -v "${CROSS_COMPILE}${CC}")" ]
+if [ -z "$(command -v "$CROSS_COMPILE$CC")" ]
then
- echo "No ${CROSS_COMPILE}${CC} found" >&2
+ echo "No $CROSS_COMPILE$CC found" >&2
exit 1
fi
@@ -16,26 +16,30 @@ fi
# Tell linker to do dead code elimination at function level
if [ "$(uname)" == "Darwin" ]
then
+ CFLAGS+=" -Wno-deprecated-declarations"
: ${LDOPTIMIZE:=-Wl,-dead_strip} ${STRIP:=strip}
else
: ${LDOPTIMIZE:=-Wl,--gc-sections -Wl,--as-needed} ${STRIP:=strip -s -R .note* -R .comment}
fi
+# Disable a pointless warning only clang produces
+[ -n "$("$CROSS_COMPILE$CC" --version | grep -w clang)" ] &&
+ CFLAGS+=" -Wno-string-plus-int -Wno-invalid-source-encoding"
+
# Address Sanitizer
-if [ ! -z "$ASAN" ]; then
+if [ -n "$ASAN" ]; then
# 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="$CFLAGS $ASAN_FLAGS"
- HOSTCC="$HOSTCC $ASAN_FLAGS"
- NOSTRIP=1
+ export CFLAGS="$CFLAGS -fsanitize=address -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls"
+ export NOSTRIP=1
# Ignore leaks on exit. TODO
export ASAN_OPTIONS="detect_leaks=0"
+ # only do this once
unset ASAN
fi
-# Centos 7 bug workaround, EOL June 30 2024. TODO
-DASHN=-n; wait -n 2>/dev/null; [ $? -eq 2 ] && unset DASHN
+# Probe number of available processors, and add one.
+: ${CPUS:=$(($(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)+1))}
# If the build is using gnu tools, make them behave less randomly.
export LANG=c