jmolloy created this revision.
jmolloy added a reviewer: rafael.
jmolloy added a subscriber: cfe-commits.
jmolloy set the repository for this revision to rL LLVM.
Herald added a subscriber: joker.eph.

The gold plugin can take LLVM options, but the syntax is confusing: 
-Wl,-plugin-opt= or -Xlinker -plugin-opt=.

Instead, pass -mllvm options through to Gold so the obvious syntax works.

Repository:
  rL LLVM

http://reviews.llvm.org/D16056

Files:
  lib/Driver/Tools.cpp
  test/Driver/gold-lto.c

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 \
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 \
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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to