Support cross-compiling and testing in WSL - #6404
Open
dscho wants to merge 3 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When developing Git for Windows, I often found the speed with which MSYS2 tools like
make.exeandbash.exeoperate 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.