[clang] 1df50e6 - [PS5][Driver] Don't link with --build-id when -static (#123930)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 22 06:57:55 PST 2025


Author: Edd Dawson
Date: 2025-01-22T14:57:52Z
New Revision: 1df50e6245cbc04f3b28de3c40127ad61d46b43b

URL: https://github.com/llvm/llvm-project/commit/1df50e6245cbc04f3b28de3c40127ad61d46b43b
DIFF: https://github.com/llvm/llvm-project/commit/1df50e6245cbc04f3b28de3c40127ad61d46b43b.diff

LOG: [PS5][Driver] Don't link with --build-id when -static (#123930)

Users of the PlayStation SDK aren't given the means to create or run
static executables. Uses of `-static` are limited a few specialized
cases within SIE. A `--build-id` isn't wanted in those cases.

SIE tracker: TOOLCHAIN-16704

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/PS4CPU.cpp
    clang/test/Driver/ps5-linker.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index e1187ce48c3e4c..4f9755db238d99 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -262,7 +262,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     // 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");
+    // Static executables are only used for a handful of specialized components,
+    // where the extra section is not wanted.
+    if (!Static)
+      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

diff  --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 9dd35c40619b68..777826aade7ff2 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -49,7 +49,6 @@
 // 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"
@@ -63,10 +62,23 @@
 // 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 --build-id is supplied to the linker for non-static executables
+// and -shared.
+
+// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BUILD-ID %s
+// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BUILD-ID %s
+
+// CHECK-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-BUILD-ID-SAME: "--build-id=uuid"
+
+// CHECK-NO-BUILD-ID: {{ld(\.exe)?}}"
+// CHECK-NO-BUILD-ID-NOT: "--build-id
+
 // Test that an appropriate linker script is supplied by the driver, but can
 // be overridden with -T.
 


        


More information about the cfe-commits mailing list