Merge bitcoin/bitcoin#33181: guix: build for Linux HOSTS with -static-libgcc

f06c6e1898 guix: build for Linux HOSTS with -static-libgcc (fanquake)
1bdf4695b0 guix: patch store paths out of libunwind (fanquake)
078a72c35f guix: move static-libc++ into CMAKE_EXE_LINKER_FLAGS flags (fanquake)

Pull request description:

  Build release binaries with `-static-libgcc`.
  Would avoid future issues like https://github.com/bitcoin/bitcoin/pull/33178.

ACKs for top commit:
  willcl-ark:
    ACK f06c6e1898
  hebasto:
    ACK f06c6e1898.
  janb84:
    Concept ACK f06c6e1898

Tree-SHA512: 79409d9044fe7a339ea8090ca0e70e1305816aa3225b41ca6e4f2fec37650206ab5a78c1b2495a27a0c6c0dd6d5f86bd696101d2d1c5ecc72c630dc34e55f7dc
This commit is contained in:
merge-script committed 2025-11-11 11:09:27 +00:00
commit a7e8067610
4 files changed
+24 -17

No files matched your search

+8 -2
View File
@@ -225,10 +225,15 @@ esac
# LDFLAGS # LDFLAGS
case "$HOST" in case "$HOST" in
*linux*) HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$glibc_dynamic_linker -static-libstdc++ -Wl,-O2" ;; *linux*) HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$glibc_dynamic_linker -Wl,-O2" ;;
*mingw*) HOST_LDFLAGS="-Wl,--no-insert-timestamp" ;; *mingw*) HOST_LDFLAGS="-Wl,--no-insert-timestamp" ;;
esac esac
# EXE FLAGS
case "$HOST" in
*linux*) CMAKE_EXE_LINKER_FLAGS="-DCMAKE_EXE_LINKER_FLAGS=${HOST_LDFLAGS} -static-libstdc++ -static-libgcc" ;;
esac
mkdir -p "$DISTSRC" mkdir -p "$DISTSRC"
( (
cd "$DISTSRC" cd "$DISTSRC"
@@ -243,7 +248,8 @@ mkdir -p "$DISTSRC"
--toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \ --toolchain "${BASEPREFIX}/${HOST}/toolchain.cmake" \
-DWITH_CCACHE=OFF \ -DWITH_CCACHE=OFF \
-Werror=dev \ -Werror=dev \
${CONFIGFLAGS} ${CONFIGFLAGS} \
"${CMAKE_EXE_LINKER_FLAGS}"
# Build Bitcoin Core # Build Bitcoin Core
cmake --build build -j "$JOBS" ${V:+--verbose} cmake --build build -j "$JOBS" ${V:+--verbose}
+5 -5
View File
@@ -99,10 +99,10 @@ chain for " target " development."))
(define* (make-bitcoin-cross-toolchain target (define* (make-bitcoin-cross-toolchain target
#:key #:key
(base-gcc-for-libc linux-base-gcc) (base-gcc-for-libc (gcc-libgcc-patches linux-base-gcc))
(base-kernel-headers base-linux-kernel-headers) (base-kernel-headers base-linux-kernel-headers)
(base-libc glibc-2.31) (base-libc glibc-2.31)
(base-gcc linux-base-gcc)) (base-gcc (gcc-libgcc-patches linux-base-gcc)))
"Convenience wrapper around MAKE-CROSS-TOOLCHAIN with default values "Convenience wrapper around MAKE-CROSS-TOOLCHAIN with default values
desirable for building Bitcoin Core release binaries." desirable for building Bitcoin Core release binaries."
(make-cross-toolchain target (make-cross-toolchain target
@@ -111,7 +111,7 @@ desirable for building Bitcoin Core release binaries."
base-libc base-libc
base-gcc)) base-gcc))
(define (gcc-mingw-patches gcc) (define (gcc-libgcc-patches gcc)
(package-with-extra-patches gcc (package-with-extra-patches gcc
(search-our-patches "gcc-remap-guix-store.patch"))) (search-our-patches "gcc-remap-guix-store.patch")))
@@ -128,10 +128,10 @@ desirable for building Bitcoin Core release binaries."
(let* ((xbinutils (binutils-mingw-patches (cross-binutils target))) (let* ((xbinutils (binutils-mingw-patches (cross-binutils target)))
(machine (substring target 0 (string-index target #\-))) (machine (substring target 0 (string-index target #\-)))
(pthreads-xlibc (winpthreads-patches (make-mingw-w64 machine (pthreads-xlibc (winpthreads-patches (make-mingw-w64 machine
#:xgcc (cross-gcc target #:xgcc (gcc-mingw-patches base-gcc)) #:xgcc (cross-gcc target #:xgcc (gcc-libgcc-patches base-gcc))
#:with-winpthreads? #t))) #:with-winpthreads? #t)))
(pthreads-xgcc (cross-gcc target (pthreads-xgcc (cross-gcc target
#:xgcc (gcc-mingw-patches mingw-w64-base-gcc) #:xgcc (gcc-libgcc-patches mingw-w64-base-gcc)
#:xbinutils xbinutils #:xbinutils xbinutils
#:libc pthreads-xlibc))) #:libc pthreads-xlibc)))
;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and ;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and
@@ -1,4 +1,4 @@
Without ffile-prefix-map, the debug symbols will contain paths for the Without -ffile-prefix-map, the debug symbols will contain paths for the
guix store which will include the hashes of each package. However, the guix store which will include the hashes of each package. However, the
hash for the same package will differ when on different architectures. hash for the same package will differ when on different architectures.
In order to be reproducible regardless of the architecture used to build In order to be reproducible regardless of the architecture used to build
@@ -6,7 +6,7 @@ the package, map all guix store prefixes to something fixed, e.g. /usr.
--- a/libgcc/Makefile.in --- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in +++ b/libgcc/Makefile.in
@@ -854,7 +854,7 @@ endif @@ -857,7 +857,7 @@ endif
# libgcc_eh.a, only LIB2ADDEH matters. If we do, only LIB2ADDEHSTATIC and # libgcc_eh.a, only LIB2ADDEH matters. If we do, only LIB2ADDEHSTATIC and
# LIB2ADDEHSHARED matter. (Usually all three are identical.) # LIB2ADDEHSHARED matter. (Usually all three are identical.)
@@ -15,6 +15,15 @@ the package, map all guix store prefixes to something fixed, e.g. /usr.
ifeq ($(enable_shared),yes) ifeq ($(enable_shared),yes)
@@ -880,7 +880,7 @@ endif
# Build LIBUNWIND. Use -fno-exceptions so that the unwind library does
# not generate calls to __gcc_personality_v0.
-c_flags := -fno-exceptions
+c_flags := -fno-exceptions $(shell find /gnu/store -maxdepth 1 -mindepth 1 -type d -exec echo -n " -ffile-prefix-map={}=/usr" \;)
libunwind-objects += $(addsuffix $(objext),$(basename $(notdir $(LIBUNWIND))))
-- --
2.37.0 2.37.0
-8
View File
@@ -16,23 +16,18 @@ import lief
# Debian 11 (Bullseye) EOL: 2026. https://wiki.debian.org/LTS # Debian 11 (Bullseye) EOL: 2026. https://wiki.debian.org/LTS
# #
# - libgcc version 10.2.1 (https://packages.debian.org/bullseye/libgcc-s1)
# - libc version 2.31 (https://packages.debian.org/source/bullseye/glibc) # - libc version 2.31 (https://packages.debian.org/source/bullseye/glibc)
# #
# Ubuntu 20.04 (Focal) EOL: 2030. https://wiki.ubuntu.com/ReleaseTeam # Ubuntu 20.04 (Focal) EOL: 2030. https://wiki.ubuntu.com/ReleaseTeam
# #
# - libgcc version 10.5.0 (https://packages.ubuntu.com/focal/libgcc1)
# - libc version 2.31 (https://packages.ubuntu.com/focal/libc6) # - libc version 2.31 (https://packages.ubuntu.com/focal/libc6)
# #
# CentOS Stream 9 EOL: 2027. https://www.centos.org/cl-vs-cs/#end-of-life # CentOS Stream 9 EOL: 2027. https://www.centos.org/cl-vs-cs/#end-of-life
# #
# - libgcc version 12.2.1 (https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/)
# - libc version 2.34 (https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/) # - libc version 2.34 (https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/)
# #
# See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html for more info.
MAX_VERSIONS = { MAX_VERSIONS = {
'GCC': (7,0,0),
'GLIBC': { 'GLIBC': {
lief.ELF.ARCH.X86_64: (2,31), lief.ELF.ARCH.X86_64: (2,31),
lief.ELF.ARCH.ARM: (2,31), lief.ELF.ARCH.ARM: (2,31),
@@ -40,7 +35,6 @@ MAX_VERSIONS = {
lief.ELF.ARCH.PPC64: (2,31), lief.ELF.ARCH.PPC64: (2,31),
lief.ELF.ARCH.RISCV: (2,31), lief.ELF.ARCH.RISCV: (2,31),
}, },
'LIBATOMIC': (1,0),
'V': (0,5,0), # xkb (bitcoin-qt only) 'V': (0,5,0), # xkb (bitcoin-qt only)
} }
@@ -93,11 +87,9 @@ ELF_ABIS: dict[lief.ELF.ARCH, dict[lief.Header.ENDIANNESS, list[int]]] = {
# Allowed NEEDED libraries # Allowed NEEDED libraries
ELF_ALLOWED_LIBRARIES = { ELF_ALLOWED_LIBRARIES = {
# bitcoind and bitcoin-qt # bitcoind and bitcoin-qt
'libgcc_s.so.1', # GCC base support
'libc.so.6', # C library 'libc.so.6', # C library
'libpthread.so.0', # threading 'libpthread.so.0', # threading
'libm.so.6', # math library 'libm.so.6', # math library
'libatomic.so.1',
'ld-linux-x86-64.so.2', # 64-bit dynamic linker 'ld-linux-x86-64.so.2', # 64-bit dynamic linker
'ld-linux.so.2', # 32-bit dynamic linker 'ld-linux.so.2', # 32-bit dynamic linker
'ld-linux-aarch64.so.1', # 64-bit ARM dynamic linker 'ld-linux-aarch64.so.1', # 64-bit ARM dynamic linker