Changeset View
Changeset View
Standalone View
Standalone View
contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp
Show First 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0], | ||||
D.getLTOMode() == LTOK_Thin); | D.getLTOMode() == LTOK_Thin); | ||||
} | } | ||||
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); | bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); | ||||
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); | bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); | ||||
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs); | addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs); | ||||
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); | AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); | ||||
bool Profiling = Args.hasArg(options::OPT_pg) && | |||||
ToolChain.getTriple().getOSMajorVersion() < 14; | |||||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { | if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { | ||||
// Use the static OpenMP runtime with -static-openmp | // Use the static OpenMP runtime with -static-openmp | ||||
bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) && | bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) && | ||||
!Args.hasArg(options::OPT_static); | !Args.hasArg(options::OPT_static); | ||||
addOpenMPRuntime(CmdArgs, ToolChain, Args, StaticOpenMP); | addOpenMPRuntime(CmdArgs, ToolChain, Args, StaticOpenMP); | ||||
if (D.CCCIsCXX()) { | if (D.CCCIsCXX()) { | ||||
if (ToolChain.ShouldLinkCXXStdlib(Args)) | if (ToolChain.ShouldLinkCXXStdlib(Args)) | ||||
ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); | ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); | ||||
if (Args.hasArg(options::OPT_pg)) | if (Profiling) | ||||
CmdArgs.push_back("-lm_p"); | CmdArgs.push_back("-lm_p"); | ||||
else | else | ||||
CmdArgs.push_back("-lm"); | CmdArgs.push_back("-lm"); | ||||
} | } | ||||
if (NeedsSanitizerDeps) | if (NeedsSanitizerDeps) | ||||
linkSanitizerRuntimeDeps(ToolChain, CmdArgs); | linkSanitizerRuntimeDeps(ToolChain, CmdArgs); | ||||
if (NeedsXRayDeps) | if (NeedsXRayDeps) | ||||
linkXRayRuntimeDeps(ToolChain, CmdArgs); | linkXRayRuntimeDeps(ToolChain, CmdArgs); | ||||
// FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding | // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding | ||||
// the default system libraries. Just mimic this for now. | // the default system libraries. Just mimic this for now. | ||||
if (Args.hasArg(options::OPT_pg)) | if (Profiling) | ||||
CmdArgs.push_back("-lgcc_p"); | CmdArgs.push_back("-lgcc_p"); | ||||
else | else | ||||
CmdArgs.push_back("-lgcc"); | CmdArgs.push_back("-lgcc"); | ||||
if (Args.hasArg(options::OPT_static)) { | if (Args.hasArg(options::OPT_static)) { | ||||
CmdArgs.push_back("-lgcc_eh"); | CmdArgs.push_back("-lgcc_eh"); | ||||
} else if (Args.hasArg(options::OPT_pg)) { | } else if (Profiling) { | ||||
CmdArgs.push_back("-lgcc_eh_p"); | CmdArgs.push_back("-lgcc_eh_p"); | ||||
} else { | } else { | ||||
CmdArgs.push_back("--as-needed"); | CmdArgs.push_back("--as-needed"); | ||||
CmdArgs.push_back("-lgcc_s"); | CmdArgs.push_back("-lgcc_s"); | ||||
CmdArgs.push_back("--no-as-needed"); | CmdArgs.push_back("--no-as-needed"); | ||||
} | } | ||||
if (Args.hasArg(options::OPT_pthread)) { | if (Args.hasArg(options::OPT_pthread)) { | ||||
if (Args.hasArg(options::OPT_pg)) | if (Profiling) | ||||
CmdArgs.push_back("-lpthread_p"); | CmdArgs.push_back("-lpthread_p"); | ||||
else | else | ||||
CmdArgs.push_back("-lpthread"); | CmdArgs.push_back("-lpthread"); | ||||
} | } | ||||
if (Args.hasArg(options::OPT_pg)) { | if (Profiling) { | ||||
if (Args.hasArg(options::OPT_shared)) | if (Args.hasArg(options::OPT_shared)) | ||||
CmdArgs.push_back("-lc"); | CmdArgs.push_back("-lc"); | ||||
else | else | ||||
CmdArgs.push_back("-lc_p"); | CmdArgs.push_back("-lc_p"); | ||||
CmdArgs.push_back("-lgcc_p"); | CmdArgs.push_back("-lgcc_p"); | ||||
} else { | } else { | ||||
CmdArgs.push_back("-lc"); | CmdArgs.push_back("-lc"); | ||||
CmdArgs.push_back("-lgcc"); | CmdArgs.push_back("-lgcc"); | ||||
} | } | ||||
if (Args.hasArg(options::OPT_static)) { | if (Args.hasArg(options::OPT_static)) { | ||||
CmdArgs.push_back("-lgcc_eh"); | CmdArgs.push_back("-lgcc_eh"); | ||||
} else if (Args.hasArg(options::OPT_pg)) { | } else if (Profiling) { | ||||
CmdArgs.push_back("-lgcc_eh_p"); | CmdArgs.push_back("-lgcc_eh_p"); | ||||
} else { | } else { | ||||
CmdArgs.push_back("--as-needed"); | CmdArgs.push_back("--as-needed"); | ||||
CmdArgs.push_back("-lgcc_s"); | CmdArgs.push_back("-lgcc_s"); | ||||
CmdArgs.push_back("--no-as-needed"); | CmdArgs.push_back("--no-as-needed"); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | void FreeBSD::addLibStdCxxIncludePaths( | ||||
llvm::opt::ArgStringList &CC1Args) const { | llvm::opt::ArgStringList &CC1Args) const { | ||||
addLibStdCXXIncludePaths(getDriver().SysRoot, "/usr/include/c++/4.2", "", "", | addLibStdCXXIncludePaths(getDriver().SysRoot, "/usr/include/c++/4.2", "", "", | ||||
"", "", DriverArgs, CC1Args); | "", "", DriverArgs, CC1Args); | ||||
} | } | ||||
void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args, | void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args, | ||||
ArgStringList &CmdArgs) const { | ArgStringList &CmdArgs) const { | ||||
CXXStdlibType Type = GetCXXStdlibType(Args); | CXXStdlibType Type = GetCXXStdlibType(Args); | ||||
bool Profiling = Args.hasArg(options::OPT_pg); | bool Profiling = | ||||
Args.hasArg(options::OPT_pg) && getTriple().getOSMajorVersion() < 14; | |||||
switch (Type) { | switch (Type) { | ||||
case ToolChain::CST_Libcxx: | case ToolChain::CST_Libcxx: | ||||
CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++"); | CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++"); | ||||
break; | break; | ||||
case ToolChain::CST_Libstdcxx: | case ToolChain::CST_Libstdcxx: | ||||
CmdArgs.push_back(Profiling ? "-lstdc++_p" : "-lstdc++"); | CmdArgs.push_back(Profiling ? "-lstdc++_p" : "-lstdc++"); | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |