@@ -404,7 +404,7 @@ shouldUseExceptionTablesForObjCExceptions(const ObjCRuntime &runtime,
404
404
// / master flag, -fexceptions and also language specific flags to enable/disable
405
405
// / C++ and Objective-C exceptions. This makes it possible to for example
406
406
// / disable C++ exceptions but enable Objective-C exceptions.
407
- static void addExceptionArgs (const ArgList &Args, types::ID InputType,
407
+ static bool addExceptionArgs (const ArgList &Args, types::ID InputType,
408
408
const ToolChain &TC, bool KernelOrKext,
409
409
const ObjCRuntime &objcRuntime,
410
410
ArgStringList &CmdArgs) {
@@ -419,7 +419,7 @@ static void addExceptionArgs(const ArgList &Args, types::ID InputType,
419
419
Args.ClaimAllArgs (options::OPT_fno_objc_exceptions);
420
420
Args.ClaimAllArgs (options::OPT_fcxx_exceptions);
421
421
Args.ClaimAllArgs (options::OPT_fno_cxx_exceptions);
422
- return ;
422
+ return false ;
423
423
}
424
424
425
425
// See if the user explicitly enabled exceptions.
@@ -462,6 +462,7 @@ static void addExceptionArgs(const ArgList &Args, types::ID InputType,
462
462
463
463
if (EH)
464
464
CmdArgs.push_back (" -fexceptions" );
465
+ return EH;
465
466
}
466
467
467
468
static bool ShouldEnableAutolink (const ArgList &Args, const ToolChain &TC,
@@ -4971,14 +4972,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
4971
4972
// This is a coarse approximation of what llvm-gcc actually does, both
4972
4973
// -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
4973
4974
// complicated ways.
4974
- bool AsynchronousUnwindTables =
4975
+ bool UnwindTables =
4975
4976
Args.hasFlag (options::OPT_fasynchronous_unwind_tables,
4976
4977
options::OPT_fno_asynchronous_unwind_tables,
4977
4978
(TC.IsUnwindTablesDefault (Args) ||
4978
4979
TC.getSanitizerArgs ().needsUnwindTables ()) &&
4979
4980
!Freestanding);
4980
- if (Args.hasFlag (options::OPT_funwind_tables, options::OPT_fno_unwind_tables,
4981
- AsynchronousUnwindTables))
4981
+ UnwindTables = Args.hasFlag (options::OPT_funwind_tables,
4982
+ options::OPT_fno_unwind_tables, UnwindTables);
4983
+ if (UnwindTables)
4982
4984
CmdArgs.push_back (" -munwind-tables" );
4983
4985
4984
4986
// Prepare `-aux-target-cpu` and `-aux-target-feature` unless
@@ -6039,8 +6041,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
6039
6041
CmdArgs.push_back (" -fapplication-extension" );
6040
6042
6041
6043
// Handle GCC-style exception args.
6044
+ bool EH = false ;
6042
6045
if (!C.getDriver ().IsCLMode ())
6043
- addExceptionArgs (Args, InputType, TC, KernelOrKext, Runtime, CmdArgs);
6046
+ EH = addExceptionArgs (Args, InputType, TC, KernelOrKext, Runtime, CmdArgs);
6044
6047
6045
6048
// Handle exception personalities
6046
6049
Arg *A = Args.getLastArg (
@@ -6600,6 +6603,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
6600
6603
!TC.getTriple ().isAndroid () && TC.useIntegratedAs ()))
6601
6604
CmdArgs.push_back (" -faddrsig" );
6602
6605
6606
+ if ((Triple.isOSBinFormatELF () || Triple.isOSBinFormatMachO ()) &&
6607
+ (EH || UnwindTables || DebugInfoKind != codegenoptions::NoDebugInfo))
6608
+ CmdArgs.push_back (" -D__GCC_HAVE_DWARF2_CFI_ASM=1" );
6609
+
6603
6610
if (Arg *A = Args.getLastArg (options::OPT_fsymbol_partition_EQ)) {
6604
6611
std::string Str = A->getAsString (Args);
6605
6612
if (!TC.getTriple ().isOSBinFormatELF ())
0 commit comments