On Fri, 15 Aug 2025, Johannes Schindelin via GitGitGadget wrote:
From: Johannes Schindelin <johannes.schindelin@xxxxxx>
By default, Rust wants to build MS Visual C-compatible libraries on
Windows, because that is _the_ native C compiler.
Git is historically lacking in its MSVC support, and the official Git
for Windows versions are built using GCC instead. As a consequence, a
(subset of a) GCC toolchain is installed as part of the `windows-build`
job of every CI build.
Naturally, this requires adjustments in how Rust is called, most
importantly it requires installing support for a GCC-compatible build
target.
Let's make the necessary adjustment both in the CI-specific code that
installs Rust as well as in the Windows-specific configuration in
`config.mak.uname`.
Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
[en: Moved lib userenv handling to a later patch]
Signed-off-by: Ezekiel Newren <ezekielnewren@xxxxxxxxx>
---
ci/install-rust.sh | 3 +++
config.mak.uname | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/ci/install-rust.sh b/ci/install-rust.sh
index 141ceddb17cf..c22baa629ceb 100644
--- a/ci/install-rust.sh
+++ b/ci/install-rust.sh
@@ -28,6 +28,9 @@ if [ "$BITNESS" = "32" ]; then
$CARGO_HOME/bin/rustup default --force-non-host $RUST_VERSION || exit $?
else
$CARGO_HOME/bin/rustup default $RUST_VERSION || exit $?
+ if [ "$CI_OS_NAME" = "windows" ]; then
+ $CARGO_HOME/bin/rustup target add x86_64-pc-windows-gnu || exit $?
+ fi
fi
. $CARGO_HOME/env
diff --git a/config.mak.uname b/config.mak.uname
index 3e26bb074a4b..a22703284b56 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -727,19 +727,26 @@ ifeq ($(uname_S),MINGW)
prefix = /mingw32
HOST_CPU = i686
BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
+ CARGO_BUILD_TARGET = i686-pc-windows-gnu
endif
ifeq (MINGW64,$(MSYSTEM))
prefix = /mingw64
HOST_CPU = x86_64
BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
+ CARGO_BUILD_TARGET = x86_64-pc-windows-gnu
I've said it when Johannes originally sent this patch[1], but it bears
repeating: The *-pc-windows-gnu targets will pass CI, but would mean
raising the required Windows version from 8.1 to 10. We'd want to use
the *-win7-windows-gnu targets[2] to keep Windows 8.1 supported.
[1]
https://lore.kernel.org/git/pull.1980.git.git.1752784344.gitgitgadget@xxxxxxxxx/T/#ma10be2ed0a0e776b0af2fdd0de63d51ba51609e4
[2]
https://doc.rust-lang.org/nightly/rustc/platform-support/win7-windows-gnu.html
else ifeq (CLANGARM64,$(MSYSTEM))
prefix = /clangarm64
HOST_CPU = aarch64
BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
+ CARGO_BUILD_TARGET = aarch64-pc-windows-gnu
As I've also mentioned before [1], this target doesn't seem to exist. The
correct target seems to be aarch64-pc-windows-gnullvm. [3]
[3] https://doc.rust-lang.org/rustc/platform-support/windows-gnullvm.html
else
COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
BASIC_LDFLAGS += -Wl,--large-address-aware
endif
+
+ export CARGO_BUILD_TARGET
+ RUST_TARGET_DIR = rust/target/$(CARGO_BUILD_TARGET)/$(RUST_BUILD_MODE)
+
CC = gcc
COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
-fstack-protector-strong
--
gitgitgadget
Best regards
Matthias