Skip to content

Reinstate mingw-w64-git, synchronizing the package definition from Git for Windows#26470

Open
dscho wants to merge 4 commits intomsys2:masterfrom
dscho:upstream-git-for-windows
Open

Reinstate mingw-w64-git, synchronizing the package definition from Git for Windows#26470
dscho wants to merge 4 commits intomsys2:masterfrom
dscho:upstream-git-for-windows

Conversation

@dscho
Copy link
Contributor

@dscho dscho commented Nov 20, 2025

Ever since I moved Git for Windows from MSys to MSYS2 in 2015, I have dreamed of this: To share the identical package definition of mingw-w64-git with MSYS2. This will allow MSYS2 users to benefit from Git for Windows within their regular MSYS2 setup, while allowing existing Git for Windows users to continue using the official installer to install and upgrade.

This here PR is a vital part of the initiative laid out in #16383.

@dscho
Copy link
Contributor Author

dscho commented Nov 20, 2025

@ognevny I notice that the CLANGARM64 job does not build any packages. Is there any trick to this?

@ognevny
Copy link
Collaborator

ognevny commented Nov 20, 2025

@ognevny I notice that the CLANGARM64 job does not build any packages. Is there any trick to this?

I've put a suggestion in proper place. there was a missing field

@ognevny
Copy link
Collaborator

ognevny commented Nov 20, 2025

  1. by the way there was a compiler error about using 32-bit time. why is this important for GfW?
  2. git history seems not clean after rebase...

@dscho
Copy link
Contributor Author

dscho commented Nov 20, 2025

Whoops. Will of course drop them when cleaning up this PR branch.

@dscho
Copy link
Contributor Author

dscho commented Nov 20, 2025

  1. by the way there was a compiler error about using 32-bit time. why is this important for GfW?

You mean this:

D:/M/msys64/ucrt64/include/corecrt.h:128:2: error: #error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64
    128 | #error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64
        |  ^~~~~

Wow, that required some digging. That _USE_32BIT_TIME_T stems from git-for-windows/git@fa93bb2, i.e. way before we switched from MinGW to mingw-64. Let's see whether it is possible to drop this flag.

@dscho dscho force-pushed the upstream-git-for-windows branch from 66e13b0 to 191ac7e Compare November 20, 2025 10:59
@rimrul
Copy link
Contributor

rimrul commented Nov 20, 2025

Wow, that required some digging. That _USE_32BIT_TIME_T stems from git-for-windows/git@fa93bb2, i.e. way before we switched from MinGW to mingw-64.

Isn't this only part of the issue that config.mak.uname treats all native envs beside MINGW64 and CLANGARM64 as MINGW32?

@dscho
Copy link
Contributor Author

dscho commented Nov 20, 2025

Wow, that required some digging. That _USE_32BIT_TIME_T stems from git-for-windows/git@fa93bb2, i.e. way before we switched from MinGW to mingw-64.

Isn't this only part of the issue that config.mak.uname treats all native envs beside MINGW64 and CLANGARM64 as MINGW32?

It totally is. That's the reason for the -large-address-aware problem in UCRT64.

For now, I'd like to get the build green so as to know what has to be done, and then fix git-for-windows/git properly. Unfortunately, those fixes won't be in a tagged version immediately, but with a little bit of "luck", there will be a v2.52.1 anyway, and if I can get the fixes into the code base before that, we're good to go.

@dscho dscho force-pushed the upstream-git-for-windows branch from de1149a to 2bc1458 Compare November 20, 2025 16:46
dscho added a commit to dscho/git that referenced this pull request Nov 21, 2025
This option was added in fa93bb2 (MinGW: Fix stat definitions to
work with MinGW runtime version 4.0, 2013-09-11), i.e. a _long_ time
ago. So long, in fact, that it still targeted MinGW. But we switched to
mingw-w64 in 2015, which seems not to share the problem, and therefore
does not require a fix.

Even worse: This flag is incompatible with UCRT64, which we are about to
support by way of upstreaming `mingw-w64-git` to the MSYS2 project, see
msys2/MINGW-packages#26470 for details.

So let's send that option into its well-deserved retirement.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/MINGW-packages that referenced this pull request Nov 21, 2025
There are now a good deal of work-arounds for things in
git-for-windows/git that need to be adjusted before we can mark
msys2#26470 as ready for review.
Better develop the patches directly in the Git repository than playing
more of those `config.mak` and `sed` games.

This here commit will of course be dropped as soon as things work and
the git-for-windows/git patches made it into a tagged version of Git for
Windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/MINGW-packages that referenced this pull request Nov 21, 2025
There are now a good deal of work-arounds for things in
git-for-windows/git that need to be adjusted before we can mark
msys2#26470 as ready for review.
Better develop the patches directly in the Git repository than playing
more of those `config.mak` and `sed` games.

This here commit will of course be dropped as soon as things work and
the git-for-windows/git patches made it into a tagged version of Git for
Windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the upstream-git-for-windows branch from eaea93f to 394a6a5 Compare November 21, 2025 14:19
dscho added a commit to dscho/MINGW-packages that referenced this pull request Nov 21, 2025
There are now a good deal of work-arounds for things in
git-for-windows/git that need to be adjusted before we can mark
msys2#26470 as ready for review.
Better develop the patches directly in the Git repository than playing
more of those `config.mak` and `sed` games.

This here commit will of course be dropped as soon as things work and
the git-for-windows/git patches made it into a tagged version of Git for
Windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the upstream-git-for-windows branch from 394a6a5 to 6ebbd8a Compare November 21, 2025 17:17
@ognevny
Copy link
Collaborator

ognevny commented Nov 21, 2025

by the way, can we try to enable rust like in msys2/MSYS2-packages#5812? (but with mingw-w64-rust)

@rimrul
Copy link
Contributor

rimrul commented Nov 21, 2025

by the way, can we try to enable rust like in msys2/MSYS2-packages#5812? (but with mingw-w64-rust)

Could we keep that as a separate second step?
@dscho has mentioned wanting to keep the package definitions somewhat in sync between Msys2 and Git for Windows and we'll need some preparing for a mingw-w64-rust setup with *-win7-windows-gnu targets on the Git for Windows side.

@ognevny
Copy link
Collaborator

ognevny commented Nov 21, 2025

mingw-w64-rust setup with *-win7-windows-gnu targets on the Git for Windows side.

do you actually need it? I mean win7 target

@dscho
Copy link
Contributor Author

dscho commented Nov 21, 2025

by the way, can we try to enable rust like in msys2/MSYS2-packages#5812? (but with mingw-w64-rust)

Good idea! Rust won't stay optional forever, Git's planning on making it mandatory by the end of next year.

Maybe we should leave that for a follow-up PR, though. It'll take some work to get the fixes into Git for Windows, and I get the sense, after reading on the Git mailing list about the last-modified issues and about the :(optional) segfault, that Git v2.52.0 might not be the most robust, and there might be a v2.52.1 soon, which would be the perfect opportunity to integrate the fixes which I developed in this PR's context into git-for-windows/git and then into a tagged version.

In other words, Rust isn't my highest priority right now :-)

@ognevny
Copy link
Collaborator

ognevny commented Nov 21, 2025

no hurries with Rust, just a suggestion

@dscho
Copy link
Contributor Author

dscho commented Nov 21, 2025

mingw-w64-rust setup with *-win7-windows-gnu targets on the Git for Windows side.

do you actually need it?

Rust will be mandatory in Git soon and yes, we will need to keep supporting Windows 8.1 and I have been led to believe that this Rust toolchain version is the only one that could provide that support.

@rimrul
Copy link
Contributor

rimrul commented Nov 21, 2025

mingw-w64-rust setup with *-win7-windows-gnu targets on the Git for Windows side.

do you actually need it? I mean win7 target

Yes. We do intend to keep supporting Windows 8.1 for now, so it's either win7 targets on MINGW32 and MINGW64 (at least in Git for Windows, not necessarily in Msys2) or older rust.

@ognevny
Copy link
Collaborator

ognevny commented Nov 21, 2025

mingw-w64-rust setup with *-win7-windows-gnu targets on the Git for Windows side.

do you actually need it?

Rust will be mandatory in Git soon and yes, we will need to keep supporting Windows 8.1 and I have been led to believe that this Rust toolchain version is the only one that could provide that support.

in next years older Windows support seems less relevant... I guess there could be issues with maintaining separate target for older systems

edit: and it's only about MINGW{32,64}

@ognevny
Copy link
Collaborator

ognevny commented Feb 3, 2026

it seems you need to re-run updpkgsums

@dscho
Copy link
Contributor Author

dscho commented Feb 3, 2026

it seems you need to re-run updpkgsums

Of course ;-) I keep forgetting that.

I'd like to foster tighter collaboration between the Git for Windows and
the MSYS2 project, as I documented here:
msys2#16383

As part of that effort, here is the exact same package definition of the
`mingw-w64-git` package as Git for Windows uses, as per
https://github.com/git-for-window/MINGW-packages/commit/fa6b8ebc02
(Prepare some more for upstreaming `mingw-w64-git` to MSYS2 (git-for-windows#174),
2025-11-25).

Note: As part of this effort, I have split out the Git for
Windows-specific part from that package that would be highly
inappropriate in MSYS2's context: For example, Git for Windows comes
with a `git-bash.exe` in the top-level directory, and it also installs
its logo into `$MINGW_PREFIX/share/git/`. These now live in the
`mingw-w64-git-for-windows-addons` package.

This is not the first time that a `mingw-w64-git` package definition has
lived in this here repository: Six years ago, such a definition was
removed (as "deprecated"), in 446b69f (More cleanup for packages.
Move all packages not provided by pacman and deprecated to new repo
https://github.com/msys2/MINGW-packages-dev, 2019-06-03).

The chances of success are much better now, though: Git for Windows is
much more mature now, and already collaborates highly successfully with
the MSYS2 project in the msys2-runtime repository. So there is precedent
for fruitful and friendly working together. Besides, all of the blockers
are resolved that would have let Git's test suite fail due to
differences in the MSYS2 runtime or in other parts of the tree.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the upstream-git-for-windows branch from 13b6d77 to e452dfe Compare February 3, 2026 07:51
@dscho dscho marked this pull request as ready for review February 3, 2026 08:33
@dscho
Copy link
Contributor Author

dscho commented Feb 3, 2026

Finally! This is it, at long last: ready for review.

@ognevny
Copy link
Collaborator

ognevny commented Feb 3, 2026

for me it's fine. some nits like metadata can be added in later PRs. waiting for others...

@dscho
Copy link
Contributor Author

dscho commented Feb 3, 2026

some nits like metadata can be added in later PRs.

Cool, cool. I'll synchronize those changes back to Git for Windows so that the mingw-w64-git/ directories of MSYS2 and Git for Windows can be identical. That will allow me to add automation to easily keep MSYS2 up to date as part of Git for Windows' release process.

@ognevny ognevny requested a review from lazka February 3, 2026 10:36
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this pull request Feb 3, 2026
This option was added in fa93bb2 (MinGW: Fix stat definitions to
work with MinGW runtime version 4.0, 2013-09-11), i.e. a _long_ time
ago. So long, in fact, that it still targeted MinGW. But we switched to
mingw-w64 in 2015, which seems not to share the problem, and therefore
does not require a fix.

Even worse: This flag is incompatible with UCRT64, which we are about to
support by way of upstreaming `mingw-w64-git` to the MSYS2 project, see
msys2/MINGW-packages#26470 for details.

So let's send that option into its well-deserved retirement.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this pull request Feb 3, 2026
Every once in a while, there are bug reports in Git for Windows' bug
tracker that describe an issue running [inside MSYS2
proper](https://gitforwindows.org/install-inside-msys2-proper), totally
ignoring the big, honking warning on top of [the
page](https://gitforwindows.org/install-inside-msys2-proper) that spells
out clearly that this is an unsupported use case.

At the same time, we cannot easily deflect and say "just use MSYS2
directly" (and leave the "and stop pestering us" out). We cannot do that
because there is only an _MSYS_ `git` package in MSYS2 (i.e. a Git that
uses the quite slow POSIX emulation layer provided by the MSYS2
runtime), but no `mingw-w64-git` package (which would be equivalent in
speed to Git for Windows).

In msys2/MINGW-packages#26470, I am preparing to
change that. As part of that PR, I noticed and fixed a couple of issues
_in `git-for-windows/git` that prevented full support for
`mingw-w64-git` in MSYS2, such as problems with CLANG64 and UCRT64.

While at it, I simplified the entire setup to trust MSYS2's
`MINGW_PREFIX` & related environment variables instead of hard-coding
values like the installation prefix and what `MSYSTEM` to fall back on
if it is unset.
@lazka
Copy link
Member

lazka commented Feb 4, 2026

I'd prefer if the .install file would be dropped, at least for now.

It's depending on MINGW_PREFIX which is not the prefix of the package, but the environment you call pacman from, so installing is broken from the MSYS env, and broken when installing from a different env. The files it creates are not namespaced, so uninstalling might break another env. The first one can be fixed by having an .install file per env, like we do in all packages, the later I don't know, depends on what it's trying to achieve.

I get this when installing in MSYS:

mkdir: cannot create directory ‘’: No such file or directory
error: command failed to execute correctly

I get this when installing in the matching env:

cp: cannot stat '/clang64/share/git/compat-bash.exe': No such file or directory

Unrelated to that, uninstalling gave me:

rm: cannot remove '/proc/cygdrive/C/msys64/bin/git.exe': No such file or directory
rm: cannot remove '/proc/cygdrive/C/msys64/bin/bash.exe': No such file or directory
rm: cannot remove '/proc/cygdrive/C/msys64/bin/sh.exe': No such file or directory

@dscho
Copy link
Contributor Author

dscho commented Feb 4, 2026

I'd prefer if the .install file would be dropped, at least for now.

Oh wow, this should only have been part of the git-for-windows-addons package... Sorry for not spotting that earlier.

I's depending on MINGW_PREFIX which is not the prefix of the package, but the environment you call pacman from, so installing is broken from the MSYS env, and broken when installing from a different env. The files it creates are not namespaced, so uninstalling might break another envs. The first one can be fixed by having an .install file per env, like we do in all packages, the later I don't know, depends on what it's trying to achieve.

I get this when installing in MSYS:

mkdir: cannot create directory ‘’: No such file or directory
error: command failed to execute correctly

I get this when installing in the matching env:

cp: cannot stat '/clang64/share/git/compat-bash.exe': No such file or directory

Unrelated to that, uninstalling gave me:

rm: cannot remove '/proc/cygdrive/C/msys64/bin/git.exe': No such file or directory
rm: cannot remove '/proc/cygdrive/C/msys64/bin/bash.exe': No such file or directory
rm: cannot remove '/proc/cygdrive/C/msys64/bin/sh.exe': No such file or directory

True; It should probably hard-code the MINGW_PREFIX at build time. Will experiment with that.

"${MINGW_PACKAGE_PREFIX}-openssl"
"${MINGW_PACKAGE_PREFIX}-pcre2"
"${MINGW_PACKAGE_PREFIX}-asciidoctor")
install=git.install
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using git-${MSYSTEM}.install files with hard-coded prefixes can probably help

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I actually went for MINGW_PACKAGE_PREFIX instead, and generate it on the fly, but the idea is the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. That did work locally, but not in CI...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better write these install files manually

@dscho dscho marked this pull request as draft February 5, 2026 08:01
@dscho dscho force-pushed the upstream-git-for-windows branch 2 times, most recently from 2cd2136 to de3acc5 Compare February 5, 2026 08:10
This file's goal is to ensure that the compatibility wrapper is
installed into the `<top>\bin\` directory so that e.g.

    D:\path\to\msys2\bin\sh.exe -lc "echo Hello"

would work. These wrappers are totally inappropriate for the
mingw-w64-git package and should therefore not be installed via the
`.install` script.

Instead, let's move it to the place that is totally appropriate a place
for this: the mingw-w64-git-for-windows-addons package which already
installs wrappers like `<top>\git-bash.exe`.

This commit is best viewed with `--color-moved`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the upstream-git-for-windows branch 3 times, most recently from 7961e62 to e40689c Compare February 5, 2026 10:03
The idea of the Git wrapper is that it is installed into various places
(as part of the `mingw-w64-git-for-windows-addons` package), e.g. into
`<msys64>\git-bash.exe`. This executable will then set up the required
environment variables and spawn the actual `bash.exe`.

Likewise, the Git wrapper is installed into `<msys64>\cmd\git.exe`
where it can be called directly from, say, a PowerShell, without needing
to add all the correct `PATH` entries and without setting `MSYSTEM`: the
wrapper will do all that, and then spawn the actual `git.exe` in the
correct subdirectory.

Now, grace to Git for Windows' history, which started out before MSYS2
was invented and was based on MSys and MinGW instead, the actual logic
grew organically. In the early days, when Git for Windows only supported
i686 builds, all of those environment variable values were hardcoded.
Later, when Git for Windows was moved on top of MSYS2, only two values
were possible: "MINGW64" and "MINGW32". When timid steps were taken to
support Windows/ARM64, a third option was added: "CLANGARM64".

All this was unnecessary, though: The environment variable `MSYSTEM` is
set when building the mingw-w64-git package, and it is guaranteed to be
set to the very value the Git wrapper wants to use at run-time.

So let's stop hard-coding the MINGW{32,64} values, and drop the hack we
needed in Git for Windows while the clangarm64 builds were only
experimental.

Instead, just use the value in the environment variable `MSYSTEM` at
build time, hard-coding _that_ into the binary. This will allow the Git
wrapper to find the executables that were put into the corresponding
`mingw-w64-git-*` packages.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the upstream-git-for-windows branch from e40689c to 8679563 Compare February 5, 2026 11:13
@dscho dscho marked this pull request as ready for review February 5, 2026 11:55
@dscho
Copy link
Contributor Author

dscho commented Feb 5, 2026

Good that y'all pointed me to the .install file! Its purpose is (limited to the git-for-windows-addons package!) to add a few compatibility executables: <msys2>\bin\git.exe and <msys2>\bin\sh.exe. The <msys2>\bin folder does not exist in MSYS2, but it did exist in MSys/MinGW (the ecosystem on which Git for Windows was originally based).

If you hadn't pointed me to this, I wouldn't have verified that they work for, say, the UCRT64 version. I did test that, realized that some major changes were still needed in git-wrapper.c, and made those changes. They are not big, just... major (instead of hard-coding the MSYSTEM and dependent values based on the compiler's pre-defined CPU architecture constants, now the MSYSTEM value at build time is respected). Here they are, tested and verified: e452dfe...8679563

git-for-windows-ci pushed a commit to git-for-windows/git that referenced this pull request Feb 5, 2026
This option was added in fa93bb2 (MinGW: Fix stat definitions to
work with MinGW runtime version 4.0, 2013-09-11), i.e. a _long_ time
ago. So long, in fact, that it still targeted MinGW. But we switched to
mingw-w64 in 2015, which seems not to share the problem, and therefore
does not require a fix.

Even worse: This flag is incompatible with UCRT64, which we are about to
support by way of upstreaming `mingw-w64-git` to the MSYS2 project, see
msys2/MINGW-packages#26470 for details.

So let's send that option into its well-deserved retirement.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this pull request Feb 5, 2026
Every once in a while, there are bug reports in Git for Windows' bug
tracker that describe an issue running [inside MSYS2
proper](https://gitforwindows.org/install-inside-msys2-proper), totally
ignoring the big, honking warning on top of [the
page](https://gitforwindows.org/install-inside-msys2-proper) that spells
out clearly that this is an unsupported use case.

At the same time, we cannot easily deflect and say "just use MSYS2
directly" (and leave the "and stop pestering us" out). We cannot do that
because there is only an _MSYS_ `git` package in MSYS2 (i.e. a Git that
uses the quite slow POSIX emulation layer provided by the MSYS2
runtime), but no `mingw-w64-git` package (which would be equivalent in
speed to Git for Windows).

In msys2/MINGW-packages#26470, I am preparing to
change that. As part of that PR, I noticed and fixed a couple of issues
_in `git-for-windows/git` that prevented full support for
`mingw-w64-git` in MSYS2, such as problems with CLANG64 and UCRT64.

While at it, I simplified the entire setup to trust MSYS2's
`MINGW_PREFIX` & related environment variables instead of hard-coding
values like the installation prefix and what `MSYSTEM` to fall back on
if it is unset.
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this pull request Feb 5, 2026
This option was added in fa93bb2 (MinGW: Fix stat definitions to
work with MinGW runtime version 4.0, 2013-09-11), i.e. a _long_ time
ago. So long, in fact, that it still targeted MinGW. But we switched to
mingw-w64 in 2015, which seems not to share the problem, and therefore
does not require a fix.

Even worse: This flag is incompatible with UCRT64, which we are about to
support by way of upstreaming `mingw-w64-git` to the MSYS2 project, see
msys2/MINGW-packages#26470 for details.

So let's send that option into its well-deserved retirement.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/git that referenced this pull request Feb 5, 2026
Every once in a while, there are bug reports in Git for Windows' bug
tracker that describe an issue running [inside MSYS2
proper](https://gitforwindows.org/install-inside-msys2-proper), totally
ignoring the big, honking warning on top of [the
page](https://gitforwindows.org/install-inside-msys2-proper) that spells
out clearly that this is an unsupported use case.

At the same time, we cannot easily deflect and say "just use MSYS2
directly" (and leave the "and stop pestering us" out). We cannot do that
because there is only an _MSYS_ `git` package in MSYS2 (i.e. a Git that
uses the quite slow POSIX emulation layer provided by the MSYS2
runtime), but no `mingw-w64-git` package (which would be equivalent in
speed to Git for Windows).

In msys2/MINGW-packages#26470, I am preparing to
change that. As part of that PR, I noticed and fixed a couple of issues
_in `git-for-windows/git` that prevented full support for
`mingw-w64-git` in MSYS2, such as problems with CLANG64 and UCRT64.

While at it, I simplified the entire setup to trust MSYS2's
`MINGW_PREFIX` & related environment variables instead of hard-coding
values like the installation prefix and what `MSYSTEM` to fall back on
if it is unset.
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.

7 participants