From: Rafael Espindola Date: Tue, 17 May 2011 16:26:17 +0000 (+0000) Subject: The logic about -static is darwin only. For now assume that all non X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97f6abb4470a82be4a8c6f1603e7bb303f9079b5;p=clang The logic about -static is darwin only. For now assume that all non darwin assembler can handle cfi. Add a test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131464 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 19a830cac1..ffaa5724ac 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -908,21 +908,28 @@ static void addExceptionArgs(const ArgList &Args, types::ID InputType, static bool ShouldDisableCFI(const ArgList &Args, const ToolChain &TC) { - - // 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; + 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; + } + + // For now we assume that every other assembler support CFI. + return false; } /// \brief Check whether the given input tree contains any compilation actions. diff --git a/test/Driver/cfi.c b/test/Driver/cfi.c new file mode 100644 index 0000000000..b5c0c03e7a --- /dev/null +++ b/test/Driver/cfi.c @@ -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