1 // Test sanitizer link flags on Darwin.
3 // RUN: %clang -### --target=x86_64-darwin \
4 // RUN: -stdlib=platform -fsanitize=address %s 2>&1 \
5 // RUN: | FileCheck --check-prefix=CHECK-ASAN %s
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"
14 // RUN: %clang -### --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
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"
24 // RUN: %clang -### --target=x86_64-darwin \
25 // RUN: -stdlib=platform -fsanitize=undefined %s 2>&1 \
26 // RUN: | FileCheck --check-prefix=CHECK-UBSAN %s
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"
35 // RUN: %clang -### --target=x86_64-darwin \
36 // RUN: -fsanitize=bounds -fsanitize-undefined-trap-on-error \
38 // RUN: | FileCheck --check-prefix=CHECK-BOUNDS %s
40 // CHECK-BOUNDS: "{{.*}}ld{{(.exe)?}}"
41 // CHECK-BOUNDS-NOT: libclang_rt.ubsan_osx.a"
43 // RUN: %clang -### --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
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"
53 // RUN: %clang -### --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
58 // CHECK-DYN-BOUNDS: "{{.*}}ld{{(.exe)?}}"
59 // CHECK-DYN-BOUNDS-NOT: ubsan_osx
61 // RUN: %clang -### --target=x86_64-darwin \
62 // RUN: -stdlib=platform -fsanitize=address -mios-simulator-version-min=7.0 \
63 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
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"
72 // RUN: %clang -### --target=x86_64-darwin \
73 // RUN: -stdlib=platform -fsanitize=address \
74 // RUN: -mtvos-simulator-version-min=8.3.0 %s 2>&1 \
75 // RUN: | FileCheck --check-prefix=CHECK-ASAN-TVOSSIM %s
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"
84 // RUN: %clang -### --target=x86_64-darwin \
85 // RUN: -stdlib=platform -fsanitize=address \
86 // RUN: -mwatchos-simulator-version-min=2.0.0 %s 2>&1 \
87 // RUN: | FileCheck --check-prefix=CHECK-ASAN-WATCHOSSIM %s
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"
96 // RUN: %clang -### --target=x86_64-apple-ios13.1-macabi \
97 // RUN: -stdlib=platform -fsanitize=address \
98 // RUN: -resource-dir %S/Inputs/resource_dir \
99 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-ASAN-MACCATALYST %s
101 // CHECK-ASAN-MACCATALYST: "{{.*}}ld{{(.exe)?}}"
102 // CHECK-ASAN-MACCATALYST-NOT: "-lstdc++"
103 // CHECK-ASAN-MACCATALYST-NOT: "-lc++"
104 // CHECK-ASAN-MACCATALYST: libclang_rt.asan_osx_dynamic.dylib"
105 // CHECK-ASAN-MACCATALYST: "-rpath" "@executable_path"
106 // CHECK-ASAN-MACCATALYST: "-rpath" "{{.*}}lib{{.*}}darwin"
108 // RUN: %clang -### --target=armv7-apple-ios \
109 // RUN: -stdlib=platform -fsanitize=address -miphoneos-version-min=7 \
110 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-ASAN-IOS %s
112 // CHECK-ASAN-IOS: "{{.*}}ld{{(.exe)?}}"
113 // CHECK-ASAN-IOS-NOT: "-lstdc++"
114 // CHECK-ASAN-IOS-NOT: "-lc++"
115 // CHECK-ASAN-IOS: libclang_rt.asan_ios_dynamic.dylib"
116 // CHECK-ASAN-IOS: "-rpath" "@executable_path"
117 // CHECK-ASAN-IOS: "-rpath" "{{.*}}lib{{.*}}darwin"
119 // RUN: %clang -### --target=arm64-apple-tvos \
120 // RUN: -stdlib=platform -fsanitize=address -mtvos-version-min=8.3 \
121 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-ASAN-TVOS %s
123 // CHECK-ASAN-TVOS: "{{.*}}ld{{(.exe)?}}"
124 // CHECK-ASAN-TVOS-NOT: "-lstdc++"
125 // CHECK-ASAN-TVOS-NOT: "-lc++"
126 // CHECK-ASAN-TVOS: libclang_rt.asan_tvos_dynamic.dylib"
127 // CHECK-ASAN-TVOS: "-rpath" "@executable_path"
128 // CHECK-ASAN-TVOS: "-rpath" "{{.*}}lib{{.*}}darwin"
130 // RUN: %clang -### --target=armv7k-apple-watchos \
131 // RUN: -stdlib=platform -fsanitize=address -mwatchos-version-min=2.0 \
132 // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-ASAN-WATCHOS %s
134 // CHECK-ASAN-WATCHOS: "{{.*}}ld{{(.exe)?}}"
135 // CHECK-ASAN-WATCHOS-NOT: "-lstdc++"
136 // CHECK-ASAN-WATCHOS-NOT: "-lc++"
137 // CHECK-ASAN-WATCHOS: libclang_rt.asan_watchos_dynamic.dylib"
138 // CHECK-ASAN-WATCHOS: "-rpath" "@executable_path"
139 // CHECK-ASAN-WATCHOS: "-rpath" "{{.*}}lib{{.*}}darwin"