Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1817,6 +1817,12 @@ if (IsThinLTO) CmdArgs.push_back("-plugin-opt=thinlto"); + + // Claim and pass through -mllvm options to the Gold plugin. + for (const Arg *A : Args.filtered(options::OPT_mllvm)) { + A->claim(); + CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + A->getValue(0))); + } } /// This is a helper function for validating the optional refinement step Index: test/Driver/gold-lto.c =================================================================== --- test/Driver/gold-lto.c +++ test/Driver/gold-lto.c @@ -16,11 +16,14 @@ // CHECK-X86-64-COREI7: "-plugin-opt=foo" // // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \ -// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \ +// RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 -mllvm -bar=baz \ +// RUN: -mllvm -test-option \ // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A // CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so" // CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8" // CHECK-ARM-V7A: "-plugin-opt=O0" +// CHECK-ARM-V7A: "-plugin-opt=-bar=baz" +// CHECK-ARM-V7A: "-plugin-opt=-test-option" // CHECK-ARM-V7A: "-plugin-opt=foo" // // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \