guix: consolidate mingw-w64 toolchain setup
What changed, and why it matters
This commit is a straightforward cleanup of Bitcoin Core's Windows build scripts. It moves duplicated toolchain setup code into a shared helper function, with no functional changes visible in the diff. There is no indication this affects runtime security, user funds, or network behavior.
No security action required. Treat as normal build-system maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch consolidates identical mingw-w64 toolchain environment setup blocks from build_win.sh and build_win_gui.sh into a new mingw_w64_toolchain() function in setup.sh. The exported variables (build_CC, build_CXX, CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH, CROSS_LIBRARY_PATH) and the check_cross_paths call are preserved verbatim. The change is purely refactor/DRY with no observable behavioral difference in the build configuration.
Changed components
contrib/guix/libexec/build_win.shcontrib/guix/libexec/build_win_gui.shcontrib/guix/libexec/setup.shInspect captured patch +35 / −52
diff --git a/contrib/guix/libexec/build_win.sh b/contrib/guix/libexec/build_win.sh
index de9870f8..6e54a390 100755
--- a/contrib/guix/libexec/build_win.sh
+++ b/contrib/guix/libexec/build_win.sh
@@ -8,32 +8,8 @@ set -o errexit -o pipefail
# shellcheck source=setup.sh
source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
-# Set environment variables to point the NATIVE toolchain to the right
-# includes/libs
-NATIVE_GCC="$(store_path gcc-toolchain)"
-
-# Set native toolchain
-build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include"
-build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include"
-
-# Set environment variables to point the CROSS toolchain to the right
-# includes/libs for $HOST
-# Determine output paths to use in CROSS_* environment variables
-CROSS_GLIBC="$(store_path "mingw-w64-x86_64-winpthreads")"
-CROSS_GCC="$(store_path "gcc-cross-${HOST}")"
-CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)"
-CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories...
-CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one)
-
-# The search path ordering is generally:
-# 1. gcc-related search paths
-# 2. libc-related search paths
-# 2. kernel-header-related search paths (not applicable to mingw-w64 hosts)
-export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include"
-export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}"
-export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib"
-
-check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
+# setup mingw-w64 toolchain
+mingw_w64_toolchain
# Build the depends tree
make -C depends --jobs="$JOBS" HOST="$HOST" \
diff --git a/contrib/guix/libexec/build_win_gui.sh b/contrib/guix/libexec/build_win_gui.sh
index ec5048d8..809e1c72 100755
--- a/contrib/guix/libexec/build_win_gui.sh
+++ b/contrib/guix/libexec/build_win_gui.sh
@@ -8,32 +8,8 @@ set -o errexit -o pipefail
# shellcheck source=setup.sh
source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
-# Set environment variables to point the NATIVE toolchain to the right
-# includes/libs
-NATIVE_GCC="$(store_path gcc-toolchain)"
-
-# Set native toolchain
-build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include"
-build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include"
-
-# Set environment variables to point the CROSS toolchain to the right
-# includes/libs for $HOST
-# Determine output paths to use in CROSS_* environment variables
-CROSS_GLIBC="$(store_path "mingw-w64-x86_64-winpthreads")"
-CROSS_GCC="$(store_path "gcc-cross-${HOST}")"
-CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)"
-CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories...
-CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one)
-
-# The search path ordering is generally:
-# 1. gcc-related search paths
-# 2. libc-related search paths
-# 2. kernel-header-related search paths (not applicable to mingw-w64 hosts)
-export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include"
-export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}"
-export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib"
-
-check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
+# setup mingw-w64 toolchain
+mingw_w64_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 af2e8add..031d5904 100755
--- a/contrib/guix/libexec/setup.sh
+++ b/contrib/guix/libexec/setup.sh
@@ -102,6 +102,37 @@ llvm_toolchain() {
export build_STRIP="${CLANG_TOOLCHAIN}/bin/llvm-strip"
}
+mingw_w64_toolchain() {
+ # Set environment variables to point the NATIVE toolchain to the right
+ # includes/libs
+ local NATIVE_GCC CROSS_GLIBC CROSS_GCC CROSS_GCC_LIB_STORE CROSS_GCC_LIBS CROSS_GCC_LIB
+
+ NATIVE_GCC="$(store_path gcc-toolchain)"
+
+ # Set native toolchain
+ export build_CC="${NATIVE_GCC}/bin/gcc -isystem ${NATIVE_GCC}/include"
+ export build_CXX="${NATIVE_GCC}/bin/g++ -isystem ${NATIVE_GCC}/include/c++ -isystem ${NATIVE_GCC}/include"
+
+ # Set environment variables to point the CROSS toolchain to the right
+ # includes/libs for $HOST
+ # Determine output paths to use in CROSS_* environment variables
+ CROSS_GLIBC="$(store_path "mingw-w64-x86_64-winpthreads")"
+ CROSS_GCC="$(store_path "gcc-cross-${HOST}")"
+ CROSS_GCC_LIB_STORE="$(store_path "gcc-cross-${HOST}" lib)"
+ CROSS_GCC_LIBS=( "${CROSS_GCC_LIB_STORE}/lib/gcc/${HOST}"/* ) # This expands to an array of directories...
+ CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one)
+
+ # The search path ordering is generally:
+ # 1. gcc-related search paths
+ # 2. libc-related search paths
+ # 2. kernel-header-related search paths (not applicable to mingw-w64 hosts)
+ export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include"
+ export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}"
+ export CROSS_LIBRARY_PATH="${CROSS_GCC_LIB_STORE}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib"
+
+ check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
+}
+
# 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.