guix: turn linux/win linker warnings into errors
What changed, and why it matters
This commit changes Bitcoin Core's build scripts so that linker warnings are treated as fatal errors during Linux and Windows release builds. It is a hardening of the build process, not a fix for a user-facing security bug. The change makes the build fail if the linker emits warnings, which helps catch build-time problems early. It is not something an attacker can directly exploit.
No immediate action required. This is a build-hardening improvement. Reviewers may verify that the riscv64-linux-gnu exception is temporary and tracked, and consider extending the same treatment to Darwin once the referenced prerequisite pull request is merged.
Security signals we found
Build hardening: linker warnings promoted to errors
Exclusion for riscv64-linux-gnu references upstream Boost issue
No runtime, consensus, or cryptographic code changed
Evidence from the diff
The commit adds -Wl,--fatal-warnings to HOST_LDFLAGS in Guix build scripts for Linux (except riscv64-linux-gnu due to a known Boost.Test issue) and Windows (both non-GUI and GUI builds). This causes the GNU linker to treat any linker warning as a fatal error. The change improves build hygiene and prevents shipping binaries with unresolved or risky linker warnings. It does not modify runtime code, consensus code, or network behavior.
Changed components
contrib/guix/libexec/build_linux.shcontrib/guix/libexec/build_win.shcontrib/guix/libexec/build_win_gui.shInspect captured patch +8 / −2
diff --git a/contrib/guix/libexec/build_linux.sh b/contrib/guix/libexec/build_linux.sh
index 492890ec..f1b25b52 100755
--- a/contrib/guix/libexec/build_linux.sh
+++ b/contrib/guix/libexec/build_linux.sh
@@ -65,6 +65,12 @@ esac
# LDFLAGS
HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$(glibc_dynamic_linker "$HOST") -Wl,-O2"
+# Use LINK_WARNING_AS_ERROR when using CMake 4.x
+case "$HOST" in
+ riscv64-linux-gnu) ;; # https://github.com/boostorg/test/issues/345
+ *) HOST_LDFLAGS="${HOST_LDFLAGS} -Wl,--fatal-warnings" ;;
+esac
+
mkdir -p "$DISTSRC"
(
cd "$DISTSRC"
diff --git a/contrib/guix/libexec/build_win.sh b/contrib/guix/libexec/build_win.sh
index ce1f7fd4..de9870f8 100755
--- a/contrib/guix/libexec/build_win.sh
+++ b/contrib/guix/libexec/build_win.sh
@@ -54,7 +54,7 @@ HOST_CFLAGS+=" -fno-ident"
HOST_CXXFLAGS="$HOST_CFLAGS"
# LDFLAGS
-HOST_LDFLAGS="-Wl,--no-insert-timestamp"
+HOST_LDFLAGS="-Wl,--no-insert-timestamp -Wl,--fatal-warnings"
mkdir -p "$DISTSRC"
(
diff --git a/contrib/guix/libexec/build_win_gui.sh b/contrib/guix/libexec/build_win_gui.sh
index 94f21166..ec5048d8 100755
--- a/contrib/guix/libexec/build_win_gui.sh
+++ b/contrib/guix/libexec/build_win_gui.sh
@@ -53,7 +53,7 @@ HOST_CFLAGS+=" -fno-ident"
HOST_CXXFLAGS="$HOST_CFLAGS"
# LDFLAGS
-HOST_LDFLAGS="-Wl,--no-insert-timestamp"
+HOST_LDFLAGS="-Wl,--no-insert-timestamp -Wl,--fatal-warnings"
mkdir -p "$DISTSRC"
(
Why this scored 20/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.