The logic about -static is darwin only. For now assume that all non

darwin assembler can handle cfi. Add a test.

llvm-svn: 131464
This commit is contained in:
Rafael Espindola 2011-05-17 16:26:17 +00:00
parent 0693182265
commit f934f98ad2
2 changed files with 29 additions and 14 deletions

View File

@ -908,21 +908,28 @@ static void addExceptionArgs(const ArgList &Args, types::ID InputType,
static bool ShouldDisableCFI(const ArgList &Args,
const ToolChain &TC) {
if (TC.getTriple().getOS() == llvm::Triple::Darwin) {
// The native darwin assembler doesn't support cfi directives, so
// we disable them if with think the .s file will be passed to it.
// FIXME: Duplicated code with ToolChains.cpp
// FIXME: This doesn't belong here, but ideally we will support static soon
// anyway.
bool HasStatic = (Args.hasArg(options::OPT_mkernel) ||
Args.hasArg(options::OPT_static) ||
Args.hasArg(options::OPT_fapple_kext));
bool IsIADefault = TC.IsIntegratedAssemblerDefault() && !HasStatic;
bool UseIntegratedAs = Args.hasFlag(options::OPT_integrated_as,
options::OPT_no_integrated_as,
IsIADefault);
bool UseCFI = Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
options::OPT_fno_dwarf2_cfi_asm,
UseIntegratedAs);
return !UseCFI;
// FIXME: Duplicated code with ToolChains.cpp
// FIXME: This doesn't belong here, but ideally we will support static soon
// anyway.
bool HasStatic = (Args.hasArg(options::OPT_mkernel) ||
Args.hasArg(options::OPT_static) ||
Args.hasArg(options::OPT_fapple_kext));
bool IsIADefault = TC.IsIntegratedAssemblerDefault() && !HasStatic;
bool UseIntegratedAs = Args.hasFlag(options::OPT_integrated_as,
options::OPT_no_integrated_as,
IsIADefault);
bool UseCFI = Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
options::OPT_fno_dwarf2_cfi_asm,
UseIntegratedAs);
return !UseCFI;
}
// For now we assume that every other assembler support CFI.
return false;
}
/// \brief Check whether the given input tree contains any compilation actions.

8
clang/test/Driver/cfi.c Normal file
View File

@ -0,0 +1,8 @@
// RUN: %clang -ccc-host-triple i386-apple-darwin10 -static -### %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-DARWIN %s
// RUN: %clang -ccc-host-triple i386-pc-linux-gnu -static -### %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-LINUX %s
// CHECK-DARWIN: -fno-dwarf2-cfi-asm
// CHECK-LINUX-NOT: -fno-dwarf2-cfi-asm