From bbc204b944eea829a029268fff37faabdf61fcaf Mon Sep 17 00:00:00 2001 From: Matthew Voss Date: Wed, 29 Mar 2023 09:36:46 -0700 Subject: [PATCH] [PS4][clang] Limit ThinLTO parallelism when requested Pass the correct option to the linker when "-flto-jobs=" is passed to the driver. --- clang/lib/Driver/ToolChains/PS4CPU.cpp | 6 ++++++ clang/test/Driver/lto-jobs.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index b3e1461..8c8b7c7 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -187,6 +187,12 @@ void tools::PScpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue()); } + 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", ""); diff --git a/clang/test/Driver/lto-jobs.c b/clang/test/Driver/lto-jobs.c index c28d0ad..443f8ab 100644 --- a/clang/test/Driver/lto-jobs.c +++ b/clang/test/Driver/lto-jobs.c @@ -3,6 +3,9 @@ // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto-jobs=5 2> %t // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s // +// RUN: %clang -target x86_64-sie-ps5 -### %s -flto=thin -flto-jobs=5 2> %t +// 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-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t -- 2.7.4