aboutsummaryrefslogtreecommitdiff
path: root/core/binutils
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-06-08 14:27:33 +0300
committerCem Keylan <cem@ckyln.com>2020-06-08 14:27:33 +0300
commitb2ec62574ed8f6417f57f8f3d3f98d3d0967876e (patch)
tree3cc41855e62fa6457991425c327aed98a2b18baa /core/binutils
parent5aa3a0822c81791cdce2cbac428d9bd4e12b6886 (diff)
downloadrepository-b2ec62574ed8f6417f57f8f3d3f98d3d0967876e.tar.gz
binutils: link statically
Diffstat (limited to 'core/binutils')
-rwxr-xr-xcore/binutils/build37
1 files changed, 33 insertions, 4 deletions
diff --git a/core/binutils/build b/core/binutils/build
index 67a1af16..06e14461 100755
--- a/core/binutils/build
+++ b/core/binutils/build
@@ -1,12 +1,15 @@
#!/bin/sh -e
+export LDFLAGS="$LDFLAGS -static"
+export CCLD="${CC:-cc} -all-static"
+
# Architecture specific build options
case ${3:-$(uname -m)} in
i*86) archopts="--build=i686-pc-linux-musl \
--host=i686-pc-linux-musl \
--enable-64-bit-bfd" ;;
- x86_64) archopts="--build=x86_64-pc-linux-musl \
- --host=x86_64-pc-linux-musl"
+ x86-64) archopts="--build=x86_64-pc-linux-musl \
+ --host=x86-64-pc-linux-musl"
esac
cat > makeinfo <<EOF
@@ -24,13 +27,39 @@ export PATH=$PATH:$PWD
$archopts \
--enable-targets=x86_64-pep \
--disable-multilib \
+ --disable-shared \
--disable-werror \
--disable-gdb \
--disable-nls \
--disable-readline \
--disable-gprof \
--with-mmap \
+ --with-static-standard-libraries \
--with-system-zlib
-make
-make DESTDIR="$1" install
+# Linking binutils statically is HARD. configure script
+# and the main Makefile straight up ignores our flags.
+#
+# I would have never thought that linking binutils
+# statically would lead to a size reduction, but
+# it gets 2MB smaller (25 to 23MB).
+make configure-bfd
+make configure-ld
+make configure-libctf
+
+make -C libiberty CCLD="$CCLD"
+make -C bfd CCLD="$CCLD"
+make -C libctf CCLD="$CCLD"
+make -C ld CCLD="$CCLD"
+
+make configure-opcodes
+make configure-binutils
+make configure-gas
+
+make -C opcodes CCLD="$CCLD"
+make -C binutils CCLD="$CCLD"
+make -C gas CCLD="$CCLD"
+
+for dir in libiberty bfd libctf ld opcodes binutils gas; do
+ make -C "$dir" DESTDIR="$1" install
+done