summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-06-11 17:49:23 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-06-11 17:49:23 +0000
commit7289ba91651025808071e90d79e1619e9a88aa08 (patch)
treeb1cc366f18271da31a72f09388b8d4d180b6b170 /clang/lib/Frontend/CompilerInvocation.cpp
parentd3ba0ac2a523f8dd25c1c77a52eab094872d66a2 (diff)
downloadbcm5719-llvm-7289ba91651025808071e90d79e1619e9a88aa08.tar.gz
bcm5719-llvm-7289ba91651025808071e90d79e1619e9a88aa08.zip
Driver: add support for `-gz` and `-gz=`
These options control the behaviour of the compression of debug info sections on ELF targets. Our behaviour slightly diverges from the behaviour of GCC. `-gz` maps to the `-compress-debug-sections` rather than `-compress-debug-sections=zlib` or `-compress-debug-sections=zlib-gnu`. This small divergence allows us to be compatible across versions of binutils (=zlib support was introduced in 2.26, while earlier versions only support =zlib-gnu). This also allows users to not have to worry about the version of the assembler they may be using if they are not using the IAS. Previously, users would have had to go through the internal option `-compress-debug-sectionss` and pass that through to the assembler, which is no longer needed. llvm-svn: 305165
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index bb635b7ad71..4fd4872f385 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -739,9 +739,22 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
Opts.CallFEntry = Args.hasArg(OPT_mfentry);
Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
- // TODO: map this from -gz in the driver and give it a named value
- if (Args.hasArg(OPT_compress_debug_sections))
- Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
+
+ 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);
+ } else {
+ auto DCT = llvm::StringSwitch<llvm::DebugCompressionType>(A->getValue())
+ .Case("none", llvm::DebugCompressionType::None)
+ .Case("zlib", llvm::DebugCompressionType::Z)
+ .Case("zlib-gnu", llvm::DebugCompressionType::GNU)
+ .Default(llvm::DebugCompressionType::None);
+ Opts.setCompressDebugSections(DCT);
+ }
+ }
+
Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
for (auto A : Args.filtered(OPT_mlink_bitcode_file, OPT_mlink_cuda_bitcode)) {
OpenPOWER on IntegriCloud