Skip to content

Commit

Permalink
[AIX] Consolidate Crt0Basename logic
Browse files Browse the repository at this point in the history
when certain flags are specified, the Crt0 object files are not linked.
However, the logic for determining which files will always run. This
patch moves that logic so that the basename is only determined if it is
needed.

Differential Revision: https://reviews.llvm.org/D146443
  • Loading branch information
KappaMikey1337 committed Mar 21, 2023
1 parent c0f3a3d commit 4c483a0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions clang/lib/Driver/ToolChains/AIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,19 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-bpD:0x110000000");
}

auto getCrt0Basename = [&Args, IsArch32Bit] {
if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
// Enable gprofiling when "-pg" is specified.
if (A->getOption().matches(options::OPT_pg))
return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
// Enable profiling when "-p" is specified.
return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
}
return IsArch32Bit ? "crt0.o" : "crt0_64.o";
};

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_shared, options::OPT_r)) {
auto getCrt0Basename = [&Args, IsArch32Bit] {
if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
// Enable gprofiling when "-pg" is specified.
if (A->getOption().matches(options::OPT_pg))
return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
// Enable profiling when "-p" is specified.
return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
}
return IsArch32Bit ? "crt0.o" : "crt0_64.o";
};

CmdArgs.push_back(
Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename())));

Expand Down

0 comments on commit 4c483a0

Please sign in to comment.