Home | History | Annotate | Download | only in Driver
      1 // 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:     -resource-dir=%S/Inputs/resource_dir \
      6 // 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"
     13 // CHECK-ASAN-LINUX: "-lrt"
     14 // CHECK-ASAN-LINUX: "-ldl"
     15 // CHECK-ASAN-LINUX-NOT: "-export-dynamic"
     16 // CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan-i386.a.syms"
     17 
     18 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
     19 // RUN:     -target i386-unknown-linux -fsanitize=address \
     20 // RUN:     -resource-dir=%S/Inputs/empty_resource_dir \
     21 // 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"
     28 // CHECK-ASAN-LINUX-CXX: "-lrt"
     29 // CHECK-ASAN-LINUX-CXX: "-ldl"
     30 // CHECK-ASAN-LINUX-CXX: "-export-dynamic"
     31 // CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
     32 // 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 \
     67 // RUN:     -resource-dir=%S/Inputs/resource_dir \
     68 // 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"
     75 // CHECK-TSAN-LINUX-CXX: "-lrt"
     76 // CHECK-TSAN-LINUX-CXX: "-ldl"
     77 // CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
     78 // CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan-x86_64.a.syms"
     79 // 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 \
     83 // RUN:     -resource-dir=%S/Inputs/resource_dir \
     84 // 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"
     91 // CHECK-MSAN-LINUX-CXX: "-lrt"
     92 // CHECK-MSAN-LINUX-CXX: "-ldl"
     93 // CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
     94 // CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan-x86_64.a.syms"
     95 // 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)?}}"
    102 // 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
    107 // CHECK-UBSAN-LINUX: "-lpthread"
    108 // 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++"
    148 
    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)?}}"
    155 // CHECK-UBSAN-LINUX-SHARED-NOT: libclang_rt.ubsan-i386.a"
    156 
    157 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    158 // RUN:     -target x86_64-unknown-linux -fsanitize=leak \
    159 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    160 // RUN:   | FileCheck --check-prefix=CHECK-LSAN-LINUX %s
    161 //
    162 // CHECK-LSAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    163 // CHECK-LSAN-LINUX-NOT: "-lc"
    164 // CHECK-LSAN-LINUX: libclang_rt.lsan-x86_64.a"
    165 // CHECK-LSAN-LINUX: "-lpthread"
    166 // CHECK-LSAN-LINUX: "-ldl"
    167 
    168 // RUN: %clang -fsanitize=leak,undefined %s -### -o %t.o 2>&1 \
    169 // RUN:     -target x86_64-unknown-linux \
    170 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    171 // RUN:   | FileCheck --check-prefix=CHECK-LSAN-UBSAN-LINUX %s
    172 // CHECK-LSAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
    173 // CHECK-LSAN-UBSAN-LINUX-NOT: libclang_rt.san
    174 // CHECK-LSAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.lsan-x86_64.a" "-no-whole-archive"
    175 // CHECK-LSAN-UBSAN-LINUX-NOT: libclang_rt.san
    176 // CHECK-LSAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-x86_64.a" "-no-whole-archive"
    177 // CHECK-LSAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
    178 // CHECK-LSAN-UBSAN-LINUX: "-lpthread"
    179 // CHECK-LSAN-UBSAN-LINUX-NOT: "-lstdc++"
    180 
    181 // RUN: %clang -fsanitize=leak,address %s -### -o %t.o 2>&1 \
    182 // RUN:     -target x86_64-unknown-linux \
    183 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    184 // RUN:   | FileCheck --check-prefix=CHECK-LSAN-ASAN-LINUX %s
    185 // CHECK-LSAN-ASAN-LINUX: "{{.*}}ld{{(.exe)?}}"
    186 // CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
    187 // CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
    188 // CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
    189