1 // RUN: %clang %s -### -no-canonical-prefixes --target=x86_64-fuchsia \ 2 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 3 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \ 4 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s 5 // RUN: %clang %s -### -no-canonical-prefixes --target=aarch64-fuchsia \ 6 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 7 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \ 8 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s 9 // RUN: %clang %s -### -no-canonical-prefixes --target=riscv64-fuchsia \ 10 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 11 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \ 12 // RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s 13 // CHECK: {{.*}}clang{{.*}}" "-cc1" 14 // CHECK-X86_64: "-triple" "x86_64-unknown-fuchsia" 15 // CHECK-AARCH64: "-triple" "aarch64-unknown-fuchsia" 16 // CHECK-RISCV64: "-triple" "riscv64-unknown-fuchsia" 17 // CHECK: "--mrelax-relocations" 18 // CHECK: "-munwind-tables" 19 // CHECK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 20 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]" 21 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|\\\\}}include" 22 // CHECK-AARCH64: "-fsanitize=shadow-call-stack" 23 // CHECK-X86_64: "-fsanitize=safe-stack" 24 // CHECK: "-stack-protector" "2" 25 // CHECK-NOT: "-fcommon" 26 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "--pack-dyn-relocs=relr" 27 // CHECK: "--sysroot=[[SYSROOT]]" 28 // CHECK: "-pie" 29 // CHECK: "--build-id" 30 // CHECK: "--hash-style=gnu" 31 // CHECK: "-dynamic-linker" "ld.so.1" 32 // CHECK: Scrt1.o 33 // CHECK-NOT: crti.o 34 // CHECK-NOT: crtbegin.o 35 // CHECK: "-L[[SYSROOT]]{{/|\\\\}}lib" 36 // CHECK-X86_64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.builtins.a" 37 // CHECK-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.builtins.a" 38 // CHECK-RISCV64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}riscv64-fuchsia{{/|\\\\}}libclang_rt.builtins.a" 39 // CHECK: "-lc" 40 // CHECK-NOT: crtend.o 41 // CHECK-NOT: crtn.o 42 43 // RUN: %clang %s -### --target=x86_64-fuchsia -rtlib=libgcc -fuse-ld=lld 2>&1 \ 44 // RUN: | FileCheck %s -check-prefix=CHECK-RTLIB 45 // CHECK-RTLIB: error: invalid runtime library name in argument '-rtlib=libgcc' 46 47 // RUN: %clang %s -### --target=x86_64-fuchsia -static -fuse-ld=lld 2>&1 \ 48 // RUN: | FileCheck %s -check-prefix=CHECK-STATIC 49 // CHECK-STATIC: "-Bstatic" 50 // CHECK-STATIC: "-Bdynamic" 51 // CHECK-STATIC: "-lc" 52 53 // RUN: %clang %s -### --target=x86_64-fuchsia -shared -fuse-ld=lld 2>&1 \ 54 // RUN: | FileCheck %s -check-prefix=CHECK-SHARED 55 // CHECK-SHARED-NOT: "-pie" 56 // CHECK-SHARED: "-shared" 57 58 // RUN: %clang %s -### --target=x86_64-fuchsia -r -fuse-ld=lld 2>&1 \ 59 // RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE 60 // CHECK-RELOCATABLE-NOT: "-pie" 61 // CHECK-RELOCATABLE-NOT: "--build-id" 62 // CHECK-RELOCATABLE: "-r" 63 64 // RUN: %clang %s -### --target=x86_64-fuchsia -nodefaultlibs -fuse-ld=lld 2>&1 \ 65 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 66 // RUN: | FileCheck %s -check-prefix=CHECK-NODEFAULTLIBS 67 // CHECK-NODEFAULTLIBS: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 68 // CHECK-NODEFAULTLIBS-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.builtins.a" 69 // CHECK-NODEFAULTLIBS-NOT: "-lc" 70 71 // RUN: %clang %s -### --target=x86_64-fuchsia -nostdlib -fuse-ld=lld 2>&1 \ 72 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 73 // RUN: | FileCheck %s -check-prefix=CHECK-NOSTDLIB 74 // CHECK-NOSTDLIB: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 75 // CHECK-NOSTDLIB-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.builtins.a" 76 // CHECK-NOSTDLIB-NOT: "-lc" 77 78 // RUN: %clang %s -### --target=x86_64-fuchsia -nolibc -fuse-ld=lld 2>&1 \ 79 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 80 // RUN: | FileCheck %s -check-prefix=CHECK-NOLIBC 81 // CHECK-NOLIBC: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 82 // CHECK-NOLIBC: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.builtins.a" 83 // CHECK-NOLIBC-NOT: "-lc" 84 85 // RUN: %clang %s -### --target=x86_64-fuchsia \ 86 // RUN: -fsanitize=safe-stack 2>&1 \ 87 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 88 // RUN: -fuse-ld=lld \ 89 // RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK 90 // CHECK-SAFESTACK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 91 // CHECK-SAFESTACK: "-fsanitize=safe-stack" 92 // CHECK-SAFESTACK-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.safestack.a" 93 // CHECK-SAFESTACK-NOT: "__safestack_init" 94 95 // RUN: %clang %s -### --target=x86_64-fuchsia \ 96 // RUN: -fsanitize=address 2>&1 \ 97 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 98 // RUN: -fuse-ld=lld \ 99 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-X86 100 // CHECK-ASAN-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 101 // CHECK-ASAN-X86: "-fsanitize=address" 102 // CHECK-ASAN-X86: "-fsanitize-address-globals-dead-stripping" 103 // CHECK-ASAN-X86: "-dynamic-linker" "asan/ld.so.1" 104 // CHECK-ASAN-X86: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.asan.so" 105 // CHECK-ASAN-X86: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.asan-preinit.a" 106 107 // RUN: %clang %s -### --target=aarch64-fuchsia \ 108 // RUN: -fsanitize=address 2>&1 \ 109 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 110 // RUN: -fuse-ld=lld \ 111 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-AARCH64 112 // CHECK-ASAN-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 113 // CHECK-ASAN-AARCH64: "-fsanitize=address,shadow-call-stack" 114 // CHECK-ASAN-AARCH64: "-fsanitize-address-globals-dead-stripping" 115 // CHECK-ASAN-AARCH64: "-dynamic-linker" "asan/ld.so.1" 116 // CHECK-ASAN-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.asan.so" 117 // CHECK-ASAN-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.asan-preinit.a" 118 119 // RUN: %clang %s -### --target=x86_64-fuchsia \ 120 // RUN: -fsanitize=address -fPIC -shared 2>&1 \ 121 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 122 // RUN: -fuse-ld=lld \ 123 // RUN: | FileCheck %s -check-prefix=CHECK-ASAN-SHARED 124 // CHECK-ASAN-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 125 // CHECK-ASAN-SHARED: "-fsanitize=address" 126 // CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping" 127 // CHECK-ASAN-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.asan.so" 128 // CHECK-ASAN-SHARED-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.asan-preinit.a" 129 130 // RUN: %clang %s -### --target=x86_64-fuchsia \ 131 // RUN: -fsanitize=fuzzer 2>&1 \ 132 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 133 // RUN: -fuse-ld=lld \ 134 // RUN: | FileCheck %s -check-prefix=CHECK-FUZZER-X86 135 // CHECK-FUZZER-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 136 // CHECK-FUZZER-X86: "-fsanitize=fuzzer,fuzzer-no-link,safe-stack" 137 // CHECK-FUZZER-X86: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.fuzzer.a" 138 139 // RUN: %clang %s -### --target=aarch64-fuchsia \ 140 // RUN: -fsanitize=fuzzer 2>&1 \ 141 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 142 // RUN: -fuse-ld=lld \ 143 // RUN: | FileCheck %s -check-prefix=CHECK-FUZZER-AARCH64 144 // CHECK-FUZZER-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 145 // CHECK-FUZZER-AARCH64: "-fsanitize=fuzzer,fuzzer-no-link,shadow-call-stack" 146 // CHECK-FUZZER-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.fuzzer.a" 147 148 // RUN: %clang %s -### --target=x86_64-fuchsia \ 149 // RUN: -fsanitize=scudo 2>&1 \ 150 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 151 // RUN: -fuse-ld=lld \ 152 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-X86 153 // CHECK-SCUDO-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 154 // CHECK-SCUDO-X86: "-fsanitize=safe-stack,scudo" 155 // CHECK-SCUDO-X86: "-pie" 156 // CHECK-SCUDO-X86: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.scudo.so" 157 158 // RUN: %clang %s -### --target=aarch64-fuchsia \ 159 // RUN: -fsanitize=scudo 2>&1 \ 160 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 161 // RUN: -fuse-ld=lld \ 162 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64 163 // CHECK-SCUDO-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 164 // CHECK-SCUDO-AARCH64: "-fsanitize=shadow-call-stack,scudo" 165 // CHECK-SCUDO-AARCH64: "-pie" 166 // CHECK-SCUDO-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.scudo.so" 167 168 // RUN: %clang %s -### --target=x86_64-fuchsia \ 169 // RUN: -fsanitize=scudo -fPIC -shared 2>&1 \ 170 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 171 // RUN: -fuse-ld=lld \ 172 // RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED 173 // CHECK-SCUDO-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 174 // CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo" 175 // CHECK-SCUDO-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.scudo.so" 176 177 // RUN: %clang %s -### --target=aarch64-fuchsia \ 178 // RUN: -fsanitize=leak 2>&1 \ 179 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 180 // RUN: -fuse-ld=lld \ 181 // RUN: | FileCheck %s -check-prefix=CHECK-LSAN-AARCH64 182 // CHECK-LSAN-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 183 // CHECK-LSAN-AARCH64: "-fsanitize=leak,shadow-call-stack" 184 // CHECK-LSAN-AARCH64: "-pie" 185 // CHECK-LSAN-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.lsan.a" 186 187 // RUN: %clang %s -### --target=x86_64-fuchsia \ 188 // RUN: -fsanitize=leak 2>&1 \ 189 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 190 // RUN: -fuse-ld=lld \ 191 // RUN: | FileCheck %s -check-prefix=CHECK-LSAN-X86 192 // CHECK-LSAN-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 193 // CHECK-LSAN-X86: "-fsanitize=leak,safe-stack" 194 // CHECK-LSAN-X86: "-pie" 195 // CHECK-LSAN-X86: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.lsan.a" 196 197 // RUN: %clang %s -### --target=aarch64-fuchsia \ 198 // RUN: -fsanitize=leak -fPIC -shared 2>&1 \ 199 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 200 // RUN: -fuse-ld=lld \ 201 // RUN: | FileCheck %s -check-prefix=CHECK-LSAN-SHARED 202 // CHECK-LSAN-SHARED: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 203 // CHECK-LSAN-SHARED: "-fsanitize=leak,shadow-call-stack" 204 // CHECK-LSAN-SHARED-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.lsan.a" 205 206 // RUN: %clang %s -### --target=x86_64-fuchsia \ 207 // RUN: -fxray-instrument -fxray-modes=xray-basic \ 208 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 209 // RUN: -fuse-ld=lld 2>&1 \ 210 // RUN: | FileCheck %s -check-prefix=CHECK-XRAY-X86 211 // CHECK-XRAY-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 212 // CHECK-XRAY-X86: "-fxray-instrument" 213 // CHECK-XRAY-X86: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.xray.a" 214 // CHECK-XRAY-X86: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.xray-basic.a" 215 216 // RUN: %clang %s -### --target=aarch64-fuchsia \ 217 // RUN: -fxray-instrument -fxray-modes=xray-basic \ 218 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 219 // RUN: -fuse-ld=lld 2>&1 \ 220 // RUN: | FileCheck %s -check-prefix=CHECK-XRAY-AARCH64 221 // CHECK-XRAY-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 222 // CHECK-XRAY-AARCH64: "-fxray-instrument" 223 // CHECK-XRAY-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.xray.a" 224 // CHECK-XRAY-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.xray-basic.a" 225 226 // RUN: %clang %s -### --target=aarch64-fuchsia \ 227 // RUN: -O3 -flto -mcpu=cortex-a53 2>&1 \ 228 // RUN: -fuse-ld=lld \ 229 // RUN: | FileCheck %s -check-prefix=CHECK-LTO 230 // CHECK-LTO: "-plugin-opt=mcpu=cortex-a53" 231 // CHECK-LTO: "-plugin-opt=O3" 232 233 // RUN: %clang %s -### --target=x86_64-fuchsia \ 234 // RUN: -flto=thin -flto-jobs=8 2>&1 \ 235 // RUN: -fuse-ld=lld \ 236 // RUN: | FileCheck %s -check-prefix=CHECK-THINLTO 237 // CHECK-THINLTO: "-plugin-opt=mcpu=x86-64" 238 // CHECK-THINLTO: "-plugin-opt=thinlto" 239 // CHECK-THINLTO: "-plugin-opt=jobs=8" 240 241 // RUN: %clang %s -### --target=x86_64-fuchsia \ 242 // RUN: -gsplit-dwarf -g -c %s 2>&1 \ 243 // RUN: | FileCheck %s -check-prefix=CHECK-SPLIT-DWARF 244 // CHECK-SPLIT-DWARF: "-split-dwarf-output" "fuchsia.dwo" 245 246 // RUN: %clang %s -### --target=aarch64-fuchsia \ 247 // RUN: -fprofile-instr-generate -fcoverage-mapping \ 248 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 249 // RUN: -fuse-ld=lld 2>&1 \ 250 // RUN: | FileCheck %s -check-prefix=CHECK-PROFRT-AARCH64 251 // CHECK-PROFRT-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 252 // CHECK-PROFRT-AARCH64: "-u__llvm_profile_runtime" 253 // CHECK-PROFRT-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}libclang_rt.profile.a" 254 255 // RUN: %clang %s -### --target=x86_64-fuchsia \ 256 // RUN: -fprofile-instr-generate -fcoverage-mapping \ 257 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \ 258 // RUN: -fuse-ld=lld 2>&1 \ 259 // RUN: | FileCheck %s -check-prefix=CHECK-PROFRT-X86_64 260 // CHECK-PROFRT-X86_64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" 261 // CHECK-PROFRT-X86_64: "-u__llvm_profile_runtime" 262 // CHECK-PROFRT-X86_64: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}libclang_rt.profile.a" 263