diff --git a/configure b/configure index edaa3dad5..c718e83b6 100755 --- a/configure +++ b/configure @@ -20,9 +20,3 @@ CFLAGS="$CFLAGS -Wall -Wundef -Wno-char-subscripts -Werror=implicit-function-dec : ${OPTIMIZE:=-Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing} # 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} -fi diff --git a/scripts/portability.sh b/scripts/portability.sh index 3e86c36c7..1ee438702 100644 --- a/scripts/portability.sh +++ b/scripts/portability.sh @@ -13,6 +13,14 @@ then [ ! -z "$(command -v gsed 2>/dev/null)" ] && SED=gsed || SED=sed fi +# Tell linker to do dead code elimination at function level +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} +fi + # Address Sanitizer if [ ! -z "$ASAN" ]; then # Turn ASan on and disable most optimization to get more readable backtraces.