Merge bitcoin/bitcoin#35877: build: ci/doc win64-cross build via nix

fa8762da62 build: ci/doc win64-cross build via nix (MarcoFalke)
fafe7205cc doc: Clarify that cygwin/msys2 are not tested/supported (MarcoFalke)

Pull request description:

  Release cross-builds to win64 are done in guix. There are also docs to use Debian/Ubuntu for those cross-builds and this approach is used in CI. However, there are many problems:

  * The CI is intended to mirror the guix build, but often it is not possible to find the major versions used for mingw and GCC in the guix build in the `apt` packages for an LTS distro.
  * Users on older distro releases may lack released bugfixes, such as 8e06daa36d in mingw 13  (e.g. Debian Trixie with mingw 12, https://packages.debian.org/trixie/mingw-w64-x86-64-dev).
  * When using the UCRT variant of the build, this uncovers bugs such as https://bugs.launchpad.net/ubuntu/+source/mingw-w64/+bug/2106420 or https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1121403.

  So add a way to use nix to do the cross build. This allows to closer mimic the guix build.

  Also, clarify that cygwin/msys2 are not tested/supported.

ACKs for top commit:
  willcl-ark:
    reACK fa8762da62
  hebasto:
    re-ACK fa8762da62.

Tree-SHA512: de94f8bc4bb6ed9a75352cd909aa227c5954e336bf9b14969d7412b5cedfbe6cd6b2d8b476d5b1b0bcfc93bdb32fc229015855082350c8c507189e34b9b3ef3f
This commit is contained in:
merge-script
2026-08-20 15:26:53 +01:00
8 changed files with 79 additions and 8 deletions

View File

@@ -0,0 +1,45 @@
# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
{ pkgs ? import (builtins.fetchTarball {
# Pin, to keep the versions of the toolchain aligned with the versions used by Guix.
url = "https://github.com/NixOS/nixpkgs/archive/531670d871c0e29724a02f3cbcac170adc65b58c.tar.gz";
}) {} }:
let
host = builtins.getEnv "HOST";
crossPkgs = if host == "x86_64-w64-mingw32ucrt"
then pkgs.pkgsCross.ucrt64
else if host == "x86_64-w64-mingw32"
then pkgs.pkgsCross.mingwW64
else throw "Unsupported HOST: ${host}";
toolchain = crossPkgs.stdenv.cc.targetPrefix;
pthreads = crossPkgs.windows.pthreads;
in
pkgs.mkShellNoCC {
packages = [
crossPkgs.gcc14
pkgs.nsis
];
shellHook = ''
export NIX_CFLAGS_COMPILE="-isystem ${pthreads}/include $NIX_CFLAGS_COMPILE"
export NIX_LDFLAGS="-L${pthreads}/lib $NIX_LDFLAGS"
export CC=$(command -v ${toolchain}gcc)
export CXX=$(command -v ${toolchain}g++)
export LD=$(command -v ${toolchain}ld)
export AR=$(command -v ${toolchain}ar)
export AS=$(command -v ${toolchain}as)
export RANLIB=$(command -v ${toolchain}ranlib)
export NM=$(command -v ${toolchain}nm)
export STRIP=$(command -v ${toolchain}strip)
export OBJCOPY=$(command -v ${toolchain}objcopy)
export OBJDUMP=$(command -v ${toolchain}objdump)
export READELF=$(command -v ${toolchain}readelf)
export SIZE=$(command -v ${toolchain}size)
export WINDRES=$(command -v ${toolchain}windres)
export RC=$(command -v ${toolchain}windres)
'';
}