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. --- project.conf | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'project.conf') 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