aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2021-03-09 10:52:26 -0800
committerFangrui Song <i@maskray.me>2021-03-09 10:52:26 -0800
commitc11ff4bbada3b5127a1f010e0a97a1e6e46fb61a (patch)
tree154e5f482ad93d1e3cce831b4f0c9ffbc83af35a /clang/lib/Frontend/CompilerInvocation.cpp
parentcc52ea30012d3d9495a41255be50dccc77464cad (diff)
downloadllvm-c11ff4bbada3b5127a1f010e0a97a1e6e46fb61a.zip
llvm-c11ff4bbada3b5127a1f010e0a97a1e6e46fb61a.tar.gz
llvm-c11ff4bbada3b5127a1f010e0a97a1e6e46fb61a.tar.bz2
Define __GCC_HAVE_DWARF2_CFI_ASM if applicable
In -fno-exceptions -fno-asynchronous-unwind-tables -g0 mode, GCC does not emit `.cfi_*` directives. ``` % diff <(gcc -fno-asynchronous-unwind-tables -dM -E a.c) <(gcc -dM -E a.c) 130a131 > #define __GCC_HAVE_DWARF2_CFI_ASM 1 ``` This macro is useful because code can decide whether inline asm should include `.cfi_*` directives. `.cfi_*` directives without `.cfi_startproc` can cause assembler errors (integrated assembler: `this directive must appear between .cfi_startproc and .cfi_endproc directives`). Differential Revision: https://reviews.llvm.org/D97743
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 2606e9f..bd02408 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4355,6 +4355,11 @@ bool CompilerInvocation::CreateFromArgsImpl(
Res.getCodeGenOpts().Argv0 = Argv0;
Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
+ if ((T.isOSBinFormatELF() || T.isOSBinFormatMachO()) &&
+ (Res.getLangOpts()->Exceptions || Res.getCodeGenOpts().UnwindTables ||
+ Res.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo))
+ Res.getPreprocessorOpts().addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1");
+
Success &= FixupInvocation(Res, Diags, Args, DashX);
return Success;