]> granicus.if.org Git - clang/commitdiff
Add option to use temporary file for assembling with clang
authorDavid Peixotto <dpeixott@codeaurora.org>
Fri, 6 Dec 2013 20:27:33 +0000 (20:27 +0000)
committerDavid Peixotto <dpeixott@codeaurora.org>
Fri, 6 Dec 2013 20:27:33 +0000 (20:27 +0000)
This commit adds the flag '-via-file-asm' to the clang driver. The
purpose of this flag is to have a way to test that clang can consume
the assembly code that it outputs. When passed this flag, clang will
generate a temporary file that contains the assembly output from the
compile step. This assembly file will then be consumed by either the
integrated assembler or the external assembler. To test that the
integrated assembler can consume its own output compile with:

  $ clang -integrated-assembler -via-file-asm

Without the '-via-file-asm' flag, clang would directly create the
object file when using the integrated assembler. With the flag it
will first create the temporary assembly file and then read that
file and assemble it with the integrated assembler.

The flow is similar to -save-temps, except that it only effects
the assembly input and the temporary file is not saved.

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

include/clang/Driver/Options.td
lib/Driver/Driver.cpp
test/Driver/via-file-asm.c [new file with mode: 0644]

index f80069591a3d13169ed79bf5809ba3cc83beb611..34641722affdfc8c66d40376e0fe1fc736df342b 100644 (file)
@@ -1230,6 +1230,8 @@ def rtlib_EQ : Joined<["-", "--"], "rtlib=">;
 def r : Flag<["-"], "r">;
 def save_temps : Flag<["-", "--"], "save-temps">, Flags<[DriverOption]>,
   HelpText<"Save intermediate compilation results">;
+def via_file_asm : Flag<["-", "--"], "via-file-asm">, Flags<[DriverOption]>,
+  HelpText<"Write assembly to file for input to assemble jobs">;
 def sectalign : MultiArg<["-"], "sectalign", 3>;
 def sectcreate : MultiArg<["-"], "sectcreate", 3>;
 def sectobjectsymbols : MultiArg<["-"], "sectobjectsymbols", 2>;
index d4a2e470488cd9c799a8c7f8e6279cd3a3bf3358..7826cb30fcfb1e899e93ce843e5440b144934528 100644 (file)
@@ -1456,6 +1456,7 @@ static const Tool *SelectToolForJob(Compilation &C, const ToolChain *TC,
 
   if (TC->useIntegratedAs() &&
       !C.getArgs().hasArg(options::OPT_save_temps) &&
+      !C.getArgs().hasArg(options::OPT_via_file_asm) &&
       !C.getArgs().hasArg(options::OPT__SLASH_FA) &&
       !C.getArgs().hasArg(options::OPT__SLASH_Fa) &&
       isa<AssembleJobAction>(JA) &&
diff --git a/test/Driver/via-file-asm.c b/test/Driver/via-file-asm.c
new file mode 100644 (file)
index 0000000..92fc190
--- /dev/null
@@ -0,0 +1,14 @@
+// Should save and read back the assembly from a file
+// RUN: %clang -integrated-as -via-file-asm %s -### 2>&1 | FileCheck %s
+// CHECK: "-cc1"
+// CHECK: "-o" "[[TMP:[^"]*]]"
+// CHECK: -cc1as
+// CHECK: [[TMP]]
+
+// Should not force using the integrated assembler
+// RUN: %clang -no-integrated-as -via-file-asm %s -### 2>&1 | FileCheck --check-prefix=NO_IAS %s
+// NO_IAS-NOT: "-cc1as"
+
+// Test arm target specifically for the same behavior
+// RUN: %clang -target arm -integrated-as -via-file-asm %s -### 2>&1 | FileCheck %s
+// RUN: %clang -target arm -no-integrated-as -via-file-asm %s -### 2>&1 | FileCheck --check-prefix=NO_IAS %s