1 // Test the that the driver produces reasonable linker invocations with
2 // -fopenmp or -fopenmp|libgomp.
3 //
4 // FIXME: Replace DEFAULT_OPENMP_LIB below with the value chosen at configure time.
5 //
6 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
7 // RUN:     -fopenmp -target i386-unknown-linux -rtlib=platform \
8 // RUN:   | FileCheck --check-prefix=CHECK-LD-32 %s
9 // CHECK-LD-32: "{{.*}}ld{{(.exe)?}}"
10 // CHECK-LD-32: "-l[[DEFAULT_OPENMP_LIB:[^"]*]]"
11 // CHECK-LD-32: "-lpthread" "-lc"
12 //
13 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
14 // RUN:     -fopenmp -target x86_64-unknown-linux -rtlib=platform \
15 // RUN:   | FileCheck --check-prefix=CHECK-LD-64 %s
16 // CHECK-LD-64: "{{.*}}ld{{(.exe)?}}"
17 // CHECK-LD-64: "-l[[DEFAULT_OPENMP_LIB:[^"]*]]"
18 // CHECK-LD-64: "-lpthread" "-lc"
19 //
20 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
21 // RUN:     -fopenmp=libgomp -target i386-unknown-linux -rtlib=platform \
22 // RUN:   | FileCheck --check-prefix=CHECK-GOMP-LD-32 %s
23 
24 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target i386-unknown-linux -rtlib=platform | FileCheck --check-prefix SIMD-ONLY2 %s
25 // SIMD-ONLY2-NOT: lgomp
26 // SIMD-ONLY2-NOT: lomp
27 // SIMD-ONLY2-NOT: liomp
28 // CHECK-GOMP-LD-32: "{{.*}}ld{{(.exe)?}}"
29 // CHECK-GOMP-LD-32: "-lgomp" "-lrt"
30 // CHECK-GOMP-LD-32: "-lpthread" "-lc"
31 
32 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target i386-unknown-linux -rtlib=platform | FileCheck --check-prefix SIMD-ONLY2 %s
33 // SIMD-ONLY2-NOT: lgomp
34 // SIMD-ONLY2-NOT: lomp
35 // SIMD-ONLY2-NOT: liomp
36 //
37 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
38 // RUN:     -fopenmp=libgomp -target x86_64-unknown-linux -rtlib=platform \
39 // RUN:   | FileCheck --check-prefix=CHECK-GOMP-LD-64 %s
40 // CHECK-GOMP-LD-64: "{{.*}}ld{{(.exe)?}}"
41 // CHECK-GOMP-LD-64: "-lgomp" "-lrt"
42 // CHECK-GOMP-LD-64: "-lpthread" "-lc"
43 //
44 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
45 // RUN:     -fopenmp -target i386-unknown-linux -rtlib=platform \
46 // RUN:   | FileCheck --check-prefix=CHECK-IOMP5-LD-32 %s
47 // CHECK-IOMP5-LD-32: "{{.*}}ld{{(.exe)?}}"
48 // CHECK-IOMP5-LD-32: "-l[[DEFAULT_OPENMP_LIB:[^"]*]]"
49 // CHECK-IOMP5-LD-32: "-lpthread" "-lc"
50 //
51 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
52 // RUN:     -fopenmp -target x86_64-unknown-linux -rtlib=platform \
53 // RUN:   | FileCheck --check-prefix=CHECK-IOMP5-LD-64 %s
54 // CHECK-IOMP5-LD-64: "{{.*}}ld{{(.exe)?}}"
55 // CHECK-IOMP5-LD-64: "-l[[DEFAULT_OPENMP_LIB:[^"]*]]"
56 // CHECK-IOMP5-LD-64: "-lpthread" "-lc"
57 //
58 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
59 // RUN:     -fopenmp=lib -target i386-unknown-linux \
60 // RUN:   | FileCheck --check-prefix=CHECK-LIB-LD-32 %s
61 // CHECK-LIB-LD-32: error: unsupported argument 'lib' to option 'fopenmp='
62 //
63 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
64 // RUN:     -fopenmp=lib -target x86_64-unknown-linux \
65 // RUN:   | FileCheck --check-prefix=CHECK-LIB-LD-64 %s
66 // CHECK-LIB-LD-64: error: unsupported argument 'lib' to option 'fopenmp='
67 //
68 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
69 // RUN:     -fopenmp -fopenmp=libgomp -target i386-unknown-linux \
70 // RUN:     -rtlib=platform \
71 // RUN:   | FileCheck --check-prefix=CHECK-LD-OVERRIDE-32 %s
72 // CHECK-LD-OVERRIDE-32: "{{.*}}ld{{(.exe)?}}"
73 // CHECK-LD-OVERRIDE-32: "-lgomp" "-lrt"
74 // CHECK-LD-OVERRIDE-32: "-lpthread" "-lc"
75 //
76 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
77 // RUN:     -fopenmp -fopenmp=libgomp -target x86_64-unknown-linux \
78 // RUN:     -rtlib=platform \
79 // RUN:   | FileCheck --check-prefix=CHECK-LD-OVERRIDE-64 %s
80 // CHECK-LD-OVERRIDE-64: "{{.*}}ld{{(.exe)?}}"
81 // CHECK-LD-OVERRIDE-64: "-lgomp" "-lrt"
82 // CHECK-LD-OVERRIDE-64: "-lpthread" "-lc"
83 //
84 // RUN: %clang -no-canonical-prefixes -fuse-ld=link %s -### -o %t.o 2>&1 \
85 // RUN:     -fopenmp=libomp -target x86_64-msvc-win32 -rtlib=platform \
86 // RUN:   | FileCheck --check-prefix=CHECK-MSVC-LINK-64 %s
87 // CHECK-MSVC-LINK-64: link.exe
88 // CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcomp.lib
89 // CHECK-MSVC-LINK-64-SAME: -nodefaultlib:vcompd.lib
90 // CHECK-MSVC-LINK-64-SAME: -libpath:{{.+}}/../lib
91 // CHECK-MSVC-LINK-64-SAME: -defaultlib:libomp.lib
92 
93 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target x86_64-msvc-win32 -rtlib=platform | FileCheck --check-prefix SIMD-ONLY11 %s
94 // SIMD-ONLY11-NOT: libiomp
95 // SIMD-ONLY11-NOT: libomp
96 // SIMD-ONLY11-NOT: libgomp
97 //
98 // RUN: %clang -no-canonical-prefixes %s -fuse-ld=link -### -o %t.o 2>&1 \
99 // RUN:     -fopenmp=libiomp5 -target x86_64-msvc-win32 -rtlib=platform \
100 // RUN:   | FileCheck --check-prefix=CHECK-MSVC-ILINK-64 %s
101 
102 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fopenmp-simd -target x86_64-msvc-win32 -rtlib=platform | FileCheck --check-prefix SIMD-ONLY11 %s
103 // SIMD-ONLY11-NOT: libiomp
104 // SIMD-ONLY11-NOT: libomp
105 // SIMD-ONLY11-NOT: libgomp
106 // CHECK-MSVC-ILINK-64: link.exe
107 // CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcomp.lib
108 // CHECK-MSVC-ILINK-64-SAME: -nodefaultlib:vcompd.lib
109 // CHECK-MSVC-ILINK-64-SAME: -libpath:{{.+}}/../lib
110 // CHECK-MSVC-ILINK-64-SAME: -defaultlib:libiomp5md.lib
111 //
112