Skip to content

Commit 1df50e6

Browse files
[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
1 parent 4f40b07 commit 1df50e6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
262262
// index the symbols. `uuid` is the cheapest fool-proof method.
263263
// (The non-determinism and alternative methods are noted in the downstream
264264
// PlayStation docs).
265-
CmdArgs.push_back("--build-id=uuid");
265+
// Static executables are only used for a handful of specialized components,
266+
// where the extra section is not wanted.
267+
if (!Static)
268+
CmdArgs.push_back("--build-id=uuid");
266269

267270
// All references are expected to be resolved at static link time for both
268271
// executables and dynamic libraries. This has been the default linking

clang/test/Driver/ps5-linker.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
// CHECK-EXE: {{ld(\.exe)?}}"
5050
// CHECK-EXE-SAME: "--eh-frame-hdr"
5151
// CHECK-EXE-SAME: "--hash-style=sysv"
52-
// CHECK-EXE-SAME: "--build-id=uuid"
5352
// CHECK-EXE-SAME: "--unresolved-symbols=report-all"
5453
// CHECK-EXE-SAME: "-z" "now"
5554
// CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden"
@@ -63,10 +62,23 @@
6362
// CHECK-NO-EXE: {{ld(\.exe)?}}"
6463
// CHECK-NO-EXE-NOT: "--eh-frame-hdr"
6564
// CHECK-NO-EXE-NOT: "--hash-style
66-
// CHECK-NO-EXE-NOT: "--build-id
6765
// CHECK-NO-EXE-NOT: "--unresolved-symbols
6866
// CHECK-NO-EXE-NOT: "-z"
6967

68+
// Test that --build-id is supplied to the linker for non-static executables
69+
// and -shared.
70+
71+
// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-BUILD-ID %s
72+
// RUN: %clang --target=x86_64-sie-ps5 %s -shared -### 2>&1 | FileCheck --check-prefixes=CHECK-BUILD-ID %s
73+
// RUN: %clang --target=x86_64-sie-ps5 %s -static -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BUILD-ID %s
74+
// RUN: %clang --target=x86_64-sie-ps5 %s -r -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-BUILD-ID %s
75+
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-id
81+
7082
// Test that an appropriate linker script is supplied by the driver, but can
7183
// be overridden with -T.
7284

0 commit comments

Comments
 (0)