[PS4][clang] Pass -flto-jobs argument to orbis-ld
authorMatthew Voss <matthew.voss@sony.com>
Tue, 11 Apr 2023 17:13:58 +0000 (10:13 -0700)
committerMatthew Voss <matthew.voss@sony.com>
Tue, 11 Apr 2023 17:33:16 +0000 (10:33 -0700)
Pass -flto-jobs to orbis-ld correctly.

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

clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/lto-jobs.c

index 71c6b65..b280abb 100644 (file)
@@ -180,6 +180,14 @@ 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());
 
+    StringRef Parallelism = getLTOParallelism(Args, D);
+    if (!Parallelism.empty()) {
+      if (IsPS4)
+        AddCodeGenFlag(Twine("-threads=") + Parallelism);
+      else
+        CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + Parallelism));
+    }
+
     if (IsPS4) {
       const char *Prefix = nullptr;
       if (D.getLTOMode() == LTOK_Thin)
@@ -193,12 +201,6 @@ void tools::PScpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     }
   }
 
-  if (IsPS5 && UseLTO) {
-    StringRef Parallelism = getLTOParallelism(Args, D);
-    if (!Parallelism.empty())
-      CmdArgs.push_back(Args.MakeArgString("-plugin-opt=jobs=" + Parallelism));
-  }
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
     TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 
index 443f8ab..5402442 100644 (file)
@@ -7,6 +7,11 @@
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s
 //
 // CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5"
+//
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin -flto-jobs=5 2> %t
+// RUN: FileCheck -check-prefix=CHECK-PS4-LINK-THIN-JOBS-ACTION < %t %s
+//
+// CHECK-PS4-LINK-THIN-JOBS-ACTION: "-lto-thin-debug-options= -generate-arange-section -threads=5"
 
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s