blob: fd7e97fc20f87aa66d44282be93a50176e74b4f7 [file] [log] [blame]
Alexey Samsonov86143042013-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 Smith76e6e132013-03-23 00:30:08 +00005// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonov86143042013-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 Stepanov3a8aff92013-05-24 14:28:03 +000013// CHECK-ASAN-LINUX: "-lrt"
Alexey Samsonov86143042013-02-27 11:14:55 +000014// CHECK-ASAN-LINUX: "-ldl"
Richard Smith76e6e132013-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 Samsonov86143042013-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 Smith76e6e132013-03-23 00:30:08 +000020// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
Alexey Samsonov86143042013-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 Stepanov3a8aff92013-05-24 14:28:03 +000028// CHECK-ASAN-LINUX-CXX: "-lrt"
Alexey Samsonov86143042013-02-27 11:14:55 +000029// CHECK-ASAN-LINUX-CXX: "-ldl"
30// CHECK-ASAN-LINUX-CXX: "-export-dynamic"
Richard Smith76e6e132013-03-23 00:30:08 +000031// CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
Alexey Samsonov86143042013-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 \
45// RUN: -target arm-linux-androideabi -fsanitize=address \
46// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
47// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID %s
48//
49// CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
50// CHECK-ASAN-ANDROID-NOT: "-lc"
51// CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
52// CHECK-ASAN-ANDROID-NOT: "-lpthread"
53//
54// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
55// RUN: -target arm-linux-androideabi -fsanitize=address \
56// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
57// RUN: -shared \
58// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED %s
59//
60// CHECK-ASAN-ANDROID-SHARED: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
61// CHECK-ASAN-ANDROID-SHARED-NOT: "-lc"
62// CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
63// CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"
64
65// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
66// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=thread \
Richard Smith76e6e132013-03-23 00:30:08 +000067// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonov86143042013-02-27 11:14:55 +000068// RUN: --sysroot=%S/Inputs/basic_linux_tree \
69// RUN: | FileCheck --check-prefix=CHECK-TSAN-LINUX-CXX %s
70//
71// CHECK-TSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
72// CHECK-TSAN-LINUX-CXX-NOT: stdc++
73// CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
74// CHECK-TSAN-LINUX-CXX: "-lpthread"
Evgeniy Stepanov3a8aff92013-05-24 14:28:03 +000075// CHECK-TSAN-LINUX-CXX: "-lrt"
Alexey Samsonov86143042013-02-27 11:14:55 +000076// CHECK-TSAN-LINUX-CXX: "-ldl"
Richard Smith76e6e132013-03-23 00:30:08 +000077// CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
78// CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan-x86_64.a.syms"
Alexey Samsonov86143042013-02-27 11:14:55 +000079// CHECK-TSAN-LINUX-CXX: stdc++
80
81// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
82// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=memory \
Richard Smith76e6e132013-03-23 00:30:08 +000083// RUN: -resource-dir=%S/Inputs/resource_dir \
Alexey Samsonov86143042013-02-27 11:14:55 +000084// RUN: --sysroot=%S/Inputs/basic_linux_tree \
85// RUN: | FileCheck --check-prefix=CHECK-MSAN-LINUX-CXX %s
86//
87// CHECK-MSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
88// CHECK-MSAN-LINUX-CXX-NOT: stdc++
89// CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
90// CHECK-MSAN-LINUX-CXX: "-lpthread"
Evgeniy Stepanov3a8aff92013-05-24 14:28:03 +000091// CHECK-MSAN-LINUX-CXX: "-lrt"
Alexey Samsonov86143042013-02-27 11:14:55 +000092// CHECK-MSAN-LINUX-CXX: "-ldl"
Richard Smith76e6e132013-03-23 00:30:08 +000093// CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
94// CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan-x86_64.a.syms"
Alexey Samsonov86143042013-02-27 11:14:55 +000095// CHECK-MSAN-LINUX-CXX: stdc++
96
97// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
98// RUN: -target i386-unknown-linux \
99// RUN: --sysroot=%S/Inputs/basic_linux_tree \
100// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
101// CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
Richard Smith61a574f2013-03-20 23:49:07 +0000102// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
103// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
104// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
105// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
106// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
Alexey Samsonov86143042013-02-27 11:14:55 +0000107// CHECK-UBSAN-LINUX: "-lpthread"
Richard Smith61a574f2013-03-20 23:49:07 +0000108// CHECK-UBSAN-LINUX-NOT: "-lstdc++"
109
110// RUN: %clangxx -fsanitize=undefined %s -### -o %t.o 2>&1 \
111// RUN: -target i386-unknown-linux \
112// RUN: --sysroot=%S/Inputs/basic_linux_tree \
113// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-CXX %s
114// CHECK-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
115// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
116// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
117// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
118// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
119// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
120// CHECK-UBSAN-LINUX-CXX: "-lpthread"
121// CHECK-UBSAN-LINUX-CXX: "-lstdc++"
122
123// RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
124// RUN: -target i386-unknown-linux \
125// RUN: --sysroot=%S/Inputs/basic_linux_tree \
126// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX %s
127// CHECK-ASAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
128// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
129// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
130// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
131// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
132// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
133// CHECK-ASAN-UBSAN-LINUX: "-lpthread"
134// CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"
135
136// RUN: %clangxx -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
137// RUN: -target i386-unknown-linux \
138// RUN: --sysroot=%S/Inputs/basic_linux_tree \
139// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX-CXX %s
140// CHECK-ASAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
141// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
142// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
143// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
144// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
145// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
146// CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
147// CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
Alexey Samsonov86143042013-02-27 11:14:55 +0000148
149// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
150// RUN: -target i386-unknown-linux \
151// RUN: --sysroot=%S/Inputs/basic_linux_tree \
152// RUN: -shared \
153// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHARED %s
154// CHECK-UBSAN-LINUX-SHARED: "{{.*}}ld{{(.exe)?}}"
Richard Smith61a574f2013-03-20 23:49:07 +0000155// CHECK-UBSAN-LINUX-SHARED-NOT: libclang_rt.ubsan-i386.a"