[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
This commit is contained in:
Chad Rosier 2018-04-11 14:20:37 +00:00
parent 6f411905a8
commit 7175a52e21
2 changed files with 13 additions and 0 deletions

View 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);
}
}

View 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