-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[PS5][Driver] Allow -T
to override --default-script
#116074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PS5][Driver] Allow -T
to override --default-script
#116074
Conversation
If a linker script is supplied, there's no benefit to supplying a default script. SIE tracker: TOOLCHAIN-17524
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Edd Dawson (playstation-edd) ChangesIf a linker script is explicitly supplied, there's no benefit to supplying a default script. SIE tracker: TOOLCHAIN-17524 Full diff: https://github.com/llvm/llvm-project/pull/116074.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index df43da93d77555..03445375796533 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -303,10 +303,12 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
// with the SDK. The scripts are inside <sdkroot>/target/lib, which is
// added as a search path elsewhere.
// "PRX" has long stood for "PlayStation Relocatable eXecutable".
- CmdArgs.push_back("--default-script");
- CmdArgs.push_back(Static ? "static.script"
- : Shared ? "prx.script"
- : "main.script");
+ if (!Args.hasArgNoClaim(options::OPT_T)) {
+ CmdArgs.push_back("--default-script");
+ CmdArgs.push_back(Static ? "static.script"
+ : Shared ? "prx.script"
+ : "main.script");
+ }
}
if (Static)
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 95267942edc172..216b11a8c52d71 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -67,12 +67,14 @@
// CHECK-NO-EXE-NOT: "--unresolved-symbols
// CHECK-NO-EXE-NOT: "-z"
-// Test that an appropriate linker script is supplied by the driver.
+// Test that an appropriate linker script is supplied by the driver, but can
+// be overridden with -T.
// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=main %s
// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=prx %s
// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-SCRIPT -DSCRIPT=static %s
// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-SCRIPT %s
+// 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
// CHECK-SCRIPT: {{ld(\.exe)?}}"
// CHECK-SCRIPT-SAME: "--default-script" "[[SCRIPT]].script"
@@ -80,6 +82,9 @@
// CHECK-NO-SCRIPT: {{ld(\.exe)?}}"
// CHECK-NO-SCRIPT-NOT: "--default-script"
+// CHECK-CUSTOM-SCRIPT: {{ld(\.exe)?}}"
+// CHECK-CUSTOM-SCRIPT-SAME: "-T" "custom.script"
+
// Test that -static is forwarded to the linker
// RUN: %clang --target=x86_64-sie-ps5 -static %s -### 2>&1 | FileCheck --check-prefixes=CHECK-STATIC %s
|
@@ -67,19 +67,24 @@ | |||
// CHECK-NO-EXE-NOT: "--unresolved-symbols | |||
// CHECK-NO-EXE-NOT: "-z" | |||
|
|||
// Test that an appropriate linker script is supplied by the driver. | |||
// Test that an appropriate linker script is supplied by the driver, but can | |||
// be overridden with -T. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: -T/--script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no --script
on clang
. I may not understand your comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you haven't. I just assumed that there was, apologies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I would have preferred a simpler way of checking that there are no other occurrences of -T/--script/--default-script but couldn't think of anything.
I didn't notice that this was an upstream review initially. It would be worth waiting for approval from Jeremy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If a linker script is explicitly supplied, there's no benefit to supplying a default script.
SIE tracker: TOOLCHAIN-17524