guix: consolidate LLVM toolchain setup
What changed, and why it matters
This commit is a straightforward cleanup of Bitcoin Core's macOS build scripts. It moves repeated LLVM/clang toolchain setup code from two separate scripts into a single shared function, with no change to the actual commands or build behavior. There is no security issue visible in the diff.
No security action needed. Treat as normal build-system maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors contrib/guix/libexec/build_macos.sh and contrib/guix/libexec/build_macos_gui.sh to call a new shared llvm_toolchain() function defined in contrib/guix/libexec/setup.sh. The exported variables (build_CC, build_CXX, build_LDFLAGS, build_AR, build_RANLIB, build_OBJDUMP, build_NM, build_STRIP) and their values are identical to the previous inline definitions, except they are now exported from within a function. This is a pure code-consolidation refactor with no functional or security-relevant change.
Changed components
contrib/guix/libexec/build_macos.shcontrib/guix/libexec/build_macos_gui.shcontrib/guix/libexec/setup.shInspect captured patch +20 / −30
diff --git a/contrib/guix/libexec/build_macos.sh b/contrib/guix/libexec/build_macos.sh
index b8dc2500..e765b279 100755
--- a/contrib/guix/libexec/build_macos.sh
+++ b/contrib/guix/libexec/build_macos.sh
@@ -8,21 +8,8 @@ set -o errexit -o pipefail
# shellcheck source=setup.sh
source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
-# Set toolchain
-CLANG_TOOLCHAIN="$(store_path clang-toolchain)"
-LIBCXX="$(store_path libcxx)"
-build_CC="${CLANG_TOOLCHAIN}/bin/clang \
- -isystem ${CLANG_TOOLCHAIN}/include"
-build_CXX="${CLANG_TOOLCHAIN}/bin/clang++ \
- -stdlib=libc++ \
- -isystem ${LIBCXX}/include/c++/v1 \
- -isystem ${CLANG_TOOLCHAIN}/include"
-build_LDFLAGS="-fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -L${LIBCXX}/lib -Wl,-rpath,${LIBCXX}/lib"
-build_AR="${CLANG_TOOLCHAIN}/bin/llvm-ar"
-build_RANLIB="${CLANG_TOOLCHAIN}/bin/llvm-ranlib"
-build_OBJDUMP="${CLANG_TOOLCHAIN}/bin/llvm-objdump"
-build_NM="${CLANG_TOOLCHAIN}/bin/llvm-nm"
-build_STRIP="${CLANG_TOOLCHAIN}/bin/llvm-strip"
+# Setup toolchain
+llvm_toolchain
# Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \
diff --git a/contrib/guix/libexec/build_macos_gui.sh b/contrib/guix/libexec/build_macos_gui.sh
index 3db1cfac..c1636bbf 100755
--- a/contrib/guix/libexec/build_macos_gui.sh
+++ b/contrib/guix/libexec/build_macos_gui.sh
@@ -8,21 +8,8 @@ set -o errexit -o pipefail
# shellcheck source=setup.sh
source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
-# Set toolchain
-CLANG_TOOLCHAIN="$(store_path clang-toolchain)"
-LIBCXX="$(store_path libcxx)"
-build_CC="${CLANG_TOOLCHAIN}/bin/clang \
- -isystem ${CLANG_TOOLCHAIN}/include"
-build_CXX="${CLANG_TOOLCHAIN}/bin/clang++ \
- -stdlib=libc++ \
- -isystem ${LIBCXX}/include/c++/v1 \
- -isystem ${CLANG_TOOLCHAIN}/include"
-build_LDFLAGS="-fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -L${LIBCXX}/lib -Wl,-rpath,${LIBCXX}/lib"
-build_AR="${CLANG_TOOLCHAIN}/bin/llvm-ar"
-build_RANLIB="${CLANG_TOOLCHAIN}/bin/llvm-ranlib"
-build_OBJDUMP="${CLANG_TOOLCHAIN}/bin/llvm-objdump"
-build_NM="${CLANG_TOOLCHAIN}/bin/llvm-nm"
-build_STRIP="${CLANG_TOOLCHAIN}/bin/llvm-strip"
+# Setup toolchain
+llvm_toolchain
# Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \
diff --git a/contrib/guix/libexec/setup.sh b/contrib/guix/libexec/setup.sh
index c6858c98..af2e8add 100755
--- a/contrib/guix/libexec/setup.sh
+++ b/contrib/guix/libexec/setup.sh
@@ -86,6 +86,22 @@ glibc_dynamic_linker() {
esac
}
+llvm_toolchain() {
+ local CLANG_TOOLCHAIN LIB_CXX
+
+ CLANG_TOOLCHAIN="$(store_path clang-toolchain)"
+ LIB_CXX="$(store_path libcxx)"
+
+ export build_CC="${CLANG_TOOLCHAIN}/bin/clang -isystem ${CLANG_TOOLCHAIN}/include"
+ export build_CXX="${CLANG_TOOLCHAIN}/bin/clang++ -stdlib=libc++ -isystem ${LIB_CXX}/include/c++/v1 -isystem ${CLANG_TOOLCHAIN}/include"
+ export build_LDFLAGS="-fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -L${LIB_CXX}/lib -Wl,-rpath,${LIB_CXX}/lib"
+ export build_AR="${CLANG_TOOLCHAIN}/bin/llvm-ar"
+ export build_RANLIB="${CLANG_TOOLCHAIN}/bin/llvm-ranlib"
+ export build_OBJDUMP="${CLANG_TOOLCHAIN}/bin/llvm-objdump"
+ export build_NM="${CLANG_TOOLCHAIN}/bin/llvm-nm"
+ export build_STRIP="${CLANG_TOOLCHAIN}/bin/llvm-strip"
+}
+
# Disable Guix ld auto-rpath behavior
export GUIX_LD_WRAPPER_DISABLE_RPATH=yes
Why this scored 15/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.