Skip to content

Commit 35d67df

Browse files
committed
build(guix): add x86_64-pc-windows-msvc cross-compilation
Adds a fourth reproducibility target: the MSVC ABI Windows build that CKB's CI currently produces via a Visual Studio runner. Cross-compiled from Linux using clang-cl + lld-link and an xwin-extracted Microsoft SDK (user-provided at depends/SDKs/msvc-vs17-sdk10.0.22621, same pattern as the Apple SDK for darwin). What changes: * manifest.scm — a (string-suffix? "-pc-windows-msvc" target) cond branch that pulls in clang-toolchain-20, lld-20, rust-src-pkg, and zip. rust-src-pkg was inlined in the darwin branch; it's now a top-level definition shared between darwin and windows-msvc because both need the Rust source to build library/std from scratch via x.py. * guix-build — x86_64-pc-windows-msvc in SUPPORTED_HOSTS; MSVC SDK detection block modelled on OSX_SDK; --share the SDK into the guix container and pass MSVC_SDK into the environment. * libexec/build.sh — new HOST case with clang-cl as REAL_CC and an lld-link wrapper (cross-lld-link) that injects /LIBPATH: for the xwin SDK lib directories so neither x.py nor rustc has to know the paths. x.py builds library/std from source using the same pattern as darwin (config.toml, checksum regen, host rustlib copy). The host rustlib copy now chmod -R u+w so subsequent `rm -rf distsrc` can clean up the /gnu/store-read-only files (latent bug: also affected darwin on reruns). RUSTFLAGS carries /Brepro and /DEBUG:NONE for a deterministic PE. * libexec/rust-linker.sh — dedicated *-pc-windows-msvc case that forwards rustc's linker args verbatim to lld-link. The previous *windows* branch is kept for MinGW and now explicitly excludes msvc (the two take different flag dialects — GNU-style -Wl,... vs MSVC /FLAG). Patch pipeline refactor (prerequisite): * Replace the sed-based patch_vendored_crate with a helper, apply_vendored_patch, that applies a real .patch file to a vendored crate directory and refreshes .cargo-checksum.json afterwards so cargo --frozen accepts the modified files. The existing rocksdb-cross-compile-platform.patch was stale (wrong hunk line counts, also semantically incorrect for darwin) — replaced with ckb-librocksdb-sys-cross-compile.patch, regenerated from a real git diff. * New patches/ckb-vm-msvc-cc-env.patch: ckb-vm 0.24.14's build.rs hardcodes build.compiler("gcc") for its is_msvc branch (to route its GNU AT&T-syntax execute_x64.S through a GNU assembler, which works on a native Windows machine that also has MinGW-w64's gcc installed alongside cl.exe). For cross-compile from Linux, "gcc" resolves to the host's Linux cc which cannot emit MSVC COFF. The patch adds a CKB_VM_ASM_CC env-var override — build.sh sets it to clang-cl, which handles GNU AT&T .S via LLVM's integrated assembler and produces valid MSVC-ABI COFF. Reproducibility verified: x86_64-pc-windows-msvc: e31f5af8e04efde939f09d66cc3b1a77534f1cf575f5f9afc36894bdbbdd6226 - host run 1, host run 2, docker run: all identical The existing four targets are unaffected by the patch-pipeline refactor (mingw re-verified post-refactor at 39901c3e..., matching the pre-refactor hash byte-for-byte; linux/aarch64-linux never hit that code path). The xwin SDK is user-provided. The release flow documents pinning \`xwin --manifest-version 17 --sdk-version 10.0.22621\` — two xwin extractions from the same pin produce byte-identical trees (5547 files + 2895 symlinks, all matching), so users can either re-run xwin or consume a pre-extracted tarball. Microsoft's Visual Studio Build Tools EULA applies to the SDK; xwin's --accept-license flag handles it.
1 parent e055c61 commit 35d67df

7 files changed

Lines changed: 422 additions & 93 deletions

File tree

contrib/guix/guix-build

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ EOF
8989
}
9090

9191
HOSTS="${HOSTS:-x86_64-unknown-linux-gnu}"
92-
SUPPORTED_HOSTS="x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-pc-windows-gnu aarch64-apple-darwin"
92+
SUPPORTED_HOSTS="x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu x86_64-pc-windows-gnu x86_64-pc-windows-msvc aarch64-apple-darwin"
9393
for host in $HOSTS; do
9494
if ! echo "$SUPPORTED_HOSTS" | grep -qw "$host"; then
9595
echo "ERR: Unsupported HOST '$host'. Supported: $SUPPORTED_HOSTS" >&2
@@ -119,7 +119,19 @@ for host in $HOSTS; do
119119
exit 1
120120
fi
121121
echo "Found macOS SDK at '${OSX_SDK}'"
122-
break
122+
;;
123+
*pc-windows-msvc*)
124+
MSVC_SDK="${SDK_PATH}/msvc-vs17-sdk10.0.22621"
125+
if [[ ! -d "$MSVC_SDK" ]]; then
126+
echo "ERR: MSVC SDK not found at '${MSVC_SDK}'."
127+
echo " Extract it via xwin, pinned to the same versions we verified reproducible:"
128+
echo " cargo install xwin"
129+
echo " xwin --accept-license --manifest-version 17 --sdk-version 10.0.22621 \\"
130+
echo " splat --output '${MSVC_SDK}'"
131+
echo " The resulting tree is governed by Microsoft's Visual Studio Build Tools EULA."
132+
exit 1
133+
fi
134+
echo "Found MSVC SDK at '${MSVC_SDK}'"
123135
;;
124136
esac
125137
done
@@ -207,9 +219,11 @@ for HOST in $HOSTS; do
207219
--share="$OUTDIR_BASE"=/outdir-base \
208220
--expose="$GIT_COMMON_DIR" \
209221
${OSX_SDK:+--share="$OSX_SDK"} \
222+
${MSVC_SDK:+--share="$MSVC_SDK"} \
210223
--cores="$JOBS" \
211224
-- env HOST="$MANIFEST_HOST" \
212225
${OSX_SDK:+OSX_SDK="$OSX_SDK"} \
226+
${MSVC_SDK:+MSVC_SDK="$MSVC_SDK"} \
213227
RUST_TARGET="$RUST_TARGET" \
214228
VERSION="$VERSION" \
215229
JOBS="$JOBS" \

0 commit comments

Comments
 (0)