Skip to content

Commit 6f8ea42

Browse files
committed
avoid duplication of -lpthreads in flang
1 parent e23c895 commit 6f8ea42

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

clang/lib/Driver/ToolChains/AIX.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
297297
}
298298

299299
// Add directory to library search path.
300+
bool hasFOpenMP = false;
300301
Args.AddAllArgs(CmdArgs, options::OPT_L);
301302
if (!Args.hasArg(options::OPT_r)) {
302303
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
@@ -309,9 +310,8 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
309310
AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
310311

311312
// Add OpenMP runtime if -fopenmp is specified.
312-
const bool hasFOpenMP =
313-
Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
314-
options::OPT_fno_openmp, false);
313+
hasFOpenMP = Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
314+
options::OPT_fno_openmp, false);
315315
if (hasFOpenMP) {
316316
switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
317317
case Driver::OMPRT_OMP:
@@ -355,7 +355,9 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
355355
ToolChain.addFortranRuntimeLibraryPath(Args, CmdArgs);
356356
ToolChain.addFortranRuntimeLibs(Args, CmdArgs);
357357
CmdArgs.push_back("-lm");
358-
CmdArgs.push_back("-lpthread");
358+
// If the -fopenmp option is specified, no need to add it again.
359+
if (!hasFOpenMP)
360+
CmdArgs.push_back("-lpthreads");
359361
}
360362
const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
361363
C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),

0 commit comments

Comments
 (0)