From 515a1f2eddc19bc08be2e029557f14c7c1438cc9 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 12 Feb 2022 02:45:22 -0600 Subject: [PATCH] Move some of the uglier make.sh plumbing into portability.sh. --- scripts/make.sh | 17 ----------------- scripts/portability.sh | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/scripts/make.sh b/scripts/make.sh index a04d3306..2abb5169 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -2,23 +2,6 @@ # Grab default values for $CFLAGS and such. -if [ ! -z "$ASAN" ]; then - echo "Enabling ASan..." - # Turn ASan on. Everything except -fsanitize=address is optional, but - # but effectively required for useful backtraces. - asan_flags="-fsanitize=address \ - -O1 -g -fno-omit-frame-pointer -fno-optimize-sibling-calls" - CFLAGS="$asan_flags $CFLAGS" - HOSTCC="$HOSTCC $asan_flags" - # Ignore leaks on exit. TODO - export ASAN_OPTIONS="detect_leaks=0" -fi - -# Centos 7 bug workaround, EOL June 30 2024. -DASHN=-n; wait -n 2>/dev/null; [ $? -eq 2 ] && unset DASHN - -export LANG=c -export LC_ALL=C set -o pipefail source scripts/portability.sh diff --git a/scripts/portability.sh b/scripts/portability.sh index 19be1e6a..50793ade 100644 --- a/scripts/portability.sh +++ b/scripts/portability.sh @@ -12,3 +12,23 @@ if [ -z "$SED" ] then [ ! -z "$(command -v gsed 2>/dev/null)" ] && SED=gsed || SED=sed fi + +# Extra debug plumbing the Android guys want +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 + HOSTCC="$HOSTCC $ASAN_FLAGS" + # Ignore leaks on exit. TODO + export ASAN_OPTIONS="detect_leaks=0" +fi + +# Centos 7 bug workaround, EOL June 30 2024. +DASHN=-n; wait -n 2>/dev/null; [ $? -eq 2 ] && unset DASHN + +# If the build is using gnu tools, make them behave less randomly. +export LANG=c +export LC_ALL=C -- 2.39.2