xref: /minix3/external/bsd/llvm/dist/clang/test/Driver/darwin-sanitizer-ld.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // Test sanitizer link flags on Darwin.
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
4f4a2713aSLionel Sambuc // RUN:   -fsanitize=address %s -o %t.o 2>&1 \
5f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-ASAN %s
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc // CHECK-ASAN: "{{.*}}ld{{(.exe)?}}"
8f4a2713aSLionel Sambuc // CHECK-ASAN: stdc++
9f4a2713aSLionel Sambuc // CHECK-ASAN: libclang_rt.asan_osx_dynamic.dylib"
10*0a6a1f1dSLionel Sambuc // CHECK-ASAN: "-rpath" "@executable_path"
11*0a6a1f1dSLionel Sambuc // CHECK-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
14f4a2713aSLionel Sambuc // RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
15f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc // CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
18f4a2713aSLionel Sambuc // CHECK-ASAN-IOSSIM: lc++
19f4a2713aSLionel Sambuc // CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
20*0a6a1f1dSLionel Sambuc // CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
21*0a6a1f1dSLionel Sambuc // CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
24f4a2713aSLionel Sambuc // RUN:   -fPIC -shared -fsanitize=address %s -o %t.so 2>&1 \
25f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-DYN-ASAN %s
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc // CHECK-DYN-ASAN: "{{.*}}ld{{(.exe)?}}"
28f4a2713aSLionel Sambuc // CHECK-DYN-ASAN: "-dylib"
29*0a6a1f1dSLionel Sambuc // CHECK-DYN-ASAN: libclang_rt.asan_osx_dynamic.dylib"
30*0a6a1f1dSLionel Sambuc // CHECK-DYN-ASAN: "-rpath" "@executable_path"
31*0a6a1f1dSLionel Sambuc // CHECK-DYN-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
32f4a2713aSLionel Sambuc 
33f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
34f4a2713aSLionel Sambuc // RUN:   -fsanitize=undefined %s -o %t.o 2>&1 \
35f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-UBSAN %s
36f4a2713aSLionel Sambuc 
37f4a2713aSLionel Sambuc // CHECK-UBSAN: "{{.*}}ld{{(.exe)?}}"
38f4a2713aSLionel Sambuc // CHECK-UBSAN: libclang_rt.ubsan_osx.a"
39f4a2713aSLionel Sambuc // CHECK-UBSAN: stdc++
40f4a2713aSLionel Sambuc 
41f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
42f4a2713aSLionel Sambuc // RUN:   -fsanitize=bounds -fsanitize-undefined-trap-on-error \
43f4a2713aSLionel Sambuc // RUN:   %s -o %t.o 2>&1 \
44f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-BOUNDS %s
45f4a2713aSLionel Sambuc 
46f4a2713aSLionel Sambuc // CHECK-BOUNDS: "{{.*}}ld{{(.exe)?}}"
47f4a2713aSLionel Sambuc // CHECK-BOUNDS-NOT: libclang_rt.ubsan_osx.a"
48f4a2713aSLionel Sambuc 
49f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
50f4a2713aSLionel Sambuc // RUN:   -fPIC -shared -fsanitize=undefined %s -o %t.so 2>&1 \
51f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-DYN-UBSAN %s
52f4a2713aSLionel Sambuc 
53f4a2713aSLionel Sambuc // CHECK-DYN-UBSAN: "{{.*}}ld{{(.exe)?}}"
54f4a2713aSLionel Sambuc // CHECK-DYN-UBSAN: "-dylib"
55f4a2713aSLionel Sambuc // CHECK-DYN-UBSAN: libclang_rt.ubsan_osx.a
56f4a2713aSLionel Sambuc 
57f4a2713aSLionel Sambuc // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
58f4a2713aSLionel Sambuc // RUN:   -fsanitize=bounds -fsanitize-undefined-trap-on-error \
59f4a2713aSLionel Sambuc // RUN:   %s -o %t.so -fPIC -shared 2>&1 \
60f4a2713aSLionel Sambuc // RUN:   | FileCheck --check-prefix=CHECK-DYN-BOUNDS %s
61f4a2713aSLionel Sambuc 
62f4a2713aSLionel Sambuc // CHECK-DYN-BOUNDS: "{{.*}}ld{{(.exe)?}}"
63f4a2713aSLionel Sambuc // CHECK-DYN-BOUNDS-NOT: libclang_rt.ubsan_osx.a
64