]> granicus.if.org Git - clang/commitdiff
[driver] Only enable -fmodules-autolink if we are using the integrated assembler.
authorTed Kremenek <kremenek@apple.com>
Tue, 12 Mar 2013 21:08:08 +0000 (21:08 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 12 Mar 2013 21:08:08 +0000 (21:08 +0000)
Fixes <rdar://problem/13289240>

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

lib/Driver/Tools.cpp
test/Driver/modules_integrated_as.c [new file with mode: 0644]

index 62b1febd52919684a55677ad77ced471abbd15ab..065ee7d719b9e51d48c308ab62480e607814fecd 100644 (file)
@@ -1414,15 +1414,21 @@ static void addExceptionArgs(const ArgList &Args, types::ID InputType,
     CmdArgs.push_back("-fexceptions");
 }
 
+/// \brief Check if the toolchain should use the integrated assembler.
+static bool ShouldUseIntegratedAssembler(const ArgList &Args,
+                                         const ToolChain &TC) {
+  return Args.hasFlag(options::OPT_integrated_as,
+                      options::OPT_no_integrated_as,
+                      TC.IsIntegratedAssemblerDefault());
+}
+
 static bool ShouldDisableCFI(const ArgList &Args,
                              const ToolChain &TC) {
   bool Default = true;
   if (TC.getTriple().isOSDarwin()) {
     // The native darwin assembler doesn't support cfi directives, so
     // we disable them if we think the .s file will be passed to it.
-    Default = Args.hasFlag(options::OPT_integrated_as,
-                           options::OPT_no_integrated_as,
-                           TC.IsIntegratedAssemblerDefault());
+    Default = ShouldUseIntegratedAssembler(Args, TC);
   }
   return !Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
                        options::OPT_fno_dwarf2_cfi_asm,
@@ -1431,13 +1437,9 @@ static bool ShouldDisableCFI(const ArgList &Args,
 
 static bool ShouldDisableDwarfDirectory(const ArgList &Args,
                                         const ToolChain &TC) {
-  bool IsIADefault = TC.IsIntegratedAssemblerDefault();
-  bool UseIntegratedAs = Args.hasFlag(options::OPT_integrated_as,
-                                      options::OPT_no_integrated_as,
-                                      IsIADefault);
   bool UseDwarfDirectory = Args.hasFlag(options::OPT_fdwarf_directory_asm,
                                         options::OPT_fno_dwarf_directory_asm,
-                                        UseIntegratedAs);
+                                        ShouldUseIntegratedAssembler(Args, TC));
   return !UseDwarfDirectory;
 }
 
@@ -2802,8 +2804,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   Args.AddAllArgs(CmdArgs, options::OPT_fmodules_ignore_macro);
 
   // -fmodules-autolink (on by default when modules is enabled) automatically
-  // links against libraries for imported modules.
-  if (HaveModules &&
+  // links against libraries for imported modules.  This requires the
+  // integrated assembler.
+  if (HaveModules && ShouldUseIntegratedAssembler(Args, getToolChain()) &&
       Args.hasFlag(options::OPT_fmodules_autolink,
                    options::OPT_fno_modules_autolink,
                    true)) {
diff --git a/test/Driver/modules_integrated_as.c b/test/Driver/modules_integrated_as.c
new file mode 100644 (file)
index 0000000..0abd18f
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang -fsyntax-only modules_integrated_as.c -fmodules -no-integrated-as -### 2>&1 | FileCheck %s
+
+// Test that the autolinking feature is disabled with *not* using the
+// integrated assembler.
+
+// CHECK-NOT: -fmodules-autolink