brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.6 KiB · 16c9967 Raw
210 lines · c
1// Test that a target emulation is supplied to the linker2 3// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-EMU %s4 5// CHECK-EMU: {{ld(\.exe)?}}"6// CHECK-EMU-SAME: "-m" "elf_x86_64_fbsd"7 8// Test that PIE is the default for main components9 10// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PIE %s11 12// CHECK-PIE: {{ld(\.exe)?}}"13// CHECK-PIE-SAME: "-pie"14 15// RUN: %clang --target=x86_64-sie-ps5 -no-pie %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-PIE %s16// RUN: %clang --target=x86_64-sie-ps5 -r %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-PIE %s17// RUN: %clang --target=x86_64-sie-ps5 -shared %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-PIE,CHECK-SHARED %s18// RUN: %clang --target=x86_64-sie-ps5 -static %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-PIE %s19 20// CHECK-NO-PIE: {{ld(\.exe)?}}"21// CHECK-NO-PIE-NOT: "-pie"22// CHECK-SHARED: "--shared"23 24// Test the driver supplies an --image-base to the linker only for non-pie25// executables.26 27// RUN: %clang --target=x86_64-sie-ps5 -static %s -### 2>&1 | FileCheck --check-prefixes=CHECK-BASE %s28// RUN: %clang --target=x86_64-sie-ps5 -no-pie %s -### 2>&1 | FileCheck --check-prefixes=CHECK-BASE %s29 30// CHECK-BASE: {{ld(\.exe)?}}"31// CHECK-BASE-SAME: "--image-base=0x400000"32 33// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BASE %s34// RUN: %clang --target=x86_64-sie-ps5 -r %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BASE %s35// RUN: %clang --target=x86_64-sie-ps5 -shared %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BASE %s36 37// CHECK-NO-BASE: {{ld(\.exe)?}}"38// CHECK-NO-BASE-NOT: --image-base39 40// Test the driver passes PlayStation-specific options to the linker that are41// appropriate for the type of output. Many options don't apply for relocatable42// output (-r).43 44// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s45// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s46// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s47// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-EXE %s48 49// CHECK-EXE: {{ld(\.exe)?}}"50// CHECK-EXE-SAME: "--eh-frame-hdr"51// CHECK-EXE-SAME: "--hash-style=sysv"52// CHECK-EXE-SAME: "--unresolved-symbols=report-all"53// CHECK-EXE-SAME: "-z" "now"54// CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"55// CHECK-EXE-SAME: "-z" "rodynamic"56// CHECK-EXE-SAME: "-z" "common-page-size=0x4000"57// CHECK-EXE-SAME: "-z" "max-page-size=0x4000"58// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0xffffffffffffffff"59// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe"60// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe"61 62// CHECK-NO-EXE: {{ld(\.exe)?}}"63// CHECK-NO-EXE-NOT: "--eh-frame-hdr"64// CHECK-NO-EXE-NOT: "--hash-style65// CHECK-NO-EXE-NOT: "--unresolved-symbols66// CHECK-NO-EXE-NOT: "-z"67 68// Test that --build-id is supplied to the linker for non-static executables69// and -shared.70 71// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-BUILD-ID %s72// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-BUILD-ID %s73// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BUILD-ID %s74// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BUILD-ID %s75 76// CHECK-BUILD-ID: {{ld(\.exe)?}}"77// CHECK-BUILD-ID-SAME: "--build-id=uuid"78 79// CHECK-NO-BUILD-ID: {{ld(\.exe)?}}"80// CHECK-NO-BUILD-ID-NOT: "--build-id81 82// Test that an appropriate linker script is supplied by the driver, but can83// be overridden with -T.84 85// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=main %s86// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=prx %s87// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=static %s88// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-SCRIPT %s89// RUN: %clang --target=x86_64-sie-ps5 %s -T custom.script -### 2>&1 | FileCheck --check-prefixes=CHECK-CUSTOM-SCRIPT --implicit-check-not "\"{{-T|--script|--default-script}}\"" %s90 91// CHECK-SCRIPT: {{ld(\.exe)?}}"92// CHECK-SCRIPT-SAME: "--default-script" "[[SCRIPT]].script"93 94// CHECK-NO-SCRIPT: {{ld(\.exe)?}}"95// CHECK-NO-SCRIPT-NOT: "--default-script"96 97// CHECK-CUSTOM-SCRIPT: {{ld(\.exe)?}}"98// CHECK-CUSTOM-SCRIPT-SAME: "-T" "custom.script"99 100// Test that -static is forwarded to the linker101 102// RUN: %clang --target=x86_64-sie-ps5 -static %s -### 2>&1 | FileCheck --check-prefixes=CHECK-STATIC %s103 104// CHECK-STATIC: {{ld(\.exe)?}}"105// CHECK-STATIC-SAME: "-static"106 107// Test the driver's control over the JustMyCode behavior with linker flags.108 109// RUN: %clang --target=x86_64-sie-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-JMC %s110// RUN: %clang --target=x86_64-sie-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-JMC %s111 112// CHECK: -plugin-opt=-enable-jmc-instrument113 114// Check the default library name.115// CHECK-JMC: "--push-state" "--whole-archive" "-lSceJmc_nosubmission" "--pop-state"116 117// Test that CRT objects and libraries are supplied to the linker and can be118// omitted with -noxxx options. These switches have some interaction with119// sanitizer RT libraries. That's checked in fsanitize.c120 121// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-MAIN-CRT,CHECK-DYNAMIC-LIBC,CHECK-DYNAMIC-CORE-LIBS %s122// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-SHARED-CRT,CHECK-DYNAMIC-LIBC,CHECK-DYNAMIC-CORE-LIBS %s123// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-STATIC-CRT,CHECK-STATIC-LIBCPP,CHECK-STATIC-LIBC,CHECK-STATIC-CORE-LIBS %s124// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-NO-CRT,CHECK-NO-LIBS %s125 126// RUN: %clang --target=x86_64-sie-ps5 %s -pthread -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-PTHREAD %s127 128// RUN: %clang --target=x86_64-sie-ps5 %s -nostartfiles -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-NO-CRT,CHECK-DYNAMIC-LIBC,CHECK-DYNAMIC-CORE-LIBS %s129// RUN: %clang --target=x86_64-sie-ps5 %s -nostartfiles -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-NO-CRT,CHECK-DYNAMIC-LIBC,CHECK-DYNAMIC-CORE-LIBS %s130// RUN: %clang --target=x86_64-sie-ps5 %s -nostartfiles -static -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-NO-CRT,CHECK-STATIC-LIBCPP,CHECK-STATIC-LIBC,CHECK-STATIC-CORE-LIBS %s131 132// RUN: %clang --target=x86_64-sie-ps5 %s -nodefaultlibs -pthread -fjmc -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-MAIN-CRT,CHECK-NO-LIBS %s133// RUN: %clang --target=x86_64-sie-ps5 %s -nodefaultlibs -pthread -fjmc -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-SHARED-CRT,CHECK-NO-LIBS %s134// RUN: %clang --target=x86_64-sie-ps5 %s -nodefaultlibs -pthread -fjmc -static -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-STATIC-CRT,CHECK-NO-LIBS %s135 136// RUN: %clang --target=x86_64-sie-ps5 %s -nostdlib -pthread -fjmc -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-NO-CRT,CHECK-NO-LIBS %s137// RUN: %clang --target=x86_64-sie-ps5 %s -nostdlib -pthread -fjmc -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-NO-CRT,CHECK-NO-LIBS %s138// RUN: %clang --target=x86_64-sie-ps5 %s -nostdlib -pthread -fjmc -static -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-NO-CRT,CHECK-NO-LIBS %s139 140// RUN: %clang --target=x86_64-sie-ps5 %s -nolibc -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-MAIN-CRT,CHECK-NO-LIBC,CHECK-DYNAMIC-CORE-LIBS %s141// RUN: %clang --target=x86_64-sie-ps5 %s -nolibc -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-SHARED-CRT,CHECK-NO-LIBC,CHECK-DYNAMIC-CORE-LIBS %s142// RUN: %clang --target=x86_64-sie-ps5 %s -nolibc -static -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-STATIC-CRT,CHECK-STATIC-LIBCPP,CHECK-NO-LIBC,CHECK-STATIC-CORE-LIBS %s143 144// RUN: %clang --target=x86_64-sie-ps5 %s -nostdlib++ -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-MAIN-CRT,CHECK-NO-LIBCPP,CHECK-DYNAMIC-CORE-LIBS %s145// RUN: %clang --target=x86_64-sie-ps5 %s -nostdlib++ -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-SHARED-CRT,CHECK-NO-LIBCPP,CHECK-DYNAMIC-CORE-LIBS %s146// RUN: %clang --target=x86_64-sie-ps5 %s -nostdlib++ -static -### 2>&1 | FileCheck --check-prefixes=CHECK-LD,CHECK-STATIC-CRT,CHECK-NO-LIBCPP,CHECK-STATIC-LIBC,CHECK-STATIC-CORE-LIBS %s147 148// CHECK-LD: {{ld(\.exe)?}}"149// CHECK-MAIN-CRT-SAME: "-l:crt1.o" "-l:crti.o" "-l:crtbegin.o"150// CHECK-SHARED-CRT-SAME: "-l:crti.o" "-l:crtbeginS.o"151// CHECK-STATIC-CRT-SAME: "-l:crt1.o" "-l:crti.o" "-l:crtbeginT.o"152 153// CHECK-NO-LIBC-NOT: "-lc{{(_stub_weak)?}}"154// CHECK-NO-LIBCPP-NOT: "-l{{c_stub_weak|stdc\+\+}}"155 156// CHECK-DYNAMIC-LIBC-SAME: "-lc_stub_weak"157// CHECK-DYNAMIC-CORE-LIBS-SAME: "-lkernel_stub_weak"158// CHECK-STATIC-LIBCPP-SAME: "-lstdc++"159// CHECK-STATIC-LIBC-SAME: "-lm" "-lc"160// CHECK-STATIC-CORE-LIBS-SAME: "-lcompiler_rt" "-lkernel"161 162// CHECK-PTHREAD-SAME: "-lpthread"163 164// CHECK-MAIN-CRT-SAME: "-l:crtend.o" "-l:crtn.o"165// CHECK-SHARED-CRT-SAME: "-l:crtendS.o" "-l:crtn.o"166// CHECK-STATIC-CRT-SAME: "-l:crtend.o" "-l:crtn.o"167 168// CHECK-NO-CRT-NOT: "-l:crt169// CHECK-NO-LIBS-NOT: "-l{{[^"]*}}"170 171// Test the driver's control over the -fcrash-diagnostics-dir behavior with linker flags.172 173// RUN: %clang --target=x86_64-sie-ps5 -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG %s174// RUN: %clang --target=x86_64-sie-ps5 -flto -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG %s175 176// CHECK-DIAG: -plugin-opt=-crash-diagnostics-dir=mydumps177 178// Test the driver passes a sysroot to the linker. Without --sysroot, its value179// is sourced from the SDK environment variable.180 181// RUN: env SCE_PROSPERO_SDK_DIR=mysdk %clang --target=x64_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-SYSROOT %s182// RUN: env SCE_PROSPERO_SDK_DIR=other %clang --target=x64_64-sie-ps5 %s -### --sysroot=mysdk 2>&1 | FileCheck --check-prefixes=CHECK-SYSROOT %s183 184// CHECK-SYSROOT: {{ld(\.exe)?}}"185// CHECK-SYSROOT-SAME: "--sysroot=mysdk"186 187// Test implicit library search paths are supplied to the linker, after any188// search paths specified by the user. <sdk-root>/target/lib is implicitly189// added if it exists. CRT objects are found there if not on user search paths.190// "." is always implicitly added to library search paths. These are191// long-standing and entrenched behaviors, unique to PlayStation toolchains.192 193// RUN: rm -rf %t.dir && mkdir %t.dir194// RUN: env SCE_PROSPERO_SDK_DIR=%t.dir %clang --target=x64_64-sie-ps5 %s -### -Luser 2>&1 | FileCheck --check-prefixes=CHECK-NO-TARGETLIB %s195// RUN: %clang --target=x64_64-sie-ps5 %s -### -Luser --sysroot=%t.dir 2>&1 | FileCheck --check-prefixes=CHECK-NO-TARGETLIB %s196 197// CHECK-NO-TARGETLIB: {{ld(\.exe)?}}"198// CHECK-NO-TARGETLIB-SAME: "-Luser"199// CHECK-NO-TARGETLIB-NOT: "-L{{.*[/\\]}}target/lib"200// CHECK-NO-TARGETLIB-SAME: "-L."201 202// RUN: mkdir -p %t.dir/myroot/target/lib203// RUN: env SCE_PROSPERO_SDK_DIR=%t.dir/myroot %clang --target=x64_64-sie-ps5 %s -### -Luser 2>&1 | FileCheck --check-prefixes=CHECK-TARGETLIB %s204// RUN: %clang --target=x64_64-sie-ps5 %s -### -Luser --sysroot=%t.dir/myroot 2>&1 | FileCheck --check-prefixes=CHECK-TARGETLIB %s205 206// CHECK-TARGETLIB: {{ld(\.exe)?}}"207// CHECK-TARGETLIB-SAME: "-Luser"208// CHECK-TARGETLIB-SAME: "-L{{.*}}myroot{{/|\\\\}}target{{/|\\\\}}lib"209// CHECK-TARGETLIB-SAME: "-L."210