What changed, and why it matters
This commit updates Bitcoin Core's build system to support cross-compiling FreeBSD binaries using Clang and the LLVM toolchain. It changes compiler and linker settings in makefiles used only during the build process. There is no indication this fixes or introduces a security vulnerability.
No security action required. Treat as ordinary build-system maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies depends/builders/freebsd.mk and depends/hosts/freebsd.mk to switch FreeBSD cross-compilation to Clang with explicit –target and –sysroot flags, LLVM binutils (llvm-ar, llvm-nm, etc.), the lld linker, and libc++. It also moves 32/64-bit flags from per-host CC/CXX definitions to CFLAGS/CXXFLAGS. This is a build-system modernization/cleanup for FreeBSD cross builds.
Changed components
depends/builders/freebsd.mkdepends/hosts/freebsd.mkInspect captured patch +34 / −21
diff --git a/depends/builders/freebsd.mk b/depends/builders/freebsd.mk
index 910de28b..f66d3fcd 100644
--- a/depends/builders/freebsd.mk
+++ b/depends/builders/freebsd.mk
@@ -7,3 +7,9 @@ build_freebsd_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CON
# freebsd host on freebsd builder: override freebsd host preferences.
freebsd_CC = clang
freebsd_CXX = clang++
+
+i686_freebsd_CFLAGS += -m32
+i686_freebsd_CXXFLAGS += -m32
+
+x86_64_freebsd_CFLAGS += -m64
+x86_64_freebsd_CXXFLAGS += -m64
diff --git a/depends/hosts/freebsd.mk b/depends/hosts/freebsd.mk
index b69535cc..bcbf2f77 100644
--- a/depends/hosts/freebsd.mk
+++ b/depends/hosts/freebsd.mk
@@ -1,5 +1,33 @@
+FREEBSD_VERSION ?= 15.0
+FREEBSD_SDK=$(SDK_PATH)/freebsd-$(host)-$(FREEBSD_VERSION)/
+
+# We can't just use $(shell command -v clang) because GNU Make handles builtins
+# in a special way and doesn't know that `command` is a POSIX-standard builtin
+# prior to 1af314465e5dfe3e8baa839a32a72e83c04f26ef, first released in v4.2.90.
+# At the time of writing, GNU Make v4.2.1 is still being used in supported
+# distro releases.
+#
+# Source: https://lists.gnu.org/archive/html/bug-make/2017-11/msg00017.html
+clang_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang")
+clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
+
+freebsd_AR=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-ar")
+freebsd_NM=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-nm")
+freebsd_OBJCOPY=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-objcopy")
+freebsd_OBJDUMP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-objdump")
+freebsd_RANLIB=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-ranlib")
+freebsd_STRIP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-strip")
+
+
+freebsd_CC=$(clang_prog) --target=$(host) \
+ --sysroot=$(FREEBSD_SDK)
+
+freebsd_CXX=$(clangxx_prog) --target=$(host) \
+ --sysroot=$(FREEBSD_SDK) -stdlib=libc++
+
freebsd_CFLAGS=
freebsd_CXXFLAGS=
+freebsd_LDFLAGS=-fuse-ld=lld
freebsd_release_CFLAGS=-O2
freebsd_release_CXXFLAGS=$(freebsd_release_CFLAGS)
@@ -7,25 +35,4 @@ freebsd_release_CXXFLAGS=$(freebsd_release_CFLAGS)
freebsd_debug_CFLAGS=-O1 -g
freebsd_debug_CXXFLAGS=$(freebsd_debug_CFLAGS)
-ifeq (86,$(findstring 86,$(build_arch)))
-i686_freebsd_CC=clang -m32
-i686_freebsd_CXX=clang++ -m32
-i686_freebsd_AR=ar
-i686_freebsd_RANLIB=ranlib
-i686_freebsd_NM=nm
-i686_freebsd_STRIP=strip
-
-x86_64_freebsd_CC=clang -m64
-x86_64_freebsd_CXX=clang++ -m64
-x86_64_freebsd_AR=ar
-x86_64_freebsd_RANLIB=ranlib
-x86_64_freebsd_NM=nm
-x86_64_freebsd_STRIP=strip
-else
-i686_freebsd_CC=$(default_host_CC) -m32
-i686_freebsd_CXX=$(default_host_CXX) -m32
-x86_64_freebsd_CC=$(default_host_CC) -m64
-x86_64_freebsd_CXX=$(default_host_CXX) -m64
-endif
-
freebsd_cmake_system_name=FreeBSD
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.