]> granicus.if.org Git - clang/commitdiff
[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

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

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

index a50e5bd6632a0d7f4ad506511cec876f53b02654..f70e5a58c813029942f5e00aa5455fef84e68d67 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 d28e432b1e178a9321e969a0486099b63f029126..f75b1c738b05cc417b800162c0f70385e61c1f2c 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