[clang] [Driver] Add LTO support for NetBSD (PR #187923)

via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 22 02:15:34 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: YAMAMOTO Takashi (yamt)

<details>
<summary>Changes</summary>

Note: as system /usr/bin/ld is not threaded, LLVMgold.so fails if it attempts to create threads. i couldn't find a way to suppress the use of threads. -fuse-ld=lld works.

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


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/NetBSD.cpp (+6) 
- (modified) clang/lib/Driver/ToolChains/NetBSD.h (+1) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp
index ea722b59853d6..56a42710106fe 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -274,6 +274,10 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
                             options::OPT_s, options::OPT_t});
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
+  if (D.isUsingLTO())
+    addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs,
+                  D.getLTOMode() == LTOK_Thin);
+
   bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
   bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
@@ -437,6 +441,8 @@ Tool *NetBSD::buildAssembler() const {
 
 Tool *NetBSD::buildLinker() const { return new tools::netbsd::Linker(*this); }
 
+bool NetBSD::HasNativeLLVMSupport() const { return true; }
+
 ToolChain::CXXStdlibType NetBSD::GetDefaultCXXStdlibType() const {
   switch (getArch()) {
   case llvm::Triple::aarch64:
diff --git a/clang/lib/Driver/ToolChains/NetBSD.h b/clang/lib/Driver/ToolChains/NetBSD.h
index 96303acaa0099..45848e06abef5 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.h
+++ b/clang/lib/Driver/ToolChains/NetBSD.h
@@ -52,6 +52,7 @@ class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
 public:
   NetBSD(const Driver &D, const llvm::Triple &Triple,
          const llvm::opt::ArgList &Args);
+  bool HasNativeLLVMSupport() const override;
 
   bool IsMathErrnoDefault() const override { return false; }
   bool IsObjCNonFragileABIDefault() const override { return true; }

``````````

</details>


https://github.com/llvm/llvm-project/pull/187923


More information about the cfe-commits mailing list