From: Saleem Abdulrasool Date: Sun, 11 Jun 2017 17:49:17 +0000 (+0000) Subject: Driver: pass along [-]-[no]compress-debug-sections unfiltered X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9a2469400780e701d911fd294fcebaa40e7a99c;p=clang Driver: pass along [-]-[no]compress-debug-sections unfiltered Rather than validating the flags, pass them through without any validation. Arguments passed via -Wa or -Xassembler are passed directly to the assembler without validation. The validation was previously required since we did not provide proper driver level support for controlling the debug compression on ELF targets. A subsequent change will add support for the `-gz` and `-gz=` flags which provide proper driver level control of the ELF compressed debug sections. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305164 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 6d3dbb5b52..87ca065a46 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -1744,10 +1744,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, // arg after parsing the '-I' arg. bool TakeNextArg = false; - // When using an integrated assembler, translate -Wa, and -Xassembler - // options. - bool CompressDebugSections = false; - bool UseRelaxRelocations = ENABLE_X86_RELAX_RELOCATIONS; const char *MipsTargetFeature = nullptr; for (const Arg *A : @@ -1822,12 +1818,11 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back("-massembler-fatal-warnings"); } else if (Value == "--noexecstack") { CmdArgs.push_back("-mnoexecstack"); - } else if (Value == "-compress-debug-sections" || - Value == "--compress-debug-sections") { - CompressDebugSections = true; - } else if (Value == "-nocompress-debug-sections" || + } else if (Value.startswith("-compress-debug-sections") || + Value.startswith("--compress-debug-sections") || + Value == "-nocompress-debug-sections" || Value == "--nocompress-debug-sections") { - CompressDebugSections = false; + CmdArgs.push_back(Value.data()); } else if (Value == "-mrelax-relocations=yes" || Value == "--mrelax-relocations=yes") { UseRelaxRelocations = true; @@ -1880,12 +1875,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, } } } - if (CompressDebugSections) { - if (llvm::zlib::isAvailable()) - CmdArgs.push_back("-compress-debug-sections"); - else - D.Diag(diag::warn_debug_compression_unavailable); - } if (UseRelaxRelocations) CmdArgs.push_back("--mrelax-relocations"); if (MipsTargetFeature != nullptr) { diff --git a/test/Driver/compress.c b/test/Driver/compress.c index 6cdc6b7224..e7ee83bce5 100644 --- a/test/Driver/compress.c +++ b/test/Driver/compress.c @@ -1,8 +1,20 @@ -// RUN: %clang -### -c -integrated-as -Wa,-compress-debug-sections %s 2>&1 | FileCheck --check-prefix=COMPRESS_DEBUG %s -// RUN: %clang -### -c -integrated-as -Wa,--compress-debug-sections %s 2>&1 | FileCheck --check-prefix=COMPRESS_DEBUG %s // REQUIRES: zlib -// COMPRESS_DEBUG: "-compress-debug-sections" +// RUN: %clang -### -fintegrated-as -Wa,-compress-debug-sections -c %s 2>&1 | FileCheck -check-prefix CHECK-_COMPRESS_DEBUG_SECTIONS %s +// RUN: %clang -### -fno-integrated-as -Wa,-compress-debug-sections -c %s 2>&1 | FileCheck -check-prefix CHECK-_COMPRESS_DEBUG_SECTIONS %s +// CHECK-_COMPRESS_DEBUG_SECTIONS: "-compress-debug-sections" + +// RUN: %clang -### -fintegrated-as -Wa,--compress-debug-sections -c %s 2>&1 | FileCheck -check-prefix CHECK-__COMPRESS_DEBUG_SECTIONS %s +// RUN: %clang -### -fno-integrated-as -Wa,--compress-debug-sections -c %s 2>&1 | FileCheck -check-prefix CHECK-__COMPRESS_DEBUG_SECTIONS %s +// CHECK-__COMPRESS_DEBUG_SECTIONS: "--compress-debug-sections" + +// RUN: %clang -### -fintegrated-as -Wa,--compress-debug-sections -Wa,--nocompress-debug-sections -c %s 2>&1 | FileCheck -check-prefix CHECK-POSNEG %s +// RUN: %clang -### -fno-integrated-as -Wa,--compress-debug-sections -Wa,--nocompress-debug-sections -c %s 2>&1 | FileCheck -check-prefix CHECK-POSNEG %s +// CHECK-POSNEG: "--compress-debug-sections" +// CHECK-POSNEG: "--nocompress-debug-sections" + +// RUN: %clang -### -fintegrated-as -Wa,-compress-debug-sections -Wa,--compress-debug-sections -c %s 2>&1 | FileCheck -check-prefix CHECK-MULTIPLE %s +// RUN: %clang -### -fno-integrated-as -Wa,-compress-debug-sections -Wa,--compress-debug-sections -c %s 2>&1 | FileCheck -check-prefix CHECK-MULTIPLE %s +// CHECK-MULTIPLE: "-compress-debug-sections" +// CHECK-MULTIPLE: "--compress-debug-sections" -// RUN: %clang -### -c -integrated-as -Wa,--compress-debug-sections -Wa,--nocompress-debug-sections %s 2>&1 | FileCheck --check-prefix=NOCOMPRESS_DEBUG %s -// NOCOMPRESS_DEBUG-NOT: "-compress-debug-sections"