Page MenuHomePhabricator

Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED)
ClosedPublic

Authored by MaskRay on May 8 2019, 9:15 AM.

Details

Summary

Since July 15, 2015 (binutils-gdb commit
19a7fe52ae3d0971e67a134bcb1648899e21ae1c, included in 2.26), gas
--compress-debug-sections=zlib (gcc -gz) means zlib-gabi:
SHF_COMPRESSED. Before that it meant zlib-gnu (.zdebug).

clang's -gz was introduced in rC306115 (Jun 2017) to indicate zlib-gnu. It
is 2019 now and it is not unreasonable to assume users of the new
feature to have new linkers (ld.bfd/gold >= 2.26, lld >= rLLD273661).

Change clang's default accordingly to improve standard conformance.
zlib-gnu becomes out of fashion and gets poorer toolchain support.
Its mangled names confuse tools and are more likely to cause problems.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.May 8 2019, 9:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 8 2019, 9:15 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I don't really have a problem with this change. But, if we make this change, please include a change to the release notes *now*. This is something which may catch users off guard and confuse them and require them to go looking for what happened.

As an aside, I think that it is high time that we consider the -mlinker-version= option coming over to Linux (and Windows?). macOS has had this option for a long time, and it allows you to properly control the linker invocation because you know what version of the linker you are using (with a default version that is determined at runtime).

compnerd accepted this revision.May 9 2019, 10:05 AM

(Accepting with the condition that you will update the release notes before committing)

This revision is now accepted and ready to land.May 9 2019, 10:05 AM
MaskRay updated this revision to Diff 198970.May 9 2019, 6:42 PM
MaskRay edited the summary of this revision. (Show Details)

Update release notes

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 9 2019, 7:06 PM

So, while I think this is an entirely reasonable assumption in most cases, it's also not one that provides any kind of workaround for the few cases where it's not universally true.

  • As mentioned in the patch, this effectively changes the default from -gz=zlib-gnu to -gz=zlib. Anyone with an older toolchain that wants the old behavior can set -gz=zlib-gnu. Seems OK so far.
  • However, passing the -gz flag also implies sending --compress-debug-sections=XXX to the assembler, which -- if someone is using -no-integrated-as has an older toolchain -- is not a supported option (at least the variant that takes a value).

In other works, for the few users that have an older toolchain, this provides literally no workaround. Not setting the flag causes failures with an older linker, and setting the flag causes failures with the assembler.

(echristo reverted this in rL360703, I wanted to add some context)