Skip to content

Conversation

@rosefromthedead
Copy link
Contributor

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

When clang is driving the linker and is passed -ffat-lto-objects,
pass it on to the linker as --fat-lto-objects.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Dec 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 18, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Rose Hudson (rosefromthedead)

Changes

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


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

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+4)
  • (modified) clang/test/Driver/ps5-linker.c (+13)
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: {{$}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants