[Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking
authorChad Rosier <mcrosier@codeaurora.org>
Wed, 11 Apr 2018 14:20:37 +0000 (14:20 +0000)
committerChad Rosier <mcrosier@codeaurora.org>
Wed, 11 Apr 2018 14:20:37 +0000 (14:20 +0000)
Differential Revision: https://reviews.llvm.org/D45092

llvm-svn: 329810

clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/gcc_forward.c

index a50e5bd..f70e5a5 100644 (file)
@@ -85,6 +85,13 @@ void tools::gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
           A->getOption().matches(options::OPT_W_Group))
         continue;
 
+      // Don't forward -mno-unaligned-access since GCC doesn't understand
+      // it and because it doesn't affect the assembly or link steps.
+      if ((isa<AssembleJobAction>(JA) || isa<LinkJobAction>(JA)) &&
+          (A->getOption().matches(options::OPT_munaligned_access) ||
+           A->getOption().matches(options::OPT_mno_unaligned_access)))
+        continue;
+
       A->render(Args, CmdArgs);
     }
   }
index d28e432..f75b1c7 100644 (file)
@@ -34,3 +34,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 // CHECK-ASM: as
 // CHECK-ASM-NOT: "-g"
+
+// Check that we're not forwarding -mno-unaligned-access.
+// RUN: %clang -target aarch64-none-elf -mno-unaligned-access %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: gcc{{[^"]*}}"
+// CHECK-ARM-NOT: -mno-unaligned-access