[clang] [PS4][Driver] Only pass -lto-debug-options to linker when necessary (PR #101202)
Edd Dawson via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 30 09:32:46 PDT 2024
https://github.com/playstation-edd created https://github.com/llvm/llvm-project/pull/101202
The PS4 linker doesn't accept an empty LTO options string. Passing nothing is also consistent with other drivers.
SIE tracker: TOOLCHAIN-16575
>From 4ee96bd211de1c1499c1860988af1f8369e20d93 Mon Sep 17 00:00:00 2001
From: Edd Dawson <edd.dawson at sony.com>
Date: Tue, 30 Jul 2024 17:22:42 +0100
Subject: [PATCH] [PS4][Driver] Only pass -lto-debug-options to linker when
necessary
The PS4 linker doesn't accept an empty LTO options string. Passing
nothing is also consistent with other drivers.
SIE tracker: TOOLCHAIN-16575
---
clang/lib/Driver/ToolChains/PS4CPU.cpp | 4 +++-
clang/test/Driver/ps4-linker.c | 5 +++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index f883f29f0c8ca..a9e612c44da06 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -177,7 +177,9 @@ void tools::PS4cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (StringRef Threads = getLTOParallelism(Args, D); !Threads.empty())
AddLTOFlag(Twine("-threads=") + Threads);
- CmdArgs.push_back(Args.MakeArgString(Twine("-lto-debug-options=") + LTOArgs));
+ if (*LTOArgs)
+ CmdArgs.push_back(
+ Args.MakeArgString(Twine("-lto-debug-options=") + LTOArgs));
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
diff --git a/clang/test/Driver/ps4-linker.c b/clang/test/Driver/ps4-linker.c
index 449da3040e758..2a095d660bf36 100644
--- a/clang/test/Driver/ps4-linker.c
+++ b/clang/test/Driver/ps4-linker.c
@@ -16,3 +16,8 @@
// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-LTO %s
// CHECK-DIAG-LTO: "-lto-debug-options= -crash-diagnostics-dir=mydumps"
+
+// Test that -lto-debug-options is only supplied to the linker when necessary
+
+// RUN: %clang --target=x86_64-scei-ps4 %s -### 2>&1 | FileCheck --check-prefixes=CHECK-NO-LTO %s
+// CHECK-NO-LTO-NOT: -lto-debug-options
More information about the cfe-commits
mailing list