guix: consolidate gcc toolchain setup
What changed, and why it matters
This commit is a routine cleanup of the Bitcoin Core build scripts used for Guix (a reproducible build system). It moves duplicated GCC toolchain setup code from two separate files into a single shared function in setup.sh, with no functional changes visible in the diff. There is no indication this affects the security of Bitcoin Core itself or introduces a vulnerability.
No security action required. Treat as normal build-system refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch consolidates identical native and cross GCC toolchain environment setup blocks from build_linux.sh and build_linux_gui.sh into a new gcc_toolchain() function in setup.sh. The new function is then called from both build scripts. The exported variables, store_path invocations, include/library paths, and check_cross_paths call are preserved verbatim. No changes to compiler flags, paths, or build logic are introduced.
Changed components
contrib/guix/libexec/build_linux.shcontrib/guix/libexec/build_linux_gui.shcontrib/guix/libexec/setup.shInspect captured patch +35 / −52
diff --git a/contrib/guix/libexec/build_linux.sh b/contrib/guix/libexec/build_linux.sh
index f1b25b52..7cf39d4b 100755
--- a/contrib/guix/libexec/build_linux.sh
+++ b/contrib/guix/libexec/build_linux.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"
-
-NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)"
-export LIBRARY_PATH="${NATIVE_GCC}/lib:${NATIVE_GCC_STATIC}/lib"
-
-# Set environment variables to point the CROSS toolchain to the right
-# includes/libs for $HOST
-CROSS_GLIBC="$(store_path "glibc-cross-${HOST}")"
-CROSS_GLIBC_STATIC="$(store_path "glibc-cross-${HOST}" static)"
-CROSS_KERNEL="$(store_path "linux-libre-headers-cross-${HOST}")"
-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)
-
-export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include:${CROSS_KERNEL}/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:${CROSS_GLIBC_STATIC}/lib"
-
-check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
+# setup gcc toolchain
+gcc_toolchain
# Build the depends tree, overriding variables that assume multilib gcc
make -C depends --jobs="$JOBS" HOST="$HOST" \
diff --git a/contrib/guix/libexec/build_linux_gui.sh b/contrib/guix/libexec/build_linux_gui.sh
index 218bc0a9..33aa8768 100755
--- a/contrib/guix/libexec/build_linux_gui.sh
+++ b/contrib/guix/libexec/build_linux_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"
-
-NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)"
-export LIBRARY_PATH="${NATIVE_GCC}/lib:${NATIVE_GCC_STATIC}/lib"
-
-# Set environment variables to point the CROSS toolchain to the right
-# includes/libs for $HOST
-CROSS_GLIBC="$(store_path "glibc-cross-${HOST}")"
-CROSS_GLIBC_STATIC="$(store_path "glibc-cross-${HOST}" static)"
-CROSS_KERNEL="$(store_path "linux-libre-headers-cross-${HOST}")"
-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)
-
-export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include:${CROSS_KERNEL}/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:${CROSS_GLIBC_STATIC}/lib"
-
-check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
+# setup gcc toolchain
+gcc_toolchain
# Build the depends tree, overriding variables that assume multilib gcc
make -C depends --jobs="$JOBS" HOST="$HOST" \
diff --git a/contrib/guix/libexec/setup.sh b/contrib/guix/libexec/setup.sh
index 031d5904..2e3eb159 100755
--- a/contrib/guix/libexec/setup.sh
+++ b/contrib/guix/libexec/setup.sh
@@ -86,6 +86,37 @@ glibc_dynamic_linker() {
esac
}
+gcc_toolchain() {
+ # Set environment variables to point the NATIVE toolchain to the right
+ # includes/libs
+ local NATIVE_GCC NATIVE_GCC_STATIC CROSS_GLIBC CROSS_GLIBC_STATIC CROSS_KERNEL 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"
+
+ NATIVE_GCC_STATIC="$(store_path gcc-toolchain static)"
+ export LIBRARY_PATH="${NATIVE_GCC}/lib:${NATIVE_GCC_STATIC}/lib"
+
+ # Set environment variables to point the CROSS toolchain to the right
+ # includes/libs for $HOST
+ CROSS_GLIBC="$(store_path "glibc-cross-${HOST}")"
+ CROSS_GLIBC_STATIC="$(store_path "glibc-cross-${HOST}" static)"
+ CROSS_KERNEL="$(store_path "linux-libre-headers-cross-${HOST}")"
+ 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)
+
+ export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GCC_LIB}/include-fixed:${CROSS_GLIBC}/include:${CROSS_KERNEL}/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:${CROSS_GLIBC_STATIC}/lib"
+
+ check_cross_paths "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
+}
+
llvm_toolchain() {
local CLANG_TOOLCHAIN LIB_CXX
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.