@@ -21,12 +21,13 @@ int bar() {
2121}
2222#else
2323extern int y ;
24- int __attribute__(( visibility ( "hidden" ))) x = 999 ;
24+ extern int x ;
2525int baz () { return y + x ; }
2626#endif
2727
2828// Create various inputs to test basic linking and LTO capabilities. Creating a
2929// CUDA binary requires access to the `ptxas` executable, so we just use x64.
30+ // RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.o
3031// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -DX -o %t-x.o
3132// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -DY -o %t-y.o
3233// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -DZ -o %t-z.o
@@ -36,6 +37,7 @@ int baz() { return y + x; }
3637// RUN: llvm-ar rcs %t-y.a %t-y.o
3738// RUN: llvm-ar rcs %t-z.a %t-z.o
3839// RUN: llvm-ar rcs %t-w.a %t-w.o
40+ // RUN: llvm-ar rcs %t-u.a %t-u.o
3941
4042//
4143// Check that we forward any unrecognized argument to 'nvlink'.
@@ -49,11 +51,16 @@ int baz() { return y + x; }
4951// `libx.a` and `liby.a` because extern weak symbols do not extract and `libz.a`
5052// is not used at all.
5153//
52- // RUN: clang-nvlink-wrapper --dry-run %t-x.a %t-u.o %t-y.a %t-z.a %t-w.a \
54+ // RUN: clang-nvlink-wrapper --dry-run %t-x.a %t-u.a %t-y.a %t-z.a %t-w.a %t.o \
5355// RUN: -arch sm_52 -o a.out 2>&1 | FileCheck %s --check-prefix=LINK
5456// LINK: nvlink{{.*}} -arch sm_52 -o a.out [[INPUT:.+]].cubin {{.*}}-x-{{.*}}.cubin{{.*}}-y-{{.*}}.cubin
5557
56- // RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.o
58+ //
59+ // Same as above but we use '--undefined' to forcibly extract 'libz.a'
60+ //
61+ // RUN: clang-nvlink-wrapper --dry-run %t-x.a %t-u.a %t-y.a %t-z.a %t-w.a %t.o \
62+ // RUN: -u z -arch sm_52 -o a.out 2>&1 | FileCheck %s --check-prefix=LINK
63+ // UNDEFINED: nvlink{{.*}} -arch sm_52 -o a.out [[INPUT:.+]].cubin {{.*}}-x-{{.*}}.cubin{{.*}}-y-{{.*}}.cubin{{.*}}-z-{{.*}}.cubin
5764
5865//
5966// Check that the LTO interface works and properly preserves symbols used in a
0 commit comments