]> granicus.if.org Git - clang/commitdiff
Revert "Revert "Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""""
authorDan Albert <danalbert@google.com>
Tue, 22 Aug 2017 21:05:01 +0000 (21:05 +0000)
committerDan Albert <danalbert@google.com>
Tue, 22 Aug 2017 21:05:01 +0000 (21:05 +0000)
With tests fixed for Windows style paths now that they are going
through path canonicalization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311487 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/CommonArgs.cpp
test/Driver/freebsd.c
test/Driver/gold-lto.c
test/Driver/lto-plugin-darwin.c [new file with mode: 0644]
test/Driver/lto-plugin-linux.c [new file with mode: 0644]
test/Driver/lto-plugin-windows.c [new file with mode: 0644]
test/Driver/lto.c
test/Driver/thinlto.c

index 02d64f87bfee28b7083983ed3ae79f73d2442fbd..f4881181181ec34c4924f3ab269a57c993a314b0 100644 (file)
@@ -376,8 +376,20 @@ void tools::AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
   // as gold requires -plugin to come before any -plugin-opt that -Wl might
   // forward.
   CmdArgs.push_back("-plugin");
-  std::string Plugin =
-      ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
+
+#if defined(LLVM_ON_WIN32)
+  const char *Suffix = ".dll";
+#elif defined(__APPLE__)
+  const char *Suffix = ".dylib";
+#else
+  const char *Suffix = ".so";
+#endif
+
+  SmallString<1024> Plugin;
+  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
+                              "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
+                              Suffix,
+                          Plugin);
   CmdArgs.push_back(Args.MakeArgString(Plugin));
 
   // Try to pass driver level flags relevant to LTO code generation down to
index f008b76b93ae40078f8ee9591c25df6c9613a72c..0f89d25ac4fa29a1f548669eb04e219af130de3b 100644 (file)
 
 // RUN: %clang -target x86_64-pc-freebsd8 %s -### -flto 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LTO %s
-// CHECK-LTO: ld{{.*}}" "-plugin{{.*}}LLVMgold.so
+// CHECK-LTO: ld{{.*}}" "-plugin{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}
 
 // RUN: %clang -target sparc-unknown-freebsd8 %s -### -fpic -no-integrated-as 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-SPARC-PIE %s
index b8eca5112b5a209bebe460e5cb2132e2f7ae9054..d16961eeda456468b37168a52eb7b02918847917 100644 (file)
@@ -3,14 +3,14 @@
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN:     -Wl,-plugin-opt=foo -O3 \
 // RUN:     | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
-// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN:     -march=corei7 -Wl,-plugin-opt=foo -Ofast \
 // RUN:     | FileCheck %s --check-prefix=CHECK-X86-64-COREI7
-// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-COREI7: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7"
 // CHECK-X86-64-COREI7: "-plugin-opt=O3"
 // 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:     | FileCheck %s --check-prefix=CHECK-ARM-V7A
-// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-ARM-V7A: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 // CHECK-ARM-V7A: "-plugin-opt=mcpu=generic"
 // CHECK-ARM-V7A: "-plugin-opt=O0"
 // CHECK-ARM-V7A: "-plugin-opt=foo"
 //
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN:     | FileCheck %s --check-prefix=CHECK-X86-ANDROID
-// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-ANDROID: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
diff --git a/test/Driver/lto-plugin-darwin.c b/test/Driver/lto-plugin-darwin.c
new file mode 100644 (file)
index 0000000..db21f99
--- /dev/null
@@ -0,0 +1,6 @@
+// Check that Darwin uses LLVMgold.dylib.
+// REQUIRES: system-darwin
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"
diff --git a/test/Driver/lto-plugin-linux.c b/test/Driver/lto-plugin-linux.c
new file mode 100644 (file)
index 0000000..e30dce6
--- /dev/null
@@ -0,0 +1,6 @@
+// Check that non-Windows, non-Darwin OSs use LLVMgold.so.
+// REQUIRES: !system-darwin && !system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so"
diff --git a/test/Driver/lto-plugin-windows.c b/test/Driver/lto-plugin-windows.c
new file mode 100644 (file)
index 0000000..9d26df2
--- /dev/null
@@ -0,0 +1,6 @@
+// Check that Windows uses LLVMgold.dll.
+// REQUIRES: system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}\\LLVMgold.dll"
index d2f68f571afd27cbc9e63a61e56cbe3a4d0523fc..570c80b94188a04bddd6c5ef69f3bd1384931a81 100644 (file)
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-LTO-ACTION < %t %s
 //
-// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
 // -flto=full should cause link using gold plugin
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
 //
-// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
 // Check that subsequent -fno-lto takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
 // -flto passes along an explicit debugger tuning argument.
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
index 0369b78be0f5093424e59f5317123110849f3f36..bef7b2b0a6f127ea955015ae8430ad2fecd3de09 100644 (file)
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s
 //
-// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto"
 
 // Check that subsequent -flto=full takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
 //
-// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto"
 
 // Check that subsequent -fno-lto takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-lto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto"