blob: 89cbb6b284fd3094e23e4fdd6f52bc8a991fb993 [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 \
5// RUN: --sysroot=%S/Inputs/basic_linux_tree \
6// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX %s
7//
8// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
9// CHECK-ASAN-LINUX-NOT: "-lc"
10// CHECK-ASAN-LINUX: libclang_rt.asan-i386.a"
11// CHECK-ASAN-LINUX: "-lpthread"
12// CHECK-ASAN-LINUX: "-ldl"
13// CHECK-ASAN-LINUX: "-export-dynamic"
14
15// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
16// RUN: -target i386-unknown-linux -fsanitize=address \
17// RUN: --sysroot=%S/Inputs/basic_linux_tree \
18// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s
19//
20// CHECK-ASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
21// CHECK-ASAN-LINUX-CXX-NOT: "-lc"
22// CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
23// CHECK-ASAN-LINUX-CXX: "-lpthread"
24// CHECK-ASAN-LINUX-CXX: "-ldl"
25// CHECK-ASAN-LINUX-CXX: "-export-dynamic"
26// CHECK-ASAN-LINUX-CXX: stdc++
27
28// RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
29// RUN: -target i386-unknown-linux --sysroot=%S/Inputs/basic_linux_tree \
30// RUN: -lstdc++ -static 2>&1 \
31// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX-STATIC %s
32//
33// CHECK-ASAN-LINUX-CXX-STATIC: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
34// CHECK-ASAN-LINUX-CXX-STATIC-NOT: stdc++
35// CHECK-ASAN-LINUX-CXX-STATIC: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
36// CHECK-ASAN-LINUX-CXX-STATIC: stdc++
37
38// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
39// RUN: -target arm-linux-androideabi -fsanitize=address \
40// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
41// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID %s
42//
43// CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
44// CHECK-ASAN-ANDROID-NOT: "-lc"
45// CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
46// CHECK-ASAN-ANDROID-NOT: "-lpthread"
47//
48// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
49// RUN: -target arm-linux-androideabi -fsanitize=address \
50// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
51// RUN: -shared \
52// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED %s
53//
54// CHECK-ASAN-ANDROID-SHARED: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
55// CHECK-ASAN-ANDROID-SHARED-NOT: "-lc"
56// CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
57// CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"
58
59// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
60// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=thread \
61// RUN: --sysroot=%S/Inputs/basic_linux_tree \
62// RUN: | FileCheck --check-prefix=CHECK-TSAN-LINUX-CXX %s
63//
64// CHECK-TSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
65// CHECK-TSAN-LINUX-CXX-NOT: stdc++
66// CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
67// CHECK-TSAN-LINUX-CXX: "-lpthread"
68// CHECK-TSAN-LINUX-CXX: "-ldl"
69// CHECK-TSAN-LINUX-CXX: "-export-dynamic"
70// CHECK-TSAN-LINUX-CXX: stdc++
71
72// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
73// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=memory \
74// RUN: --sysroot=%S/Inputs/basic_linux_tree \
75// RUN: | FileCheck --check-prefix=CHECK-MSAN-LINUX-CXX %s
76//
77// CHECK-MSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
78// CHECK-MSAN-LINUX-CXX-NOT: stdc++
79// CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
80// CHECK-MSAN-LINUX-CXX: "-lpthread"
81// CHECK-MSAN-LINUX-CXX: "-ldl"
82// CHECK-MSAN-LINUX-CXX: "-export-dynamic"
83// CHECK-MSAN-LINUX-CXX: stdc++
84
85// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
86// RUN: -target i386-unknown-linux \
87// RUN: --sysroot=%S/Inputs/basic_linux_tree \
88// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
89// CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
Richard Smith61a574f2013-03-20 23:49:07 +000090// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
91// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
92// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
93// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
94// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
Alexey Samsonov86143042013-02-27 11:14:55 +000095// CHECK-UBSAN-LINUX: "-lpthread"
Richard Smith61a574f2013-03-20 23:49:07 +000096// CHECK-UBSAN-LINUX-NOT: "-lstdc++"
97
98// RUN: %clangxx -fsanitize=undefined %s -### -o %t.o 2>&1 \
99// RUN: -target i386-unknown-linux \
100// RUN: --sysroot=%S/Inputs/basic_linux_tree \
101// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-CXX %s
102// CHECK-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
103// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
104// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
105// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
106// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
107// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
108// CHECK-UBSAN-LINUX-CXX: "-lpthread"
109// CHECK-UBSAN-LINUX-CXX: "-lstdc++"
110
111// RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
112// RUN: -target i386-unknown-linux \
113// RUN: --sysroot=%S/Inputs/basic_linux_tree \
114// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX %s
115// CHECK-ASAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
116// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
117// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
118// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
119// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
120// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
121// CHECK-ASAN-UBSAN-LINUX: "-lpthread"
122// CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"
123
124// RUN: %clangxx -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
125// RUN: -target i386-unknown-linux \
126// RUN: --sysroot=%S/Inputs/basic_linux_tree \
127// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX-CXX %s
128// CHECK-ASAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
129// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
130// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
131// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
132// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
133// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
134// CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
135// CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
Alexey Samsonov86143042013-02-27 11:14:55 +0000136
137// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
138// RUN: -target i386-unknown-linux \
139// RUN: --sysroot=%S/Inputs/basic_linux_tree \
140// RUN: -shared \
141// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHARED %s
142// CHECK-UBSAN-LINUX-SHARED: "{{.*}}ld{{(.exe)?}}"
Richard Smith61a574f2013-03-20 23:49:07 +0000143// CHECK-UBSAN-LINUX-SHARED-NOT: libclang_rt.ubsan-i386.a"