Skip to content

Support cross-compiling and testing in WSL - #6404

Open
dscho wants to merge 3 commits into
git-for-windows:mainfrom
dscho:support-cross-compiling-and-testing-in-wsl
Open

Support cross-compiling and testing in WSL#6404
dscho wants to merge 3 commits into
git-for-windows:mainfrom
dscho:support-cross-compiling-and-testing-in-wsl

Conversation

@dscho

@dscho dscho commented Sep 9, 2026

Copy link
Copy Markdown
Member

When developing Git for Windows, I often found the speed with which MSYS2 tools like make.exe and bash.exe operate a bit taxing for my impatience. I always dreamed of cross-compiling, and with an AI-assisted exploration (because I am a slow typer and sometimes even a slow reader), I was finally able to reach that goal.

I'm not sure how useful this will be to others, so I'm offering this not as the Git for Windows maintainer, but as a contributor with the clear understanding that I won't be mad if people argue against merging this into main.

When cross-compiling Git for Windows under Linux, the generated build
options embed a Linux template path that the Git SDK Bash cannot use (to
that Bash, the Linux paths look like UNC paths of the form
`//wsl.localhost/Ubuntu/home/git-dev/src/git`).

This could be accommodated by editing the `bin-wrappers/*` files
manually, but those changes would be lost when `make` regenerates the
files.

Allow the hard-coded value to be overridden via the environment variable
`GIT_TEST_TEMPLATE_DIR` so that an SDK-readable path can be specified.

Assisted-by: GPT-6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
WSL does not automatically forward all environment variables to Windows
executables. The `WSLENV` variable controls which ones are forwarded.

Also, conflicting `PATH` and `Path` values can select an installed Git
in SDK subprocesses, and test repositories appear as non-local UNC
paths.

Provide opt-in `GIT_TEST_WSL=1` support for checking Windows
cross-builds from WSL without hand-editing generated wrappers after each
regeneration. Leave the default wrapper behavior unchanged.

Assisted-by: GPT-6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Due to its heritage, Git works best on Linux. Git for Windows does its
best to accommodate for the ecosystem expected by Git (also for building
Git), but Linux is still the platform where developing Git is the
easiest.

To help with developing Git for Windows, we can use the Windows
Subsystem for Linux (WSL, pronounced like "whistle"), if we
cross-compile. With the changes leading up to this commit, we also have
the infrastructure to allow running the tests in WSL, using the WSL Bash
with the cross-compiled `git.exe`.

For some tests, using WSL Bash cannot work (or does not test the
actually supported scenario in a full Git for Windows installation); To
support such circumstances, the built `git.exe` can also be tested using
a Git SDK Bash from a Git for Windows SDK installed on a Windows drive.

Assisted-by: GPT-6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant