chore(toolchain): no-sudo mingw-w64 i686 cross toolchain + smoke DLL

This commit is contained in:
ulw-execute committed 2026-11-28 03:25:37 -05:00
1 parent 259d2cb903
commit f01d0e65ac
4 files changed
+90

No files matched your search

Executable
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Source this to put the pinned no-sudo i686-w64-mingw32 cross toolchain + wine on PATH.
# See toolchain.lock for exact provenance (nixpkgs rev, package versions, store paths).
source "$HOME/.nix-profile/etc/profile.d/nix.sh" 2>/dev/null || true
export PATH="$HOME/.nix-profile/bin:$PATH"
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Cross-compiles tests/smoke/hello.c into a 32-bit Windows DLL using the pinned
# i686-w64-mingw32 toolchain. Run from the worktree root or this directory.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
# shellcheck source=/dev/null
source "$ROOT_DIR/activate.sh"
command -v i686-w64-mingw32-gcc >/dev/null || { echo "i686-w64-mingw32-gcc not found on PATH" >&2; exit 1; }
# The pinned i686-w64-mingw32-gcc (16.2.0) links its default startup objects
# against mcfgthread; that runtime lib ships as its own nix package
# (pkgsCross.mingw32.windows.mcfgthreads) rather than bundled in gcc's own
# search path, so point the linker at it explicitly.
MCFGTHREAD_LIB="/nix/store/g72bh3mrbh6gkh59axd2199js9kccxfs-mcfgthread-i686-w64-mingw32-2.5.1/lib"
cd "$SCRIPT_DIR"
i686-w64-mingw32-gcc -shared -o hello.dll hello.c -L"$MCFGTHREAD_LIB" -Wl,--out-implib,libhello.a
echo "Built: $SCRIPT_DIR/hello.dll"
+1
View File
@@ -0,0 +1 @@
__declspec(dllexport) int hello(void) { return 42; }
+63
View File
@@ -0,0 +1,63 @@
# toolchain.lock
# Pinned no-sudo i686-windows cross toolchain + wine, installed via user-space Nix
# (~/.nix-profile; no apt, no sudo, no daemon other than the user's own nix client).
#
# Reinstall exactly this set with (after sourcing ~/.nix-profile/etc/profile.d/nix.sh):
# NIX_CONFIG="extra-experimental-features = nix-command flakes" \
# nix profile install \
# github:NixOS/nixpkgs/619c39f6eac5d1ed6b8f073a9414baf7034b2356#pkgsCross.mingw32.buildPackages.binutils
# nix profile install --priority 11 \
# github:NixOS/nixpkgs/619c39f6eac5d1ed6b8f073a9414baf7034b2356#pkgsCross.mingw32.buildPackages.gcc
# nix profile install \
# github:NixOS/nixpkgs/619c39f6eac5d1ed6b8f073a9414baf7034b2356#gendef
# nix profile install \
# github:NixOS/nixpkgs/619c39f6eac5d1ed6b8f073a9414baf7034b2356#pkgsCross.mingw32.windows.mcfgthreads
# nix profile install \
# github:NixOS/nixpkgs/619c39f6eac5d1ed6b8f073a9414baf7034b2356#wine
# (gcc is installed last with --priority 11, i.e. lower precedence than binutils'
# default priority 10, because both wrapper derivations ship a conflicting
# i686-w64-mingw32-nm symlink; binutils' copy wins, gcc's unique files still link in.)
#
# nixpkgs pin
nixpkgs.type = github
nixpkgs.owner = NixOS
nixpkgs.repo = nixpkgs
nixpkgs.rev = 619c39f6eac5d1ed6b8f073a9414baf7034b2356
nixpkgs.narHash = sha256-3Xq+XlDu5l+UJ0cc+Jigs84+tz7Qu92NgXVHgJwC52M=
nixpkgs.resolvedUrl = https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1126808.619c39f6eac5/nixexprs.tar.zst
nixpkgs.flake.locked.narHash = sha256-oa2P5WZer1A4wuhatl92JyHHEjrrOdIyuvTuI5LUi9Q=
# Compiler choice: GCC (mingw-w64), NOT llvm-mingw / clang. Do not mix the two.
compiler = i686-w64-mingw32-gcc / i686-w64-mingw32-g++ (GCC 16.2.0, mingw-w64 14.0.0 headers/CRT)
[package] binutils (i686-w64-mingw32 cross binutils, provides dlltool/ar/nm/ld/as/objdump for the target)
flake-attr = legacyPackages.x86_64-linux.pkgsCross.mingw32.buildPackages.binutils
version = 2.46
store-path = /nix/store/ypw1imklip65354wky0dki0w89gi0i0p-i686-w64-mingw32-binutils-wrapper-2.46
/nix/store/mkc8rsfh38qpgfihrxy430y79g33mv3r-i686-w64-mingw32-binutils-2.46
[package] gcc (i686-w64-mingw32 cross C/C++ compiler)
flake-attr = legacyPackages.x86_64-linux.pkgsCross.mingw32.buildPackages.gcc
version = 16.2.0
store-path = /nix/store/x8zwwv7ajhcnp0iyy9qch2li4xr49yqa-i686-w64-mingw32-gcc-wrapper-16.2.0
/nix/store/8ypjm5h1hqs6b89yps8kbs16x7ihkva7-i686-w64-mingw32-gcc-16.2.0
[package] gendef (dumps .def files from DLL exports; mingw-w64 tools)
flake-attr = legacyPackages.x86_64-linux.gendef
version = 14.0.0
store-path = /nix/store/i55qn804ddjjg063d9hk8wb9yd7hnzg1-gendef-14.0.0
[package] mcfgthreads (mingw-w64 C11 threads runtime; GCC 16.2.0's i686-w64-mingw32
default link spec needs -lmcfgthread, which ships as this separate
nix package rather than bundled with the gcc derivation)
flake-attr = legacyPackages.x86_64-linux.pkgsCross.mingw32.windows.mcfgthreads
version = 2.5.1
store-path = /nix/store/g72bh3mrbh6gkh59axd2199js9kccxfs-mcfgthread-i686-w64-mingw32-2.5.1
note = tests/smoke/build.sh passes -L<this store path>/lib explicitly
[package] wine (user-space, loads/runs the built 32-bit PE on Linux)
flake-attr = legacyPackages.x86_64-linux.wine
version = 11.0
store-path = /nix/store/y952wc8l7vkn3yv9brgg3b3zkcim4541-wine-11.0
# PATH setup: source ./activate.sh (adds ~/.nix-profile/bin to PATH).