]> granicus.if.org Git - clang/commitdiff
Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED)
authorFangrui Song <maskray@google.com>
Fri, 10 May 2019 02:08:21 +0000 (02:08 +0000)
committerFangrui Song <maskray@google.com>
Fri, 10 May 2019 02:08:21 +0000 (02:08 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360403 91177308-0d34-0410-b5e6-96231b3b80d8

docs/ReleaseNotes.rst
lib/Frontend/CompilerInvocation.cpp
tools/driver/cc1as_main.cpp

index 1f09655027fc46940b4f0565401830a87be0c8fb..cf15a024fca335d34b372d30c2cd5ebc0ad54d5d 100644 (file)
@@ -77,7 +77,10 @@ Modified Compiler Flags
 
 - `clang -dumpversion` now returns the version of Clang itself.
 
-- ...
+- On ELF, ``-gz`` now defaults to ``-gz=zlib``. It produces ``SHF_COMPRESSED``
+  style compression of debug information. GNU binutils 2.26 or newer, or lld is
+  required to link produced object files. Use ``-gz=zlib-gnu`` to get the old
+  behavior.
 
 New Pragmas in Clang
 --------------------
index ca95dec16184a3c596cf6af1387e24bcf11ce980..21bcd7aa09448342921dc76bdffb832027a57eac 100644 (file)
@@ -1052,8 +1052,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
                                      OPT_compress_debug_sections_EQ)) {
     if (A->getOption().getID() == OPT_compress_debug_sections) {
-      // TODO: be more clever about the compression type auto-detection
-      Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
+      Opts.setCompressDebugSections(llvm::DebugCompressionType::Z);
     } else {
       auto DCT = llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
                      .Case("none", llvm::DebugCompressionType::None)
index c0334609be5f76f1fefde08198a36065dc3d25c2..f9c25399b372c016465b0953ad8c78867dadf463 100644 (file)
@@ -221,8 +221,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
                                      OPT_compress_debug_sections_EQ)) {
     if (A->getOption().getID() == OPT_compress_debug_sections) {
-      // TODO: be more clever about the compression type auto-detection
-      Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
+      Opts.CompressDebugSections = llvm::DebugCompressionType::Z;
     } else {
       Opts.CompressDebugSections =
           llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())