Skip to content

Commit

Permalink
[clang][AIX]Fix -flto-jobs for AIX. (#67853)
Browse files Browse the repository at this point in the history
Currently using the `-flto-jobs=N` option passes `-bplugin_opt:jobs=N`
to the AIX linker which is not a valid option. This PR seeks to change
this behaviour to instead pass `-bplugin_opt:-threads=N` to control the
level of concurrency during LTO builds.
  • Loading branch information
Dhanrajbir-Hira committed Oct 3, 2023
1 parent 7006b90 commit 0bb4b24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,

const char *PluginOptPrefix = IsOSAIX ? "-bplugin_opt:" : "-plugin-opt=";
const char *ExtraDash = IsOSAIX ? "-" : "";
const char *ParallelismOpt = IsOSAIX ? "-threads=" : "jobs=";

// Note, this solution is far from perfect, better to encode it into IR
// metadata, but this may not be worth it, since it looks like aranges is on
Expand Down Expand Up @@ -690,8 +691,8 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,

StringRef Parallelism = getLTOParallelism(Args, D);
if (!Parallelism.empty())
CmdArgs.push_back(
Args.MakeArgString(Twine(PluginOptPrefix) + "jobs=" + Parallelism));
CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) +
ParallelismOpt + Parallelism));

// If an explicit debugger tuning argument appeared, pass it along.
if (Arg *A =
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Driver/lto-jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@
// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s
//
// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads={{[0-9]+}}"

// RUN: %clang --target=powerpc-ibm-aix -### %s -flto=thin -flto-jobs=5 2> %t
// RUN: FileCheck -check-prefix=CHECK-AIX-LINK-THIN-JOBS-ACTION < %t %s
//
// CHECK-AIX-LINK-THIN-JOBS-ACTION: "-bplugin_opt:-threads=5"

0 comments on commit 0bb4b24

Please sign in to comment.