Commit

86909a94db5d29b2277bfc54331801199cf3ccaf

ci(windows): build with Rust

The Windows runners used by Git's GitHub workflow's `windows-build` job
ship `rustup` plus a `*-pc-windows-msvc` default toolchain (see
https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
and
https://github.com/actions/partner-runner-images/blob/main/images/arm-windows-11-image.md),
but no precompiled `std` for `*-pc-windows-gnu` or
`*-pc-windows-gnullvm`. With the Makefile now picking a GCC-compatible
target triple based on `$(MSYSTEM)`, the build step needs that
precompiled `std` to be installed before invoking `make`, otherwise
`cargo build --target <triple>` fails to find a usable `std` for the
chosen target.

Add a step between the SDK setup and the `make` invocation that selects
the matching triple from `$MSYSTEM` (which
`git-for-windows/setup-git-for-windows-sdk` exports for every subsequent
step) and runs `rustup target add` for it. The mapping mirrors what
`config.mak.uname` derives from `$(MSYSTEM)` and `$(HOST_CPU)`, just
enumerated explicitly here since CI has direct knowledge of which MSYS2
subsystems the matrix actually exercises (`CLANGARM64` for the ARM64
runner, `MINGW64` for the x86_64 runner). Technically, we only need to
handle MINGW64 at present, but the switch to UCRT64 is imminent, and the
other case arms serve as a very fine documentation of what people should
do for other MSYSTEM values.

For a `staticlib` crate-type `cargo build` does not invoke an external
linker, so no further toolchain components (e.g. the `gnullvm` LLVM
linker) need to be installed; `rustup target add` alone is sufficient.

Assisted-by: Claude Opus 4.7
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin <johannes.schindelin@gmx.de> · 2026-09-13 15:57 UTC · committed by Junio C Hamano

Browse files
2 files changed, +24 −3
modified .github/workflows/main.yml
@@ -114,6 +114,30 @@ jobs:
114 114 steps:
115 115 - uses: actions/checkout@v6
116 116 - uses: git-for-windows/setup-git-for-windows-sdk@v2
117 + - name: Install GCC-compatible Rust target
118 + shell: bash
119 + run: |
120 + # The hosted Windows runners ship a rustup-managed Rust whose
121 + # default toolchain targets the MSVC ABI. That produces a
122 + # `gitcore.lib` which the MinGW GCC used by the rest of the
123 + # build cannot link. Install the precompiled `std` for a
124 + # GCC-compatible target triple matching the MSYS2 subsystem;
125 + # the Makefile selects the same triple via $(MSYSTEM) and
126 + # passes it to `cargo build --target`.
127 + case "$MSYSTEM" in
128 + CLANGARM64) target=aarch64-pc-windows-gnullvm ;;
129 + CLANG64) target=x86_64-pc-windows-gnullvm ;;
130 + CLANG32) target=i686-pc-windows-gnullvm ;;
131 + UCRT64) target=x86_64-pc-windows-gnu ;;
132 + MINGW64) target=x86_64-pc-windows-gnu ;;
133 + MINGW32) target=i686-pc-windows-gnu ;;
134 + *) echo "::error::Unsupported MSYSTEM: $MSYSTEM"; exit 1 ;;
135 + esac &&
136 + rustup target add "$target" &&
137 +
138 + # Ensure that cargo.exe is found even with the minimal SDK's restricted PATH
139 + CARGO="$(type -p cargo.exe)" &&
140 + echo "export PATH=\$PATH:${CARGO%/cargo.exe}" >>/etc/profile
117 141 - name: build
118 142 shell: bash
119 143 env:
modified ci/lib.sh
@@ -391,9 +391,6 @@ linux-asan-ubsan)
391 391 osx-meson)
392 392 MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain"
393 393 ;;
394 - windows-*)
395 - export NO_RUST=UnfortunatelyYes
396 - ;;
397 394 esac
398 395
399 396 MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"