[clang] [PS5][Driver] Pass a target emulation to the linker (PR #114060)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 29 07:18:38 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Edd Dawson (playstation-edd)

<details>
<summary>Changes</summary>

Until now, this has been hardcoded as a downstream patch in lld. Add it to the driver so that the private patch can be removed.

PS5 only. On PS4, the equivalent hardcoded configuration will remain in the proprietary linker.

SIE tracker: TOOLCHAIN-16704

---
Full diff: https://github.com/llvm/llvm-project/pull/114060.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+3) 
- (modified) clang/test/Driver/ps5-linker.c (+7) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 9daafbe703f68e..aaba95951c5060 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -241,6 +241,9 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   // handled somewhere else.
   Args.ClaimAllArgs(options::OPT_w);
 
+  CmdArgs.push_back("-m");
+  CmdArgs.push_back("elf_x86_64_fbsd");
+
   CmdArgs.push_back(
       Args.MakeArgString("--sysroot=" + TC.getSDKLibraryRootDir()));
 
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 2080f4dc91a7fb..5175d8dbca567a 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -1,3 +1,10 @@
+// Test that a target emulation is supplied to the linker
+
+// RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-EMU %s
+
+// CHECK-EMU: {{ld(\.exe)?}}"
+// CHECK-EMU-SAME: "-m" "elf_x86_64_fbsd"
+
 // Test that PIE is the default for main components
 
 // RUN: %clang --target=x86_64-sie-ps5 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PIE %s

``````````

</details>


https://github.com/llvm/llvm-project/pull/114060


More information about the cfe-commits mailing list