Skip to content

Commit

Permalink
fix stage0 build issues on host distros with compressed debug sections
Browse files Browse the repository at this point in the history
distros using bleeding edge binutils default to produce compressed debug
sections, even if debug info was disabled via -g0 in CFLAGS, which leads
to error message like the following as soon as stage0 is built and the
user tries to use the toolchain (e.g., for building stage1):

/lib/gcc/x86_64-unknown-linux-gnu/3.4.6/../../../crti.o:
file not recognized: File format not recognized

or

/bin/ld: /lib/gcc/x86_64-unknown-linux-gnu/3.4.6/../../../crtn.o:
unable to initialize decompress status for section .debug_aranges

more info in this PR: richfelker/musl-cross-make#73

other distros would probably just update to latest binutils to mitigate such
an issue, but this opens pandora's box and leads to a chain of consequences
such that gdb needs to be updated too, newer versions of which now use C++,
etc.
seen from a different PoV, sticking with an older and well-test binutils
version for the time being has the nice effect that binaries produced on
sabotage are way more portable and can be debugged with e.g. a 10 year old
gdb without issues.
  • Loading branch information
rofl0r committed Aug 28, 2021
1 parent 9dd878a commit 2cf2795
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions KEEP/etc/butch-optflags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ cflags_speed="-O3 -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip
ldflags_base="-Wl,-z,relro,-z,now -Wl,-z,text"
ldflags_size="-Wl,--gc-sections"

if [ "$STAGE" = 0 ] ; then
cflags_base="$cflags_base -Wa,--compress-debug-sections=none"
ldflags_base="$ldflags_base -Wl,--compress-debug-sections=none"
fi

if [ "$OPT_KEEP_DEBUG" = 1 ] ; then
cflags_base="$cflags_base -g"
else
Expand Down

0 comments on commit 2cf2795

Please sign in to comment.