blob: f1c36446e91c81f4dd7e09d8e384f93d5e7477bd [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"
12// CHECK-ASAN-LINUX: "-lpthread"
Evgeniy Stepanov758b5072013-05-24 14:28:03 +000013// CHECK-ASAN-LINUX: "-lrt"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000014// CHECK-ASAN-LINUX: "-ldl"
Richard Smithf3e624c2013-03-23 00:30:08 +000015// CHECK-ASAN-LINUX-NOT: "-export-dynamic"
16// CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan-i386.a.syms"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000017
18// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
19// RUN: -target i386-unknown-linux -fsanitize=address \
Richard Smithf3e624c2013-03-23 00:30:08 +000020// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000021// RUN: --sysroot=%S/Inputs/basic_linux_tree \
22// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s
23//
24// CHECK-ASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
25// CHECK-ASAN-LINUX-CXX-NOT: "-lc"
26// CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
27// CHECK-ASAN-LINUX-CXX: "-lpthread"
Evgeniy Stepanov758b5072013-05-24 14:28:03 +000028// CHECK-ASAN-LINUX-CXX: "-lrt"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000029// CHECK-ASAN-LINUX-CXX: "-ldl"
30// CHECK-ASAN-LINUX-CXX: "-export-dynamic"
Richard Smithf3e624c2013-03-23 00:30:08 +000031// CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000032// CHECK-ASAN-LINUX-CXX: stdc++
33
34// RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
35// RUN: -target i386-unknown-linux --sysroot=%S/Inputs/basic_linux_tree \
36// RUN: -lstdc++ -static 2>&1 \
37// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX-STATIC %s
38//
39// CHECK-ASAN-LINUX-CXX-STATIC: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
40// CHECK-ASAN-LINUX-CXX-STATIC-NOT: stdc++
41// CHECK-ASAN-LINUX-CXX-STATIC: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
42// CHECK-ASAN-LINUX-CXX-STATIC: stdc++
43
44// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Renato Goline2dbedd2014-01-31 12:21:55 +000045// RUN: -target arm-linux-gnueabi -fsanitize=address \
46// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
47// RUN: | FileCheck --check-prefix=CHECK-ASAN-ARM %s
48//
49// CHECK-ASAN-ARM: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
50// CHECK-ASAN-ARM-NOT: "-lc"
51// CHECK-ASAN-ARM: libclang_rt.asan-arm.a"
52//
53// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
54// RUN: -target armv7l-linux-gnueabi -fsanitize=address \
55// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
56// RUN: | FileCheck --check-prefix=CHECK-ASAN-ARMv7 %s
57//
58// CHECK-ASAN-ARMv7: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
59// CHECK-ASAN-ARMv7-NOT: "-lc"
60// CHECK-ASAN-ARMv7: libclang_rt.asan-arm.a"
61//
62
63// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000064// RUN: -target arm-linux-androideabi -fsanitize=address \
65// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
66// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID %s
67//
68// CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
69// CHECK-ASAN-ANDROID-NOT: "-lc"
70// CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
71// CHECK-ASAN-ANDROID-NOT: "-lpthread"
72//
73// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
74// RUN: -target arm-linux-androideabi -fsanitize=address \
75// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
76// RUN: -shared \
77// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED %s
78//
79// CHECK-ASAN-ANDROID-SHARED: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
80// CHECK-ASAN-ANDROID-SHARED-NOT: "-lc"
81// CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
82// CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"
83
84// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
85// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=thread \
Richard Smithf3e624c2013-03-23 00:30:08 +000086// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000087// RUN: --sysroot=%S/Inputs/basic_linux_tree \
88// RUN: | FileCheck --check-prefix=CHECK-TSAN-LINUX-CXX %s
89//
90// CHECK-TSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
91// CHECK-TSAN-LINUX-CXX-NOT: stdc++
92// CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
93// CHECK-TSAN-LINUX-CXX: "-lpthread"
Evgeniy Stepanov758b5072013-05-24 14:28:03 +000094// CHECK-TSAN-LINUX-CXX: "-lrt"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000095// CHECK-TSAN-LINUX-CXX: "-ldl"
Richard Smithf3e624c2013-03-23 00:30:08 +000096// CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
97// CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan-x86_64.a.syms"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +000098// CHECK-TSAN-LINUX-CXX: stdc++
99
100// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
101// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=memory \
Richard Smithf3e624c2013-03-23 00:30:08 +0000102// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000103// RUN: --sysroot=%S/Inputs/basic_linux_tree \
104// RUN: | FileCheck --check-prefix=CHECK-MSAN-LINUX-CXX %s
105//
106// CHECK-MSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
107// CHECK-MSAN-LINUX-CXX-NOT: stdc++
108// CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
109// CHECK-MSAN-LINUX-CXX: "-lpthread"
Evgeniy Stepanov758b5072013-05-24 14:28:03 +0000110// CHECK-MSAN-LINUX-CXX: "-lrt"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000111// CHECK-MSAN-LINUX-CXX: "-ldl"
Richard Smithf3e624c2013-03-23 00:30:08 +0000112// CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
113// CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan-x86_64.a.syms"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000114// CHECK-MSAN-LINUX-CXX: stdc++
115
116// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
117// RUN: -target i386-unknown-linux \
118// RUN: --sysroot=%S/Inputs/basic_linux_tree \
119// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
120// CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
Richard Smithcff3cde2013-03-20 23:49:07 +0000121// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
Peter Collingbournef7ef3fd812013-10-20 21:29:13 +0000122// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
Nick Lewycky24921692013-10-19 00:27:23 +0000123// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
Peter Collingbournef7ef3fd812013-10-20 21:29:13 +0000124// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
125// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000126// CHECK-UBSAN-LINUX: "-lpthread"
Richard Smithcff3cde2013-03-20 23:49:07 +0000127// CHECK-UBSAN-LINUX-NOT: "-lstdc++"
128
129// RUN: %clangxx -fsanitize=undefined %s -### -o %t.o 2>&1 \
130// RUN: -target i386-unknown-linux \
131// RUN: --sysroot=%S/Inputs/basic_linux_tree \
132// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-CXX %s
133// CHECK-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
134// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
Peter Collingbournef7ef3fd812013-10-20 21:29:13 +0000135// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
Richard Smithcff3cde2013-03-20 23:49:07 +0000136// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
Peter Collingbournef7ef3fd812013-10-20 21:29:13 +0000137// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
138// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
Richard Smithcff3cde2013-03-20 23:49:07 +0000139// CHECK-UBSAN-LINUX-CXX: "-lpthread"
140// CHECK-UBSAN-LINUX-CXX: "-lstdc++"
141
142// RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
143// RUN: -target i386-unknown-linux \
144// RUN: --sysroot=%S/Inputs/basic_linux_tree \
145// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX %s
146// CHECK-ASAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
147// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
148// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
149// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
Peter Collingbournef7ef3fd812013-10-20 21:29:13 +0000150// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
Richard Smithcff3cde2013-03-20 23:49:07 +0000151// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
152// CHECK-ASAN-UBSAN-LINUX: "-lpthread"
153// CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"
154
155// RUN: %clangxx -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
156// RUN: -target i386-unknown-linux \
157// RUN: --sysroot=%S/Inputs/basic_linux_tree \
158// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX-CXX %s
159// CHECK-ASAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
160// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
161// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
162// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
Peter Collingbournef7ef3fd812013-10-20 21:29:13 +0000163// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
164// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
Richard Smithcff3cde2013-03-20 23:49:07 +0000165// CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
166// CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
Alexey Samsonovbfb0cd32013-02-27 11:14:55 +0000167
168// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
169// RUN: -target i386-unknown-linux \
170// RUN: --sysroot=%S/Inputs/basic_linux_tree \
171// RUN: -shared \
172// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHARED %s
173// CHECK-UBSAN-LINUX-SHARED: "{{.*}}ld{{(.exe)?}}"
Nick Lewyckybbd6db82013-08-13 22:32:35 +0000174// CHECK-UBSAN-LINUX-SHARED: libclang_rt.ubsan-i386.a"
Sergey Matveev1814e9e2013-05-27 11:17:01 +0000175
176// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
177// RUN: -target x86_64-unknown-linux -fsanitize=leak \
178// RUN: --sysroot=%S/Inputs/basic_linux_tree \
179// RUN: | FileCheck --check-prefix=CHECK-LSAN-LINUX %s
180//
181// CHECK-LSAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
182// CHECK-LSAN-LINUX-NOT: "-lc"
183// CHECK-LSAN-LINUX: libclang_rt.lsan-x86_64.a"
184// CHECK-LSAN-LINUX: "-lpthread"
185// CHECK-LSAN-LINUX: "-ldl"
186
187// RUN: %clang -fsanitize=leak,undefined %s -### -o %t.o 2>&1 \
188// RUN: -target x86_64-unknown-linux \
189// RUN: --sysroot=%S/Inputs/basic_linux_tree \
190// RUN: | FileCheck --check-prefix=CHECK-LSAN-UBSAN-LINUX %s
191// CHECK-LSAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
192// CHECK-LSAN-UBSAN-LINUX-NOT: libclang_rt.san
193// CHECK-LSAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.lsan-x86_64.a" "-no-whole-archive"
194// CHECK-LSAN-UBSAN-LINUX-NOT: libclang_rt.san
Peter Collingbournef7ef3fd812013-10-20 21:29:13 +0000195// CHECK-LSAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-x86_64.a" "-no-whole-archive"
Sergey Matveev1814e9e2013-05-27 11:17:01 +0000196// CHECK-LSAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
197// CHECK-LSAN-UBSAN-LINUX: "-lpthread"
198// CHECK-LSAN-UBSAN-LINUX-NOT: "-lstdc++"
199
200// RUN: %clang -fsanitize=leak,address %s -### -o %t.o 2>&1 \
201// RUN: -target x86_64-unknown-linux \
202// RUN: --sysroot=%S/Inputs/basic_linux_tree \
203// RUN: | FileCheck --check-prefix=CHECK-LSAN-ASAN-LINUX %s
204// CHECK-LSAN-ASAN-LINUX: "{{.*}}ld{{(.exe)?}}"
205// CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
206// CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
207// CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan