]> granicus.if.org Git - clang/commitdiff
[DebugInfo] Error out when enabling -fdebug-types-section on non-ELF target.
authorJonas Devlieghere <jonas@devlieghere.com>
Mon, 23 Jul 2018 17:50:15 +0000 (17:50 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Mon, 23 Jul 2018 17:50:15 +0000 (17:50 +0000)
Currently, support for debug_types is only present for ELF and trying to
pass -fdebug-types-section for other targets results in a crash in the
backend. Until this is fixed, we should emit a diagnostic in the front
end when the option is passed for non-linux targets.

Differential revision: https://reviews.llvm.org/D49594

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

lib/Driver/ToolChains/Clang.cpp
test/Driver/debug-options.c

index e23ff16699f4c393293f2e513af42f163591b46e..a95080bbec6777411b6bbc88fd69747fb66e0eaa 100644 (file)
@@ -3028,6 +3028,11 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
 
   if (Args.hasFlag(options::OPT_fdebug_types_section,
                    options::OPT_fno_debug_types_section, false)) {
+    if (!T.isOSBinFormatELF())
+      D.Diag(diag::err_drv_unsupported_opt_for_target)
+          << Args.getLastArg(options::OPT_fdebug_types_section)
+                 ->getAsString(Args)
+          << T.getTriple();
     CmdArgs.push_back("-mllvm");
     CmdArgs.push_back("-generate-type-units");
   }
index 6d28a7169d9994e5bdcd8636880a776c52923d8a..0dd32e983ad85ebcdfb5485ac9dce759ccdbcb85 100644 (file)
 //
 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
 //
-// RUN: %clang -### -fdebug-types-section %s 2>&1 \
+// RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \
 // RUN:        | FileCheck -check-prefix=FDTS %s
 //
-// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \
+// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \
 // RUN:        | FileCheck -check-prefix=NOFDTS %s
 //
+// RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \
+// RUN:        | FileCheck -check-prefix=FDTSE %s
+//
+// RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-apple-darwin %s 2>&1 \
+// RUN:        | FileCheck -check-prefix=NOFDTSE %s
+//
 // RUN: %clang -### -g -gno-column-info %s 2>&1 \
 // RUN:        | FileCheck -check-prefix=NOCI %s
 //
 // GARANGE: -generate-arange-section
 //
 // FDTS: "-mllvm" "-generate-type-units"
+// FDTSE: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin'
 //
 // NOFDTS-NOT: "-mllvm" "-generate-type-units"
+// NOFDTSE-NOT: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin'
 //
 // CI: "-dwarf-column-info"
 //