[clang] c37b95b - [PS4][clang] Fix the format of the LTO debug options passed to orbis-ld

Matthew Voss via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 5 13:00:16 PDT 2023


Author: Matthew Voss
Date: 2023-04-05T12:57:21-07:00
New Revision: c37b95b515a5c69b2050c8fd50f076368742c6cb

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

LOG: [PS4][clang] Fix the format of the LTO debug options passed to orbis-ld

Currently, we pass multiple LTO debug options to orbis-ld like this:

orbis-ld --lto=thin --lto-thin-debug-options=<arg1> --lto-thin-debug-options=<arg2> ...

When it should be like this:

orbis-ld --lto=thin "--lto-thin-debug-options= <arg1> <arg2>" ...

Differential Revision: https://reviews.llvm.org/D147546

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 8c8b7c73c1bf5..71c6b650e1f52 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -160,18 +160,12 @@ void tools::PScpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   const bool IsPS5 = TC.getTriple().isPS5();
   assert(IsPS4 || IsPS5);
 
+  const char *PS4LTOArgs = "";
   auto AddCodeGenFlag = [&](Twine Flag) {
-    const char *Prefix = nullptr;
-    if (IsPS4 && D.getLTOMode() == LTOK_Thin)
-      Prefix = "-lto-thin-debug-options=";
-    else if (IsPS4 && D.getLTOMode() == LTOK_Full)
-      Prefix = "-lto-debug-options=";
+    if (IsPS4)
+      PS4LTOArgs = Args.MakeArgString(Twine(PS4LTOArgs) + " " + Flag);
     else if (IsPS5)
-      Prefix = "-plugin-opt=";
-    else
-      llvm_unreachable("new LTO mode?");
-
-    CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + Flag));
+      CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + Flag));
   };
 
   if (UseLTO) {
@@ -185,6 +179,18 @@ void tools::PScpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
     if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
       AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
+
+    if (IsPS4) {
+      const char *Prefix = nullptr;
+      if (D.getLTOMode() == LTOK_Thin)
+        Prefix = "-lto-thin-debug-options=";
+      else if (D.getLTOMode() == LTOK_Full)
+        Prefix = "-lto-debug-options=";
+      else
+        llvm_unreachable("new LTO mode?");
+
+      CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + PS4LTOArgs));
+    }
   }
 
   if (IsPS5 && UseLTO) {

diff  --git a/clang/test/Driver/ps4-ps5-linker.c b/clang/test/Driver/ps4-ps5-linker.c
index ee8e96bbfbd02..8aae94c838834 100644
--- a/clang/test/Driver/ps4-ps5-linker.c
+++ b/clang/test/Driver/ps4-ps5-linker.c
@@ -7,8 +7,8 @@
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
 
 // CHECK-PS4-NOT: -enable-jmc-instrument
-// CHECK-PS4-THIN-LTO: -lto-thin-debug-options=-enable-jmc-instrument
-// CHECK-PS4-FULL-LTO: -lto-debug-options=-enable-jmc-instrument
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section -enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section -enable-jmc-instrument"
 // CHECK-PS5-NOT: -plugin-opt=-enable-jmc-instrument
 // CHECK-PS5-LTO: -plugin-opt=-enable-jmc-instrument
 
@@ -23,7 +23,7 @@
 // RUN: %clang --target=x86_64-scei-ps5 -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5 %s
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5-LTO %s
 
-// CHECK-DIAG-PS4-THIN-LTO: -lto-thin-debug-options=-crash-diagnostics-dir=mydumps
-// CHECK-DIAG-PS4-FULL-LTO: -lto-debug-options=-crash-diagnostics-dir=mydumps
+// CHECK-DIAG-PS4-THIN-LTO: "-lto-thin-debug-options= -generate-arange-section -crash-diagnostics-dir=mydumps"
+// CHECK-DIAG-PS4-FULL-LTO: "-lto-debug-options= -generate-arange-section -crash-diagnostics-dir=mydumps"
 // CHECK-DIAG-PS5-NOT: -plugin-opt=-crash-diagnostics-dir=mydumps
 // CHECK-DIAG-PS5-LTO: -plugin-opt=-crash-diagnostics-dir=mydumps


        


More information about the cfe-commits mailing list