Page MenuHomeFreeBSD

D50956.id168499.diff
No OneTemporary

D50956.id168499.diff

diff --git a/lib/clang/libclang/Makefile b/lib/clang/libclang/Makefile
--- a/lib/clang/libclang/Makefile
+++ b/lib/clang/libclang/Makefile
@@ -1,8 +1,8 @@
-.include <bsd.init.mk>
+.include <src.opts.mk>
.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 @@
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
--- a/lib/clang/liblldb/Makefile
+++ b/lib/clang/liblldb/Makefile
@@ -1,10 +1,16 @@
-.include <bsd.init.mk>
+.include <src.opts.mk>
.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 @@
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
--- a/lib/clang/libllvm/Makefile
+++ b/lib/clang/libllvm/Makefile
@@ -1,8 +1,8 @@
-.include <bsd.init.mk>
+.include <src.opts.mk>
.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
diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5
--- 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 December 15, 2025
+.Dd December 21, 2025
.Dt SRC.CONF 5
.Os
.Sh NAME
@@ -999,6 +999,13 @@
.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
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -213,6 +213,7 @@
LOADER_VERBOSE \
LOADER_VERIEXEC_PASS_MANIFEST \
LLVM_FULL_DEBUGINFO \
+ LLVM_LINK_STATIC_LIBRARIES \
MALLOC_PRODUCTION \
OFED_EXTRA \
OPENLDAP \
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -892,12 +892,14 @@
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
@@ -3868,10 +3870,13 @@
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
--- /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
--- a/usr.bin/clang/Makefile.inc
+++ b/usr.bin/clang/Makefile.inc
@@ -1,6 +1,6 @@
.include <src.opts.mk>
-.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
--- a/usr.bin/clang/clang.prog.mk
+++ b/usr.bin/clang/clang.prog.mk
@@ -18,7 +18,7 @@
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
--- a/usr.bin/clang/lld/Makefile
+++ b/usr.bin/clang/lld/Makefile
@@ -81,7 +81,7 @@
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
--- a/usr.bin/clang/lldb-server/Makefile
+++ b/usr.bin/clang/lldb-server/Makefile
@@ -22,8 +22,13 @@
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
--- a/usr.bin/clang/lldb/Makefile
+++ b/usr.bin/clang/lldb/Makefile
@@ -15,8 +15,13 @@
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
--- a/usr.bin/clang/llvm.prog.mk
+++ b/usr.bin/clang/llvm.prog.mk
@@ -14,8 +14,13 @@
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

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 19, 2:47 AM (14 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27728379
Default Alt Text
D50956.id168499.diff (6 KB)

Event Timeline