[clang] c69ed8a - [PS4][Driver] Only pass -lto-debug-options to linker when necessary (#101202)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 30 15:54:29 PDT 2024


Author: Edd Dawson
Date: 2024-07-30T23:54:25+01:00
New Revision: c69ed8a3122569a65cd54d8e0d5ef9431f160245

URL: https://github.com/llvm/llvm-project/commit/c69ed8a3122569a65cd54d8e0d5ef9431f160245
DIFF: https://github.com/llvm/llvm-project/commit/c69ed8a3122569a65cd54d8e0d5ef9431f160245.diff

LOG: [PS4][Driver] Only pass -lto-debug-options to linker when necessary (#101202)

The PS4 linker doesn't accept an empty LTO options string. Passing
nothing is also consistent with other drivers.

SIE tracker: TOOLCHAIN-16575

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/PS4CPU.cpp
    clang/test/Driver/ps4-linker.c

Removed: 
    


################################################################################
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