[Toybox] [PATCH] macOS: Apple's ancient linker doesn't have --as-needed or --gc-sections.
enh
enh at google.com
Fri Nov 30 13:48:37 PST 2018
---
configure | 6 +++++-
scripts/make.sh | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 58e754ad..06d7cbab 100755
--- a/configure
+++ b/configure
@@ -22,7 +22,11 @@ CFLAGS="$CFLAGS -funsigned-char"
[ -z "$OPTIMIZE" ] && 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
-[ -z "$LDOPTIMIZE" ] && LDOPTIMIZE="-Wl,--gc-sections"
+if [ "$(uname)" != "Darwin" ]
+then
+ [ -z "$LDOPTIMIZE" ] && LDOPTIMIZE="-Wl,--gc-sections"
+ LDASNEEDED="-Wl,--as-needed"
+fi
# The makefile provides defaults for these, so this only gets used if
# you call scripts/make.sh and friends directly.
diff --git a/scripts/make.sh b/scripts/make.sh
index 306a7cda..640dcbed 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -115,7 +115,7 @@ then
for i in util crypt m resolv selinux smack attr rt crypto z log
do
echo "int main(int argc, char *argv[]) {return 0;}" | \
- ${CROSS_COMPILE}${CC} $CFLAGS $LDFLAGS -xc - -o
generated/libprobe -Wl,--as-needed -l$i > /dev/null 2>/dev/null &&
+ ${CROSS_COMPILE}${CC} $CFLAGS $LDFLAGS -xc - -o
generated/libprobe $LDASNEEDED -l$i > /dev/null 2>/dev/null &&
echo -l$i >> generated/optlibs.dat
echo -n .
done
@@ -125,7 +125,7 @@ fi
# LINK needs optlibs.dat, above
-LINK="$(echo $LDOPTIMIZE $LDFLAGS -o "$UNSTRIPPED" -Wl,--as-needed
$(cat generated/optlibs.dat))"
+LINK="$(echo $LDOPTIMIZE $LDFLAGS -o "$UNSTRIPPED" $LDASNEEDED $(cat
generated/optlibs.dat))"
genbuildsh > generated/build.sh && chmod +x generated/build.sh || exit 1
#TODO: "make $SED && make" doesn't regenerate config.h because diff .config
--
2.19.0.605.g01d371f741-goog
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-macOS-Apple-s-ancient-linker-doesn-t-have-as-needed-.patch
Type: application/octet-stream
Size: 2022 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20181130/b3698859/attachment.obj>
More information about the Toybox
mailing list