Skip to content

Commit bdb2133

Browse files
committed
Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED)
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. Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D61689 llvm-svn: 360403
1 parent ea38ac5 commit bdb2133

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ Modified Compiler Flags
7777

7878
- `clang -dumpversion` now returns the version of Clang itself.
7979

80-
- ...
80+
- On ELF, ``-gz`` now defaults to ``-gz=zlib``. It produces ``SHF_COMPRESSED``
81+
style compression of debug information. GNU binutils 2.26 or newer, or lld is
82+
required to link produced object files. Use ``-gz=zlib-gnu`` to get the old
83+
behavior.
8184

8285
New Pragmas in Clang
8386
--------------------

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,8 +1052,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
10521052
if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
10531053
OPT_compress_debug_sections_EQ)) {
10541054
if (A->getOption().getID() == OPT_compress_debug_sections) {
1055-
// TODO: be more clever about the compression type auto-detection
1056-
Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
1055+
Opts.setCompressDebugSections(llvm::DebugCompressionType::Z);
10571056
} else {
10581057
auto DCT = llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
10591058
.Case("none", llvm::DebugCompressionType::None)

clang/tools/driver/cc1as_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
221221
if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
222222
OPT_compress_debug_sections_EQ)) {
223223
if (A->getOption().getID() == OPT_compress_debug_sections) {
224-
// TODO: be more clever about the compression type auto-detection
225-
Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
224+
Opts.CompressDebugSections = llvm::DebugCompressionType::Z;
226225
} else {
227226
Opts.CompressDebugSections =
228227
llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())

0 commit comments

Comments
 (0)