1 // General tests that ld invocations on Solaris targets sane. Note that we use
2 // sysroot to make these tests independent of the host system.
4 // Check sparc-sun-solaris2.11, 32bit
5 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld= \
6 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
7 // RUN: | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-LD %s
8 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld=gld \
9 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
10 // RUN: | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-GLD %s
11 // CHECK-LD-SPARC32-NOT: warning:
12 // CHECK-LD-SPARC32: "-cc1" "-triple" "sparc-sun-solaris2.11"
13 // CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
14 // CHECK-LD-SPARC32: "{{.*}}ld{{(.exe)?}}"
15 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crt1.o"
16 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o"
17 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtbegin.o"
18 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
19 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
20 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
21 // CHECK-LD: "-z" "ignore" "-latomic" "-z" "record"
22 // CHECK-GLD: "--as-needed" "-latomic" "--no-as-needed"
23 // CHECK-LD: "-z" "ignore" "-lgcc_s" "-z" "record"
24 // CHECK-GLD: "--as-needed" "-lgcc_s" "--no-as-needed"
25 // CHECK-LD-SPARC32-SAME: "-lc"
26 // CHECK-LD-SPARC32-SAME: "-lgcc"
27 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtend.o"
28 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crtn.o"
30 // Check sparc-sun-solaris2.11, 64bit
31 // RUN: %clang -m64 -### %s 2>&1 --target=sparc-sun-solaris2.11 \
32 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
33 // RUN: | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
34 // CHECK-LD-SPARC64-NOT: warning:
35 // CHECK-LD-SPARC64: "-cc1" "-triple" "sparcv9-sun-solaris2.11"
36 // CHECK-LD-SPARC64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
37 // CHECK-LD-SPARC64: "{{.*}}ld{{(.exe)?}}"
38 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crt1.o"
39 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|\\\\}}crti.o"
40 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crtbegin.o"
41 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
42 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
43 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
44 // CHECK-LD-SPARC64-NOT: "-latomic"
45 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
46 // CHECK-LD-SPARC64-SAME: "-lc"
47 // CHECK-LD-SPARC64-SAME: "-lgcc"
48 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crtend.o"
49 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|\\\\}}crtn.o"
51 // Check i386-pc-solaris2.11, 32bit
52 // RUN: %clang -### %s 2>&1 --target=i386-pc-solaris2.11 \
53 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
54 // RUN: | FileCheck --check-prefix=CHECK-LD-X32 %s
55 // CHECK-LD-X32-NOT: warning:
56 // CHECK-LD-X32: "-cc1" "-triple" "i386-pc-solaris2.11"
57 // CHECK-LD-X32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
58 // CHECK-LD-X32: "{{.*}}ld{{(.exe)?}}"
59 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt1.o"
60 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o"
61 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|\\\\}}crtbegin.o"
62 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4"
63 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
64 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
65 // CHECK-LD-X32-NOT: "-latomic"
66 // CHECK-LD-X32-SAME: "-lgcc_s"
67 // CHECK-LD-X32-SAME: "-lc"
68 // CHECK-LD-X32-SAME: "-lgcc"
69 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|\\\\}}crtend.o"
70 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crtn.o"
72 // Check i386-pc-solaris2.11, 64bit
73 // RUN: %clang -m64 -### %s 2>&1 \
74 // RUN: --target=i386-pc-solaris2.11 \
75 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
76 // RUN: | FileCheck --check-prefix=CHECK-LD-X64 %s
77 // CHECK-LD-X64-NOT: warning:
78 // CHECK-LD-X64: "-cc1" "-triple" "x86_64-pc-solaris2.11"
79 // CHECK-LD-X64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
80 // CHECK-LD-X64: "{{.*}}ld{{(.exe)?}}"
81 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|\\\\}}crt1.o"
82 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|\\\\}}crti.o"
83 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|\\\\}}crtbegin.o"
84 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64"
85 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../../amd64"
86 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/lib/amd64"
87 // CHECK-LD-X64-NOT: "-latomic"
88 // CHECK-LD-X64-SAME: "-lgcc_s"
89 // CHECK-LD-X64-SAME: "-lc"
90 // CHECK-LD-X64-SAME: "-lgcc"
91 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|\\\\}}crtend.o"
92 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|\\\\}}crtn.o"
94 // Check the right -l flags are present with -shared
95 // RUN: %clang -### %s -shared 2>&1 \
96 // RUN: --target=sparc-sun-solaris2.11 \
97 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
98 // RUN: | FileCheck --check-prefix=CHECK-SPARC32-SHARED %s
99 // CHECK-SPARC32-SHARED: "{{.*}}ld{{(.exe)?}}"
100 // CHECK-SPARC32-SHARED-SAME: "-lgcc_s"
101 // CHECK-SPARC32-SHARED-SAME: "-lc"
102 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
104 // Check that libm is only linked with clang++.
105 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
106 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
107 // RUN: | FileCheck --check-prefix=CHECK-NOLIBM %s
108 // RUN: %clang -### %s -shared --target=sparc-sun-solaris2.11 \
109 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
110 // RUN: | FileCheck --check-prefix=CHECK-NOLIBM %s
111 // RUN: %clangxx -### %s --target=sparc-sun-solaris2.11 \
112 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
113 // RUN: | FileCheck --check-prefix=CHECK-LIBM %s
114 // RUN: %clangxx -### %s -shared --target=sparc-sun-solaris2.11 \
115 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
116 // RUN: | FileCheck --check-prefix=CHECK-LIBM %s
118 // CHECK-NOLIBM-NOT: "-lm"
120 // Check the right ld flags are present with -pie.
121 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie -fuse-ld= \
122 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
123 // RUN: | FileCheck --check-prefix=CHECK-PIE-LD %s
124 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie -fuse-ld=gld \
125 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
126 // RUN: | FileCheck --check-prefix=CHECK-PIE-GLD %s
127 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie -fuse-ld= \
128 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
129 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
130 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie -fuse-ld=gld \
131 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
132 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
134 // Check that -shared/-r/-static disable PIE.
135 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -shared -pie -fuse-ld= \
136 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
137 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
138 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -shared -pie -fuse-ld=gld \
139 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
140 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
141 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -r -pie -fuse-ld= \
142 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
143 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
144 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -r -pie -fuse-ld=gld \
145 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
146 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
147 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -static -pie -fuse-ld= \
148 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
149 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
150 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -static -pie -fuse-ld=gld \
151 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
152 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
154 // CHECK-PIE-LD: "-z" "type=pie"
155 // CHECK-PIE-GLD: "-pie"
156 // CHECK-NOPIE-LD-NOT: "-z" "type=pie"
157 // CHECK-NOPIE-GLD-NOT: "-pie"
159 // -r suppresses default -l and crt*.o, values-*.o like -nostdlib.
160 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -r 2>&1 \
161 // RUN: | FileCheck %s --check-prefix=CHECK-RELOCATABLE
162 // CHECK-RELOCATABLE: "-L
163 // CHECK-RELOCATABLE: "-r"
164 // CHECK-RELOCATABLE-NOT: "-e"
165 // CHECK-RELOCATABLE-NOT: "-l
166 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
167 // CHECK-RELOCATABLE-NOT: /values-{{[^.]+}}.o
169 // Check that crt{begin,end}S.o is linked with -shared/-pie.
170 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
171 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
172 // RUN: | FileCheck --check-prefix=CHECK-NOCRTS %s
173 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -shared \
174 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
175 // RUN: | FileCheck --check-prefix=CHECK-CRTS %s
176 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -no-pie \
177 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
178 // RUN: | FileCheck --check-prefix=CHECK-NOCRTS %s
179 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie \
180 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
181 // RUN: | FileCheck --check-prefix=CHECK-CRTS %s
182 // CHECK-CRTS: crtbeginS.o
183 // CHECK-CRTS: crtendS.o
184 // CHECK-NOCRTS-NOT: crtbeginS.o
185 // CHECK-NOCRTS-NOT: crtendS.o
187 // Check that crtfastmath.o is linked with -ffast-math.
189 // Check sparc-sun-solaris2.11, 32bit
190 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
191 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
192 // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC32 %s
193 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -ffast-math \
194 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
195 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC32 %s
196 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -ffp-model=fast \
197 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
198 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC32 %s
199 // CHECK-CRTFASTMATH-SPARC32: "-isysroot" "[[SYSROOT:[^"]+]]"
200 // CHECK-CRTFASTMATH-SPARC32: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtfastmath.o"
201 // CHECK-NOCRTFASTMATH-SPARC32-NOT: crtfastmath.o
203 // Check sparc-pc-solaris2.11, 64bit
204 // RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s \
205 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
206 // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC64 %s
207 // RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s -ffast-math \
208 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
209 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC64 %s
210 // CHECK-CRTFASTMATH-SPARC64: "-isysroot" "[[SYSROOT:[^"]+]]"
211 // CHECK-CRTFASTMATH-SPARC64: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crtfastmath.o"
212 // CHECK-NOCRTFASTMATH-SPARC64-NOT: crtfastmath.o
214 // Check i386-pc-solaris2.11, 32bit
215 // RUN: %clang --target=i386-pc-solaris2.11 -### %s \
216 // RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
217 // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X32 %s
218 // RUN: %clang --target=i386-pc-solaris2.11 -### %s -ffast-math \
219 // RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
220 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-X32 %s
221 // CHECK-CRTFASTMATH-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
222 // CHECK-CRTFASTMATH-X32: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|\\\\}}crtfastmath.o"
223 // CHECK-NOCRTFASTMATH-X32-NOT: crtfastmath.o
225 // Check i386-pc-solaris2.11, 64bit
226 // RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s \
227 // RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
228 // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X64 %s
229 // RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s -ffast-math \
230 // RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
231 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-X64 %s
232 // CHECK-CRTFASTMATH-X64: "-isysroot" "[[SYSROOT:[^"]+]]"
233 // CHECK-CRTFASTMATH-X64: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|\\\\}}crtfastmath.o"
234 // CHECK-NOCRTFASTMATH-X64-NOT: crtfastmath.o