[clang] 70e0935 - [Driver][test] Refactor LLVMgold tests

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 7 22:37:53 PST 2020


Author: Fangrui Song
Date: 2020-02-07T22:37:11-08:00
New Revision: 70e0935256fc173fbc57c7333727ab222af476eb

URL: https://github.com/llvm/llvm-project/commit/70e0935256fc173fbc57c7333727ab222af476eb
DIFF: https://github.com/llvm/llvm-project/commit/70e0935256fc173fbc57c7333727ab222af476eb.diff

LOG: [Driver][test] Refactor LLVMgold tests

LLVMgold.so tests are duplicated in several places. Deduplicate them.
Move the tests to lto.c and lto.cu
Specify -fuse-ld=bfd or -fuse-ld=gold.

In a future change, if -fuse-ld=lld or CLANG_DEFAULT_LINKER=lld without -fuse-ld=, we will remove -plugin /path/to/LLVMgold.so

Added: 
    

Modified: 
    clang/test/Driver/freebsd.c
    clang/test/Driver/lto.c
    clang/test/Driver/lto.cu
    clang/test/Driver/thinlto.c
    clang/test/Driver/thinlto.cu

Removed: 
    clang/test/Driver/gold-lto.c
    clang/test/Driver/lto-plugin-darwin.c
    clang/test/Driver/lto-plugin-linux.c
    clang/test/Driver/lto-plugin-windows.c


################################################################################
diff  --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c
index dc209704d7ab..5eb00ce65d71 100644
--- a/clang/test/Driver/freebsd.c
+++ b/clang/test/Driver/freebsd.c
@@ -161,10 +161,6 @@
 // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-mfpu=softvfp"
 // CHECK-ARM-EABIHF-NOT: as{{.*}}" "-matpcs"
 
-// RUN: %clang -target x86_64-pc-freebsd8 %s -### -flto 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-LTO %s
-// 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
 // CHECK-SPARC-PIE: as{{.*}}" "-KPIC

diff  --git a/clang/test/Driver/gold-lto.c b/clang/test/Driver/gold-lto.c
deleted file mode 100644
index d16961eeda45..000000000000
--- a/clang/test/Driver/gold-lto.c
+++ /dev/null
@@ -1,28 +0,0 @@
-// RUN: touch %t.o
-//
-// 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.{{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.{{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.{{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.{{dll|dylib|so}}"

diff  --git a/clang/test/Driver/lto-plugin-darwin.c b/clang/test/Driver/lto-plugin-darwin.c
deleted file mode 100644
index 2e9e6ba5b425..000000000000
--- a/clang/test/Driver/lto-plugin-darwin.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// Check that Darwin uses LLVMgold.dylib.
-// REQUIRES: system-darwin
-// RUN: %clang -### %s -target x86_64-unknown-linux -flto 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
-//
-// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"

diff  --git a/clang/test/Driver/lto-plugin-linux.c b/clang/test/Driver/lto-plugin-linux.c
deleted file mode 100644
index ac1eb14e2e9f..000000000000
--- a/clang/test/Driver/lto-plugin-linux.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// Check that non-Windows, non-Darwin OSs use LLVMgold.so.
-// REQUIRES: !system-darwin && !system-windows
-// RUN: %clang -### %s -target x86_64-unknown-linux -flto 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
-//
-// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so"

diff  --git a/clang/test/Driver/lto-plugin-windows.c b/clang/test/Driver/lto-plugin-windows.c
deleted file mode 100644
index 1b12702a98a7..000000000000
--- a/clang/test/Driver/lto-plugin-windows.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// Check that Windows uses LLVMgold.dll.
-// REQUIRES: system-windows
-// RUN: %clang -### %s -target x86_64-unknown-linux -flto 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
-//
-// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}\\LLVMgold.dll"

diff  --git a/clang/test/Driver/lto.c b/clang/test/Driver/lto.c
index 570c80b94188..becaa9e7a0a3 100644
--- a/clang/test/Driver/lto.c
+++ b/clang/test/Driver/lto.c
@@ -32,23 +32,18 @@
 // RUN: not %clang %s -emit-llvm 2>&1 | FileCheck --check-prefix=LLVM-LINK %s
 // LLVM-LINK: -emit-llvm cannot be used when linking
 
-// -flto should cause link using gold plugin
-// 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.{{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.{{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.{{dll|dylib|so}}"
+/// With ld.bfd or gold, link against LLVMgold.
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=bfd -flto=thin -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=gold -flto=full -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=gold -fno-lto -flto -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s
+// LLVMGOLD: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=gold -flto -fno-lto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s
+// NO-LLVMGOLD-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

diff  --git a/clang/test/Driver/lto.cu b/clang/test/Driver/lto.cu
index 821dfcd20319..d3d71f305fda 100644
--- a/clang/test/Driver/lto.cu
+++ b/clang/test/Driver/lto.cu
@@ -47,26 +47,19 @@
 // RUN:    | FileCheck --check-prefix=LLVM-LINK %s
 // LLVM-LINK: -emit-llvm cannot be used when linking
 
-// -flto should cause link using gold plugin
-// RUN: %clangxx -nocudainc -nocudalib \
-// RUN:          -target x86_64-unknown-linux -### %s -flto 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LINK-LTO-ACTION < %t %s
+/// With ld.bfd or gold, link against LLVMgold.
+// RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=bfd -flto=thin -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s
+// RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=gold -flto=full -### 2>&1 | FileCheck --check-prefix=LLVMGOLD %s
 //
-// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
-
-// -flto=full should cause link using gold plugin
-// RUN: %clangxx -nocudainc -nocudalib \
-// RUN:          -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.{{dll|dylib|so}}"
+// LLVMGOLD: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
 // Check that subsequent -fno-lto takes precedence
-// RUN: %clangxx -nocudainc -nocudalib \
-// RUN:          -target x86_64-unknown-linux -### %s -flto=full -fno-lto 2> %t
-// RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
+// RUN: %clangxx -nocudainc -nocudalib -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=gold -flto=full -fno-lto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+// NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
 // -flto passes along an explicit debugger tuning argument.
 // RUN: %clangxx -nocudainc -nocudalib \

diff  --git a/clang/test/Driver/thinlto.c b/clang/test/Driver/thinlto.c
index bef7b2b0a6f1..e08435f71cc0 100644
--- a/clang/test/Driver/thinlto.c
+++ b/clang/test/Driver/thinlto.c
@@ -13,25 +13,3 @@
 // CHECK-COMPILELINK-ACTIONS: 2: compiler, {1}, ir
 // CHECK-COMPILELINK-ACTIONS: 3: backend, {2}, lto-bc
 // CHECK-COMPILELINK-ACTIONS: 4: linker, {3}, image
-
-// -flto=thin should cause link using gold plugin with thinlto option,
-// also confirm that it takes precedence over earlier -fno-lto and -flto=full.
-// 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.{{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.{{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.{{dll|dylib|so}}"
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto"

diff  --git a/clang/test/Driver/thinlto.cu b/clang/test/Driver/thinlto.cu
index c5a76b0cbdfd..bd13e2e3b731 100644
--- a/clang/test/Driver/thinlto.cu
+++ b/clang/test/Driver/thinlto.cu
@@ -27,28 +27,3 @@
 // CHECK-COMPILELINK-ACTIONS: 11: offload, "host-cuda {{.*}}" {2}, "device-cuda{{.*}}" {10}, ir
 // CHECK-COMPILELINK-ACTIONS: 12: backend, {11}, lto-bc, (host-cuda)
 // CHECK-COMPILELINK-ACTIONS: 13: linker, {12}, image, (host-cuda)
-
-// -flto=thin should cause link using gold plugin with thinlto option,
-// also confirm that it takes precedence over earlier -fno-lto and -flto=full.
-// RUN: %clangxx -nocudainc -nocudalib \
-// RUN:        -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.{{dll|dylib|so}}"
-// CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto"
-
-// Check that subsequent -flto=full takes precedence
-// RUN: %clangxx -nocudainc -nocudalib \
-// RUN:        -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.{{dll|dylib|so}}"
-// CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto"
-
-// Check that subsequent -fno-lto takes precedence
-// RUN: %clangxx -nocudainc -nocudalib \
-// RUN:        -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.{{dll|dylib|so}}"
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto"


        


More information about the cfe-commits mailing list