The `cc1as` driver supports the `-target-feature` option, but the Clang driver 
refuses to forward such an option specified with `-Xassembler` or `-Wa` through 
to `cc1as`, claiming it is unrecognized.  This patch makes Clang forward the 
`target-feature` option and its argument through to the assembler.

The `-target-feature` option is useful for enabling/disabling optional features 
when using Clang as an assembler. For example (assuming `test.s` contains 
appropriate content),

```
$ clang -c -target arm-none-eabi -mcpu=cortex-a9 -Xassembler -target-feature 
-Xassembler -mp test.s
# Or
$ clang -c -target arm-none-eabi -mcpu=cortex-a9 -Wa,-target-feature,-mp test.s
```

Would signal an error if the assembly file `test.s` contained any 
multiprocessing extension instructions, such as `PLDW`,

```
$ clang -c -target arm-none-eabi -mcpu=cortex-a9 -Xassembler -target-feature 
-Xassembler -mp test.s
test.s:31:2: error: instruction requires: mp-extensions
        pldw    [r0]
```

However, currently the behavior is,

```
$ clang -c -target arm-none-eabi -mcpu=cortex-a9 -Xassembler -target-feature 
-Xassembler -mp test.s
clang-3.6: error: unsupported argument '-target-feature' to option 'Xassembler'
clang-3.6: error: unsupported argument '-mp' to option 'Xassembler
```

Which I consider incorrect.

http://reviews.llvm.org/D6170

Files:
  lib/Driver/Tools.cpp
  test/Driver/integrated-as.s
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2107,6 +2107,9 @@
             TakeNextArg = true;
         } else if (Value.startswith("-gdwarf-")) {
           CmdArgs.push_back(Value.data());
+        } else if (Value == "-target-feature") {
+          CmdArgs.push_back("-target-feature");
+          TakeNextArg = true;
         } else {
           D.Diag(diag::err_drv_unsupported_option_argument)
             << A->getOption().getName() << Value;
Index: test/Driver/integrated-as.s
===================================================================
--- test/Driver/integrated-as.s
+++ test/Driver/integrated-as.s
@@ -43,3 +43,9 @@
 
 // RUN: %clang -### -c -integrated-as %s -Wa,-gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2WA %s
 // DWARF2WA: "-gdwarf-2"
+
+// RUN: %clang -### -c -integrated-as %s -Xassembler -target-feature -Xassembler -mp 2>&1 \
+// RUN:    | FileCheck --check-prefix=TARGET_FEATURE1 %s
+// RUN: %clang -### -c -integrated-as %s -Wa,-target-feature,-mp 2>&1 | FileCheck --check-prefix=TARGET_FEATURE1 %s
+// TARGET_FEATURE1: "-target-feature"
+// TARGET_FEATURE1: "-mp"
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to