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-NOT: "-export-dynamic"
     13 // CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan-i386.a.syms"
     14 // CHECK-ASAN-LINUX-NOT: "-export-dynamic"
     15 // CHECK-ASAN-LINUX: "-lpthread"
     16 // CHECK-ASAN-LINUX: "-lrt"
     17 // CHECK-ASAN-LINUX: "-ldl"
     18 
     19 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
     20 // RUN:     -target i386-unknown-linux -fsanitize=address -shared-libasan \
     21 // RUN:     -resource-dir=%S/Inputs/resource_dir \
     22 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
     23 // RUN:   | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s
     24 //
     25 // CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
     26 // CHECK-SHARED-ASAN-LINUX-NOT: "-lc"
     27 // CHECK-SHARED-ASAN-LINUX-NOT: libclang_rt.asan-i386.a"
     28 // CHECK-SHARED-ASAN-LINUX: libclang_rt.asan-i386.so"
     29 // CHECK-SHARED-ASAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-preinit-i386.a" "-no-whole-archive"
     30 // CHECK-SHARED-ASAN-LINUX-NOT: "-lpthread"
     31 // CHECK-SHARED-ASAN-LINUX-NOT: "-lrt"
     32 // CHECK-SHARED-ASAN-LINUX-NOT: "-ldl"
     33 // CHECK-SHARED-ASAN-LINUX-NOT: "-export-dynamic"
     34 // CHECK-SHARED-ASAN-LINUX-NOT: "--dynamic-list"
     35 
     36 // RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \
     37 // RUN:     -target i386-unknown-linux -fsanitize=address -shared-libasan \
     38 // RUN:     -resource-dir=%S/Inputs/resource_dir \
     39 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
     40 // RUN:   | FileCheck --check-prefix=CHECK-DSO-SHARED-ASAN-LINUX %s
     41 //
     42 // CHECK-DSO-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
     43 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lc"
     44 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: libclang_rt.asan-i386.a"
     45 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "libclang_rt.asan-preinit-i386.a"
     46 // CHECK-DSO-SHARED-ASAN-LINUX: libclang_rt.asan-i386.so"
     47 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lpthread"
     48 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-lrt"
     49 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-ldl"
     50 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "-export-dynamic"
     51 // CHECK-DSO-SHARED-ASAN-LINUX-NOT: "--dynamic-list"
     52 
     53 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
     54 // RUN:     -target i386-unknown-freebsd -fsanitize=address \
     55 // RUN:     -resource-dir=%S/Inputs/resource_dir \
     56 // RUN:     --sysroot=%S/Inputs/basic_freebsd_tree \
     57 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-FREEBSD %s
     58 //
     59 // CHECK-ASAN-FREEBSD: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
     60 // CHECK-ASAN-FREEBSD-NOT: "-lc"
     61 // CHECK-ASAN-FREEBSD-NOT: libclang_rt.asan_cxx
     62 // CHECK-ASAN-FREEBSD: freebsd{{/|\\+}}libclang_rt.asan-i386.a"
     63 // CHECK-ASAN-FREEBSD-NOT: libclang_rt.asan_cxx
     64 // CHECK-ASAN-FREEBSD-NOT: "--dynamic-list"
     65 // CHECK-ASAN-FREEBSD: "-export-dynamic"
     66 // CHECK-ASAN-FREEBSD: "-lpthread"
     67 // CHECK-ASAN-FREEBSD: "-lrt"
     68 
     69 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
     70 // RUN:     -target i386-unknown-freebsd -fsanitize=address \
     71 // RUN:     -resource-dir=%S/Inputs/resource_dir \
     72 // RUN:     --sysroot=%S/Inputs/basic_freebsd_tree \
     73 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-FREEBSD-LDL %s
     74 //
     75 // CHECK-ASAN-FREEBSD-LDL: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
     76 // CHECK-ASAN-FREEBSD-LDL-NOT: "-ldl"
     77 
     78 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
     79 // RUN:     -target i386-unknown-linux -stdlib=platform -fsanitize=address \
     80 // RUN:     -resource-dir=%S/Inputs/empty_resource_dir \
     81 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
     82 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s
     83 //
     84 // CHECK-ASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
     85 // CHECK-ASAN-LINUX-CXX-NOT: "-lc"
     86 // CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
     87 // CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan_cxx-i386.a" "-no-whole-archive"
     88 // CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
     89 // CHECK-ASAN-LINUX-CXX: "-export-dynamic"
     90 // CHECK-ASAN-LINUX-CXX: stdc++
     91 // CHECK-ASAN-LINUX-CXX: "-lpthread"
     92 // CHECK-ASAN-LINUX-CXX: "-lrt"
     93 // CHECK-ASAN-LINUX-CXX: "-ldl"
     94 
     95 // RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
     96 // RUN:     -target i386-unknown-linux -stdlib=platform \
     97 // RUN:     --sysroot=%S/Inputs/basic_linux_tree -lstdc++ -static 2>&1 \
     98 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX-STATIC %s
     99 //
    100 // CHECK-ASAN-LINUX-CXX-STATIC: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    101 // CHECK-ASAN-LINUX-CXX-STATIC-NOT: stdc++
    102 // CHECK-ASAN-LINUX-CXX-STATIC: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
    103 // CHECK-ASAN-LINUX-CXX-STATIC: stdc++
    104 
    105 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    106 // RUN:     -target arm-linux-gnueabi -fsanitize=address \
    107 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
    108 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-ARM %s
    109 //
    110 // CHECK-ASAN-ARM: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    111 // CHECK-ASAN-ARM-NOT: "-lc"
    112 // CHECK-ASAN-ARM: libclang_rt.asan-arm.a"
    113 //
    114 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    115 // RUN:     -target armv7l-linux-gnueabi -fsanitize=address \
    116 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
    117 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-ARMv7 %s
    118 //
    119 // CHECK-ASAN-ARMv7: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    120 // CHECK-ASAN-ARMv7-NOT: "-lc"
    121 // CHECK-ASAN-ARMv7: libclang_rt.asan-arm.a"
    122 
    123 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    124 // RUN:     -target arm-linux-androideabi -fsanitize=address \
    125 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
    126 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-ANDROID %s
    127 //
    128 // CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    129 // CHECK-ASAN-ANDROID-NOT: "-lc"
    130 // CHECK-ASAN-ANDROID: "-pie"
    131 // CHECK-ASAN-ANDROID-NOT: "-lpthread"
    132 // CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
    133 // CHECK-ASAN-ANDROID-NOT: "-lpthread"
    134 //
    135 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    136 // RUN:     -target arm-linux-androideabi -fsanitize=address \
    137 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
    138 // RUN:     -shared-libasan \
    139 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED-LIBASAN %s
    140 //
    141 // CHECK-ASAN-ANDROID-SHARED-LIBASAN-NOT: argument unused during compilation: '-shared-libasan'
    142 //
    143 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    144 // RUN:     -target arm-linux-androideabi -fsanitize=address \
    145 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
    146 // RUN:     -shared \
    147 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED %s
    148 //
    149 // CHECK-ASAN-ANDROID-SHARED: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    150 // CHECK-ASAN-ANDROID-SHARED-NOT: "-lc"
    151 // CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
    152 // CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"
    153 
    154 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    155 // RUN:     -target x86_64-unknown-linux -stdlib=platform -lstdc++ \
    156 // RUN:     -fsanitize=thread \
    157 // RUN:     -resource-dir=%S/Inputs/resource_dir \
    158 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    159 // RUN:   | FileCheck --check-prefix=CHECK-TSAN-LINUX-CXX %s
    160 //
    161 // CHECK-TSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    162 // CHECK-TSAN-LINUX-CXX-NOT: stdc++
    163 // CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
    164 // CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan-x86_64.a.syms"
    165 // CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan_cxx-x86_64.a" "-no-whole-archive"
    166 // CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan_cxx-x86_64.a.syms"
    167 // CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
    168 // CHECK-TSAN-LINUX-CXX: stdc++
    169 // CHECK-TSAN-LINUX-CXX: "-lpthread"
    170 // CHECK-TSAN-LINUX-CXX: "-lrt"
    171 // CHECK-TSAN-LINUX-CXX: "-ldl"
    172 
    173 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    174 // RUN:     -target x86_64-unknown-linux -stdlib=platform -lstdc++ \
    175 // RUN:     -fsanitize=memory \
    176 // RUN:     -resource-dir=%S/Inputs/resource_dir \
    177 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    178 // RUN:   | FileCheck --check-prefix=CHECK-MSAN-LINUX-CXX %s
    179 //
    180 // CHECK-MSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    181 // CHECK-MSAN-LINUX-CXX-NOT: stdc++
    182 // CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
    183 // CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan-x86_64.a.syms"
    184 // CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan_cxx-x86_64.a" "-no-whole-archive"
    185 // CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan_cxx-x86_64.a.syms"
    186 // CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
    187 // CHECK-MSAN-LINUX-CXX: stdc++
    188 // CHECK-MSAN-LINUX-CXX: "-lpthread"
    189 // CHECK-MSAN-LINUX-CXX: "-lrt"
    190 // CHECK-MSAN-LINUX-CXX: "-ldl"
    191 
    192 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
    193 // RUN:     -target i386-unknown-linux \
    194 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    195 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
    196 // CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
    197 // CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
    198 // CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_standalone_cxx
    199 // CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone-i386.a" "-no-whole-archive"
    200 // CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
    201 // CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_standalone_cxx
    202 // CHECK-UBSAN-LINUX-NOT: "-lstdc++"
    203 // CHECK-UBSAN-LINUX: "-lpthread"
    204 
    205 // RUN: %clang -fsanitize=undefined -fsanitize-link-c++-runtime %s -### -o %t.o 2>&1 \
    206 // RUN:     -target i386-unknown-linux \
    207 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    208 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX-LINK-CXX %s
    209 // CHECK-UBSAN-LINUX-LINK-CXX-NOT: "-lstdc++"
    210 // CHECK-UBSAN-LINUX-LINK-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone_cxx-i386.a" "-no-whole-archive"
    211 // CHECK-UBSAN-LINUX-LINK-CXX-NOT: "-lstdc++"
    212 
    213 // RUN: %clangxx -fsanitize=undefined %s -### -o %t.o 2>&1 \
    214 // RUN:     -target i386-unknown-linux -stdlib=platform \
    215 // RUN:     -resource-dir=%S/Inputs/resource_dir \
    216 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    217 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX-CXX %s
    218 // CHECK-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
    219 // CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
    220 // CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone-i386.a" "-no-whole-archive"
    221 // CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
    222 // CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone_cxx-i386.a" "-no-whole-archive"
    223 // CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
    224 // CHECK-UBSAN-LINUX-CXX: "-lstdc++"
    225 // CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
    226 // CHECK-UBSAN-LINUX-CXX: "-lpthread"
    227 
    228 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
    229 // RUN:     -target i386-unknown-linux \
    230 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    231 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX %s
    232 // CHECK-ASAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
    233 // CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
    234 // CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan
    235 // CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"
    236 // CHECK-ASAN-UBSAN-LINUX: "-lpthread"
    237 
    238 // RUN: %clangxx -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
    239 // RUN:     -target i386-unknown-linux -stdlib=platform \
    240 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    241 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX-CXX %s
    242 // CHECK-ASAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
    243 // CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
    244 // CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan_cxx-i386.a" "-no-whole-archive"
    245 // CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
    246 // CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
    247 // CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
    248 
    249 // RUN: %clangxx -fsanitize=memory,undefined %s -### -o %t.o 2>&1 \
    250 // RUN:     -target x86_64-unknown-linux \
    251 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    252 // RUN:   | FileCheck --check-prefix=CHECK-MSAN-UBSAN-LINUX-CXX %s
    253 // CHECK-MSAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
    254 // CHECK-MSAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
    255 // CHECK-MSAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
    256 
    257 // RUN: %clangxx -fsanitize=thread,undefined %s -### -o %t.o 2>&1 \
    258 // RUN:     -target x86_64-unknown-linux \
    259 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    260 // RUN:   | FileCheck --check-prefix=CHECK-TSAN-UBSAN-LINUX-CXX %s
    261 // CHECK-TSAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
    262 // CHECK-TSAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
    263 // CHECK-TSAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
    264 
    265 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
    266 // RUN:     -target i386-unknown-linux \
    267 // RUN:     -resource-dir=%S/Inputs/resource_dir \
    268 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    269 // RUN:     -shared \
    270 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHARED %s
    271 // CHECK-UBSAN-LINUX-SHARED: "{{.*}}ld{{(.exe)?}}"
    272 // CHECK-UBSAN-LINUX-SHARED-NOT: --export-dynamic
    273 // CHECK-UBSAN-LINUX-SHARED-NOT: --dynamic-list
    274 // CHECK-UBSAN-LINUX-SHARED-NOT: libclang_rt.ubsan
    275 
    276 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    277 // RUN:     -target x86_64-unknown-linux -fsanitize=leak \
    278 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    279 // RUN:   | FileCheck --check-prefix=CHECK-LSAN-LINUX %s
    280 //
    281 // CHECK-LSAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    282 // CHECK-LSAN-LINUX-NOT: "-lc"
    283 // CHECK-LSAN-LINUX: libclang_rt.lsan-x86_64.a"
    284 // CHECK-LSAN-LINUX: "-lpthread"
    285 // CHECK-LSAN-LINUX: "-ldl"
    286 
    287 // RUN: %clang -fsanitize=leak,address %s -### -o %t.o 2>&1 \
    288 // RUN:     -target x86_64-unknown-linux \
    289 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    290 // RUN:   | FileCheck --check-prefix=CHECK-LSAN-ASAN-LINUX %s
    291 // CHECK-LSAN-ASAN-LINUX: "{{.*}}ld{{(.exe)?}}"
    292 // CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
    293 // CHECK-LSAN-ASAN-LINUX: libclang_rt.asan-x86_64
    294 // CHECK-LSAN-ASAN-LINUX-NOT: libclang_rt.lsan
    295 
    296 // RUN: %clang -fsanitize=address -fsanitize-coverage=func %s -### -o %t.o 2>&1 \
    297 // RUN:     -target x86_64-unknown-linux \
    298 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    299 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-COV-LINUX %s
    300 // CHECK-ASAN-COV-LINUX: "{{.*}}ld{{(.exe)?}}"
    301 // CHECK-ASAN-COV-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-x86_64.a" "-no-whole-archive"
    302 // CHECK-ASAN-COV-LINUX-NOT: libclang_rt.ubsan
    303 // CHECK-ASAN-COV-LINUX-NOT: "-lstdc++"
    304 // CHECK-ASAN-COV-LINUX: "-lpthread"
    305 
    306 // RUN: %clang -fsanitize=memory -fsanitize-coverage=func %s -### -o %t.o 2>&1 \
    307 // RUN:     -target x86_64-unknown-linux \
    308 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    309 // RUN:   | FileCheck --check-prefix=CHECK-MSAN-COV-LINUX %s
    310 // CHECK-MSAN-COV-LINUX: "{{.*}}ld{{(.exe)?}}"
    311 // CHECK-MSAN-COV-LINUX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
    312 // CHECK-MSAN-COV-LINUX-NOT: libclang_rt.ubsan
    313 // CHECK-MSAN-COV-LINUX-NOT: "-lstdc++"
    314 // CHECK-MSAN-COV-LINUX: "-lpthread"
    315 
    316 // RUN: %clang -fsanitize=dataflow -fsanitize-coverage=func %s -### -o %t.o 2>&1 \
    317 // RUN:     -target x86_64-unknown-linux \
    318 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    319 // RUN:   | FileCheck --check-prefix=CHECK-DFSAN-COV-LINUX %s
    320 // CHECK-DFSAN-COV-LINUX: "{{.*}}ld{{(.exe)?}}"
    321 // CHECK-DFSAN-COV-LINUX: "-whole-archive" "{{.*}}libclang_rt.dfsan-x86_64.a" "-no-whole-archive"
    322 // CHECK-DFSAN-COV-LINUX-NOT: libclang_rt.ubsan
    323 // CHECK-DFSAN-COV-LINUX-NOT: "-lstdc++"
    324 // CHECK-DFSAN-COV-LINUX: "-lpthread"
    325 
    326 // RUN: %clang -fsanitize=undefined -fsanitize-coverage=func %s -### -o %t.o 2>&1 \
    327 // RUN:     -target x86_64-unknown-linux \
    328 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    329 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-COV-LINUX %s
    330 // CHECK-UBSAN-COV-LINUX: "{{.*}}ld{{(.exe)?}}"
    331 // CHECK-UBSAN-COV-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone-x86_64.a" "-no-whole-archive"
    332 // CHECK-UBSAN-COV-LINUX-NOT: "-lstdc++"
    333 // CHECK-UBSAN-COV-LINUX: "-lpthread"
    334 
    335 // RUN: %clang -fsanitize-coverage=func %s -### -o %t.o 2>&1 \
    336 // RUN:     -target x86_64-unknown-linux \
    337 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    338 // RUN:   | FileCheck --check-prefix=CHECK-COV-LINUX %s
    339 // CHECK-COV-LINUX: "{{.*}}ld{{(.exe)?}}"
    340 // CHECK-COV-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan_standalone-x86_64.a" "-no-whole-archive"
    341 // CHECK-COV-LINUX-NOT: "-lstdc++"
    342 // CHECK-COV-LINUX: "-lpthread"
    343 
    344 // CFI by itself does not link runtime libraries.
    345 // RUN: %clang -fsanitize=cfi %s -### -o %t.o 2>&1 \
    346 // RUN:     -target x86_64-unknown-linux \
    347 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    348 // RUN:   | FileCheck --check-prefix=CHECK-CFI-LINUX %s
    349 // CHECK-CFI-LINUX: "{{.*}}ld{{(.exe)?}}"
    350 // CHECK-CFI-LINUX-NOT: libclang_rt.
    351 
    352 // CFI with diagnostics links the UBSan runtime.
    353 // RUN: %clang -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
    354 // RUN:     %s -### -o %t.o 2>&1\
    355 // RUN:     -target x86_64-unknown-linux \
    356 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    357 // RUN:   | FileCheck --check-prefix=CHECK-CFI-DIAG-LINUX %s
    358 // CHECK-CFI-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
    359 // CHECK-CFI-DIAG-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.ubsan_standalone-x86_64.a" "-no-whole-archive"
    360 
    361 // Cross-DSO CFI links the CFI runtime.
    362 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
    363 // RUN:     -target x86_64-unknown-linux \
    364 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    365 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-LINUX %s
    366 // CHECK-CFI-CROSS-DSO-LINUX: "{{.*}}ld{{(.exe)?}}"
    367 // CHECK-CFI-CROSS-DSO-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.cfi-x86_64.a" "-no-whole-archive"
    368 
    369 // Cross-DSO CFI with diagnostics links just the CFI runtime.
    370 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
    371 // RUN:     -fno-sanitize-trap=cfi -fsanitize-recover=cfi \
    372 // RUN:     -target x86_64-unknown-linux \
    373 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    374 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-LINUX %s
    375 // CHECK-CFI-CROSS-DSO-DIAG-LINUX: "{{.*}}ld{{(.exe)?}}"
    376 // CHECK-CFI-CROSS-DSO-DIAG-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.cfi_diag-x86_64.a" "-no-whole-archive"
    377 
    378 // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \
    379 // RUN:     -mmacosx-version-min=10.6 \
    380 // RUN:     -target x86_64-apple-darwin13.4.0 -stdlib=platform \
    381 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    382 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-DARWIN106-CXX %s
    383 // CHECK-ASAN-DARWIN106-CXX: "{{.*}}ld{{(.exe)?}}"
    384 // CHECK-ASAN-DARWIN106-CXX: libclang_rt.asan_osx_dynamic.dylib
    385 // CHECK-ASAN-DARWIN106-CXX-NOT: -lc++abi
    386 
    387 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    388 // RUN:     -target x86_64-unknown-linux -fsanitize=safe-stack \
    389 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    390 // RUN:   | FileCheck --check-prefix=CHECK-SAFESTACK-LINUX %s
    391 //
    392 // CHECK-SAFESTACK-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    393 // CHECK-SAFESTACK-LINUX-NOT: "-lc"
    394 // CHECK-SAFESTACK-LINUX: libclang_rt.safestack-x86_64.a"
    395 // CHECK-SAFESTACK-LINUX: "-lpthread"
    396 // CHECK-SAFESTACK-LINUX: "-ldl"
    397 
    398 // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
    399 // RUN:     -target x86_64-unknown-linux \
    400 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    401 // RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-LINUX %s
    402 // CHECK-CFI-STATS-LINUX: "{{.*}}ld{{(.exe)?}}"
    403 // CHECK-CFI-STATS-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.stats_client-x86_64.a" "-no-whole-archive"
    404 // CHECK-CFI-STATS-LINUX-NOT: "-whole-archive"
    405 // CHECK-CFI-STATS-LINUX: "{{[^"]*}}libclang_rt.stats-x86_64.a"
    406 
    407 // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
    408 // RUN:     -target x86_64-apple-darwin \
    409 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    410 // RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-DARWIN %s
    411 // CHECK-CFI-STATS-DARWIN: "{{.*}}ld{{(.exe)?}}"
    412 // CHECK-CFI-STATS-DARWIN: "{{[^"]*}}libclang_rt.stats_client_osx.a"
    413 // CHECK-CFI-STATS-DARWIN: "{{[^"]*}}libclang_rt.stats_osx_dynamic.dylib"
    414 
    415 // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
    416 // RUN:     -target x86_64-pc-windows \
    417 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    418 // RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-WIN64 %s
    419 // CHECK-CFI-STATS-WIN64: "--dependent-lib={{[^"]*}}clang_rt.stats_client-x86_64.lib"
    420 // CHECK-CFI-STATS-WIN64: "--dependent-lib={{[^"]*}}clang_rt.stats-x86_64.lib"
    421 // CHECK-CFI-STATS-WIN64: "--linker-option=/include:__sanitizer_stats_register"
    422 
    423 // RUN: %clang -fsanitize=cfi -fsanitize-stats %s -### -o %t.o 2>&1 \
    424 // RUN:     -target i686-pc-windows \
    425 // RUN:     --sysroot=%S/Inputs/basic_linux_tree \
    426 // RUN:   | FileCheck --check-prefix=CHECK-CFI-STATS-WIN32 %s
    427 // CHECK-CFI-STATS-WIN32: "--dependent-lib={{[^"]*}}clang_rt.stats_client-i386.lib"
    428 // CHECK-CFI-STATS-WIN32: "--dependent-lib={{[^"]*}}clang_rt.stats-i386.lib"
    429 // CHECK-CFI-STATS-WIN32: "--linker-option=/include:___sanitizer_stats_register"
    430 
    431 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    432 // RUN:     -target arm-linux-androideabi -fsanitize=safe-stack \
    433 // RUN:     --sysroot=%S/Inputs/basic_android_tree \
    434 // RUN:   | FileCheck --check-prefix=CHECK-SAFESTACK-ANDROID-ARM %s
    435 //
    436 // CHECK-SAFESTACK-ANDROID-ARM: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    437 // CHECK-SAFESTACK-ANDROID-ARM-NOT: libclang_rt.safestack
    438 
    439 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o -shared 2>&1 \
    440 // RUN:     -target arm-linux-androideabi -fsanitize=safe-stack \
    441 // RUN:     --sysroot=%S/Inputs/basic_android_tree \
    442 // RUN:   | FileCheck --check-prefix=CHECK-SAFESTACK-ANDROID-ARM %s
    443 //
    444 // CHECK-SAFESTACK-SHARED-ANDROID-ARM: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    445 // CHECK-SAFESTACK-SHARED-ANDROID-ARM-NOT: libclang_rt.safestack
    446 
    447 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
    448 // RUN:     -target aarch64-linux-android -fsanitize=safe-stack \
    449 // RUN:     --sysroot=%S/Inputs/basic_android_tree \
    450 // RUN:   | FileCheck --check-prefix=CHECK-SAFESTACK-ANDROID-AARCH64 %s
    451 //
    452 // CHECK-SAFESTACK-ANDROID-AARCH64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    453 // CHECK-SAFESTACK-ANDROID-AARCH64-NOT: libclang_rt.safestack
    454 
    455 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
    456 // RUN:     -target x86_64-scei-ps4 \
    457 // RUN:     -shared \
    458 // RUN:   | FileCheck --check-prefix=CHECK-UBSAN-PS4 %s
    459 // CHECK-UBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
    460 // CHECK-UBSAN-PS4: -lSceDbgUBSanitizer_stub_weak
    461 
    462 // RUN: %clang -fsanitize=address %s -### -o %t.o 2>&1 \
    463 // RUN:     -target x86_64-scei-ps4 \
    464 // RUN:     -shared \
    465 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-PS4 %s
    466 // CHECK-ASAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
    467 // CHECK-ASAN-PS4: -lSceDbgAddressSanitizer_stub_weak
    468 
    469 // RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
    470 // RUN:     -target x86_64-scei-ps4 \
    471 // RUN:     -shared \
    472 // RUN:   | FileCheck --check-prefix=CHECK-AUBSAN-PS4 %s
    473 // CHECK-AUBSAN-PS4: "{{.*}}ld{{(.gold)?(.exe)?}}"
    474 // CHECK-AUBSAN-PS4: -lSceDbgAddressSanitizer_stub_weak
    475 
    476 // RUN: %clang -fsanitize=efficiency-cache-frag %s -### -o %t.o 2>&1 \
    477 // RUN:     -target x86_64-unknown-linux \
    478 // RUN:   | FileCheck --check-prefix=CHECK-ESAN-LINUX %s
    479 // RUN: %clang -fsanitize=efficiency-working-set %s -### -o %t.o 2>&1 \
    480 // RUN:     -target x86_64-unknown-linux \
    481 // RUN:   | FileCheck --check-prefix=CHECK-ESAN-LINUX %s
    482 //
    483 // CHECK-ESAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
    484 // CHECK-ESAN-LINUX: libclang_rt.esan-x86_64.a
    485