Skip to content

Commit 9a6e2f3

Browse files
author
git apple-llvm automerger
committed
Merge commit '699d47472c3f' from llvm.org/main into apple/main
2 parents d320d8a + 699d474 commit 9a6e2f3

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

clang/lib/Driver/ToolChains/FreeBSD.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
293293
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
294294
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
295295

296+
bool Profiling = Args.hasArg(options::OPT_pg) &&
297+
ToolChain.getTriple().getOSMajorVersion() < 14;
296298
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
297299
// Use the static OpenMP runtime with -static-openmp
298300
bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
@@ -302,7 +304,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
302304
if (D.CCCIsCXX()) {
303305
if (ToolChain.ShouldLinkCXXStdlib(Args))
304306
ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
305-
if (Args.hasArg(options::OPT_pg))
307+
if (Profiling)
306308
CmdArgs.push_back("-lm_p");
307309
else
308310
CmdArgs.push_back("-lm");
@@ -313,13 +315,13 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
313315
linkXRayRuntimeDeps(ToolChain, CmdArgs);
314316
// FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
315317
// the default system libraries. Just mimic this for now.
316-
if (Args.hasArg(options::OPT_pg))
318+
if (Profiling)
317319
CmdArgs.push_back("-lgcc_p");
318320
else
319321
CmdArgs.push_back("-lgcc");
320322
if (Args.hasArg(options::OPT_static)) {
321323
CmdArgs.push_back("-lgcc_eh");
322-
} else if (Args.hasArg(options::OPT_pg)) {
324+
} else if (Profiling) {
323325
CmdArgs.push_back("-lgcc_eh_p");
324326
} else {
325327
CmdArgs.push_back("--as-needed");
@@ -328,13 +330,13 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
328330
}
329331

330332
if (Args.hasArg(options::OPT_pthread)) {
331-
if (Args.hasArg(options::OPT_pg))
333+
if (Profiling)
332334
CmdArgs.push_back("-lpthread_p");
333335
else
334336
CmdArgs.push_back("-lpthread");
335337
}
336338

337-
if (Args.hasArg(options::OPT_pg)) {
339+
if (Profiling) {
338340
if (Args.hasArg(options::OPT_shared))
339341
CmdArgs.push_back("-lc");
340342
else
@@ -347,7 +349,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
347349

348350
if (Args.hasArg(options::OPT_static)) {
349351
CmdArgs.push_back("-lgcc_eh");
350-
} else if (Args.hasArg(options::OPT_pg)) {
352+
} else if (Profiling) {
351353
CmdArgs.push_back("-lgcc_eh_p");
352354
} else {
353355
CmdArgs.push_back("--as-needed");
@@ -416,7 +418,8 @@ void FreeBSD::addLibStdCxxIncludePaths(
416418
void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
417419
ArgStringList &CmdArgs) const {
418420
CXXStdlibType Type = GetCXXStdlibType(Args);
419-
bool Profiling = Args.hasArg(options::OPT_pg);
421+
bool Profiling =
422+
Args.hasArg(options::OPT_pg) && getTriple().getOSMajorVersion() < 14;
420423

421424
switch (Type) {
422425
case ToolChain::CST_Libcxx:

clang/test/Driver/freebsd.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
// CHECK-TEN: "-lc++" "-lm"
66
// CHECK-NINE: "-lstdc++" "-lm"
77

8+
// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd40.0 -stdlib=platform 2>&1 \
9+
// RUN: | FileCheck --check-prefix=CHECK-PG-FOURTEEN %s
810
// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 -stdlib=platform 2>&1 \
911
// RUN: | FileCheck --check-prefix=CHECK-PG-TEN %s
1012
// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \
1113
// RUN: | FileCheck --check-prefix=CHECK-PG-NINE %s
14+
// CHECK-PG-FOURTEEN: "-lc++" "-lm"
1215
// CHECK-PG-TEN: "-lc++_p" "-lm_p"
1316
// CHECK-PG-NINE: "-lstdc++_p" "-lm_p"

0 commit comments

Comments
 (0)