@@ -293,6 +293,8 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
293
293
addLinkerCompressDebugSectionsOption (ToolChain, Args, CmdArgs);
294
294
AddLinkerInputs (ToolChain, Inputs, Args, CmdArgs, JA);
295
295
296
+ bool Profiling = Args.hasArg (options::OPT_pg) &&
297
+ ToolChain.getTriple ().getOSMajorVersion () < 14 ;
296
298
if (!Args.hasArg (options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
297
299
// Use the static OpenMP runtime with -static-openmp
298
300
bool StaticOpenMP = Args.hasArg (options::OPT_static_openmp) &&
@@ -302,7 +304,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
302
304
if (D.CCCIsCXX ()) {
303
305
if (ToolChain.ShouldLinkCXXStdlib (Args))
304
306
ToolChain.AddCXXStdlibLibArgs (Args, CmdArgs);
305
- if (Args. hasArg (options::OPT_pg) )
307
+ if (Profiling )
306
308
CmdArgs.push_back (" -lm_p" );
307
309
else
308
310
CmdArgs.push_back (" -lm" );
@@ -313,13 +315,13 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
313
315
linkXRayRuntimeDeps (ToolChain, CmdArgs);
314
316
// FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
315
317
// the default system libraries. Just mimic this for now.
316
- if (Args. hasArg (options::OPT_pg) )
318
+ if (Profiling )
317
319
CmdArgs.push_back (" -lgcc_p" );
318
320
else
319
321
CmdArgs.push_back (" -lgcc" );
320
322
if (Args.hasArg (options::OPT_static)) {
321
323
CmdArgs.push_back (" -lgcc_eh" );
322
- } else if (Args. hasArg (options::OPT_pg) ) {
324
+ } else if (Profiling ) {
323
325
CmdArgs.push_back (" -lgcc_eh_p" );
324
326
} else {
325
327
CmdArgs.push_back (" --as-needed" );
@@ -328,13 +330,13 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
328
330
}
329
331
330
332
if (Args.hasArg (options::OPT_pthread)) {
331
- if (Args. hasArg (options::OPT_pg) )
333
+ if (Profiling )
332
334
CmdArgs.push_back (" -lpthread_p" );
333
335
else
334
336
CmdArgs.push_back (" -lpthread" );
335
337
}
336
338
337
- if (Args. hasArg (options::OPT_pg) ) {
339
+ if (Profiling ) {
338
340
if (Args.hasArg (options::OPT_shared))
339
341
CmdArgs.push_back (" -lc" );
340
342
else
@@ -347,7 +349,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
347
349
348
350
if (Args.hasArg (options::OPT_static)) {
349
351
CmdArgs.push_back (" -lgcc_eh" );
350
- } else if (Args. hasArg (options::OPT_pg) ) {
352
+ } else if (Profiling ) {
351
353
CmdArgs.push_back (" -lgcc_eh_p" );
352
354
} else {
353
355
CmdArgs.push_back (" --as-needed" );
@@ -416,7 +418,8 @@ void FreeBSD::addLibStdCxxIncludePaths(
416
418
void FreeBSD::AddCXXStdlibLibArgs (const ArgList &Args,
417
419
ArgStringList &CmdArgs) const {
418
420
CXXStdlibType Type = GetCXXStdlibType (Args);
419
- bool Profiling = Args.hasArg (options::OPT_pg);
421
+ bool Profiling =
422
+ Args.hasArg (options::OPT_pg) && getTriple ().getOSMajorVersion () < 14 ;
420
423
421
424
switch (Type) {
422
425
case ToolChain::CST_Libcxx:
0 commit comments