https://github.com/rosefromthedead created 
https://github.com/llvm/llvm-project/pull/172854

When clang is driving the linker and is passed -ffat-lto-objects, pass it on to 
the linker as --fat-lto-objects.

>From ade9172795a7c0620687b2104b29ac438ff89015 Mon Sep 17 00:00:00 2001
From: Rose Hudson <[email protected]>
Date: Mon, 8 Dec 2025 10:42:38 +0000
Subject: [PATCH] [PS5][Driver] forward -ffat-lto-objects to the linker

When clang is driving the linker and is passed -ffat-lto-objects,
pass it on to the linker as --fat-lto-objects.
---
 clang/lib/Driver/ToolChains/PS4CPU.cpp |  4 ++++
 clang/test/Driver/ps5-linker.c         | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 5b5b5607da69e..ac2671a8e8078 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -351,6 +351,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
     CmdArgs.push_back(D.getLTOMode() == LTOK_Thin ? "--lto=thin"
                                                   : "--lto=full");
 
+  if (Args.hasFlag(options::OPT_ffat_lto_objects,
+                   options::OPT_fno_fat_lto_objects, false))
+    CmdArgs.push_back("--fat-lto-objects");
+
   AddLTOFlag("-emit-jump-table-sizes-section");
 
   if (UseJMC)
diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c
index 16c9967bc2b41..6f37ca8958fc1 100644
--- a/clang/test/Driver/ps5-linker.c
+++ b/clang/test/Driver/ps5-linker.c
@@ -207,3 +207,16 @@
 // CHECK-TARGETLIB-SAME: "-Luser"
 // CHECK-TARGETLIB-SAME: "-L{{.*}}myroot{{/|\\\\}}target{{/|\\\\}}lib"
 // CHECK-TARGETLIB-SAME: "-L."
+
+// Test that -ffat-lto-objects is forwarded to the linker.
+
+// RUN: %clang --target=x86_64-sie-ps5 -flto=full -ffat-lto-objects %s -### 
2>&1 | FileCheck --check-prefixes=CHECK-FAT-LTO %s
+// RUN: %clang --target=x86_64-sie-ps5 -flto=full -funified-lto 
-ffat-lto-objects %s -### 2>&1 | FileCheck --check-prefixes=CHECK-FAT-LTO %s
+// RUN: %clang --target=x86_64-sie-ps5 -flto=full %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NO-FAT-LTO %s
+// RUN: %clang --target=x86_64-sie-ps5 -flto=full -funified-lto %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-NO-FAT-LTO %s
+
+// CHECK-FAT-LTO: {{ld(\.exe)?}}"
+// CHECK-FAT-LTO-SAME: "--fat-lto-objects"
+// CHECK-NO-FAT-LTO: {{ld(\.exe)?}}"
+// CHECK-NO-FAT-LTO-NOT: "--fat-lto-objects"
+// CHECK-NO-FAT-LTO-SAME: {{$}}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to