Index: lib/Driver/ToolChains/Gnu.cpp =================================================================== --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -40,7 +40,13 @@ // Don't forward inputs from the original command line. They are added from // InputInfoList. return O.getKind() != Option::InputClass && - !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput); + !O.hasFlag(options::DriverOption) && + !O.hasFlag(options::LinkerInput) && + // Filter out -mno-unaligned-access since GCC expects -mstrict-align + // instead for some targets and this flag shouldn't effect assembly + // or link steps. + O.getID() != options::OPT_munaligned_access && + O.getID() != options::OPT_mno_unaligned_access; } // Switch CPU names not recognized by GNU assembler to a close CPU that it does Index: test/Driver/gcc_forward.c =================================================================== --- test/Driver/gcc_forward.c +++ test/Driver/gcc_forward.c @@ -34,3 +34,11 @@ // RUN: | FileCheck --check-prefix=CHECK-ASM %s // CHECK-ASM: as // CHECK-ASM-NOT: "-g" + +// Check that we're not forwarding -mno-unaligned-access since GCC expects +// -mstrict-align instead for some targets and this flag shouldn't effect +// linking. +// 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