From nobody Fri Jan 2 20:51:46 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4djbTh5Lmkz6MFFy for ; Fri, 02 Jan 2026 20:51:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4djbTg62nQz3prv for ; Fri, 02 Jan 2026 20:51:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767387111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L0//RNn1W8+H3Qu/ZLLEWSPMYNWrY9JGQGqRKji28vQ=; b=Tgsl44mKLmAebRWbR8FS23ALS91k0KVHRzAoITVGY6vKvVioNKkhw7BMQ5wSstUtPTiBlk bK4UnWS7ao5RLdRTfVq2OFH1aYfN4xArqT/pA9+DqUkAZ/sZOPOMJyTiz5xlR0PSUVJXt8 cz2SlHorA+h5rWEDBTJeZy6xjYRMJbea1xEzv9F1t0jAWMiGMMzBKp+1vb2/HEWOnWR/zL TCrizGZvlI0uWZVF4tl+nB67rK1Wma4QRXZPUfSTP1HRYZhH+yyycWz65D8CzTNhZxtnWw aiarueabXrXdfsxlZ5T6YtY9aWhCSWvjpCT3nM7/2zqFgVAf1XSHHJE8o+FpeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767387111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L0//RNn1W8+H3Qu/ZLLEWSPMYNWrY9JGQGqRKji28vQ=; b=ifkVpFy9R5nEy20TFLVy1nWXewfSdscFqRJbj0FmDkF4jaGyeZA8VaQD4RsWayrXXx6qFE jAXPxMxFYJp8wPH5JVr3cv7d5kLNN6w7zp//7eBxqSBxOLNT+6GrjCEG+41Om+y2glwXac 3T2w3MU1y5UKdsvurPRjTH0rJHLFLjE0S7fDvhz9EfErqO6qN3lU6x5k2kx5ZBH2nCxv5M HI7hji/tEPXSuI5QhY1WYgLTzcE8N8RHTvCn4mjuP07szYCAqbgO3KqjnL0ryZhEYAgO1w Zgn+PkIR5o4/IGHqAUjyhTaviKNpp2WGiUiH51rHj1Bbu+zlOxMKzAFS5m2CJA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767387111; a=rsa-sha256; cv=none; b=q3TSGKn81mfsP+q9nhzMiKNxewOQ0kqdnLur+MnCFze1wNAVD4GjQW/B1BDWGGYLaCunCL rKtQ6IDugmcm0etxUiLxxFb3en8ARp9fLZxrpqUNgGDRfBjxszdjoEF2FJY7AZ9r2c/HEn fSZmeNKtYKFKYRBhrQteapmYNXAOjrjWig1sQtgbIqHCoJRaGvim8zKzEvH4x1DuAc3yzo t5a7iP1XQRLBwjAVQmZEoIAKmBL2OpYpbuMnYUmmaimCR3FgvixxZGxmiALQUWJlbFhK6B UTYqr5hSW2bHH8m/O4lPT6olkc/TvFIoQdCh0BMgbftmNrZb/K57hf+M4XSCqA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4djbTg5bmFzZQq for ; Fri, 02 Jan 2026 20:51:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id a94f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 02 Jan 2026 20:51:46 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: ded12d66a3eb - stable/15 - src.conf: Add WITH_LLVM_LINK_STATIC_LIBRARIES build knob List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: ded12d66a3ebdac657c24746f9b13d5d332f3cbd Auto-Submitted: auto-generated Date: Fri, 02 Jan 2026 20:51:46 +0000 Message-Id: <69582fe2.a94f.17da59ca@gitrepo.freebsd.org> The branch stable/15 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=ded12d66a3ebdac657c24746f9b13d5d332f3cbd commit ded12d66a3ebdac657c24746f9b13d5d332f3cbd Author: Dimitry Andric AuthorDate: 2025-06-18 10:06:25 +0000 Commit: Dimitry Andric CommitDate: 2026-01-02 20:40:18 +0000 src.conf: Add WITH_LLVM_LINK_STATIC_LIBRARIES build knob In commit 2e47f35be5dc libllvm, libclang and liblldb were converted into private shared libraries. This allowed clang, lld, lldb, and other llvm tools to be linked against these shared libraries, which makes them smaller and avoids duplication. However, this also comes at the cost of some performance, since the dynamic libraries are quite large, and contain lots of long symbols (mangled C++ identifiers). Add a WITH_LLVM_LINK_STATIC_LIBRARIES build knob that can be used to go back to the previous behavior: libllvm, libclang and liblldb are built as internal static libraries, i.e. only available during buildworld, and fully linked into the various executables such as clang, lld, etc. PR: 287447 Reviewed by: emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D50956 (cherry picked from commit 8d5a11cd0137d3ad70f6b06e063ea91a776d510a) --- lib/clang/libclang/Makefile | 8 ++++---- lib/clang/liblldb/Makefile | 13 ++++++++++++- lib/clang/libllvm/Makefile | 9 ++++----- share/man/man5/src.conf.5 | 9 ++++++++- share/mk/src.opts.mk | 1 + tools/build/mk/OptionalObsoleteFiles.inc | 11 ++++++++--- tools/build/options/WITH_LLVM_LINK_STATIC_LIBRARIES | 6 ++++++ usr.bin/clang/Makefile.inc | 2 +- usr.bin/clang/clang.prog.mk | 2 +- usr.bin/clang/lld/Makefile | 2 +- usr.bin/clang/lldb-server/Makefile | 5 +++++ usr.bin/clang/lldb/Makefile | 5 +++++ usr.bin/clang/llvm.prog.mk | 5 +++++ 13 files changed, 61 insertions(+), 17 deletions(-) diff --git a/lib/clang/libclang/Makefile b/lib/clang/libclang/Makefile index 7eb2c99b25c8..56f6fd374fe5 100644 --- a/lib/clang/libclang/Makefile +++ b/lib/clang/libclang/Makefile @@ -1,8 +1,8 @@ -.include +.include .include "../clang.pre.mk" -.if defined(TOOLS_PREFIX) -# Build static library during cross-tools stage +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" +# Build static library during cross-tools stage, or when explicitly requested. LIB= clang INTERNALLIB= .else @@ -872,7 +872,7 @@ SRCS+= ${SRCS_ALL:O} LIBDEPS+= llvm -.if defined(TOOLS_PREFIX) +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" LIBPRIV= LIBEXT= a .else diff --git a/lib/clang/liblldb/Makefile b/lib/clang/liblldb/Makefile index a3ff8e367864..aa9e90b2f6f2 100644 --- a/lib/clang/liblldb/Makefile +++ b/lib/clang/liblldb/Makefile @@ -1,10 +1,16 @@ -.include +.include .include "../lldb.pre.mk" +.if ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" +# Build static library when explicitly requested. +LIB= lldb +INTERNALLIB= +.else PACKAGE= lldb SHLIB_CXX= lldb SHLIB_MAJOR= 19 PRIVATELIB= +.endif SHARED_CXXFLAGS+= -UPIC # To avoid compile errors @@ -753,8 +759,13 @@ SRCS+= Version/Version.cpp LIBDEPS+= clang LIBDEPS+= llvm +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" +LIBPRIV= +LIBEXT= a +.else LIBPRIV= private LIBEXT= so +.endif .for lib in ${LIBDEPS} DPADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${LIBPRIV}${lib}.${LIBEXT} diff --git a/lib/clang/libllvm/Makefile b/lib/clang/libllvm/Makefile index a4e9c628d99e..05128550827a 100644 --- a/lib/clang/libllvm/Makefile +++ b/lib/clang/libllvm/Makefile @@ -1,8 +1,8 @@ -.include +.include .include "../llvm.pre.mk" -.if defined(TOOLS_PREFIX) -# Build static library during cross-tools stage +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" +# Build static library during cross-tools stage, or when explicitly requested. LIB= llvm INTERNALLIB= .else @@ -14,6 +14,7 @@ PRIVATELIB= # Work around "relocation R_PPC_GOT16 out of range" errors PICFLAG= -fPIC .endif +CFLAGS+= -DLLVM_BUILD_LLVM_DYLIB .endif SHARED_CXXFLAGS+= -UPIC # To avoid compile errors @@ -48,8 +49,6 @@ CFLAGS+= -DBLAKE3_NO_AVX512 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_SSE41 \ CFLAGS+= -DBLAKE3_USE_NEON=0 .endif -CFLAGS+= -DLLVM_BUILD_LLVM_DYLIB - SRCDIR= llvm/lib # Explanation of different SRCS variants below: diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index ba8b79b7c5bd..724f664e2a11 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,5 +1,5 @@ .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. -.Dd October 22, 2025 +.Dd December 21, 2025 .Dt SRC.CONF 5 .Os .Sh NAME @@ -995,6 +995,13 @@ Install ELF Tool Chain's cxxfilt as c++filt, instead of LLVM's llvm-cxxfilt. .It Va WITH_LLVM_FULL_DEBUGINFO Generate full debug information for LLVM libraries and tools, which uses more disk space and build resources, but allows for easier debugging. +.It Va WITH_LLVM_LINK_STATIC_LIBRARIES +Link LLVM libraries (libllvm, libclang, liblldb) statically into each of +the binaries that use them. + +This means that binaries linked against these libraries, such as clang, +ld.lld and lldb will be much larger and position dependent, but will +start more quickly. .It Va WITHOUT_LLVM_TARGET_AARCH64 Do not build LLVM target support for AArch64. The diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 91ea9534fcd6..1167d7f7b812 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -212,6 +212,7 @@ __DEFAULT_NO_OPTIONS = \ LOADER_VERIEXEC_PASS_MANIFEST \ LLVM_ASSERTIONS \ LLVM_FULL_DEBUGINFO \ + LLVM_LINK_STATIC_LIBRARIES \ OFED_EXTRA \ OPENLDAP \ PTHREADS_ASSERTIONS \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index df51f6955d2d..f91651fd235b 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -892,12 +892,14 @@ OLD_FILES+=usr/share/man/man4/ccd.4.gz OLD_FILES+=usr/share/man/man8/ccdconfig.8.gz .endif -.if ${MK_CLANG} == no && ${MK_CLANG_FORMAT} == no && ${MK_LLDB} == no +.if ${MK_CLANG} == no && ${MK_CLANG_FORMAT} == no && ${MK_LLDB} == no && \ + ${MK_LLVM_LINK_STATIC_LIBRARIES} == no OLD_LIBS+=usr/lib/libprivateclang.so.19 .endif .if ${MK_CLANG_EXTRAS} == no && ${MK_CLANG} == no && ${MK_LLDB} == no && \ - ${MK_LLD} == no && ${MK_LLVM_BINUTILS} == no && ${MK_LLVM_COV} == no + ${MK_LLD} == no && ${MK_LLVM_BINUTILS} == no && ${MK_LLVM_COV} == no && \ + ${MK_LLVM_LINK_STATIC_LIBRARIES} == no OLD_LIBS+=usr/lib/libprivatellvm.so.19 .endif @@ -3864,10 +3866,13 @@ OLD_LIBS+=${DEBUG_LIB${LIBCOMPAT}_LIBS} OLD_FILES+=usr/bin/ld.lld .endif +.if ${MK_LLDB} == no && ${MK_LLVM_LINK_STATIC_LIBRARIES} == no +OLD_LIBS+=usr/lib/libprivatelldb.so.19 +.endif + .if ${MK_LLDB} == no OLD_FILES+=usr/bin/lldb OLD_FILES+=usr/bin/lldb-server -OLD_LIBS+=usr/lib/libprivatelldb.so.19 OLD_FILES+=usr/share/man/man1/lldb-server.1.gz OLD_FILES+=usr/share/man/man1/lldb.1.gz .endif diff --git a/tools/build/options/WITH_LLVM_LINK_STATIC_LIBRARIES b/tools/build/options/WITH_LLVM_LINK_STATIC_LIBRARIES new file mode 100644 index 000000000000..7860ee862b1d --- /dev/null +++ b/tools/build/options/WITH_LLVM_LINK_STATIC_LIBRARIES @@ -0,0 +1,6 @@ +Link LLVM libraries (libllvm, libclang, liblldb) statically into each of +the binaries that use them. + +This means that binaries linked against these libraries, such as clang, +ld.lld and lldb will be much larger and position dependent, but will +start more quickly. diff --git a/usr.bin/clang/Makefile.inc b/usr.bin/clang/Makefile.inc index 1e9998061cf6..7ce07e2eac1d 100644 --- a/usr.bin/clang/Makefile.inc +++ b/usr.bin/clang/Makefile.inc @@ -1,6 +1,6 @@ .include -.if defined(TOOLS_PREFIX) +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" MK_PIE:= no # Explicit libXXX.a references .endif diff --git a/usr.bin/clang/clang.prog.mk b/usr.bin/clang/clang.prog.mk index 3baf3d0baf0f..e35425b0d280 100644 --- a/usr.bin/clang/clang.prog.mk +++ b/usr.bin/clang/clang.prog.mk @@ -18,7 +18,7 @@ LIBADD+= z LIBADD+= zstd .endif -.if defined(TOOLS_PREFIX) +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" LIBPRIV= LIBEXT= a .else diff --git a/usr.bin/clang/lld/Makefile b/usr.bin/clang/lld/Makefile index cbad6f2b3fcd..588dc5a198fc 100644 --- a/usr.bin/clang/lld/Makefile +++ b/usr.bin/clang/lld/Makefile @@ -81,7 +81,7 @@ SRCS+= tools/lld/lld.cpp LIBDEPS+= llvm -.if defined(TOOLS_PREFIX) +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" LIBPRIV= LIBEXT= a .else diff --git a/usr.bin/clang/lldb-server/Makefile b/usr.bin/clang/lldb-server/Makefile index 5042fa1fdf04..da4d83445050 100644 --- a/usr.bin/clang/lldb-server/Makefile +++ b/usr.bin/clang/lldb-server/Makefile @@ -22,8 +22,13 @@ LIBDEPS+= lldb LIBDEPS+= clang LIBDEPS+= llvm +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" +LIBPRIV= +LIBEXT= a +.else LIBPRIV= private LIBEXT= so +.endif .for lib in ${LIBDEPS} DPADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${LIBPRIV}${lib}.${LIBEXT} diff --git a/usr.bin/clang/lldb/Makefile b/usr.bin/clang/lldb/Makefile index 452bfd23bfa2..880d4de1c8fc 100644 --- a/usr.bin/clang/lldb/Makefile +++ b/usr.bin/clang/lldb/Makefile @@ -15,8 +15,13 @@ LIBDEPS+= lldb LIBDEPS+= clang LIBDEPS+= llvm +.if defined(TOOLS_PREFIX) || ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" +LIBPRIV= +LIBEXT= a +.else LIBPRIV= private LIBEXT= so +.endif .for lib in ${LIBDEPS} DPADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${LIBPRIV}${lib}.${LIBEXT} diff --git a/usr.bin/clang/llvm.prog.mk b/usr.bin/clang/llvm.prog.mk index c369fe8d5944..00f319a246fb 100644 --- a/usr.bin/clang/llvm.prog.mk +++ b/usr.bin/clang/llvm.prog.mk @@ -14,8 +14,13 @@ LIBPRIV= LIBEXT= a .else LIBDEPS+= llvm +.if ${MK_LLVM_LINK_STATIC_LIBRARIES} == "yes" +LIBPRIV= +LIBEXT= a +.else LIBPRIV= private LIBEXT= so +.endif LIBADD+= z LIBADD+= zstd .endif