blob: 0e9c596fa2598cf38748f0f9955551a37151a8c5 [file] [log] [blame]
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +00001// Test sanitizers ld flags.
2
3// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
4// RUN: -target i386-unknown-linux -fsanitize=address \
Richard Smithf3e624c2013-03-23 00:30:08 +00005// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +00006// RUN: --sysroot=%S/Inputs/basic_linux_tree \
7// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX %s
8//
9// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
10// CHECK-ASAN-LINUX-NOT: "-lc"
11// CHECK-ASAN-LINUX: libclang_rt.asan-i386.a"
Alexey Samsonov52550342014-09-15 19:58:40 +000012// CHECK-ASAN-LINUX-NOT: "-export-dynamic"
13// CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan-i386.a.syms"
14// CHECK-ASAN-LINUX-NOT: "-export-dynamic"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000015// CHECK-ASAN-LINUX: "-lpthread"
Evgeniy Stepanov758b5072013-05-24 14:28:03 +000016// CHECK-ASAN-LINUX: "-lrt"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000017// CHECK-ASAN-LINUX: "-ldl"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000018
Viktor Kutuzovaa5b5f72014-03-18 09:36:50 +000019// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Alexey Samsonovbdfa6c22014-04-01 13:31:10 +000020// RUN: -target i386-unknown-linux -fsanitize=address -shared-libasan \
21// RUN: -resource-dir=%S/Inputs/resource_dir \
22// RUN: --sysroot=%S/Inputs/basic_linux_tree \
23// RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s
24//
25// CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
26// CHECK-SHARED-ASAN-LINUX-NOT: "-lc"
Evgeniy Stepanov8f4e7362014-08-27 09:46:54 +000027// CHECK-SHARED-ASAN-LINUX-NOT: libclang_rt.asan-i386.a"
Evgeniy Stepanov8f4e7362014-08-27 09:46:54 +000028// CHECK-SHARED-ASAN-LINUX: libclang_rt.asan-i386.so"
Alexey Samsonov52550342014-09-15 19:58:40 +000029// CHECK-SHARED-ASAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-preinit-i386.a" "-no-whole-archive"
Alexey Samsonovbdfa6c22014-04-01 13:31:10 +000030// CHECK-SHARED-ASAN-LINUX-NOT: "-lpthread"
31// CHECK-SHARED-ASAN-LINUX-NOT: "-lrt"
32// CHECK-SHARED-ASAN-LINUX-NOT: "-ldl"
33// CHECK-SHARED-ASAN-LINUX-NOT: "-export-dynamic"
34// CHECK-SHARED-ASAN-LINUX-NOT: "--dynamic-list"
35
36// RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \
37// RUN: -target i386-unknown-linux -fsanitize=address -shared-libasan \
38// RUN: -resource-dir=%S/Inputs/resource_dir \
39// RUN: --sysroot=%S/Inputs/basic_linux_tree \
40// RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-ASAN-LINUX %s
41//
42// CHECK-DSO-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
43// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lc"
Evgeniy Stepanov8f4e7362014-08-27 09:46:54 +000044// CHECK-DSO-SHARED-ASAN-LINUX-NOT: libclang_rt.asan-i386.a"
Alexey Samsonovbdfa6c22014-04-01 13:31:10 +000045// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "libclang_rt.asan-preinit-i386.a"
Evgeniy Stepanov8f4e7362014-08-27 09:46:54 +000046// CHECK-DSO-SHARED-ASAN-LINUX: libclang_rt.asan-i386.so"
Alexey Samsonovbdfa6c22014-04-01 13:31:10 +000047// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lpthread"
48// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lrt"
49// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-ldl"
50// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-export-dynamic"
51// CHECK-DSO-SHARED-ASAN-LINUX-NOT: "--dynamic-list"
52
53// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Viktor Kutuzovaa5b5f72014-03-18 09:36:50 +000054// RUN: -target i386-unknown-freebsd -fsanitize=address \
55// RUN: -resource-dir=%S/Inputs/resource_dir \
56// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
57// RUN: | FileCheck --check-prefix=CHECK-ASAN-FREEBSD %s
58//
59// CHECK-ASAN-FREEBSD: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
60// CHECK-ASAN-FREEBSD-NOT: "-lc"
Alexey Samsonovb01f9362014-05-12 18:39:51 +000061// CHECK-ASAN-FREEBSD-NOT: libclang_rt.asan_cxx
NAKAMURA Takumia65db1e2014-03-18 10:47:10 +000062// CHECK-ASAN-FREEBSD: freebsd{{/|\\+}}libclang_rt.asan-i386.a"
Alexey Samsonovb01f9362014-05-12 18:39:51 +000063// CHECK-ASAN-FREEBSD-NOT: libclang_rt.asan_cxx
Alexey Samsonov52550342014-09-15 19:58:40 +000064// CHECK-ASAN-FREEBSD-NOT: "--dynamic-list"
65// CHECK-ASAN-FREEBSD: "-export-dynamic"
Viktor Kutuzovaa5b5f72014-03-18 09:36:50 +000066// CHECK-ASAN-FREEBSD: "-lpthread"
67// CHECK-ASAN-FREEBSD: "-lrt"
Viktor Kutuzovaa5b5f72014-03-18 09:36:50 +000068
69// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
70// RUN: -target i386-unknown-freebsd -fsanitize=address \
71// RUN: -resource-dir=%S/Inputs/resource_dir \
72// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
73// RUN: | FileCheck --check-prefix=CHECK-ASAN-FREEBSD-LDL %s
74//
75// CHECK-ASAN-FREEBSD-LDL: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
76// CHECK-ASAN-FREEBSD-LDL-NOT: "-ldl"
77
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000078// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
79// RUN: -target i386-unknown-linux -fsanitize=address \
Richard Smithf3e624c2013-03-23 00:30:08 +000080// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000081// RUN: --sysroot=%S/Inputs/basic_linux_tree \
82// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s
83//
84// CHECK-ASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
85// CHECK-ASAN-LINUX-CXX-NOT: "-lc"
86// CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
Alexey Samsonov52550342014-09-15 19:58:40 +000087// CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan_cxx-i386.a" "-no-whole-archive"
88// CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
89// CHECK-ASAN-LINUX-CXX: "-export-dynamic"
90// CHECK-ASAN-LINUX-CXX: stdc++
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000091// CHECK-ASAN-LINUX-CXX: "-lpthread"
Evgeniy Stepanov758b5072013-05-24 14:28:03 +000092// CHECK-ASAN-LINUX-CXX: "-lrt"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000093// CHECK-ASAN-LINUX-CXX: "-ldl"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000094
95// RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
96// RUN: -target i386-unknown-linux --sysroot=%S/Inputs/basic_linux_tree \
97// RUN: -lstdc++ -static 2>&1 \
98// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX-STATIC %s
99//
100// CHECK-ASAN-LINUX-CXX-STATIC: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
101// CHECK-ASAN-LINUX-CXX-STATIC-NOT: stdc++
102// CHECK-ASAN-LINUX-CXX-STATIC: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
103// CHECK-ASAN-LINUX-CXX-STATIC: stdc++
104
105// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Renato Goline2dbedd2014-01-31 12:21:55 +0000106// RUN: -target arm-linux-gnueabi -fsanitize=address \
107// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
108// RUN: | FileCheck --check-prefix=CHECK-ASAN-ARM %s
109//
110// CHECK-ASAN-ARM: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
111// CHECK-ASAN-ARM-NOT: "-lc"
112// CHECK-ASAN-ARM: libclang_rt.asan-arm.a"
113//
114// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
115// RUN: -target armv7l-linux-gnueabi -fsanitize=address \
116// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
117// RUN: | FileCheck --check-prefix=CHECK-ASAN-ARMv7 %s
118//
119// CHECK-ASAN-ARMv7: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
120// CHECK-ASAN-ARMv7-NOT: "-lc"
121// CHECK-ASAN-ARMv7: libclang_rt.asan-arm.a"
Renato Goline2dbedd2014-01-31 12:21:55 +0000122
123// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000124// RUN: -target arm-linux-androideabi -fsanitize=address \
125// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
126// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID %s
127//
128// CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
129// CHECK-ASAN-ANDROID-NOT: "-lc"
Alexey Samsonove65ceb92014-02-25 13:26:03 +0000130// CHECK-ASAN-ANDROID: "-pie"
131// CHECK-ASAN-ANDROID-NOT: "-lpthread"
Alexey Samsonov52550342014-09-15 19:58:40 +0000132// CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
133// CHECK-ASAN-ANDROID-NOT: "-lpthread"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000134//
135// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
136// RUN: -target arm-linux-androideabi -fsanitize=address \
137// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
Evgeniy Stepanov6f0ae182014-06-05 11:14:00 +0000138// RUN: -shared-libasan \
139// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED-LIBASAN %s
140//
141// CHECK-ASAN-ANDROID-SHARED-LIBASAN-NOT: argument unused during compilation: '-shared-libasan'
142//
143// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
144// RUN: -target arm-linux-androideabi -fsanitize=address \
145// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000146// RUN: -shared \
147// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED %s
148//
149// CHECK-ASAN-ANDROID-SHARED: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
150// CHECK-ASAN-ANDROID-SHARED-NOT: "-lc"
Evgeniy Stepanov8f4e7362014-08-27 09:46:54 +0000151// CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000152// CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"
153
154// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
155// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=thread \
Richard Smithf3e624c2013-03-23 00:30:08 +0000156// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000157// RUN: --sysroot=%S/Inputs/basic_linux_tree \
158// RUN: | FileCheck --check-prefix=CHECK-TSAN-LINUX-CXX %s
159//
160// CHECK-TSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
161// CHECK-TSAN-LINUX-CXX-NOT: stdc++
162// CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
Alexey Samsonov52550342014-09-15 19:58:40 +0000163// CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan-x86_64.a.syms"
Alexey Samsonov381845d2015-04-27 22:07:50 +0000164// CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan_cxx-x86_64.a" "-no-whole-archive"
165// CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan_cxx-x86_64.a.syms"
Alexey Samsonov52550342014-09-15 19:58:40 +0000166// CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
167// CHECK-TSAN-LINUX-CXX: stdc++
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000168// CHECK-TSAN-LINUX-CXX: "-lpthread"
Evgeniy Stepanov758b5072013-05-24 14:28:03 +0000169// CHECK-TSAN-LINUX-CXX: "-lrt"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000170// CHECK-TSAN-LINUX-CXX: "-ldl"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000171
172// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
173// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=memory \
Richard Smithf3e624c2013-03-23 00:30:08 +0000174// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000175// RUN: --sysroot=%S/Inputs/basic_linux_tree \
176// RUN: | FileCheck --check-prefix=CHECK-MSAN-LINUX-CXX %s
177//
178// CHECK-MSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
179// CHECK-MSAN-LINUX-CXX-NOT: stdc++
180// CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
Alexey Samsonov52550342014-09-15 19:58:40 +0000181// CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan-x86_64.a.syms"
Alexey Samsonov381845d2015-04-27 22:07:50 +0000182// CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan_cxx-x86_64.a" "-no-whole-archive"
183// CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan_cxx-x86_64.a.syms"
Alexey Samsonov52550342014-09-15 19:58:40 +0000184// CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
185// CHECK-MSAN-LINUX-CXX: stdc++
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000186// CHECK-MSAN-LINUX-CXX: "-lpthread"
Evgeniy Stepanov758b5072013-05-24 14:28:03 +0000187// CHECK-MSAN-LINUX-CXX: "-lrt"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000188// CHECK-MSAN-LINUX-CXX: "-ldl"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000189
190// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
191// RUN: -target i386-unknown-linux \
192// RUN: --sysroot=%S/Inputs/basic_linux_tree \
193// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
194// CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
Richard Smithcff3cde2013-03-20 23:49:07 +0000195// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
Alexey Samsonov3ae177c2015-03-23 20:05:42 +0000196// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_standalone_cxx
197// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone-i386.a" "-no-whole-archive"
Alexey Samsonovc4f1fc22014-08-18 22:10:42 +0000198// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
Alexey Samsonov3ae177c2015-03-23 20:05:42 +0000199// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_standalone_cxx
Richard Smithcff3cde2013-03-20 23:49:07 +0000200// CHECK-UBSAN-LINUX-NOT: "-lstdc++"
Alexey Samsonov52550342014-09-15 19:58:40 +0000201// CHECK-UBSAN-LINUX: "-lpthread"
Richard Smithcff3cde2013-03-20 23:49:07 +0000202
Alexey Samsonov90490af2014-08-08 22:47:17 +0000203// RUN: %clang -fsanitize=undefined -fsanitize-link-c++-runtime %s -### -o %t.o 2>&1 \
204// RUN: -target i386-unknown-linux \
205// RUN: --sysroot=%S/Inputs/basic_linux_tree \
206// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-LINK-CXX %s
207// CHECK-UBSAN-LINUX-LINK-CXX-NOT: "-lstdc++"
Alexey Samsonov3ae177c2015-03-23 20:05:42 +0000208// CHECK-UBSAN-LINUX-LINK-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone_cxx-i386.a" "-no-whole-archive"
Alexey Samsonov90490af2014-08-08 22:47:17 +0000209// CHECK-UBSAN-LINUX-LINK-CXX-NOT: "-lstdc++"
210
Richard Smithcff3cde2013-03-20 23:49:07 +0000211// RUN: %clangxx -fsanitize=undefined %s -### -o %t.o 2>&1 \
212// RUN: -target i386-unknown-linux \
Richard Smith4244ea92014-06-04 23:28:46 +0000213// RUN: -resource-dir=%S/Inputs/resource_dir \
Richard Smithcff3cde2013-03-20 23:49:07 +0000214// RUN: --sysroot=%S/Inputs/basic_linux_tree \
215// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-CXX %s
216// CHECK-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
217// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
Alexey Samsonov3ae177c2015-03-23 20:05:42 +0000218// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone-i386.a" "-no-whole-archive"
Alexey Samsonovc4f1fc22014-08-18 22:10:42 +0000219// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
Alexey Samsonov3ae177c2015-03-23 20:05:42 +0000220// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone_cxx-i386.a" "-no-whole-archive"
Alexey Samsonov52550342014-09-15 19:58:40 +0000221// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
Richard Smithcff3cde2013-03-20 23:49:07 +0000222// CHECK-UBSAN-LINUX-CXX: "-lstdc++"
Alexey Samsonov52550342014-09-15 19:58:40 +0000223// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
224// CHECK-UBSAN-LINUX-CXX: "-lpthread"
Richard Smithcff3cde2013-03-20 23:49:07 +0000225
226// RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
227// RUN: -target i386-unknown-linux \
228// RUN: --sysroot=%S/Inputs/basic_linux_tree \
229// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX %s
230// CHECK-ASAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
Richard Smithcff3cde2013-03-20 23:49:07 +0000231// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
Alexey Samsonov31095462015-04-01 22:42:25 +0000232// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan
Richard Smithcff3cde2013-03-20 23:49:07 +0000233// CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"
Alexey Samsonov52550342014-09-15 19:58:40 +0000234// CHECK-ASAN-UBSAN-LINUX: "-lpthread"
Richard Smithcff3cde2013-03-20 23:49:07 +0000235
236// RUN: %clangxx -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
237// RUN: -target i386-unknown-linux \
238// RUN: --sysroot=%S/Inputs/basic_linux_tree \
239// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX-CXX %s
240// CHECK-ASAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
Richard Smithcff3cde2013-03-20 23:49:07 +0000241// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
Alexey Samsonov31095462015-04-01 22:42:25 +0000242// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan_cxx-i386.a" "-no-whole-archive"
243// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
Richard Smithcff3cde2013-03-20 23:49:07 +0000244// CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
Alexey Samsonov52550342014-09-15 19:58:40 +0000245// CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000246
Alexey Samsonovd60832e2015-04-28 00:56:36 +0000247// RUN: %clangxx -fsanitize=memory,undefined %s -### -o %t.o 2>&1 \
248// RUN: -target x86_64-unknown-linux \
249// RUN: --sysroot=%S/Inputs/basic_linux_tree \
250// RUN: | FileCheck --check-prefix=CHECK-MSAN-UBSAN-LINUX-CXX %s
251// CHECK-MSAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
252// CHECK-MSAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
253// CHECK-MSAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
254
255// RUN: %clangxx -fsanitize=thread,undefined %s -### -o %t.o 2>&1 \
256// RUN: -target x86_64-unknown-linux \
257// RUN: --sysroot=%S/Inputs/basic_linux_tree \
258// RUN: | FileCheck --check-prefix=CHECK-TSAN-UBSAN-LINUX-CXX %s
259// CHECK-TSAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
260// CHECK-TSAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
261// CHECK-TSAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
262
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000263// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
264// RUN: -target i386-unknown-linux \
Richard Smith4244ea92014-06-04 23:28:46 +0000265// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000266// RUN: --sysroot=%S/Inputs/basic_linux_tree \
267// RUN: -shared \
268// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHARED %s
269// CHECK-UBSAN-LINUX-SHARED: "{{.*}}ld{{(.exe)?}}"
Richard Smith4244ea92014-06-04 23:28:46 +0000270// CHECK-UBSAN-LINUX-SHARED-NOT: --export-dynamic
271// CHECK-UBSAN-LINUX-SHARED-NOT: --dynamic-list
Alexey Samsonov3ae177c2015-03-23 20:05:42 +0000272// CHECK-UBSAN-LINUX-SHARED-NOT: libclang_rt.ubsan
Sergey Matveev1814e9e2013-05-27 11:17:01 +0000273
274// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
275// RUN: -target x86_64-unknown-linux -fsanitize=leak \
276// RUN: --sysroot=%S/Inputs/basic_linux_tree \
277// RUN: | FileCheck --check-prefix=CHECK-LSAN-LINUX %s
278//
279// CHECK-LSAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
280// CHECK-LSAN-LINUX-NOT: "-lc"
281// CHECK-LSAN-LINUX: libclang_rt.lsan-x86_64.a"
282// CHECK-LSAN-LINUX: "-lpthread"
283// CHECK-LSAN-LINUX: "-ldl"
284
Sergey Matveev1814e9e2013-05-27 11:17:01 +0000285// RUN: %clang -fsanitize=leak,address %s -### -o %t.o 2>&1 \
286// RUN: -target x86_64-unknown-linux \
287// RUN: --sysroot=%S/Inputs/basic_linux_tree \
288// RUN: | FileCheck --check-prefix=CHECK-LSAN-ASAN-LINUX %s
289// CHECK-LSAN-ASAN-LINUX: "{{.*}}ld{{(.exe)?}}"
290// CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
291// CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
292// CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
Hans Wennborg10821e52015-04-09 18:47:01 +0000293
Evgeniy Stepanovfd6f92d2015-12-15 23:00:20 +0000294// CFI by itself does not link runtime libraries.
295// RUN: %clang -fsanitize=cfi %s -### -o %t.o 2>&1 \
296// RUN: -target x86_64-unknown-linux \
297// RUN: --sysroot=%S/Inputs/basic_linux_tree \
298// RUN: | FileCheck --check-prefix=CHECK-CFI-LINUX %s
299// CHECK-CFI-LINUX: "{{.*}}ld{{(.exe)?}}"
300// CHECK-CFI-LINUX-NOT: libclang_rt.
301
302// CFI with diagnostics links the UBSan runtime.
303// RUN: %clang -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
304// RUN: %s -### -o %t.o 2>&1\
305// RUN: -target x86_64-unknown-linux \
306// RUN: --sysroot=%S/Inputs/basic_linux_tree \
307// RUN: | FileCheck --check-prefix=CHECK-CFI-DIAG-LINUX %s
308// CHECK-CFI-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
Evgeniy Stepanov17d60862015-12-16 22:03:39 +0000309// CHECK-CFI-DIAG-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.ubsan_standalone-x86_64.a" "-no-whole-archive"
Evgeniy Stepanovfd6f92d2015-12-15 23:00:20 +0000310
311// Cross-DSO CFI links the CFI runtime.
312// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
313// RUN: -target x86_64-unknown-linux \
314// RUN: --sysroot=%S/Inputs/basic_linux_tree \
315// RUN: | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-LINUX %s
316// CHECK-CFI-CROSS-DSO-LINUX: "{{.*}}ld{{(.exe)?}}"
Evgeniy Stepanov17d60862015-12-16 22:03:39 +0000317// CHECK-CFI-CROSS-DSO-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.cfi-x86_64.a" "-no-whole-archive"
Evgeniy Stepanovfd6f92d2015-12-15 23:00:20 +0000318
319// Cross-DSO CFI with diagnostics links just the CFI runtime.
320// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
321// RUN: -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
322// RUN: -target x86_64-unknown-linux \
323// RUN: --sysroot=%S/Inputs/basic_linux_tree \
324// RUN: | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-LINUX %s
325// CHECK-CFI-CROSS-DSO-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
Evgeniy Stepanov17d60862015-12-16 22:03:39 +0000326// CHECK-CFI-CROSS-DSO-DIAG-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.cfi_diag-x86_64.a" "-no-whole-archive"
Evgeniy Stepanovfd6f92d2015-12-15 23:00:20 +0000327
Nick Lewyckyb9489a62015-04-10 07:43:19 +0000328// RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \
Hans Wennborg10821e52015-04-09 18:47:01 +0000329// RUN: -mmacosx-version-min=10.6 \
330// RUN: -target x86_64-apple-darwin13.4.0 \
Reid Kleckner93d05112015-04-09 20:37:38 +0000331// RUN: --sysroot=%S/Inputs/basic_linux_tree \
Hans Wennborg10821e52015-04-09 18:47:01 +0000332// RUN: | FileCheck --check-prefix=CHECK-ASAN-DARWIN106-CXX %s
333// CHECK-ASAN-DARWIN106-CXX: "{{.*}}ld{{(.exe)?}}"
334// CHECK-ASAN-DARWIN106-CXX: libclang_rt.asan_osx_dynamic.dylib
335// CHECK-ASAN-DARWIN106-CXX-NOT: -lc++abi
Evgeniy Stepanov82c00be2015-10-12 23:50:19 +0000336
337// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
338// RUN: -target x86_64-unknown-linux -fsanitize=safe-stack \
339// RUN: --sysroot=%S/Inputs/basic_linux_tree \
340// RUN: | FileCheck --check-prefix=CHECK-SAFESTACK-LINUX %s
341//
342// CHECK-SAFESTACK-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
343// CHECK-SAFESTACK-LINUX-NOT: "-lc"
344// CHECK-SAFESTACK-LINUX: libclang_rt.safestack-x86_64.a"
345// CHECK-SAFESTACK-LINUX: "-lpthread"
346// CHECK-SAFESTACK-LINUX: "-ldl"
347
348// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
349// RUN: -target arm-linux-androideabi -fsanitize=safe-stack \
350// RUN: --sysroot=%S/Inputs/basic_android_tree \
351// RUN: | FileCheck --check-prefix=CHECK-SAFESTACK-ANDROID-ARM %s
352//
353// CHECK-SAFESTACK-ANDROID-ARM: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
354// CHECK-SAFESTACK-ANDROID-ARM-NOT: libclang_rt.safestack
355
356// RUN: %clang -no-canonical-prefixes %s -### -o %t.o -shared 2>&1 \
357// RUN: -target arm-linux-androideabi -fsanitize=safe-stack \
358// RUN: --sysroot=%S/Inputs/basic_android_tree \
359// RUN: | FileCheck --check-prefix=CHECK-SAFESTACK-ANDROID-ARM %s
360//
361// CHECK-SAFESTACK-SHARED-ANDROID-ARM: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
362// CHECK-SAFESTACK-SHARED-ANDROID-ARM-NOT: libclang_rt.safestack
363
364// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
365// RUN: -target aarch64-linux-android -fsanitize=safe-stack \
366// RUN: --sysroot=%S/Inputs/basic_android_tree \
367// RUN: | FileCheck --check-prefix=CHECK-SAFESTACK-ANDROID-AARCH64 %s
368//
369// CHECK-SAFESTACK-ANDROID-AARCH64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
370// CHECK-SAFESTACK-ANDROID-AARCH64-NOT: libclang_rt.safestack
Filipe Cabecinhas4585ed02015-10-16 15:08:01 +0000371
372// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
373// RUN: -target x86_64-scei-ps4 \
374// RUN: -shared \
375// RUN: | FileCheck --check-prefix=CHECK-UBSAN-PS4 %s
Sumanth Gundapanenice7fc172015-12-16 20:18:12 +0000376// CHECK-UBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
Filipe Cabecinhas4585ed02015-10-16 15:08:01 +0000377// CHECK-UBSAN-PS4: -lSceDbgUBSanitizer_stub_weak
378
379// RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
380// RUN: -target x86_64-scei-ps4 \
381// RUN: -shared \
382// RUN: | FileCheck --check-prefix=CHECK-ASAN-PS4 %s
Sumanth Gundapanenice7fc172015-12-16 20:18:12 +0000383// CHECK-ASAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
Filipe Cabecinhas4585ed02015-10-16 15:08:01 +0000384// CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
385
386// RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
387// RUN: -target x86_64-scei-ps4 \
388// RUN: -shared \
389// RUN: | FileCheck --check-prefix=CHECK-AUBSAN-PS4 %s
Sumanth Gundapanenice7fc172015-12-16 20:18:12 +0000390// CHECK-AUBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
Filipe Cabecinhas4585ed02015-10-16 15:08:01 +0000391// CHECK-AUBSAN-PS4: -lSceDbgAddressSanitizer_stub_weak