Merge #17595: guix: Enable building for x86_64-w64-mingw32 target

a35e3235891d35daa167116cc70340140e883f06 guix: Appease travis. (Carl Dong)
0b66d22da5f53640e22f05adf880782c613e6d0f guix: Use gcc-9 for mingw-w64 instead of 8 (Carl Dong)
ba0b99bdd613ba7f17c6247ece3001e1b44759a3 guix: Don't set MINGW_HAS_SECURE_API CFLAG in depends (Carl Dong)
93439a71eda49fb69f1e82966a23a946733aa6fa guix: Bump to upstream commit with mingw-w64 changes (Carl Dong)
35a96792dda9e78165b1598aeac7b2ab759e7be5 guix: Check mingw symbols, improve SSP fix docs (Carl Dong)
449d8fe25bbe25daacfc67aa89ca32b0a3254c5a guix: Expand on INT trap message (Carl Dong)
3f1f03c67a8e9edf487f08d272adb18b0a3942c8 guix: Spelling fixes (Carl Dong)
ff821dd2a1c600488d11e7d9a20e9179ecc9144b guix: Reinstate make-ssp-fixed-gcc (Carl Dong)
360a9e0ad50a36ec79a1a160dbed3966689fd41c guix: Bump time-machine for mingw-w64 patches (Carl Dong)
93e41b7e3b54c17fd1b4c61ee95fc0dc2827e954 guix: Use gcc-8 for mingw-w64 instead of 7 (Carl Dong)
ef4f7e4c45c60a69406134122f091c77c6ef740f guix: Set the well-known timezone env var (Carl Dong)
acf4b3b3b5accf60a19441a0298ef27001b78e72 guix: Make x86_64-w64-mingw32 builds reproducible (Carl Dong)
c4cce00eac691625b78b92f7dba0b7f57def19e5 guix: Remove dead links from README. (Carl Dong)
df953a4c9a6143f45864757b706c88b6fa70545a guix: Appease shellcheck. (Carl Dong)
91897c95e191d293eb27d8af15cbeafc5b8f3895 guix: Improve guix-build.sh documentation (Carl Dong)
570d769c6c59b9f6d1a2b95b2ed60432cb33b3ba guix: Build support for Windows (Carl Dong)

Pull request description:

  ~~Based on: https://github.com/bitcoin/bitcoin/pull/16519~~
  Based on: #17933 (Time Machines are... shall we say... superior 😁)

  This PR allows us to perform Guix builds for the `x86_64-w64-mingw32` target. We do this _without_ splitting up the build script like we do in Gitian by using this newfangled alien technology called `case` statements. (This is WIP and might be changed to `if` statements soon)

ACKs for top commit:
  fanquake:
    ACK a35e3235891d35daa167116cc70340140e883f06 2/3

Tree-SHA512: c471951c23eb2cda919a71285d8b8f2580cb20f09d5db17b53e13dbd8813e01b3e7a83ea848e4913fd0f2bc12c6c133c5f76b54e65c0d89fed4dfd2e0be19875
This commit is contained in:
fanquake 2020-04-12 18:08:46 +08:00 committed by PastaPastaPasta
parent 355a735e78
commit dff599acff
5 changed files with 338 additions and 109 deletions

View File

@ -220,8 +220,6 @@ repository and will likely put one up soon.
[guix/env-setup]: https://www.gnu.org/software/guix/manual/en/html_node/Build-Environment-Setup.html [guix/env-setup]: https://www.gnu.org/software/guix/manual/en/html_node/Build-Environment-Setup.html
[guix/substitutes]: https://www.gnu.org/software/guix/manual/en/html_node/Substitutes.html [guix/substitutes]: https://www.gnu.org/software/guix/manual/en/html_node/Substitutes.html
[guix/substitute-server-auth]: https://www.gnu.org/software/guix/manual/en/html_node/Substitute-Server-Authorization.html [guix/substitute-server-auth]: https://www.gnu.org/software/guix/manual/en/html_node/Substitute-Server-Authorization.html
[guix/inferiors]: https://www.gnu.org/software/guix/manual/en/html_node/Inferiors.html
[guix/channels]: https://www.gnu.org/software/guix/manual/en/html_node/Channels.html
[guix/time-machine]: https://guix.gnu.org/manual/en/html_node/Invoking-guix-time_002dmachine.html [guix/time-machine]: https://guix.gnu.org/manual/en/html_node/Invoking-guix-time_002dmachine.html
[debian/guix-package]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=850644 [debian/guix-package]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=850644

View File

@ -13,33 +13,106 @@ make -C "${PWD}/depends" -j"$MAX_JOBS" download ${V:+V=1} ${SOURCES_PATH:+SOURCE
# Determine the reference time used for determinism (overridable by environment) # Determine the reference time used for determinism (overridable by environment)
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(git log --format=%at -1)}" SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(git log --format=%at -1)}"
# Execute "$@" in a pinned, possibly older version of Guix, for reproducibility
# across time.
time-machine() { time-machine() {
guix time-machine --url=https://github.com/dongcarl/guix.git \ guix time-machine --url=https://github.com/dongcarl/guix.git \
--commit=b3a7c72c8b2425f8ddb0fc6e3b1caeed40f86dee \ --commit=b066c25026f21fb57677aa34692a5034338e7ee3 \
-- "$@" -- "$@"
} }
# Deterministically build Bitcoin Core for HOSTs (overriable by environment) # Function to be called when building for host ${1} and the user interrupts the
for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu}; do # build
int_trap() {
cat << EOF
** INT received while building ${1}, you may want to clean up the relevant
output, deploy, and distsrc-* directories before rebuilding
Hint: To blow everything away, you may want to use:
$ git clean -xdff --exclude='/depends/SDKs/*'
Specifically, this will remove all files without an entry in the index,
excluding the SDK directory. Practically speaking, this means that all ignored
and untracked files and directories will be wiped, allowing you to start anew.
EOF
}
# Deterministically build Bitcoin Core for HOSTs (overridable by environment)
# shellcheck disable=SC2153
for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu x86_64-w64-mingw32}; do
# Display proper warning when the user interrupts the build # Display proper warning when the user interrupts the build
trap 'echo "** INT received while building ${host}, you may want to clean up the relevant output and distsrc-* directories before rebuilding"' INT trap 'int_trap ${host}' INT
# Run the build script 'contrib/guix/libexec/build.sh' in the build (
# container specified by 'contrib/guix/manifest.scm' # Required for 'contrib/guix/manifest.scm' to output the right manifest
# shellcheck disable=SC2086 # for the particular $HOST we're building for
time-machine environment --manifest="${PWD}/contrib/guix/manifest.scm" \ export HOST="$host"
--container \
--pure \ # Run the build script 'contrib/guix/libexec/build.sh' in the build
--no-cwd \ # container specified by 'contrib/guix/manifest.scm'.
--share="$PWD"=/bitcoin \ #
${SOURCES_PATH:+--share="$SOURCES_PATH"} \ # Explanation of `guix environment` flags:
${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \ #
-- env HOST="$host" \ # --container run command within an isolated container
MAX_JOBS="$MAX_JOBS" \ #
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ # Running in an isolated container minimizes build-time differences
${V:+V=1} \ # between machines and improves reproducibility
${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \ #
bash -c "cd /bitcoin && bash contrib/guix/libexec/build.sh" # --pure unset existing environment variables
#
# Same rationale as --container
#
# --no-cwd do not share current working directory with an
# isolated container
#
# When --container is specified, the default behavior is to share
# the current working directory with the isolated container at the
# same exact path (e.g. mapping '/home/satoshi/bitcoin/' to
# '/home/satoshi/bitcoin/'). This means that the $PWD inside the
# container becomes a source of irreproducibility. --no-cwd disables
# this behaviour.
#
# --share=SPEC for containers, share writable host file system
# according to SPEC
#
# --share="$PWD"=/bitcoin
#
# maps our current working directory to /bitcoin
# inside the isolated container, which we later cd
# into.
#
# While we don't want to map our current working directory to the
# same exact path (as this introduces irreproducibility), we do want
# it to be at a _fixed_ path _somewhere_ inside the isolated
# container so that we have something to build. '/bitcoin' was
# chosen arbitrarily.
#
# ${SOURCES_PATH:+--share="$SOURCES_PATH"}
#
# make the downloaded depends sources path available
# inside the isolated container
#
# The isolated container has no network access as it's in a
# different network namespace from the main machine, so we have to
# make the downloaded depends sources available to it. The sources
# should have been downloaded prior to this invocation.
#
# shellcheck disable=SC2086
time-machine environment --manifest="${PWD}/contrib/guix/manifest.scm" \
--container \
--pure \
--no-cwd \
--share="$PWD"=/bitcoin \
${SOURCES_PATH:+--share="$SOURCES_PATH"} \
${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
-- env HOST="$host" \
MAX_JOBS="$MAX_JOBS" \
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \
${V:+V=1} \
${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"} \
bash -c "cd /bitcoin && bash contrib/guix/libexec/build.sh"
)
done done

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
export LC_ALL=C export LC_ALL=C
set -e -o pipefail set -e -o pipefail
export TZ=UTC
# Check that environment variables assumed to be set by the environment are set # Check that environment variables assumed to be set by the environment are set
echo "Building for platform triple ${HOST:?not set} with reference timestamp ${SOURCE_DATE_EPOCH:?not set}..." echo "Building for platform triple ${HOST:?not set} with reference timestamp ${SOURCE_DATE_EPOCH:?not set}..."
@ -36,23 +37,41 @@ store_path() {
--expression='s|"[[:space:]]*$||' --expression='s|"[[:space:]]*$||'
} }
# Determine output paths to use in CROSS_* environment variables
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_LIBS=( "${CROSS_GCC}/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)
# Set environment variables to point Guix's cross-toolchain to the right # Set environment variables to point Guix's cross-toolchain to the right
# includes/libs for $HOST # includes/libs for $HOST
# case "$HOST" in
# NOTE: CROSS_C_INCLUDE_PATH is missing ${CROSS_GCC_LIB}/include-fixed, because *mingw*)
# the limits.h in it is missing a '#include_next <limits.h>' # Determine output paths to use in CROSS_* environment variables
# CROSS_GLIBC="$(store_path "mingw-w64-x86_64-winpthreads")"
export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${CROSS_GLIBC}/include:${CROSS_KERNEL}/include" CROSS_GCC="$(store_path "gcc-cross-${HOST}")"
export CROSS_CPLUS_INCLUDE_PATH="${CROSS_GCC}/include/c++:${CROSS_GCC}/include/c++/${HOST}:${CROSS_GCC}/include/c++/backward:${CROSS_C_INCLUDE_PATH}" CROSS_GCC_LIBS=( "${CROSS_GCC}/lib/gcc/${HOST}"/* ) # This expands to an array of directories...
export CROSS_LIBRARY_PATH="${CROSS_GCC}/lib:${CROSS_GCC}/${HOST}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib:${CROSS_GLIBC_STATIC}/lib" CROSS_GCC_LIB="${CROSS_GCC_LIBS[0]}" # ...we just want the first one (there should only be one)
NATIVE_GCC="$(store_path gcc-glibc-2.27-toolchain)"
export LIBRARY_PATH="${NATIVE_GCC}/lib:${NATIVE_GCC}/lib64"
export CPATH="${NATIVE_GCC}/include"
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:${CROSS_GCC}/${HOST}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib"
;;
*linux*)
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_LIBS=( "${CROSS_GCC}/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)
# NOTE: CROSS_C_INCLUDE_PATH is missing ${CROSS_GCC_LIB}/include-fixed, because
# the limits.h in it is missing a '#include_next <limits.h>'
export CROSS_C_INCLUDE_PATH="${CROSS_GCC_LIB}/include:${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:${CROSS_GCC}/${HOST}/lib:${CROSS_GCC_LIB}:${CROSS_GLIBC}/lib:${CROSS_GLIBC_STATIC}/lib"
;;
*)
exit 1 ;;
esac
# Sanity check CROSS_*_PATH directories # Sanity check CROSS_*_PATH directories
IFS=':' read -ra PATHS <<< "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}" IFS=':' read -ra PATHS <<< "${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
@ -74,16 +93,20 @@ export GUIX_LD_WRAPPER_DISABLE_RPATH=yes
[ -e /usr/bin/env ] || ln -s --no-dereference "$(command -v env)" /usr/bin/env [ -e /usr/bin/env ] || ln -s --no-dereference "$(command -v env)" /usr/bin/env
# Determine the correct value for -Wl,--dynamic-linker for the current $HOST # Determine the correct value for -Wl,--dynamic-linker for the current $HOST
glibc_dynamic_linker=$( case "$HOST" in
case "$HOST" in *linux*)
i686-linux-gnu) echo /lib/ld-linux.so.2 ;; glibc_dynamic_linker=$(
x86_64-linux-gnu) echo /lib64/ld-linux-x86-64.so.2 ;; case "$HOST" in
arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;; i686-linux-gnu) echo /lib/ld-linux.so.2 ;;
aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;; x86_64-linux-gnu) echo /lib64/ld-linux-x86-64.so.2 ;;
riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;; arm-linux-gnueabihf) echo /lib/ld-linux-armhf.so.3 ;;
*) exit 1 ;; aarch64-linux-gnu) echo /lib/ld-linux-aarch64.so.1 ;;
esac riscv64-linux-gnu) echo /lib/ld-linux-riscv64-lp64d.so.1 ;;
) *) exit 1 ;;
esac
)
;;
esac
# Environment variables for determinism # Environment variables for determinism
export QT_RCC_TEST=1 export QT_RCC_TEST=1
@ -136,11 +159,27 @@ DISTNAME="$(basename "$SOURCEDIST" '.tar.gz')"
# Binary Tarball Building # # Binary Tarball Building #
########################### ###########################
# Similar flags to Gitian # CONFIGFLAGS
CONFIGFLAGS="--enable-glibc-back-compat --enable-reduce-exports --disable-bench --disable-gui-tests" CONFIGFLAGS="--enable-reduce-exports --disable-bench --disable-gui-tests"
HOST_CFLAGS="-O2 -g -ffile-prefix-map=${PWD}=." case "$HOST" in
HOST_CXXFLAGS="-O2 -g -ffile-prefix-map=${PWD}=." *linux*) CONFIGFLAGS+=" --enable-glibc-back-compat" ;;
HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$glibc_dynamic_linker -static-libstdc++" esac
# CFLAGS
HOST_CFLAGS="-O2 -g"
case "$HOST" in
*linux*) HOST_CFLAGS+=" -ffile-prefix-map=${PWD}=." ;;
*mingw*) HOST_CFLAGS+=" -fno-ident" ;;
esac
# CXXFLAGS
HOST_CXXFLAGS="$HOST_CFLAGS"
# LDFLAGS
case "$HOST" in
*linux*) HOST_LDFLAGS="-Wl,--as-needed -Wl,--dynamic-linker=$glibc_dynamic_linker -static-libstdc++" ;;
*mingw*) HOST_LDFLAGS="-Wl,--no-insert-timestamp" ;;
esac
# Make $HOST-specific native binaries from depends available in $PATH # Make $HOST-specific native binaries from depends available in $PATH
export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}" export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
@ -160,7 +199,7 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
${CONFIGFLAGS} \ ${CONFIGFLAGS} \
CFLAGS="${HOST_CFLAGS}" \ CFLAGS="${HOST_CFLAGS}" \
CXXFLAGS="${HOST_CXXFLAGS}" \ CXXFLAGS="${HOST_CXXFLAGS}" \
LDFLAGS="${HOST_LDFLAGS}" ${HOST_LDFLAGS:+LDFLAGS="${HOST_LDFLAGS}"}
sed -i.old 's/-lstdc++ //g' {./,src/dashbls/,src/secp256k1/}{config.status,libtool} sed -i.old 's/-lstdc++ //g' {./,src/dashbls/,src/secp256k1/}{config.status,libtool}
@ -170,9 +209,21 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
# Perform basic ELF security checks on a series of executables. # Perform basic ELF security checks on a series of executables.
make -C src --jobs=1 check-security ${V:+V=1} make -C src --jobs=1 check-security ${V:+V=1}
# Check that executables only contain allowed gcc, glibc and libstdc++
# version symbols for Linux distro back-compatibility. case "$HOST" in
make -C src --jobs=1 check-symbols ${V:+V=1} *linux*|*mingw*)
# Check that executables only contain allowed gcc, glibc and libstdc++
# version symbols for Linux distro back-compatibility.
make -C src --jobs=1 check-symbols ${V:+V=1}
;;
esac
# Make the os-specific installers
case "$HOST" in
*mingw*)
make deploy ${V:+V=1}
;;
esac
# Setup the directory where our Bitcoin Core build for HOST will be # Setup the directory where our Bitcoin Core build for HOST will be
# installed. This directory will also later serve as the input for our # installed. This directory will also later serve as the input for our
@ -181,9 +232,21 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
mkdir -p "${INSTALLPATH}" mkdir -p "${INSTALLPATH}"
# Install built Bitcoin Core to $INSTALLPATH # Install built Bitcoin Core to $INSTALLPATH
make install DESTDIR="${INSTALLPATH}" ${V:+V=1} make install DESTDIR="${INSTALLPATH}" ${V:+V=1}
case "$HOST" in
*mingw*)
cp -f --target-directory="$OUTDIR" ./*-setup-unsigned.exe
;;
esac
( (
cd installed cd installed
case "$HOST" in
*mingw*)
mv --target-directory="$DISTNAME"/lib/ "$DISTNAME"/bin/*.dll
;;
esac
# Prune libtool and object archives # Prune libtool and object archives
find . -name "lib*.la" -delete find . -name "lib*.la" -delete
find . -name "lib*.a" -delete find . -name "lib*.a" -delete
@ -197,19 +260,60 @@ export PATH="${BASEPREFIX}/${HOST}/native/bin:${PATH}"
find "${DISTNAME}/lib" -type f -print0 find "${DISTNAME}/lib" -type f -print0
} | xargs -0 -n1 -P"$MAX_JOBS" -I{} "${DISTSRC}/contrib/devtools/split-debug.sh" {} {} {}.dbg } | xargs -0 -n1 -P"$MAX_JOBS" -I{} "${DISTSRC}/contrib/devtools/split-debug.sh" {} {} {}.dbg
cp "${DISTSRC}/doc/README.md" "${DISTNAME}/" case "$HOST" in
*mingw*)
cp "${DISTSRC}/doc/README_windows.txt" "${DISTNAME}/readme.txt"
;;
*linux*)
cp "${DISTSRC}/doc/README.md" "${DISTNAME}/"
;;
esac
# Finally, deterministically produce {non-,}debug binary tarballs ready # Finally, deterministically produce {non-,}debug binary tarballs ready
# for release # for release
find "${DISTNAME}" -not -name "*.dbg" -print0 \ case "$HOST" in
| sort --zero-terminated \ *mingw*)
| tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \ find "${DISTNAME}" -not -name "*.dbg" -print0 \
| gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}.tar.gz" \ | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}.tar.gz" && exit 1 ) find "${DISTNAME}" -not -name "*.dbg" \
find "${DISTNAME}" -name "*.dbg" -print0 \ | sort \
| sort --zero-terminated \ | zip -X@ "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}.zip" \
| tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \ || ( rm -f "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}.zip" && exit 1 )
| gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}-debug.tar.gz" \ find "${DISTNAME}" -name "*.dbg" -print0 \
|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}-debug.tar.gz" && exit 1 ) | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
find "${DISTNAME}" -name "*.dbg" \
| sort \
| zip -X@ "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}-debug.zip" \
|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}-debug.zip" && exit 1 )
;;
*linux*)
find "${DISTNAME}" -not -name "*.dbg" -print0 \
| sort --zero-terminated \
| tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \
| gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}.tar.gz" \
|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}.tar.gz" && exit 1 )
find "${DISTNAME}" -name "*.dbg" -print0 \
| sort --zero-terminated \
| tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \
| gzip -9n > "${OUTDIR}/${DISTNAME}-${HOST}-debug.tar.gz" \
|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST}-debug.tar.gz" && exit 1 )
;;
esac
) )
) )
case "$HOST" in
*mingw*)
cp -rf --target-directory=. contrib/windeploy
(
cd ./windeploy
mkdir unsigned
cp --target-directory=unsigned/ "$OUTDIR"/bitcoin-*-setup-unsigned.exe
find . -print0 \
| sort --zero-terminated \
| tar --create --no-recursion --mode='u+rw,go+r-w,a+X' --null --files-from=- \
| gzip -9n > "${OUTDIR}/${DISTNAME}-win-unsigned.tar.gz" \
|| ( rm -f "${OUTDIR}/${DISTNAME}-win-unsigned.tar.gz" && exit 1 )
)
;;
esac

View File

@ -10,18 +10,35 @@
(gnu packages file) (gnu packages file)
(gnu packages gawk) (gnu packages gawk)
(gnu packages gcc) (gnu packages gcc)
(gnu packages installers)
(gnu packages linux) (gnu packages linux)
(gnu packages mingw)
(gnu packages perl) (gnu packages perl)
(gnu packages pkg-config) (gnu packages pkg-config)
(gnu packages python) (gnu packages python)
(gnu packages shells) (gnu packages shells)
(gnu packages bison) (gnu packages bison)
(guix build-system gnu)
(guix build-system trivial) (guix build-system trivial)
(guix gexp) (guix gexp)
(guix packages) (guix packages)
(guix profiles) (guix profiles)
(guix utils)) (guix utils))
(define (make-ssp-fixed-gcc xgcc)
"Given a XGCC package, return a modified package that uses the SSP function
from glibc instead of from libssp.so. Our `symbol-check' script will complain if
we link against libssp.so, and thus will ensure that this works properly.
Taken from:
http://www.linuxfromscratch.org/hlfs/view/development/chapter05/gcc-pass1.html"
(package
(inherit xgcc)
(arguments
(substitute-keyword-arguments (package-arguments xgcc)
((#:make-flags flags)
`(cons "gcc_cv_libc_provides_ssp=yes" ,flags))))))
(define (make-gcc-rpath-link xgcc) (define (make-gcc-rpath-link xgcc)
"Given a XGCC package, return a modified package that replace each instance of "Given a XGCC package, return a modified package that replace each instance of
-rpath in the default system spec that's inserted by Guix with -rpath-link" -rpath in the default system spec that's inserted by Guix with -rpath-link"
@ -103,46 +120,78 @@ desirable for building Bitcoin Core release binaries."
base-libc base-libc
base-gcc)) base-gcc))
(define (make-gcc-with-pthreads gcc)
(package-with-extra-configure-variable gcc "--enable-threads" "posix"))
(define (make-mingw-pthreads-cross-toolchain target)
"Create a cross-compilation toolchain package for TARGET"
(let* ((xbinutils (cross-binutils target))
(pthreads-xlibc mingw-w64-x86_64-winpthreads)
(pthreads-xgcc (make-gcc-with-pthreads
(cross-gcc target
#:xgcc (make-ssp-fixed-gcc gcc-9)
#:xbinutils xbinutils
#:libc pthreads-xlibc))))
;; Define a meta-package that propagates the resulting XBINUTILS, XLIBC, and
;; XGCC
(package
(name (string-append target "-posix-toolchain"))
(version (package-version pthreads-xgcc))
(source #f)
(build-system trivial-build-system)
(arguments '(#:builder (begin (mkdir %output) #t)))
(propagated-inputs
`(("binutils" ,xbinutils)
("libc" ,pthreads-xlibc)
("gcc" ,pthreads-xgcc)))
(synopsis (string-append "Complete GCC tool chain for " target))
(description (string-append "This package provides a complete GCC tool
chain for " target " development."))
(home-page (package-home-page pthreads-xgcc))
(license (package-license pthreads-xgcc)))))
(packages->manifest (packages->manifest
(list ;; The Basics (append
bash-minimal (list ;; The Basics
which bash-minimal
coreutils which
util-linux coreutils
;; File(system) inspection util-linux
file ;; File(system) inspection
grep file
diffutils grep
findutils diffutils
;; File transformation findutils
patch ;; File transformation
gawk patch
sed gawk
;; Compression and archiving sed
tar ;; Compression and archiving
bzip2 tar
gzip bzip2
xz gzip
zlib xz
;; Build tools zlib
gnu-make ;; Build tools
libtool gnu-make
autoconf libtool
automake autoconf
pkg-config automake
bison pkg-config
;; Scripting bison
perl ;; Scripting
python-3.7 perl
;; Native gcc 9 toolchain targeting glibc 2.27 python-3.7
(make-gcc-toolchain gcc-9 glibc-2.27) ;; Native gcc 9 toolchain targeting glibc 2.27
;; Cross gcc 9 toolchains targeting glibc 2.27 (make-gcc-toolchain gcc-9 glibc-2.27))
(make-bitcoin-cross-toolchain "i686-linux-gnu") (let ((target (getenv "HOST")))
(make-bitcoin-cross-toolchain "x86_64-linux-gnu") (cond ((string-suffix? "-mingw32" target)
(make-bitcoin-cross-toolchain "aarch64-linux-gnu") ;; Windows
(make-bitcoin-cross-toolchain "arm-linux-gnueabihf") (list zip (make-mingw-pthreads-cross-toolchain "x86_64-w64-mingw32") nsis-x86_64))
;; The glibc 2.27 for riscv64 needs gcc 7 to successfully build (see: ((string-contains target "riscv64-linux-")
;; https://www.gnu.org/software/gcc/gcc-7/changes.html#riscv). The final (list (make-bitcoin-cross-toolchain "riscv64-linux-gnu"
;; toolchain is still a gcc 9 toolchain targeting glibc 2.27. #:base-gcc-for-libc gcc-7)))
(make-bitcoin-cross-toolchain "riscv64-linux-gnu" ((string-contains target "-linux-")
#:base-gcc-for-libc gcc-7))) (list (make-bitcoin-cross-toolchain target)))
(else '())))))

View File

@ -2,6 +2,11 @@ Name "@PACKAGE_NAME@ (64-bit)"
RequestExecutionLevel highest RequestExecutionLevel highest
SetCompressor /SOLID lzma SetCompressor /SOLID lzma
SetDateSave off
# Uncomment these lines when investigating reproducibility errors
#SetCompress off
#SetDatablockOptimize off
# General Symbol Definitions # General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)" !define REGKEY "SOFTWARE\$(^Name)"