1 // Test sanitizer link flags on Darwin.
2 
3 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
4 // RUN:   -stdlib=platform -fsanitize=address %s -o %t.o 2>&1 \
5 // RUN:   | FileCheck --check-prefix=CHECK-ASAN %s
6 
7 // CHECK-ASAN: "{{.*}}ld{{(.exe)?}}"
8 // CHECK-ASAN-NOT: "-lstdc++"
9 // CHECK-ASAN-NOT: "-lc++"
10 // CHECK-ASAN: libclang_rt.asan_osx_dynamic.dylib"
11 // CHECK-ASAN: "-rpath" "@executable_path"
12 // CHECK-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
13 
14 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
15 // RUN:   -fPIC -shared -fsanitize=address %s -o %t.so 2>&1 \
16 // RUN:   | FileCheck --check-prefix=CHECK-DYN-ASAN %s
17 
18 // CHECK-DYN-ASAN: "{{.*}}ld{{(.exe)?}}"
19 // CHECK-DYN-ASAN: "-dylib"
20 // CHECK-DYN-ASAN: libclang_rt.asan_osx_dynamic.dylib"
21 // CHECK-DYN-ASAN: "-rpath" "@executable_path"
22 // CHECK-DYN-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
23 
24 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
25 // RUN:   -stdlib=platform -fsanitize=undefined %s -o %t.o 2>&1 \
26 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN %s
27 
28 // CHECK-UBSAN: "{{.*}}ld{{(.exe)?}}"
29 // CHECK-UBSAN-NOT: "-lstdc++"
30 // CHECK-UBSAN-NOT: "-lc++"
31 // CHECK-UBSAN: libclang_rt.ubsan_osx_dynamic.dylib"
32 // CHECK-UBSAN: "-rpath" "@executable_path"
33 // CHECK-UBSAN: "-rpath" "{{.*}}lib{{.*}}darwin"
34 
35 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
36 // RUN:   -fsanitize=bounds -fsanitize-undefined-trap-on-error \
37 // RUN:   %s -o %t.o 2>&1 \
38 // RUN:   | FileCheck --check-prefix=CHECK-BOUNDS %s
39 
40 // CHECK-BOUNDS: "{{.*}}ld{{(.exe)?}}"
41 // CHECK-BOUNDS-NOT: libclang_rt.ubsan_osx.a"
42 
43 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
44 // RUN:   -fPIC -shared -fsanitize=undefined %s -o %t.so 2>&1 \
45 // RUN:   | FileCheck --check-prefix=CHECK-DYN-UBSAN %s
46 
47 // CHECK-DYN-UBSAN: "{{.*}}ld{{(.exe)?}}"
48 // CHECK-DYN-UBSAN: "-dylib"
49 // CHECK-DYN-UBSAN: libclang_rt.ubsan_osx_dynamic.dylib"
50 // CHECK-DYN-UBSAN: "-rpath" "@executable_path"
51 // CHECK-DYN-UBSAN: "-rpath" "{{.*}}lib{{.*}}darwin"
52 
53 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
54 // RUN:   -fsanitize=bounds -fsanitize-undefined-trap-on-error \
55 // RUN:   %s -o %t.so -fPIC -shared 2>&1 \
56 // RUN:   | FileCheck --check-prefix=CHECK-DYN-BOUNDS %s
57 
58 // CHECK-DYN-BOUNDS: "{{.*}}ld{{(.exe)?}}"
59 // CHECK-DYN-BOUNDS-NOT: ubsan_osx
60 
61 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
62 // RUN:   -stdlib=platform -fsanitize=address -mios-simulator-version-min=7.0 \
63 // RUN:   %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
64 
65 // CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
66 // CHECK-ASAN-IOSSIM-NOT: "-lstdc++"
67 // CHECK-ASAN-IOSSIM-NOT: "-lc++"
68 // CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
69 // CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
70 // CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
71 
72 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
73 // RUN:   -stdlib=platform -fsanitize=address \
74 // RUN:   -mtvos-simulator-version-min=8.3.0 %s -o %t.o 2>&1 \
75 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-TVOSSIM %s
76 
77 // CHECK-ASAN-TVOSSIM: "{{.*}}ld{{(.exe)?}}"
78 // CHECK-ASAN-TVOSSIM-NOT: "-lstdc++"
79 // CHECK-ASAN-TVOSSIM-NOT: "-lc++"
80 // CHECK-ASAN-TVOSSIM: libclang_rt.asan_tvossim_dynamic.dylib"
81 // CHECK-ASAN-TVOSSIM: "-rpath" "@executable_path"
82 // CHECK-ASAN-TVOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
83 
84 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
85 // RUN:   -stdlib=platform -fsanitize=address \
86 // RUN:   -mwatchos-simulator-version-min=2.0.0 %s -o %t.o 2>&1 \
87 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-WATCHOSSIM %s
88 
89 // CHECK-ASAN-WATCHOSSIM: "{{.*}}ld{{(.exe)?}}"
90 // CHECK-ASAN-WATCHOSSIM-NOT: "-lstdc++"
91 // CHECK-ASAN-WATCHOSSIM-NOT: "-lc++"
92 // CHECK-ASAN-WATCHOSSIM: libclang_rt.asan_watchossim_dynamic.dylib"
93 // CHECK-ASAN-WATCHOSSIM: "-rpath" "@executable_path"
94 // CHECK-ASAN-WATCHOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
95 
96 // RUN: %clang -no-canonical-prefixes -### -target armv7-apple-ios  \
97 // RUN:   -stdlib=platform -fsanitize=address -miphoneos-version-min=7 \
98 // RUN:   %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-IOS %s
99 
100 // CHECK-ASAN-IOS: "{{.*}}ld{{(.exe)?}}"
101 // CHECK-ASAN-IOS-NOT: "-lstdc++"
102 // CHECK-ASAN-IOS-NOT: "-lc++"
103 // CHECK-ASAN-IOS: libclang_rt.asan_ios_dynamic.dylib"
104 // CHECK-ASAN-IOS: "-rpath" "@executable_path"
105 // CHECK-ASAN-IOS: "-rpath" "{{.*}}lib{{.*}}darwin"
106 
107 // RUN: %clang -no-canonical-prefixes -### -target arm64-apple-tvos \
108 // RUN:   -stdlib=platform -fsanitize=address -mtvos-version-min=8.3 \
109 // RUN:   %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-TVOS %s
110 
111 // CHECK-ASAN-TVOS: "{{.*}}ld{{(.exe)?}}"
112 // CHECK-ASAN-TVOS-NOT: "-lstdc++"
113 // CHECK-ASAN-TVOS-NOT: "-lc++"
114 // CHECK-ASAN-TVOS: libclang_rt.asan_tvos_dynamic.dylib"
115 // CHECK-ASAN-TVOS: "-rpath" "@executable_path"
116 // CHECK-ASAN-TVOS: "-rpath" "{{.*}}lib{{.*}}darwin"
117 
118 // RUN: %clang -no-canonical-prefixes -### -target armv7k-apple-watchos \
119 // RUN:   -stdlib=platform -fsanitize=address -mwatchos-version-min=2.0 \
120 // RUN:   %s -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ASAN-WATCHOS %s
121 
122 // CHECK-ASAN-WATCHOS: "{{.*}}ld{{(.exe)?}}"
123 // CHECK-ASAN-WATCHOS-NOT: "-lstdc++"
124 // CHECK-ASAN-WATCHOS-NOT: "-lc++"
125 // CHECK-ASAN-WATCHOS: libclang_rt.asan_watchos_dynamic.dylib"
126 // CHECK-ASAN-WATCHOS: "-rpath" "@executable_path"
127 // CHECK-ASAN-WATCHOS: "-rpath" "{{.*}}lib{{.*}}darwin"
128