-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[PS5][Driver] Update default linking options when -r
omitted.
#113595
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] Update default linking options when -r
omitted.
#113595
Conversation
@llvm/pr-subscribers-clang-driver Author: Edd Dawson (playstation-edd) ChangesUntil now, these options have been hardcoded as downstream patches in lld. Add them to the driver so that the private patches can be removed. PS5 only. On PS4, the proprietary linker will continue to perform the equivalent behaviours itself. SIE tracker: TOOLCHAIN-16704 Full diff: https://github.com/llvm/llvm-project/pull/113595.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index a50333223ff5c4..719bba41436a57 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -250,6 +250,20 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-pie");
if (!Relocatable) {
+ CmdArgs.push_back("--eh-frame-hdr");
+ CmdArgs.push_back("--hash-style=sysv");
+
+ // Add a build-id by default to allow the PlayStation symbol server to
+ // index the symbols. `uuid` is the cheapest fool-proof method.
+ // (The non-determinism and alternative methods are noted in the downstream
+ // PlayStation docs).
+ CmdArgs.push_back("--build-id=uuid");
+
+ // All references are expected to be resolved at static link time for both
+ // executables and dynamic libraries. This has been the default linking
+ // behaviour for numerous PlayStation generations.
+ CmdArgs.push_back("--unresolved-symbols=report-all");
+
// Lazy binding of PLTs is not supported on PlayStation. They are placed in
// the RelRo segment.
CmdArgs.push_back("-z");
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index d18309a650726d..2080f4dc91a7fb 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -14,21 +14,32 @@
// CHECK-NO-PIE-NOT: "-pie"
// CHECK-SHARED: "--shared"
-// Test the driver passes PlayStation-specific -z options to the linker.
-
-// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-Z %s
-
-// CHECK-Z: {{ld(\.exe)?}}"
-// CHECK-Z-SAME: "-z" "now"
-// CHECK-Z-SAME: "-z" "start-stop-visibility=hidden"
-// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0xffffffffffffffff"
-// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe"
-// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe"
-
-// RUN: %clang --target=x86_64-sie-ps5 -r %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-Z %s
-
-// CHECK-NO-Z: {{ld(\.exe)?}}"
-// CHECK-NO-Z-NOT: "-z"
+// Test the driver passes PlayStation-specific options to the linker that are
+// appropriate for the type of output. Many options don't apply for relocatable
+// output (-r).
+
+// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-EXE %s
+
+// CHECK-EXE: {{ld(\.exe)?}}"
+// CHECK-EXE-SAME: "--eh-frame-hdr"
+// CHECK-EXE-SAME: "--hash-style=sysv"
+// CHECK-EXE-SAME: "--build-id=uuid"
+// CHECK-EXE-SAME: "--unresolved-symbols=report-all"
+// CHECK-EXE-SAME: "-z" "now"
+// CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"
+// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0xffffffffffffffff"
+// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe"
+// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe"
+
+// CHECK-NO-EXE: {{ld(\.exe)?}}"
+// CHECK-NO-EXE-NOT: "--eh-frame-hdr"
+// CHECK-NO-EXE-NOT: "--hash-style
+// CHECK-NO-EXE-NOT: "--build-id
+// CHECK-NO-EXE-NOT: "--unresolved-symbols
+// CHECK-NO-EXE-NOT: "-z"
// Test that -static is forwarded to the linker
|
@llvm/pr-subscribers-clang Author: Edd Dawson (playstation-edd) ChangesUntil now, these options have been hardcoded as downstream patches in lld. Add them to the driver so that the private patches can be removed. PS5 only. On PS4, the proprietary linker will continue to perform the equivalent behaviours itself. SIE tracker: TOOLCHAIN-16704 Full diff: https://github.com/llvm/llvm-project/pull/113595.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index a50333223ff5c4..719bba41436a57 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -250,6 +250,20 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-pie");
if (!Relocatable) {
+ CmdArgs.push_back("--eh-frame-hdr");
+ CmdArgs.push_back("--hash-style=sysv");
+
+ // Add a build-id by default to allow the PlayStation symbol server to
+ // index the symbols. `uuid` is the cheapest fool-proof method.
+ // (The non-determinism and alternative methods are noted in the downstream
+ // PlayStation docs).
+ CmdArgs.push_back("--build-id=uuid");
+
+ // All references are expected to be resolved at static link time for both
+ // executables and dynamic libraries. This has been the default linking
+ // behaviour for numerous PlayStation generations.
+ CmdArgs.push_back("--unresolved-symbols=report-all");
+
// Lazy binding of PLTs is not supported on PlayStation. They are placed in
// the RelRo segment.
CmdArgs.push_back("-z");
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index d18309a650726d..2080f4dc91a7fb 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -14,21 +14,32 @@
// CHECK-NO-PIE-NOT: "-pie"
// CHECK-SHARED: "--shared"
-// Test the driver passes PlayStation-specific -z options to the linker.
-
-// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-Z %s
-
-// CHECK-Z: {{ld(\.exe)?}}"
-// CHECK-Z-SAME: "-z" "now"
-// CHECK-Z-SAME: "-z" "start-stop-visibility=hidden"
-// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0xffffffffffffffff"
-// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe"
-// CHECK-Z-SAME: "-z" "dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe"
-
-// RUN: %clang --target=x86_64-sie-ps5 -r %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-Z %s
-
-// CHECK-NO-Z: {{ld(\.exe)?}}"
-// CHECK-NO-Z-NOT: "-z"
+// Test the driver passes PlayStation-specific options to the linker that are
+// appropriate for the type of output. Many options don't apply for relocatable
+// output (-r).
+
+// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-EXE %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-EXE %s
+
+// CHECK-EXE: {{ld(\.exe)?}}"
+// CHECK-EXE-SAME: "--eh-frame-hdr"
+// CHECK-EXE-SAME: "--hash-style=sysv"
+// CHECK-EXE-SAME: "--build-id=uuid"
+// CHECK-EXE-SAME: "--unresolved-symbols=report-all"
+// CHECK-EXE-SAME: "-z" "now"
+// CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"
+// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0xffffffffffffffff"
+// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_ranges=0xfffffffffffffffe"
+// CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_loc=0xfffffffffffffffe"
+
+// CHECK-NO-EXE: {{ld(\.exe)?}}"
+// CHECK-NO-EXE-NOT: "--eh-frame-hdr"
+// CHECK-NO-EXE-NOT: "--hash-style
+// CHECK-NO-EXE-NOT: "--build-id
+// CHECK-NO-EXE-NOT: "--unresolved-symbols
+// CHECK-NO-EXE-NOT: "-z"
// Test that -static is forwarded to the linker
|
Until now, these options have been hardcoded as downstream patches in lld. Add them to the driver so that the private patches can be removed. PS5 only. On PS4, the proprietary linker will continue to perform the equivalent behaviours itself. SIE tracker: TOOLCHAIN-16704
59d1ec4
to
5c5a6f8
Compare
-r
-r
omitted.
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
…#113595) Until now, these options have been hardcoded as downstream patches in lld. Add them to the driver so that the private patches can be removed. PS5 only. On PS4, the proprietary linker will continue to perform the equivalent behaviours itself. SIE tracker: TOOLCHAIN-16704
Until now, these options have been hardcoded as downstream patches in lld. Add them to the driver so that the private patches can be removed.
PS5 only. On PS4, the proprietary linker will continue to perform the equivalent behaviours itself.
SIE tracker: TOOLCHAIN-16704