Skip to content

Commit 67c4345

Browse files
[PS5][Driver] Allow -T to override --default-script (llvm#116074)
If a linker script is explicitly supplied, there's no benefit to supplying a default script. SIE tracker: TOOLCHAIN-17524
1 parent 21f7c62 commit 67c4345

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,12 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
303303
// with the SDK. The scripts are inside <sdkroot>/target/lib, which is
304304
// added as a search path elsewhere.
305305
// "PRX" has long stood for "PlayStation Relocatable eXecutable".
306-
CmdArgs.push_back("--default-script");
307-
CmdArgs.push_back(Static ? "static.script"
308-
: Shared ? "prx.script"
309-
: "main.script");
306+
if (!Args.hasArgNoClaim(options::OPT_T)) {
307+
CmdArgs.push_back("--default-script");
308+
CmdArgs.push_back(Static ? "static.script"
309+
: Shared ? "prx.script"
310+
: "main.script");
311+
}
310312
}
311313

312314
if (Static)

clang/test/Driver/ps5-linker.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,24 @@
6767
// CHECK-NO-EXE-NOT: "--unresolved-symbols
6868
// CHECK-NO-EXE-NOT: "-z"
6969

70-
// Test that an appropriate linker script is supplied by the driver.
70+
// Test that an appropriate linker script is supplied by the driver, but can
71+
// be overridden with -T.
7172

7273
// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=main %s
7374
// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=prx %s
7475
// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=static %s
7576
// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-SCRIPT %s
77+
// 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}}\"" %s
7678

7779
// CHECK-SCRIPT: {{ld(\.exe)?}}"
7880
// CHECK-SCRIPT-SAME: "--default-script" "[[SCRIPT]].script"
7981

8082
// CHECK-NO-SCRIPT: {{ld(\.exe)?}}"
8183
// CHECK-NO-SCRIPT-NOT: "--default-script"
8284

85+
// CHECK-CUSTOM-SCRIPT: {{ld(\.exe)?}}"
86+
// CHECK-CUSTOM-SCRIPT-SAME: "-T" "custom.script"
87+
8388
// Test that -static is forwarded to the linker
8489

8590
// RUN: %clang --target=x86_64-sie-ps5 -static %s -### 2>&1 | FileCheck --check-prefixes=CHECK-STATIC %s

0 commit comments

Comments
 (0)