From 8e880181f2cb365c80f0b05ac452710ece8a9d0c Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 26 Oct 2017 14:52:08 +0000 Subject: Disable debug section compression in stage3 The objcopy tool that we built in stage2 doesn't have zlib support, so it can't handle the `--compress-debug-sections` flag that BuildStream passes by default. --- elements/gnu-toolchain/binutils.bst | 4 ++++ elements/gnu-toolchain/busybox.bst | 4 ++++ elements/gnu-toolchain/ccache.bst | 4 ++++ elements/gnu-toolchain/fhs-dirs.bst | 4 ++++ elements/gnu-toolchain/gawk.bst | 4 ++++ elements/gnu-toolchain/gcc.bst | 4 ++++ elements/gnu-toolchain/glibc.bst | 4 ++++ elements/gnu-toolchain/m4-tarball.bst | 4 ++++ elements/gnu-toolchain/make.bst | 4 ++++ elements/gnu-toolchain/stage1-binutils.bst | 4 ++++ elements/gnu-toolchain/zlib.bst | 4 ++++ project.conf | 26 ++++++++++++++++++++++++++ 12 files changed, 70 insertions(+) diff --git a/elements/gnu-toolchain/binutils.bst b/elements/gnu-toolchain/binutils.bst index 5983c465..0548af41 100644 --- a/elements/gnu-toolchain/binutils.bst +++ b/elements/gnu-toolchain/binutils.bst @@ -22,3 +22,7 @@ config: - | ./configure --prefix="%{prefix}" --disable-nls --disable-werror \ --with-system-zlib + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/busybox.bst b/elements/gnu-toolchain/busybox.bst index be14fa51..ef86087c 100644 --- a/elements/gnu-toolchain/busybox.bst +++ b/elements/gnu-toolchain/busybox.bst @@ -102,3 +102,7 @@ config: MANDATORY_MANPATH /usr/share/man MANDATORY_MANPATH /usr/local/share/man EOF + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/ccache.bst b/elements/gnu-toolchain/ccache.bst index f66a37ca..7e435476 100644 --- a/elements/gnu-toolchain/ccache.bst +++ b/elements/gnu-toolchain/ccache.bst @@ -26,3 +26,7 @@ config: done - for cc in gcc cc g++ c++; do ln -sf "%{prefix}/bin/ccache" "%{install-root}%{prefix}/lib/ccache/%{target}-$cc"; done + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/fhs-dirs.bst b/elements/gnu-toolchain/fhs-dirs.bst index 36b6236c..7d9702db 100644 --- a/elements/gnu-toolchain/fhs-dirs.bst +++ b/elements/gnu-toolchain/fhs-dirs.bst @@ -58,3 +58,7 @@ arches: (>): - mkdir -p "%{install-root}/usr/lib64" - ln -s "./usr/lib64" "%{install-root}/lib64" + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/gawk.bst b/elements/gnu-toolchain/gawk.bst index 7a612bfd..d00bd6d8 100644 --- a/elements/gnu-toolchain/gawk.bst +++ b/elements/gnu-toolchain/gawk.bst @@ -18,3 +18,7 @@ environment: config: configure-commands: - ./configure --prefix="%{prefix}" --disable-nls + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/gcc.bst b/elements/gnu-toolchain/gcc.bst index e9a54834..5c43ca24 100644 --- a/elements/gnu-toolchain/gcc.bst +++ b/elements/gnu-toolchain/gcc.bst @@ -65,3 +65,7 @@ config: for fortran_alias in f77 f90 f95; do ln -s gfortran "%{install-root}%{prefix}/bin/$fortran_alias" done + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/glibc.bst b/elements/gnu-toolchain/glibc.bst index 9772baa5..a541a771 100644 --- a/elements/gnu-toolchain/glibc.bst +++ b/elements/gnu-toolchain/glibc.bst @@ -69,3 +69,7 @@ config: include /etc/ld.so.conf.d/*.conf EOF - install -m 644 -o root -g root ld.so.conf "%{install-root}/etc/ld.so.conf" + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/m4-tarball.bst b/elements/gnu-toolchain/m4-tarball.bst index 1019c57a..af3732c9 100644 --- a/elements/gnu-toolchain/m4-tarball.bst +++ b/elements/gnu-toolchain/m4-tarball.bst @@ -18,3 +18,7 @@ environment: config: configure-commands: - ./configure --prefix="%{prefix}" --disable-gcc-warnings + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/make.bst b/elements/gnu-toolchain/make.bst index 731d1a9f..c6192008 100644 --- a/elements/gnu-toolchain/make.bst +++ b/elements/gnu-toolchain/make.bst @@ -19,3 +19,7 @@ config: configure-commands: - ./configure --prefix="%{prefix}" --disable-nls + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/stage1-binutils.bst b/elements/gnu-toolchain/stage1-binutils.bst index 72d51bcb..a1a27326 100644 --- a/elements/gnu-toolchain/stage1-binutils.bst +++ b/elements/gnu-toolchain/stage1-binutils.bst @@ -36,3 +36,7 @@ config: --host=$(sh config.guess) \ --target=%{target-stage1} \ --with-sysroot=/nonexistentdir --with-lib-path="=%{prefix}/lib:=%{prefix}/lib64" + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/elements/gnu-toolchain/zlib.bst b/elements/gnu-toolchain/zlib.bst index 1dd353c5..b7b06bab 100644 --- a/elements/gnu-toolchain/zlib.bst +++ b/elements/gnu-toolchain/zlib.bst @@ -21,3 +21,7 @@ config: - make install-commands: - make DESTDIR="%{install-root}" install + + strip-commands: + - | + %{stage3-strip-binaries} diff --git a/project.conf b/project.conf index 18023773..699a1ce8 100644 --- a/project.conf +++ b/project.conf @@ -34,6 +34,32 @@ variables: %{target-stage1}-strip --remove-section=.comment --remove-section=.note --strip-unneeded "$1" %{target-stage1}-objcopy --add-gnu-debuglink "$debugfile" "$1"' - {} ';' + # BuildStream passes `--compress-debug-sections` to objcopy; this would be + # great if it worked but in stage3 builds I see errors like this: + # + # BFD: /buildstream/install/usr/bin/gcc-ranlib: unable to initialize compress status for section .debug_aranges + # objcopy:/buildstream/install/usr/bin/gcc-ranlib: Invalid operation + # + # This causes debug stripping to just not happen, which makes the stage3 + # sysroot huge. I haven't investigated the cause, but I guess we need to + # build zlib in stage2 for the feature to work. + stage3-strip-binaries: | + find "%{install-root}" -type f \ + '(' -perm -111 -o -name '*.so*' \ + -o -name '*.cmxs' -o -name '*.node' ')' \ + -exec sh -ec \ + 'read -n4 hdr <"$1" # check for elf header + if [ "$hdr" != "$(printf \\x7fELF)" ]; then + exit 0 + fi + debugfile="%{install-root}%{debugdir}/$(basename "$1")" + mkdir -p "$(dirname "$debugfile")" + objcopy --only-keep-debug "$1" "$debugfile" + chmod 644 "$debugfile" + strip --remove-section=.comment --remove-section=.note --strip-unneeded "$1" + objcopy --add-gnu-debuglink "$debugfile" "$1"' - {} ';' + + artifacts: pull-url: https://ostree.baserock.org/cache/ -- cgit v1.2.1