From: Chad Rosier Date: Wed, 11 Apr 2018 14:20:37 +0000 (+0000) Subject: [Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7175a52e21c264ba3daa98be5087914760a3a52f;p=clang [Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking Differential Revision: https://reviews.llvm.org/D45092 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329810 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp index a50e5bd663..f70e5a58c8 100644 --- a/lib/Driver/ToolChains/Gnu.cpp +++ b/lib/Driver/ToolChains/Gnu.cpp @@ -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(JA) || isa(JA)) && + (A->getOption().matches(options::OPT_munaligned_access) || + A->getOption().matches(options::OPT_mno_unaligned_access))) + continue; + A->render(Args, CmdArgs); } } diff --git a/test/Driver/gcc_forward.c b/test/Driver/gcc_forward.c index d28e432b1e..f75b1c738b 100644 --- a/test/Driver/gcc_forward.c +++ b/test/Driver/gcc_forward.c @@ -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