Skip to content

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented Oct 16, 2025

Draft... FreeBSD 13.x EoL is coming up in 6 months. Make 14.x the default.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Oct 16, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 16, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Brad Smith (brad0)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/163847.diff

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/FreeBSD.cpp (+7-40)
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index b17b76233ad30..b645b9077fd0c 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -281,8 +281,6 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
-  unsigned Major = ToolChain.getTriple().getOSMajorVersion();
-  bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
                    options::OPT_r)) {
     // Use the static OpenMP runtime with -static-openmp
@@ -293,10 +291,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
     if (D.CCCIsCXX()) {
       if (ToolChain.ShouldLinkCXXStdlib(Args))
         ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
-      if (Profiling)
-        CmdArgs.push_back("-lm_p");
-      else
-        CmdArgs.push_back("-lm");
+      CmdArgs.push_back("-lm");
     }
 
     // Silence warnings when linking C code with a C++ '-stdlib' argument.
@@ -310,10 +305,7 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
         !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
       ToolChain.addFortranRuntimeLibraryPath(Args, CmdArgs);
       ToolChain.addFortranRuntimeLibs(Args, CmdArgs);
-      if (Profiling)
-        CmdArgs.push_back("-lm_p");
-      else
-        CmdArgs.push_back("-lm");
+      CmdArgs.push_back("-lm");
     }
 
     if (NeedsSanitizerDeps)
@@ -322,42 +314,23 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
       linkXRayRuntimeDeps(ToolChain, Args, CmdArgs);
     // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding
     // the default system libraries. Just mimic this for now.
-    if (Profiling)
-      CmdArgs.push_back("-lgcc_p");
-    else
-      CmdArgs.push_back("-lgcc");
+    CmdArgs.push_back("-lgcc");
     if (Args.hasArg(options::OPT_static)) {
       CmdArgs.push_back("-lgcc_eh");
-    } else if (Profiling) {
-      CmdArgs.push_back("-lgcc_eh_p");
     } else {
       CmdArgs.push_back("--as-needed");
       CmdArgs.push_back("-lgcc_s");
       CmdArgs.push_back("--no-as-needed");
     }
 
-    if (Args.hasArg(options::OPT_pthread)) {
-      if (Profiling)
-        CmdArgs.push_back("-lpthread_p");
-      else
-        CmdArgs.push_back("-lpthread");
-    }
+    if (Args.hasArg(options::OPT_pthread))
+      CmdArgs.push_back("-lpthread");
 
-    if (Profiling) {
-      if (Args.hasArg(options::OPT_shared))
-        CmdArgs.push_back("-lc");
-      else
-        CmdArgs.push_back("-lc_p");
-      CmdArgs.push_back("-lgcc_p");
-    } else {
-      CmdArgs.push_back("-lc");
-      CmdArgs.push_back("-lgcc");
-    }
+    CmdArgs.push_back("-lc");
+    CmdArgs.push_back("-lgcc");
 
     if (Args.hasArg(options::OPT_static)) {
       CmdArgs.push_back("-lgcc_eh");
-    } else if (Profiling) {
-      CmdArgs.push_back("-lgcc_eh_p");
     } else {
       CmdArgs.push_back("--as-needed");
       CmdArgs.push_back("-lgcc_s");
@@ -442,12 +415,6 @@ void FreeBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
 void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
                                   ArgStringList &CmdArgs) const {
   Generic_ELF::AddCXXStdlibLibArgs(Args, CmdArgs);
-  unsigned Major = getTriple().getOSMajorVersion();
-  bool SuffixedLib = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14;
-  if (SuffixedLib && GetCXXStdlibType(Args) == CST_Libcxx)
-    std::replace_if(
-        CmdArgs.begin(), CmdArgs.end(),
-        [](const char *S) { return StringRef(S) == "-lc++"; }, "-lc++_p");
 }
 
 void FreeBSD::AddCudaIncludeArgs(const ArgList &DriverArgs,

@brad0 brad0 force-pushed the freebsd_13_remove branch from 061c4c4 to ce9dd05 Compare October 16, 2025 19:05
@brad0 brad0 requested review from DimitryAndric and emaste October 16, 2025 19:28
@brad0 brad0 force-pushed the freebsd_13_remove branch from ce9dd05 to 3ee112c Compare October 16, 2025 19:34
Copy link
Collaborator

@DimitryAndric DimitryAndric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as this is committed when FreeBSD 13 actually goes EOL, I'm fine with it. :)

@brad0
Copy link
Contributor Author

brad0 commented Oct 17, 2025

As long as this is committed when FreeBSD 13 actually goes EOL, I'm fine with it. :)

Yes, I'll be commiting this well after LLVM 22 goes out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants