https://github.com/playstation-edd created https://github.com/llvm/llvm-project/pull/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 >From 8283f20d279aa94ddcf338066d9553b15cb40725 Mon Sep 17 00:00:00 2001 From: Edd Dawson <edd.daw...@sony.com> Date: Tue, 21 Jan 2025 13:32:50 +0000 Subject: [PATCH] [PS5][Driver] Don't link with --build-id when -static 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 --- clang/lib/Driver/ToolChains/PS4CPU.cpp | 5 ++++- clang/test/Driver/ps5-linker.c | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) 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. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits