[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / Driver / solaris-ld.c
blob8f7f168c387214dba496c86a3b92b2919cbac4c1
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: --gcc-toolchain="" \
7 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
8 // RUN: | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-LD %s
9 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -fuse-ld=gld \
10 // RUN: --gcc-toolchain="" \
11 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
12 // RUN: | FileCheck --check-prefixes=CHECK-LD-SPARC32,CHECK-GLD %s
13 // CHECK-LD-SPARC32-NOT: warning:
14 // CHECK-LD-SPARC32: "-cc1" "-triple" "sparc-sun-solaris2.11"
15 // CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
16 // CHECK-LD-SPARC32: "{{.*}}ld{{(.exe)?}}"
17 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crt1.o"
18 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o"
19 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtbegin.o"
20 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
21 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
22 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
23 // CHECK-LD: "-z" "ignore" "-latomic" "-z" "record"
24 // CHECK-GLD: "--as-needed" "-latomic" "--no-as-needed"
25 // CHECK-LD: "-z" "ignore" "-lgcc_s" "-z" "record"
26 // CHECK-GLD: "--as-needed" "-lgcc_s" "--no-as-needed"
27 // CHECK-LD-SPARC32-SAME: "-lc"
28 // CHECK-LD-SPARC32-SAME: "-lgcc"
29 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtend.o"
30 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crtn.o"
32 // Check sparc-sun-solaris2.11, 64bit
33 // RUN: %clang -m64 -### %s 2>&1 --target=sparc-sun-solaris2.11 \
34 // RUN: --gcc-toolchain="" \
35 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
36 // RUN: | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
37 // CHECK-LD-SPARC64-NOT: warning:
38 // CHECK-LD-SPARC64: "-cc1" "-triple" "sparcv9-sun-solaris2.11"
39 // CHECK-LD-SPARC64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
40 // CHECK-LD-SPARC64: "{{.*}}ld{{(.exe)?}}"
41 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crt1.o"
42 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|\\\\}}crti.o"
43 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crtbegin.o"
44 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
45 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
46 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
47 // CHECK-LD-SPARC64-NOT: "-latomic"
48 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
49 // CHECK-LD-SPARC64-SAME: "-lc"
50 // CHECK-LD-SPARC64-SAME: "-lgcc"
51 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crtend.o"
52 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|\\\\}}crtn.o"
54 // Check i386-pc-solaris2.11, 32bit
55 // RUN: %clang -### %s 2>&1 --target=i386-pc-solaris2.11 \
56 // RUN: --gcc-toolchain="" \
57 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
58 // RUN: | FileCheck --check-prefix=CHECK-LD-X32 %s
59 // CHECK-LD-X32-NOT: warning:
60 // CHECK-LD-X32: "-cc1" "-triple" "i386-pc-solaris2.11"
61 // CHECK-LD-X32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
62 // CHECK-LD-X32: "{{.*}}ld{{(.exe)?}}"
63 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt1.o"
64 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crti.o"
65 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|\\\\}}crtbegin.o"
66 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4"
67 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
68 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
69 // CHECK-LD-X32-NOT: "-latomic"
70 // CHECK-LD-X32-SAME: "-lgcc_s"
71 // CHECK-LD-X32-SAME: "-lc"
72 // CHECK-LD-X32-SAME: "-lgcc"
73 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|\\\\}}crtend.o"
74 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|\\\\}}crtn.o"
76 // Check i386-pc-solaris2.11, 64bit
77 // RUN: %clang -m64 -### %s 2>&1 \
78 // RUN: --target=i386-pc-solaris2.11 \
79 // RUN: --gcc-toolchain="" \
80 // RUN: --sysroot=%S/Inputs/solaris_x86_tree \
81 // RUN: | FileCheck --check-prefix=CHECK-LD-X64 %s
82 // CHECK-LD-X64-NOT: warning:
83 // CHECK-LD-X64: "-cc1" "-triple" "x86_64-pc-solaris2.11"
84 // CHECK-LD-X64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
85 // CHECK-LD-X64: "{{.*}}ld{{(.exe)?}}"
86 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|\\\\}}crt1.o"
87 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|\\\\}}crti.o"
88 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|\\\\}}crtbegin.o"
89 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64"
90 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../../amd64"
91 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/lib/amd64"
92 // CHECK-LD-X64-NOT: "-latomic"
93 // CHECK-LD-X64-SAME: "-lgcc_s"
94 // CHECK-LD-X64-SAME: "-lc"
95 // CHECK-LD-X64-SAME: "-lgcc"
96 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|\\\\}}crtend.o"
97 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|\\\\}}crtn.o"
99 // Check the right -l flags are present with -shared
100 // RUN: %clang -### %s -shared 2>&1 \
101 // RUN: --target=sparc-sun-solaris2.11 \
102 // RUN: --gcc-toolchain="" \
103 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree \
104 // RUN: | FileCheck --check-prefix=CHECK-SPARC32-SHARED %s
105 // CHECK-SPARC32-SHARED: "{{.*}}ld{{(.exe)?}}"
106 // CHECK-SPARC32-SHARED-SAME: "-lgcc_s"
107 // CHECK-SPARC32-SHARED-SAME: "-lc"
108 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
110 // Check that libm is only linked with clang++.
111 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
112 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
113 // RUN: | FileCheck --check-prefix=CHECK-NOLIBM %s
114 // RUN: %clang -### %s -shared --target=sparc-sun-solaris2.11 \
115 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
116 // RUN: | FileCheck --check-prefix=CHECK-NOLIBM %s
117 // RUN: %clangxx -### %s --target=sparc-sun-solaris2.11 \
118 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
119 // RUN: | FileCheck --check-prefix=CHECK-LIBM %s
120 // RUN: %clangxx -### %s -shared --target=sparc-sun-solaris2.11 \
121 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
122 // RUN: | FileCheck --check-prefix=CHECK-LIBM %s
123 // CHECK-LIBM: "-lm"
124 // CHECK-NOLIBM-NOT: "-lm"
126 // Check the right ld flags are present with -pie.
127 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie -fuse-ld= \
128 // RUN: --gcc-toolchain="" \
129 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
130 // RUN: | FileCheck --check-prefix=CHECK-PIE-LD %s
131 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie -fuse-ld=gld \
132 // RUN: --gcc-toolchain="" \
133 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
134 // RUN: | FileCheck --check-prefix=CHECK-PIE-GLD %s
135 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie -fuse-ld= \
136 // RUN: --gcc-toolchain="" \
137 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
138 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
139 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie -fuse-ld=gld \
140 // RUN: --gcc-toolchain="" \
141 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
142 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
144 // Check that -shared/-r/-static disable PIE.
145 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -shared -pie -fuse-ld= \
146 // RUN: --gcc-toolchain="" \
147 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
148 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
149 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -shared -pie -fuse-ld=gld \
150 // RUN: --gcc-toolchain="" \
151 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
152 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
153 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -r -pie -fuse-ld= \
154 // RUN: --gcc-toolchain="" \
155 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
156 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
157 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -r -pie -fuse-ld=gld \
158 // RUN: --gcc-toolchain="" \
159 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
160 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
161 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -static -pie -fuse-ld= \
162 // RUN: --gcc-toolchain="" \
163 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
164 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-LD %s
165 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -static -pie -fuse-ld=gld \
166 // RUN: --gcc-toolchain="" \
167 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
168 // RUN: | FileCheck --check-prefix=CHECK-NOPIE-GLD %s
170 // CHECK-PIE-LD: "-z" "type=pie"
171 // CHECK-PIE-GLD: "-pie"
172 // CHECK-NOPIE-LD-NOT: "-z" "type=pie"
173 // CHECK-NOPIE-GLD-NOT: "-pie"
175 // -r suppresses default -l and crt*.o, values-*.o like -nostdlib.
176 // RUN: %clang -### %s --target=sparc-sun-solaris2.11 -r 2>&1 \
177 // RUN: | FileCheck %s --check-prefix=CHECK-RELOCATABLE
178 // CHECK-RELOCATABLE: "-L
179 // CHECK-RELOCATABLE: "-r"
180 // CHECK-RELOCATABLE-NOT: "-e"
181 // CHECK-RELOCATABLE-NOT: "-l
182 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
183 // CHECK-RELOCATABLE-NOT: /values-{{[^.]+}}.o
185 // Check that crt{begin,end}S.o is linked with -shared/-pie.
186 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
187 // RUN: --gcc-toolchain="" \
188 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
189 // RUN: | FileCheck --check-prefix=CHECK-NOCRTS %s
190 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -shared \
191 // RUN: --gcc-toolchain="" \
192 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
193 // RUN: | FileCheck --check-prefix=CHECK-CRTS %s
194 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -nopie \
195 // RUN: --gcc-toolchain="" \
196 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
197 // RUN: | FileCheck --check-prefix=CHECK-NOCRTS %s
198 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -pie \
199 // RUN: --gcc-toolchain="" \
200 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
201 // RUN: | FileCheck --check-prefix=CHECK-CRTS %s
202 // CHECK-CRTS: crtbeginS.o
203 // CHECK-CRTS: crtendS.o
204 // CHECK-NOCRTS-NOT: crtbeginS.o
205 // CHECK-NOCRTS-NOT: crtendS.o
207 // Check that crtfastmath.o is linked with -ffast-math.
209 // Check sparc-sun-solaris2.11, 32bit
210 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s \
211 // RUN: --gcc-toolchain="" \
212 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
213 // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC32 %s
214 // RUN: %clang --target=sparc-sun-solaris2.11 -### %s -ffast-math \
215 // RUN: --gcc-toolchain="" \
216 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
217 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC32 %s
218 // CHECK-CRTFASTMATH-SPARC32: "-isysroot" "[[SYSROOT:[^"]+]]"
219 // CHECK-CRTFASTMATH-SPARC32: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtfastmath.o"
220 // CHECK-NOCRTFASTMATH-SPARC32-NOT: crtfastmath.o
222 // Check sparc-pc-solaris2.11, 64bit
223 // RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s \
224 // RUN: --gcc-toolchain="" \
225 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
226 // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-SPARC64 %s
227 // RUN: %clang -m64 --target=sparc-sun-solaris2.11 -### %s -ffast-math \
228 // RUN: --gcc-toolchain="" \
229 // RUN: --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
230 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-SPARC64 %s
231 // CHECK-CRTFASTMATH-SPARC64: "-isysroot" "[[SYSROOT:[^"]+]]"
232 // CHECK-CRTFASTMATH-SPARC64: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|\\\\}}crtfastmath.o"
233 // CHECK-NOCRTFASTMATH-SPARC64-NOT: crtfastmath.o
235 // Check i386-pc-solaris2.11, 32bit
236 // RUN: %clang --target=i386-pc-solaris2.11 -### %s \
237 // RUN: --gcc-toolchain="" \
238 // RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
239 // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X32 %s
240 // RUN: %clang --target=i386-pc-solaris2.11 -### %s -ffast-math \
241 // RUN: --gcc-toolchain="" \
242 // RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
243 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-X32 %s
244 // CHECK-CRTFASTMATH-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
245 // CHECK-CRTFASTMATH-X32: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|\\\\}}crtfastmath.o"
246 // CHECK-NOCRTFASTMATH-X32-NOT: crtfastmath.o
248 // Check i386-pc-solaris2.11, 64bit
249 // RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s \
250 // RUN: --gcc-toolchain="" \
251 // RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
252 // RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH-X64 %s
253 // RUN: %clang -m64 --target=i386-pc-solaris2.11 -### %s -ffast-math \
254 // RUN: --gcc-toolchain="" \
255 // RUN: --sysroot=%S/Inputs/solaris_x86_tree 2>&1 \
256 // RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH-X64 %s
257 // CHECK-CRTFASTMATH-X64: "-isysroot" "[[SYSROOT:[^"]+]]"
258 // CHECK-CRTFASTMATH-X64: "[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|\\\\}}crtfastmath.o"
259 // CHECK-NOCRTFASTMATH-X64-NOT: crtfastmath.o