{"thread":{"id":"66247","subject":"[PATCH 0/2] Use Rust in the Windows CI jobs","startedAt":"2026-09-01T14:21:54Z","lastAt":"2026-09-21T18:02:46Z","messageCount":21,"participants":["Johannes Schindelin via GitGitGadget","Junio C Hamano","Johannes Schindelin","James Le Cuirot"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"551671","messageId":"pull.2213.git.1788272509.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":null,"subject":"[PATCH 0/2] Use Rust in the Windows CI jobs","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-01T14:21:47Z","receivedAt":"2026-09-01T14:21:54Z","isPatch":true,"body":"With v2.55.0, Git requires Rust by default, with an opt-out that is intended\nto be dropped in one of the next versions.\n\nDue to the special circumstances in the Windows part of the CI builds, each\nWindows build job first downloads a \"minimal Git for Windows SDK\" that\ncontains the GCC toolchain required to build and test Git. As a consequence,\nbrian m. carlson opted out of Rust in Git's CI definition in 32d5b905909e\n(Enable Rust by default, 2026-04-09).\n\nSo: How could we stop opting out? Notably, Rust is not part of that minimal\nGit for Windows SDK, and including it would more than double that payload,\nwhich I consider prohibitive. Yet including Rust in the minimal Git for\nWindows SDK is not actually necessary, at least not for the GitHub workflow:\nThe runners on which this workflow is defined to run come with Rust\npre-installed.\n\nGranted, this Rust installation is configured to target the Windows-native C\ncompiler, Visual C. To accommodate for the Windows CI job building with GCC,\nthis patch series adds a step to the workflow that ensures that the needed\nRust bits are installed and configured.\n\nRFH: I haven't been able to confirm that GitLab's Windows runners come with\nRust preinstalled,\nhttps://docs.gitlab.com/ci/runners/hosted_runners/windows/#available-runtimes\ndid not clarify that for me. Patrick (or anyone else with access to GitLab\nCI), could you see whether this patch series builds on\nsaas-windows-medium-amd64 without need for further changes?\n\nJohannes Schindelin (2):\n  rust: pick a GCC-compatible Cargo target under MSYS2/MinGW\n  ci(windows): build with Rust\n\n .github/workflows/main.yml | 24 ++++++++++++++++++++++++\n Makefile                   |  3 ++-\n ci/lib.sh                  |  3 ---\n config.mak.uname           | 24 +++++++++++++++++++++++-\n 4 files changed, 49 insertions(+), 5 deletions(-)\n\n\nbase-commit: 8cd717011ba08f30f451ec802047df275fe2980d\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2213%2Fdscho%2Fuse-rust-in-windows-ci-builds-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2213/dscho/use-rust-in-windows-ci-builds-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2213\n-- \ngitgitgadget\n"},{"id":"551672","messageId":"2b7f58a037592325c2cb9b52bf8f1ef434bd6202.1788272509.git.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.git.1788272509.gitgitgadget@gmail.com","subject":"[PATCH 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-01T14:21:48Z","receivedAt":"2026-09-01T14:21:55Z","isPatch":true,"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen Git is built under MSYS2/MinGW with Rust support enabled, the\nMakefile expects `cargo build` to drop a `target/release/libgitcore.a`\nthat is linkable by the same MinGW GCC used for every other object.\nWith Rust installed via `rustup` (the way it ships on the\nGitHub-hosted `windows-2022` and `windows-11-arm` runners that build\nmicrosoft/git), the default toolchain targets the MSVC ABI; cargo\nthen writes `target/release/gitcore.lib` instead, which the MinGW\n`ld.exe` cannot consume:\n\n    LINK git-shell.exe\n    D:\\git-sdk-64-minimal\\mingw64\\bin/ld.exe: cannot find target/release/libgitcore.a: No such file or directory\n    collect2.exe: error: ld returned 1 exit status\n\nSee https://github.com/microsoft/git/actions/runs/27341625000 for the\nfull log.\n\nLet's define the correct target. Re-use (and fix) the existing\n`HOST_CPU` variable for that purpose. Avoid relying on environment\nvariables that are simply not defined in Git for Windows' minimal SDK\nthat Git uses in its CI runs.\n\nAssisted-by: Claude Opus 4.7\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile         |  3 ++-\n config.mak.uname | 24 +++++++++++++++++++++++-\n 2 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex fac3e8879c..bf2a11c08a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib\n else\n RUST_LIB_NAME = libgitcore.a\n endif\n-RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n+RUST_LIB = target$(if $(CARGO_TARGET),/$(CARGO_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n endif\n \n GITLIBS = common-main.o $(LIB_FILE)\n@@ -993,6 +993,7 @@ endif\n ifndef DEBUG\n CARGO_ARGS += --release\n endif\n+CARGO_ARGS += $(if $(CARGO_TARGET),--target $(CARGO_TARGET))\n \n # For the 'sparse' target\n SPARSE_FLAGS ?= -std=gnu99 -D__STDC_NO_VLA__\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 0b63be10b7..720d9ba3ed 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -758,7 +758,29 @@ ifeq ($(uname_S),MINGW)\n \t\t\tMINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z)\n                 endif\n \t\tprefix = $(MINGW_PREFIX)\n-\t\tHOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST))\n+\n+\t\t# A rustup-managed Rust on Windows defaults to the MSVC ABI and\n+\t\t# produces a `gitcore.lib` that the MinGW `ld.exe` cannot link.\n+\t\t# Pick a GCC-compatible Rust target triple matching the MSYS2\n+\t\t# subsystem instead: `*-pc-windows-gnullvm` for the Clang/LLVM\n+\t\t# subsystems (which on Windows is also the only choice for\n+\t\t# ARM64, where no MinGW-GCC port exists) and `*-pc-windows-gnu`\n+\t\t# for the MSVCRT-based MinGW subsystems. For a `staticlib`\n+\t\t# crate-type Cargo does not invoke an external linker, so\n+\t\t# `rustup target add <triple>` is sufficient.\n+                ifneq (,$(filter %ARM64, $(MSYSTEM)))\n+\t\t\tHOST_CPU = aarch64\n+                else ifneq (,$(filter %32, $(MSYSTEM)))\n+\t\t\tHOST_CPU = i686\n+                else\n+\t\t\tHOST_CPU = x86_64\n+                endif\n+                ifneq (,$(filter CLANG%, $(MSYSTEM)))\n+\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnullvm\n+                else\n+\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnu\n+                endif\n+\n \t\tBASIC_LDFLAGS += -Wl,--pic-executable\n \t\tCOMPAT_CFLAGS += -DDETECT_MSYS_TTY \\\n \t\t\t-DENSURE_MSYSTEM_IS_SET=\"\\\"$(MSYSTEM)\\\"\" \\\n-- \ngitgitgadget\n\n"},{"id":"551673","messageId":"7a24630fb944aa34adebde1e9087383080c04406.1788272509.git.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.git.1788272509.gitgitgadget@gmail.com","subject":"[PATCH 2/2] ci(windows): build with Rust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-01T14:21:49Z","receivedAt":"2026-09-01T14:21:56Z","isPatch":true,"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe Windows runners used by Git's GitHub workflow's `windows-build` job\nship `rustup` plus a `*-pc-windows-msvc` default toolchain (see\nhttps://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md\nand\nhttps://github.com/actions/partner-runner-images/blob/main/images/arm-windows-11-image.md),\nbut no precompiled `std` for `*-pc-windows-gnu` or\n`*-pc-windows-gnullvm`. With the Makefile now picking a GCC-compatible\ntarget triple based on `$(MSYSTEM)`, the build step needs that\nprecompiled `std` to be installed before invoking `make`, otherwise\n`cargo build --target <triple>` fails to find a usable `std` for the\nchosen target.\n\nAdd a step between the SDK setup and the `make` invocation that selects\nthe matching triple from `$MSYSTEM` (which\n`git-for-windows/setup-git-for-windows-sdk` exports for every subsequent\nstep) and runs `rustup target add` for it. The mapping mirrors what\n`config.mak.uname` derives from `$(MSYSTEM)` and `$(HOST_CPU)`, just\nenumerated explicitly here since CI has direct knowledge of which MSYS2\nsubsystems the matrix actually exercises (`CLANGARM64` for the ARM64\nrunner, `MINGW64` for the x86_64 runner). Technically, we only need to\nhandle MINGW64 at present, but the switch to UCRT64 is imminent, and the\nother case arms serve as a very fine documentation of what people should\ndo for other MSYSTEM values.\n\nFor a `staticlib` crate-type `cargo build` does not invoke an external\nlinker, so no further toolchain components (e.g. the `gnullvm` LLVM\nlinker) need to be installed; `rustup target add` alone is sufficient.\n\nAssisted-by: Claude Opus 4.7\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .github/workflows/main.yml | 24 ++++++++++++++++++++++++\n ci/lib.sh                  |  3 ---\n 2 files changed, 24 insertions(+), 3 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 85cfedf5b0..d85e6c434f 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -114,6 +114,30 @@ jobs:\n     steps:\n     - uses: actions/checkout@v6\n     - uses: git-for-windows/setup-git-for-windows-sdk@v2\n+    - name: Install GCC-compatible Rust target\n+      shell: bash\n+      run: |\n+        # The hosted Windows runners ship a rustup-managed Rust whose\n+        # default toolchain targets the MSVC ABI. That produces a\n+        # `gitcore.lib` which the MinGW GCC used by the rest of the\n+        # build cannot link. Install the precompiled `std` for a\n+        # GCC-compatible target triple matching the MSYS2 subsystem;\n+        # the Makefile selects the same triple via $(MSYSTEM) and\n+        # passes it to `cargo build --target`.\n+        case \"$MSYSTEM\" in\n+        CLANGARM64) target=aarch64-pc-windows-gnullvm ;;\n+        CLANG64)    target=x86_64-pc-windows-gnullvm  ;;\n+        CLANG32)    target=i686-pc-windows-gnullvm    ;;\n+        UCRT64)     target=x86_64-pc-windows-gnullvm  ;;\n+        MINGW64)    target=x86_64-pc-windows-gnu      ;;\n+        MINGW32)    target=i686-pc-windows-gnu        ;;\n+        *) echo \"::error::Unsupported MSYSTEM: $MSYSTEM\"; exit 1 ;;\n+        esac &&\n+        rustup target add \"$target\" &&\n+\n+        # Ensure that cargo.exe is found even with the minimal SDK's restricted PATH\n+        CARGO=\"$(type -p cargo.exe)\" &&\n+        echo \"export PATH=\\$PATH:${CARGO%/cargo.exe}\" >>/etc/profile\n     - name: build\n       shell: bash\n       env:\ndiff --git a/ci/lib.sh b/ci/lib.sh\nindex 6c52154eac..c6ccbf8c17 100755\n--- a/ci/lib.sh\n+++ b/ci/lib.sh\n@@ -391,9 +391,6 @@ linux-asan-ubsan)\n osx-meson)\n \tMESONFLAGS=\"$MESONFLAGS -Dcredential_helpers=osxkeychain\"\n \t;;\n-windows-*)\n-\texport NO_RUST=UnfortunatelyYes\n-\t;;\n esac\n \n MAKEFLAGS=\"$MAKEFLAGS CC=${CC:-cc}\"\n-- \ngitgitgadget\n"},{"id":"551724","messageId":"xmqqy0dkjhjn.fsf@gitster.g","threadId":"66247","inReplyTo":"2b7f58a037592325c2cb9b52bf8f1ef434bd6202.1788272509.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-02T06:25:48Z","receivedAt":"2026-09-02T06:25:51Z","isPatch":true,"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> +                ifneq (,$(filter %ARM64, $(MSYSTEM)))\n> +\t\t\tHOST_CPU = aarch64\n> +                else ifneq (,$(filter %32, $(MSYSTEM)))\n> +\t\t\tHOST_CPU = i686\n> +                else\n> +\t\t\tHOST_CPU = x86_64\n> +                endif\n> +                ifneq (,$(filter CLANG%, $(MSYSTEM)))\n> +\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnullvm\n> +                else\n> +\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnu\n> +                endif\n\nAssuming HOST_CPU is x86_64 in the above, as UCRT64, unlike\nCLANG{ARM64,64,32}, does not match CLANG%, I presume that the above\ngives \"x86_64-pc-windows-gnu\" to builds with MSYSTEM set to UCRT64.\n\nThere is this \"we only need MINGW64 but the switch to UCRT64 is\nimminent, and others are for documentation\" part we see in the\n[PATCH 2/2]\n\n+        case \"$MSYSTEM\" in\n+        CLANGARM64) target=aarch64-pc-windows-gnullvm ;;\n+        CLANG64)    target=x86_64-pc-windows-gnullvm  ;;\n+        CLANG32)    target=i686-pc-windows-gnullvm    ;;\n+        UCRT64)     target=x86_64-pc-windows-gnullvm  ;;\n+        MINGW64)    target=x86_64-pc-windows-gnu      ;;\n+        MINGW32)    target=i686-pc-windows-gnu        ;;\n+        *) echo \"::error::Unsupported MSYSTEM: $MSYSTEM\"; exit 1 ;;\n+        esac &&\n+        rustup target add \"$target\" &&\n\nthat maps UCRT64 to \"x86_64-pc-windows-gnullvm\"\n\nI do not know if it is intended.  If so, please ignore.\n\nThanks.\n"},{"id":"552533","messageId":"040027f8-983b-9c12-5498-330129cd8600@gmx.de","threadId":"66247","inReplyTo":"xmqqy0dkjhjn.fsf@gitster.g","subject":"Re: [PATCH 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2026-09-11T12:25:07Z","receivedAt":"2026-09-11T12:25:12Z","isPatch":true,"body":"Hi Junio,\n\nOn Tue, 1 Sep 2026, Junio C Hamano wrote:\n\n> \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n> \n> > +                ifneq (,$(filter %ARM64, $(MSYSTEM)))\n> > +\t\t\tHOST_CPU = aarch64\n> > +                else ifneq (,$(filter %32, $(MSYSTEM)))\n> > +\t\t\tHOST_CPU = i686\n> > +                else\n> > +\t\t\tHOST_CPU = x86_64\n> > +                endif\n> > +                ifneq (,$(filter CLANG%, $(MSYSTEM)))\n> > +\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnullvm\n> > +                else\n> > +\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnu\n> > +                endif\n> \n> Assuming HOST_CPU is x86_64 in the above, as UCRT64, unlike\n> CLANG{ARM64,64,32}, does not match CLANG%, I presume that the above\n> gives \"x86_64-pc-windows-gnu\" to builds with MSYSTEM set to UCRT64.\n\nCorrect.\n\n> There is this \"we only need MINGW64 but the switch to UCRT64 is\n> imminent, and others are for documentation\" part we see in the\n> [PATCH 2/2]\n> \n> +        case \"$MSYSTEM\" in\n> +        CLANGARM64) target=aarch64-pc-windows-gnullvm ;;\n> +        CLANG64)    target=x86_64-pc-windows-gnullvm  ;;\n> +        CLANG32)    target=i686-pc-windows-gnullvm    ;;\n> +        UCRT64)     target=x86_64-pc-windows-gnullvm  ;;\n> +        MINGW64)    target=x86_64-pc-windows-gnu      ;;\n> +        MINGW32)    target=i686-pc-windows-gnu        ;;\n> +        *) echo \"::error::Unsupported MSYSTEM: $MSYSTEM\"; exit 1 ;;\n> +        esac &&\n> +        rustup target add \"$target\" &&\n> \n> that maps UCRT64 to \"x86_64-pc-windows-gnullvm\"\n> \n> I do not know if it is intended.  If so, please ignore.\n\nSince UCRT64 is still using GCC, it should be `-gnu`. Thanks for catching.\n\nCiao,\nJohannes\n"},{"id":"552587","messageId":"pull.2213.v2.git.1789153730.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.git.1788272509.gitgitgadget@gmail.com","subject":"[PATCH v2 0/2] Use Rust in the Windows CI jobs","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-11T19:08:48Z","receivedAt":"2026-09-11T19:08:53Z","isPatch":true,"body":"With v2.55.0, Git requires Rust by default, with an opt-out that is intended\nto be dropped in one of the next versions.\n\nDue to the special circumstances in the Windows part of the CI builds, each\nWindows build job first downloads a \"minimal Git for Windows SDK\" that\ncontains the GCC toolchain required to build and test Git. As a consequence,\nbrian m. carlson opted out of Rust in Git's CI definition in 32d5b905909e\n(Enable Rust by default, 2026-04-09).\n\nSo: How could we stop opting out? Notably, Rust is not part of that minimal\nGit for Windows SDK, and including it would more than double that payload,\nwhich I consider prohibitive. Yet including Rust in the minimal Git for\nWindows SDK is not actually necessary, at least not for the GitHub workflow:\nThe runners on which this workflow is defined to run come with Rust\npre-installed.\n\nGranted, this Rust installation is configured to target the Windows-native C\ncompiler, Visual C. To accommodate for the Windows CI job building with GCC,\nthis patch series adds a step to the workflow that ensures that the needed\nRust bits are installed and configured.\n\nRFH: I haven't been able to confirm that GitLab's Windows runners come with\nRust preinstalled,\nhttps://docs.gitlab.com/ci/runners/hosted_runners/windows/#available-runtimes\ndid not clarify that for me. Patrick (or anyone else with access to GitLab\nCI), could you see whether this patch series builds on\nsaas-windows-medium-amd64 without need for further changes?\n\nChanges since v1:\n\n * The inconsistency pointed out by Junio, that UCRT64 was once marked as\n   using clang and once as using gcc was fixed by clarifying that UCRT64\n   uses GCC.\n\nJohannes Schindelin (2):\n  rust: pick a GCC-compatible Cargo target under MSYS2/MinGW\n  ci(windows): build with Rust\n\n .github/workflows/main.yml | 24 ++++++++++++++++++++++++\n Makefile                   |  3 ++-\n ci/lib.sh                  |  3 ---\n config.mak.uname           | 24 +++++++++++++++++++++++-\n 4 files changed, 49 insertions(+), 5 deletions(-)\n\n\nbase-commit: f4742f3165d096130c39a71feb26374da37620f2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2213%2Fdscho%2Fuse-rust-in-windows-ci-builds-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2213/dscho/use-rust-in-windows-ci-builds-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/2213\n\nRange-diff vs v1:\n\n 1:  2b7f58a037 = 1:  6567eceb32 rust: pick a GCC-compatible Cargo target under MSYS2/MinGW\n 2:  7a24630fb9 ! 2:  07415393e5 ci(windows): build with Rust\n     @@ Commit message\n          linker) need to be installed; `rustup target add` alone is sufficient.\n      \n          Assisted-by: Claude Opus 4.7\n     +    Helped-by: Junio C Hamano <gitster@pobox.com>\n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n       ## .github/workflows/main.yml ##\n     @@ .github/workflows/main.yml: jobs:\n      +        CLANGARM64) target=aarch64-pc-windows-gnullvm ;;\n      +        CLANG64)    target=x86_64-pc-windows-gnullvm  ;;\n      +        CLANG32)    target=i686-pc-windows-gnullvm    ;;\n     -+        UCRT64)     target=x86_64-pc-windows-gnullvm  ;;\n     ++        UCRT64)     target=x86_64-pc-windows-gnu      ;;\n      +        MINGW64)    target=x86_64-pc-windows-gnu      ;;\n      +        MINGW32)    target=i686-pc-windows-gnu        ;;\n      +        *) echo \"::error::Unsupported MSYSTEM: $MSYSTEM\"; exit 1 ;;\n\n-- \ngitgitgadget\n"},{"id":"552588","messageId":"07415393e5e30f1cd4babc56296f8ed140ae262a.1789153730.git.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.v2.git.1789153730.gitgitgadget@gmail.com","subject":"[PATCH v2 2/2] ci(windows): build with Rust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-11T19:08:50Z","receivedAt":"2026-09-11T19:08:55Z","isPatch":true,"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe Windows runners used by Git's GitHub workflow's `windows-build` job\nship `rustup` plus a `*-pc-windows-msvc` default toolchain (see\nhttps://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md\nand\nhttps://github.com/actions/partner-runner-images/blob/main/images/arm-windows-11-image.md),\nbut no precompiled `std` for `*-pc-windows-gnu` or\n`*-pc-windows-gnullvm`. With the Makefile now picking a GCC-compatible\ntarget triple based on `$(MSYSTEM)`, the build step needs that\nprecompiled `std` to be installed before invoking `make`, otherwise\n`cargo build --target <triple>` fails to find a usable `std` for the\nchosen target.\n\nAdd a step between the SDK setup and the `make` invocation that selects\nthe matching triple from `$MSYSTEM` (which\n`git-for-windows/setup-git-for-windows-sdk` exports for every subsequent\nstep) and runs `rustup target add` for it. The mapping mirrors what\n`config.mak.uname` derives from `$(MSYSTEM)` and `$(HOST_CPU)`, just\nenumerated explicitly here since CI has direct knowledge of which MSYS2\nsubsystems the matrix actually exercises (`CLANGARM64` for the ARM64\nrunner, `MINGW64` for the x86_64 runner). Technically, we only need to\nhandle MINGW64 at present, but the switch to UCRT64 is imminent, and the\nother case arms serve as a very fine documentation of what people should\ndo for other MSYSTEM values.\n\nFor a `staticlib` crate-type `cargo build` does not invoke an external\nlinker, so no further toolchain components (e.g. the `gnullvm` LLVM\nlinker) need to be installed; `rustup target add` alone is sufficient.\n\nAssisted-by: Claude Opus 4.7\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .github/workflows/main.yml | 24 ++++++++++++++++++++++++\n ci/lib.sh                  |  3 ---\n 2 files changed, 24 insertions(+), 3 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 85cfedf5b0..0972547395 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -114,6 +114,30 @@ jobs:\n     steps:\n     - uses: actions/checkout@v6\n     - uses: git-for-windows/setup-git-for-windows-sdk@v2\n+    - name: Install GCC-compatible Rust target\n+      shell: bash\n+      run: |\n+        # The hosted Windows runners ship a rustup-managed Rust whose\n+        # default toolchain targets the MSVC ABI. That produces a\n+        # `gitcore.lib` which the MinGW GCC used by the rest of the\n+        # build cannot link. Install the precompiled `std` for a\n+        # GCC-compatible target triple matching the MSYS2 subsystem;\n+        # the Makefile selects the same triple via $(MSYSTEM) and\n+        # passes it to `cargo build --target`.\n+        case \"$MSYSTEM\" in\n+        CLANGARM64) target=aarch64-pc-windows-gnullvm ;;\n+        CLANG64)    target=x86_64-pc-windows-gnullvm  ;;\n+        CLANG32)    target=i686-pc-windows-gnullvm    ;;\n+        UCRT64)     target=x86_64-pc-windows-gnu      ;;\n+        MINGW64)    target=x86_64-pc-windows-gnu      ;;\n+        MINGW32)    target=i686-pc-windows-gnu        ;;\n+        *) echo \"::error::Unsupported MSYSTEM: $MSYSTEM\"; exit 1 ;;\n+        esac &&\n+        rustup target add \"$target\" &&\n+\n+        # Ensure that cargo.exe is found even with the minimal SDK's restricted PATH\n+        CARGO=\"$(type -p cargo.exe)\" &&\n+        echo \"export PATH=\\$PATH:${CARGO%/cargo.exe}\" >>/etc/profile\n     - name: build\n       shell: bash\n       env:\ndiff --git a/ci/lib.sh b/ci/lib.sh\nindex 6c52154eac..c6ccbf8c17 100755\n--- a/ci/lib.sh\n+++ b/ci/lib.sh\n@@ -391,9 +391,6 @@ linux-asan-ubsan)\n osx-meson)\n \tMESONFLAGS=\"$MESONFLAGS -Dcredential_helpers=osxkeychain\"\n \t;;\n-windows-*)\n-\texport NO_RUST=UnfortunatelyYes\n-\t;;\n esac\n \n MAKEFLAGS=\"$MAKEFLAGS CC=${CC:-cc}\"\n-- \ngitgitgadget\n"},{"id":"552589","messageId":"6567eceb32c1bdcff5927c6baf0cadc97af7485b.1789153730.git.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.v2.git.1789153730.gitgitgadget@gmail.com","subject":"[PATCH v2 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-11T19:08:49Z","receivedAt":"2026-09-11T19:08:55Z","isPatch":true,"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen Git is built under MSYS2/MinGW with Rust support enabled, the\nMakefile expects `cargo build` to drop a `target/release/libgitcore.a`\nthat is linkable by the same MinGW GCC used for every other object.\nWith Rust installed via `rustup` (the way it ships on the\nGitHub-hosted `windows-2022` and `windows-11-arm` runners that build\nmicrosoft/git), the default toolchain targets the MSVC ABI; cargo\nthen writes `target/release/gitcore.lib` instead, which the MinGW\n`ld.exe` cannot consume:\n\n    LINK git-shell.exe\n    D:\\git-sdk-64-minimal\\mingw64\\bin/ld.exe: cannot find target/release/libgitcore.a: No such file or directory\n    collect2.exe: error: ld returned 1 exit status\n\nSee https://github.com/microsoft/git/actions/runs/27341625000 for the\nfull log.\n\nLet's define the correct target. Re-use (and fix) the existing\n`HOST_CPU` variable for that purpose. Avoid relying on environment\nvariables that are simply not defined in Git for Windows' minimal SDK\nthat Git uses in its CI runs.\n\nAssisted-by: Claude Opus 4.7\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile         |  3 ++-\n config.mak.uname | 24 +++++++++++++++++++++++-\n 2 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex fac3e8879c..bf2a11c08a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib\n else\n RUST_LIB_NAME = libgitcore.a\n endif\n-RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n+RUST_LIB = target$(if $(CARGO_TARGET),/$(CARGO_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n endif\n \n GITLIBS = common-main.o $(LIB_FILE)\n@@ -993,6 +993,7 @@ endif\n ifndef DEBUG\n CARGO_ARGS += --release\n endif\n+CARGO_ARGS += $(if $(CARGO_TARGET),--target $(CARGO_TARGET))\n \n # For the 'sparse' target\n SPARSE_FLAGS ?= -std=gnu99 -D__STDC_NO_VLA__\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 0b63be10b7..720d9ba3ed 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -758,7 +758,29 @@ ifeq ($(uname_S),MINGW)\n \t\t\tMINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z)\n                 endif\n \t\tprefix = $(MINGW_PREFIX)\n-\t\tHOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST))\n+\n+\t\t# A rustup-managed Rust on Windows defaults to the MSVC ABI and\n+\t\t# produces a `gitcore.lib` that the MinGW `ld.exe` cannot link.\n+\t\t# Pick a GCC-compatible Rust target triple matching the MSYS2\n+\t\t# subsystem instead: `*-pc-windows-gnullvm` for the Clang/LLVM\n+\t\t# subsystems (which on Windows is also the only choice for\n+\t\t# ARM64, where no MinGW-GCC port exists) and `*-pc-windows-gnu`\n+\t\t# for the MSVCRT-based MinGW subsystems. For a `staticlib`\n+\t\t# crate-type Cargo does not invoke an external linker, so\n+\t\t# `rustup target add <triple>` is sufficient.\n+                ifneq (,$(filter %ARM64, $(MSYSTEM)))\n+\t\t\tHOST_CPU = aarch64\n+                else ifneq (,$(filter %32, $(MSYSTEM)))\n+\t\t\tHOST_CPU = i686\n+                else\n+\t\t\tHOST_CPU = x86_64\n+                endif\n+                ifneq (,$(filter CLANG%, $(MSYSTEM)))\n+\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnullvm\n+                else\n+\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnu\n+                endif\n+\n \t\tBASIC_LDFLAGS += -Wl,--pic-executable\n \t\tCOMPAT_CFLAGS += -DDETECT_MSYS_TTY \\\n \t\t\t-DENSURE_MSYSTEM_IS_SET=\"\\\"$(MSYSTEM)\\\"\" \\\n-- \ngitgitgadget\n\n"},{"id":"552596","messageId":"xmqqa4pna411.fsf@gitster.g","threadId":"66247","inReplyTo":"6567eceb32c1bdcff5927c6baf0cadc97af7485b.1789153730.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-11T21:09:46Z","receivedAt":"2026-09-11T21:09:49Z","isPatch":true,"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> @@ -993,6 +993,7 @@ endif\n>  ifndef DEBUG\n>  CARGO_ARGS += --release\n>  endif\n> +CARGO_ARGS += $(if $(CARGO_TARGET),--target $(CARGO_TARGET))\n\nShould this use CARGO_BUILD_TARGET (instead of CARGO_TARGET) to\nmatch what the officially supported Cargo environment variable is\ncalled?  It would also help us work better with the changes from the\njc/rust-cargo-build-target topic.\n\nThanks.\n\nAuthor: James Le Cuirot <chewi@gentoo.org>\nDate:   Thu Sep 10 11:20:14 2026 +0100\n\n    rust: respect CARGO_BUILD_TARGET when locating build output\n    \n    When cross-compiling, Cargo always writes to a target-tuple subdirectory\n    determined by CARGO_BUILD_TARGET, even when it matches the native tuple.\n    The build looked in $BUILD_DIR/$BUILD_TYPE directly, so it failed to\n    locate the freshly built library.\n    \n    Respect CARGO_BUILD_TARGET in the output path so the correct artifact\n    is located.\n    \n    Signed-off-by: James Le Cuirot <chewi@gentoo.org>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\ndiff --git a/Makefile b/Makefile\nindex d4b775953d..f0ca2e4f72 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib\n else\n RUST_LIB_NAME = libgitcore.a\n endif\n-RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n+RUST_LIB = target/$(if $(CARGO_BUILD_TARGET),$(CARGO_BUILD_TARGET)/)$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n endif\n \n GITLIBS = common-main.o $(LIB_FILE)\ndiff --git a/src/cargo-meson.sh b/src/cargo-meson.sh\nindex 75f3cd1265..83c7e7b79b 100755\n--- a/src/cargo-meson.sh\n+++ b/src/cargo-meson.sh\n@@ -38,7 +38,7 @@ then\n \texit $RET\n fi\n \n-if ! cmp \"$BUILD_DIR/$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\" >/dev/null 2>&1\n+if ! cmp \"$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\" >/dev/null 2>&1\n then\n-\tcp \"$BUILD_DIR/$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\"\n+\tcp \"$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\"\n fi\n"},{"id":"552612","messageId":"c29cd39efc7b472ff1aeaede367d7f39f3ca1eeb.camel@gentoo.org","threadId":"66247","inReplyTo":"xmqqa4pna411.fsf@gitster.g","subject":"Re: [PATCH v2 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"James Le Cuirot","fromEmail":"chewi@gentoo.org","sentAt":"2026-09-11T22:26:11Z","receivedAt":"2026-09-11T22:26:21Z","isPatch":true,"body":"On Fri, 2026-09-11 at 14:09 -0700, Junio C Hamano wrote:\n> \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n> \n> > @@ -993,6 +993,7 @@ endif\n> >  ifndef DEBUG\n> >  CARGO_ARGS += --release\n> >  endif\n> > +CARGO_ARGS += $(if $(CARGO_TARGET),--target $(CARGO_TARGET))\n> \n> Should this use CARGO_BUILD_TARGET (instead of CARGO_TARGET) to\n> match what the officially supported Cargo environment variable is\n> called?  It would also help us work better with the changes from the\n> jc/rust-cargo-build-target topic.\n> \n> Thanks.\n\nYes, without explicitly setting --target at all. This is how Gentoo Linux\nsupports cross-compiling of its Rust packages. Just avoid setting\nCARGO_BUILD_TARGET (or passing --target) when you're not cross-compiling. It\nwill cause Cargo to behave differently, even if you give the native tuple. For\nexample, RUSTFLAGS is normally applied to both the build host binaries and the\ntarget host binaries, but when an explicit target is set, RUSTFLAGS is only\napplied to the target host binaries.\n\nRegards,\nChewi\n\n> Author: James Le Cuirot <chewi@gentoo.org>\n> Date:   Thu Sep 10 11:20:14 2026 +0100\n> \n>     rust: respect CARGO_BUILD_TARGET when locating build output\n>     \n>     When cross-compiling, Cargo always writes to a target-tuple subdirectory\n>     determined by CARGO_BUILD_TARGET, even when it matches the native tuple.\n>     The build looked in $BUILD_DIR/$BUILD_TYPE directly, so it failed to\n>     locate the freshly built library.\n>     \n>     Respect CARGO_BUILD_TARGET in the output path so the correct artifact\n>     is located.\n>     \n>     Signed-off-by: James Le Cuirot <chewi@gentoo.org>\n>     Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> \n> diff --git a/Makefile b/Makefile\n> index d4b775953d..f0ca2e4f72 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib\n>  else\n>  RUST_LIB_NAME = libgitcore.a\n>  endif\n> -RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n> +RUST_LIB = target/$(if $(CARGO_BUILD_TARGET),$(CARGO_BUILD_TARGET)/)$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n>  endif\n>  \n>  GITLIBS = common-main.o $(LIB_FILE)\n> diff --git a/src/cargo-meson.sh b/src/cargo-meson.sh\n> index 75f3cd1265..83c7e7b79b 100755\n> --- a/src/cargo-meson.sh\n> +++ b/src/cargo-meson.sh\n> @@ -38,7 +38,7 @@ then\n>  \texit $RET\n>  fi\n>  \n> -if ! cmp \"$BUILD_DIR/$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\" >/dev/null 2>&1\n> +if ! cmp \"$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\" >/dev/null 2>&1\n>  then\n> -\tcp \"$BUILD_DIR/$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\"\n> +\tcp \"$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\"\n>  fi\n"},{"id":"552636","messageId":"e963a26f-6336-b52a-0466-30c81fd8ac02@gmx.de","threadId":"66247","inReplyTo":"c29cd39efc7b472ff1aeaede367d7f39f3ca1eeb.camel@gentoo.org","subject":"Re: [PATCH v2 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2026-09-13T10:30:09Z","receivedAt":"2026-09-13T10:30:17Z","isPatch":true,"body":"Hi Junio & James,\n\nOn Fri, 11 Sep 2026, James Le Cuirot wrote:\n\n> On Fri, 2026-09-11 at 14:09 -0700, Junio C Hamano wrote:\n> > \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n> > writes:\n> > \n> > > @@ -993,6 +993,7 @@ endif\n> > >  ifndef DEBUG\n> > >  CARGO_ARGS += --release\n> > >  endif\n> > > +CARGO_ARGS += $(if $(CARGO_TARGET),--target $(CARGO_TARGET))\n> > \n> > Should this use CARGO_BUILD_TARGET (instead of CARGO_TARGET) to\n> > match what the officially supported Cargo environment variable is\n> > called?  It would also help us work better with the changes from the\n> > jc/rust-cargo-build-target topic.\n\nSure.\n\n> > \n> > Thanks.\n> \n> Yes, without explicitly setting --target at all.\n\nCool! My first experiment failed because I missed that Makefile does not\nautomatically export `CARGO_BUILD_TARGET`... 🤦 But now that I explicitly\nexport it, it works as you claimed it would.\n\nThank you!\nJohannes\n\n> This is how Gentoo Linux supports cross-compiling of its Rust packages.\n> Just avoid setting CARGO_BUILD_TARGET (or passing --target) when you're\n> not cross-compiling. It will cause Cargo to behave differently, even if\n> you give the native tuple. For example, RUSTFLAGS is normally applied to\n> both the build host binaries and the target host binaries, but when an\n> explicit target is set, RUSTFLAGS is only applied to the target host\n> binaries.\n> \n> Regards,\n> Chewi\n> \n> > Author: James Le Cuirot <chewi@gentoo.org>\n> > Date:   Thu Sep 10 11:20:14 2026 +0100\n> > \n> >     rust: respect CARGO_BUILD_TARGET when locating build output\n> >     \n> >     When cross-compiling, Cargo always writes to a target-tuple subdirectory\n> >     determined by CARGO_BUILD_TARGET, even when it matches the native tuple.\n> >     The build looked in $BUILD_DIR/$BUILD_TYPE directly, so it failed to\n> >     locate the freshly built library.\n> >     \n> >     Respect CARGO_BUILD_TARGET in the output path so the correct artifact\n> >     is located.\n> >     \n> >     Signed-off-by: James Le Cuirot <chewi@gentoo.org>\n> >     Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> > \n> > diff --git a/Makefile b/Makefile\n> > index d4b775953d..f0ca2e4f72 100644\n> > --- a/Makefile\n> > +++ b/Makefile\n> > @@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib\n> >  else\n> >  RUST_LIB_NAME = libgitcore.a\n> >  endif\n> > -RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n> > +RUST_LIB = target/$(if $(CARGO_BUILD_TARGET),$(CARGO_BUILD_TARGET)/)$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n> >  endif\n> >  \n> >  GITLIBS = common-main.o $(LIB_FILE)\n> > diff --git a/src/cargo-meson.sh b/src/cargo-meson.sh\n> > index 75f3cd1265..83c7e7b79b 100755\n> > --- a/src/cargo-meson.sh\n> > +++ b/src/cargo-meson.sh\n> > @@ -38,7 +38,7 @@ then\n> >  \texit $RET\n> >  fi\n> >  \n> > -if ! cmp \"$BUILD_DIR/$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\" >/dev/null 2>&1\n> > +if ! cmp \"$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\" >/dev/null 2>&1\n> >  then\n> > -\tcp \"$BUILD_DIR/$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\"\n> > +\tcp \"$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME\" \"$BUILD_DIR/libgitcore.a\"\n> >  fi\n> \n"},{"id":"552637","messageId":"pull.2213.v3.git.1789295476.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.git.1788272509.gitgitgadget@gmail.com","subject":"[PATCH v3 0/2] Use Rust in the Windows CI jobs","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-13T10:31:14Z","receivedAt":"2026-09-13T10:31:20Z","isPatch":true,"body":"With v2.55.0, Git requires Rust by default, with an opt-out that is intended\nto be dropped in one of the next versions.\n\nDue to the special circumstances in the Windows part of the CI builds, each\nWindows build job first downloads a \"minimal Git for Windows SDK\" that\ncontains the GCC toolchain required to build and test Git. As a consequence,\nbrian m. carlson opted out of Rust in Git's CI definition in 32d5b905909e\n(Enable Rust by default, 2026-04-09).\n\nSo: How could we stop opting out? Notably, Rust is not part of that minimal\nGit for Windows SDK, and including it would more than double that payload,\nwhich I consider prohibitive. Yet including Rust in the minimal Git for\nWindows SDK is not actually necessary, at least not for the GitHub workflow:\nThe runners on which this workflow is defined to run come with Rust\npre-installed.\n\nGranted, this Rust installation is configured to target the Windows-native C\ncompiler, Visual C. To accommodate for the Windows CI job building with GCC,\nthis patch series adds a step to the workflow that ensures that the needed\nRust bits are installed and configured.\n\nRFH: I haven't been able to confirm that GitLab's Windows runners come with\nRust preinstalled,\nhttps://docs.gitlab.com/ci/runners/hosted_runners/windows/#available-runtimes\ndid not clarify that for me. Patrick (or anyone else with access to GitLab\nCI), could you see whether this patch series builds on\nsaas-windows-medium-amd64 without need for further changes?\n\nChanges since v1:\n\n * The inconsistency pointed out by Junio, that UCRT64 was once marked as\n   using clang and once as using gcc was fixed by clarifying that UCRT64\n   uses GCC.\n\nJohannes Schindelin (2):\n  rust: pick a GCC-compatible Cargo target under MSYS2/MinGW\n  ci(windows): build with Rust\n\n .github/workflows/main.yml | 24 ++++++++++++++++++++++++\n Makefile                   |  2 +-\n ci/lib.sh                  |  3 ---\n config.mak.uname           | 25 ++++++++++++++++++++++++-\n 4 files changed, 49 insertions(+), 5 deletions(-)\n\n\nbase-commit: f4742f3165d096130c39a71feb26374da37620f2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2213%2Fdscho%2Fuse-rust-in-windows-ci-builds-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2213/dscho/use-rust-in-windows-ci-builds-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/2213\n\nRange-diff vs v2:\n\n 1:  6567eceb32 ! 1:  b70b001f62 rust: pick a GCC-compatible Cargo target under MSYS2/MinGW\n     @@ Commit message\n      \n          When Git is built under MSYS2/MinGW with Rust support enabled, the\n          Makefile expects `cargo build` to drop a `target/release/libgitcore.a`\n     -    that is linkable by the same MinGW GCC used for every other object.\n     -    With Rust installed via `rustup` (the way it ships on the\n     -    GitHub-hosted `windows-2022` and `windows-11-arm` runners that build\n     -    microsoft/git), the default toolchain targets the MSVC ABI; cargo\n     -    then writes `target/release/gitcore.lib` instead, which the MinGW\n     -    `ld.exe` cannot consume:\n     +    that is linkable by the same MinGW GCC used for every other object. With\n     +    Rust installed via `rustup` (the way it ships on the GitHub-hosted\n     +    `windows-2022` and `windows-11-arm` runners that build git/git and its\n     +    forks), the default toolchain targets the MSVC ABI; cargo then writes\n     +    `target/release/gitcore.lib` instead, which the MinGW `ld.exe` cannot\n     +    consume:\n      \n              LINK git-shell.exe\n              D:\\git-sdk-64-minimal\\mingw64\\bin/ld.exe: cannot find target/release/libgitcore.a: No such file or directory\n              collect2.exe: error: ld returned 1 exit status\n      \n     -    See https://github.com/microsoft/git/actions/runs/27341625000 for the\n     -    full log.\n     +    See https://github.com/microsoft/git/actions/runs/27341625000 for a\n     +    full example log.\n      \n     -    Let's define the correct target. Re-use (and fix) the existing\n     -    `HOST_CPU` variable for that purpose. Avoid relying on environment\n     -    variables that are simply not defined in Git for Windows' minimal SDK\n     -    that Git uses in its CI runs.\n     +    Let's define the correct target, using the `CARGO_BUILD_TARGET` variable\n     +    that will be picked up by Rust, see\n     +    https://dirname.github.io/rust-std-doc/cargo/reference/environment-variables.html#:~:text=CARGO%5FBUILD%5FTARGET\n     +\n     +    Re-use (and fix) the existing `HOST_CPU` variable to determine the\n     +    correct value. Avoid relying on environment variables that are simply\n     +    not defined in Git for Windows' minimal SDK that Git uses in its CI\n     +    runs.\n     +\n     +    Note that this _still_ requires an explicit `--target` option to be\n     +    picked up in the way Git's build process calls cargo.\n      \n          Assisted-by: Claude Opus 4.7\n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n     @@ Makefile: RUST_LIB_NAME = gitcore.lib\n       RUST_LIB_NAME = libgitcore.a\n       endif\n      -RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n     -+RUST_LIB = target$(if $(CARGO_TARGET),/$(CARGO_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n     ++RUST_LIB = target$(if $(CARGO_BUILD_TARGET),/$(CARGO_BUILD_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n       endif\n       \n       GITLIBS = common-main.o $(LIB_FILE)\n     -@@ Makefile: endif\n     - ifndef DEBUG\n     - CARGO_ARGS += --release\n     - endif\n     -+CARGO_ARGS += $(if $(CARGO_TARGET),--target $(CARGO_TARGET))\n     - \n     - # For the 'sparse' target\n     - SPARSE_FLAGS ?= -std=gnu99 -D__STDC_NO_VLA__\n      \n       ## config.mak.uname ##\n      @@ config.mak.uname: ifeq ($(uname_S),MINGW)\n     @@ config.mak.uname: ifeq ($(uname_S),MINGW)\n      +\t\t\tHOST_CPU = x86_64\n      +                endif\n      +                ifneq (,$(filter CLANG%, $(MSYSTEM)))\n     -+\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnullvm\n     ++\t\t\tCARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnullvm\n      +                else\n     -+\t\t\tCARGO_TARGET = $(HOST_CPU)-pc-windows-gnu\n     ++\t\t\tCARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnu\n      +                endif\n     ++\t\texport CARGO_BUILD_TARGET\n      +\n       \t\tBASIC_LDFLAGS += -Wl,--pic-executable\n       \t\tCOMPAT_CFLAGS += -DDETECT_MSYS_TTY \\\n 2:  07415393e5 = 2:  76469029ff ci(windows): build with Rust\n\n-- \ngitgitgadget\n"},{"id":"552638","messageId":"b70b001f625e7cbf3947fbed4632a1fdb6e99763.1789295476.git.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.v3.git.1789295476.gitgitgadget@gmail.com","subject":"[PATCH v3 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-13T10:31:15Z","receivedAt":"2026-09-13T10:31:21Z","isPatch":true,"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen Git is built under MSYS2/MinGW with Rust support enabled, the\nMakefile expects `cargo build` to drop a `target/release/libgitcore.a`\nthat is linkable by the same MinGW GCC used for every other object. With\nRust installed via `rustup` (the way it ships on the GitHub-hosted\n`windows-2022` and `windows-11-arm` runners that build git/git and its\nforks), the default toolchain targets the MSVC ABI; cargo then writes\n`target/release/gitcore.lib` instead, which the MinGW `ld.exe` cannot\nconsume:\n\n    LINK git-shell.exe\n    D:\\git-sdk-64-minimal\\mingw64\\bin/ld.exe: cannot find target/release/libgitcore.a: No such file or directory\n    collect2.exe: error: ld returned 1 exit status\n\nSee https://github.com/microsoft/git/actions/runs/27341625000 for a\nfull example log.\n\nLet's define the correct target, using the `CARGO_BUILD_TARGET` variable\nthat will be picked up by Rust, see\nhttps://dirname.github.io/rust-std-doc/cargo/reference/environment-variables.html#:~:text=CARGO%5FBUILD%5FTARGET\n\nRe-use (and fix) the existing `HOST_CPU` variable to determine the\ncorrect value. Avoid relying on environment variables that are simply\nnot defined in Git for Windows' minimal SDK that Git uses in its CI\nruns.\n\nNote that this _still_ requires an explicit `--target` option to be\npicked up in the way Git's build process calls cargo.\n\nAssisted-by: Claude Opus 4.7\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile         |  2 +-\n config.mak.uname | 25 ++++++++++++++++++++++++-\n 2 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex fac3e8879c..ad1ba26f91 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib\n else\n RUST_LIB_NAME = libgitcore.a\n endif\n-RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n+RUST_LIB = target$(if $(CARGO_BUILD_TARGET),/$(CARGO_BUILD_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n endif\n \n GITLIBS = common-main.o $(LIB_FILE)\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 0b63be10b7..f3f3bcc4ef 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -758,7 +758,30 @@ ifeq ($(uname_S),MINGW)\n \t\t\tMINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z)\n                 endif\n \t\tprefix = $(MINGW_PREFIX)\n-\t\tHOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST))\n+\n+\t\t# A rustup-managed Rust on Windows defaults to the MSVC ABI and\n+\t\t# produces a `gitcore.lib` that the MinGW `ld.exe` cannot link.\n+\t\t# Pick a GCC-compatible Rust target triple matching the MSYS2\n+\t\t# subsystem instead: `*-pc-windows-gnullvm` for the Clang/LLVM\n+\t\t# subsystems (which on Windows is also the only choice for\n+\t\t# ARM64, where no MinGW-GCC port exists) and `*-pc-windows-gnu`\n+\t\t# for the MSVCRT-based MinGW subsystems. For a `staticlib`\n+\t\t# crate-type Cargo does not invoke an external linker, so\n+\t\t# `rustup target add <triple>` is sufficient.\n+                ifneq (,$(filter %ARM64, $(MSYSTEM)))\n+\t\t\tHOST_CPU = aarch64\n+                else ifneq (,$(filter %32, $(MSYSTEM)))\n+\t\t\tHOST_CPU = i686\n+                else\n+\t\t\tHOST_CPU = x86_64\n+                endif\n+                ifneq (,$(filter CLANG%, $(MSYSTEM)))\n+\t\t\tCARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnullvm\n+                else\n+\t\t\tCARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnu\n+                endif\n+\t\texport CARGO_BUILD_TARGET\n+\n \t\tBASIC_LDFLAGS += -Wl,--pic-executable\n \t\tCOMPAT_CFLAGS += -DDETECT_MSYS_TTY \\\n \t\t\t-DENSURE_MSYSTEM_IS_SET=\"\\\"$(MSYSTEM)\\\"\" \\\n-- \ngitgitgadget\n\n"},{"id":"552639","messageId":"76469029ff9ea99fa552c2b65da3c0957e2d73f5.1789295476.git.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.v3.git.1789295476.gitgitgadget@gmail.com","subject":"[PATCH v3 2/2] ci(windows): build with Rust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-13T10:31:16Z","receivedAt":"2026-09-13T10:31:22Z","isPatch":true,"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe Windows runners used by Git's GitHub workflow's `windows-build` job\nship `rustup` plus a `*-pc-windows-msvc` default toolchain (see\nhttps://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md\nand\nhttps://github.com/actions/partner-runner-images/blob/main/images/arm-windows-11-image.md),\nbut no precompiled `std` for `*-pc-windows-gnu` or\n`*-pc-windows-gnullvm`. With the Makefile now picking a GCC-compatible\ntarget triple based on `$(MSYSTEM)`, the build step needs that\nprecompiled `std` to be installed before invoking `make`, otherwise\n`cargo build --target <triple>` fails to find a usable `std` for the\nchosen target.\n\nAdd a step between the SDK setup and the `make` invocation that selects\nthe matching triple from `$MSYSTEM` (which\n`git-for-windows/setup-git-for-windows-sdk` exports for every subsequent\nstep) and runs `rustup target add` for it. The mapping mirrors what\n`config.mak.uname` derives from `$(MSYSTEM)` and `$(HOST_CPU)`, just\nenumerated explicitly here since CI has direct knowledge of which MSYS2\nsubsystems the matrix actually exercises (`CLANGARM64` for the ARM64\nrunner, `MINGW64` for the x86_64 runner). Technically, we only need to\nhandle MINGW64 at present, but the switch to UCRT64 is imminent, and the\nother case arms serve as a very fine documentation of what people should\ndo for other MSYSTEM values.\n\nFor a `staticlib` crate-type `cargo build` does not invoke an external\nlinker, so no further toolchain components (e.g. the `gnullvm` LLVM\nlinker) need to be installed; `rustup target add` alone is sufficient.\n\nAssisted-by: Claude Opus 4.7\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .github/workflows/main.yml | 24 ++++++++++++++++++++++++\n ci/lib.sh                  |  3 ---\n 2 files changed, 24 insertions(+), 3 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 85cfedf5b0..0972547395 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -114,6 +114,30 @@ jobs:\n     steps:\n     - uses: actions/checkout@v6\n     - uses: git-for-windows/setup-git-for-windows-sdk@v2\n+    - name: Install GCC-compatible Rust target\n+      shell: bash\n+      run: |\n+        # The hosted Windows runners ship a rustup-managed Rust whose\n+        # default toolchain targets the MSVC ABI. That produces a\n+        # `gitcore.lib` which the MinGW GCC used by the rest of the\n+        # build cannot link. Install the precompiled `std` for a\n+        # GCC-compatible target triple matching the MSYS2 subsystem;\n+        # the Makefile selects the same triple via $(MSYSTEM) and\n+        # passes it to `cargo build --target`.\n+        case \"$MSYSTEM\" in\n+        CLANGARM64) target=aarch64-pc-windows-gnullvm ;;\n+        CLANG64)    target=x86_64-pc-windows-gnullvm  ;;\n+        CLANG32)    target=i686-pc-windows-gnullvm    ;;\n+        UCRT64)     target=x86_64-pc-windows-gnu      ;;\n+        MINGW64)    target=x86_64-pc-windows-gnu      ;;\n+        MINGW32)    target=i686-pc-windows-gnu        ;;\n+        *) echo \"::error::Unsupported MSYSTEM: $MSYSTEM\"; exit 1 ;;\n+        esac &&\n+        rustup target add \"$target\" &&\n+\n+        # Ensure that cargo.exe is found even with the minimal SDK's restricted PATH\n+        CARGO=\"$(type -p cargo.exe)\" &&\n+        echo \"export PATH=\\$PATH:${CARGO%/cargo.exe}\" >>/etc/profile\n     - name: build\n       shell: bash\n       env:\ndiff --git a/ci/lib.sh b/ci/lib.sh\nindex 6c52154eac..c6ccbf8c17 100755\n--- a/ci/lib.sh\n+++ b/ci/lib.sh\n@@ -391,9 +391,6 @@ linux-asan-ubsan)\n osx-meson)\n \tMESONFLAGS=\"$MESONFLAGS -Dcredential_helpers=osxkeychain\"\n \t;;\n-windows-*)\n-\texport NO_RUST=UnfortunatelyYes\n-\t;;\n esac\n \n MAKEFLAGS=\"$MAKEFLAGS CC=${CC:-cc}\"\n-- \ngitgitgadget\n"},{"id":"552642","messageId":"pull.2213.v4.git.1789315032.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.git.1788272509.gitgitgadget@gmail.com","subject":"[PATCH v4 0/2] Use Rust in the Windows CI jobs","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-13T15:57:10Z","receivedAt":"2026-09-13T15:57:14Z","isPatch":true,"body":"With v2.55.0, Git requires Rust by default, with an opt-out that is intended\nto be dropped in one of the next versions.\n\nDue to the special circumstances in the Windows part of the CI builds, each\nWindows build job first downloads a \"minimal Git for Windows SDK\" that\ncontains the GCC toolchain required to build and test Git. As a consequence,\nbrian m. carlson opted out of Rust in Git's CI definition in 32d5b905909e\n(Enable Rust by default, 2026-04-09).\n\nSo: How could we stop opting out? Notably, Rust is not part of that minimal\nGit for Windows SDK, and including it would more than double that payload,\nwhich I consider prohibitive. Yet including Rust in the minimal Git for\nWindows SDK is not actually necessary, at least not for the GitHub workflow:\nThe runners on which this workflow is defined to run come with Rust\npre-installed.\n\nGranted, this Rust installation is configured to target the Windows-native C\ncompiler, Visual C. To accommodate for the Windows CI job building with GCC,\nthis patch series adds a step to the workflow that ensures that the needed\nRust bits are installed and configured.\n\nGitLab peeps, I still would love to ask for your help: I haven't been able\nto confirm that GitLab's Windows runners come with Rust preinstalled,\nhttps://docs.gitlab.com/ci/runners/hosted_runners/windows/#available-runtimes\ndid not clarify that for me. Patrick (or anyone else with access to GitLab\nCI), could you see whether this patch series builds on\nsaas-windows-medium-amd64 without need for further changes?\n\nChanges since v3:\n\n * Now including the \"Changes since v2\"... (I thought I had edited the PR\n   comment, but either I forgot to press the \"Update comment\" button, or I\n   missed one of the many issues I had today with PR comments, caused by\n   many a 500).\n * Removed the now-incorrect paragraph from the commit message that still\n   talks about --target.\n * Sending my humblest apologies for such a quick succession (but I really\n   think that v3 is ready for next).\n\nChanges since v2:\n\n * Now using CARGO_BUILD_TARGET; Reworded the commit message accordingly.\n * Dropped the now-unnecessary --target option.\n\nChanges since v1:\n\n * The inconsistency pointed out by Junio, that UCRT64 was once marked as\n   using clang and once as using gcc was fixed by clarifying that UCRT64\n   uses GCC.\n\nJohannes Schindelin (2):\n  rust: pick a GCC-compatible Cargo target under MSYS2/MinGW\n  ci(windows): build with Rust\n\n .github/workflows/main.yml | 24 ++++++++++++++++++++++++\n Makefile                   |  2 +-\n ci/lib.sh                  |  3 ---\n config.mak.uname           | 25 ++++++++++++++++++++++++-\n 4 files changed, 49 insertions(+), 5 deletions(-)\n\n\nbase-commit: f4742f3165d096130c39a71feb26374da37620f2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2213%2Fdscho%2Fuse-rust-in-windows-ci-builds-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2213/dscho/use-rust-in-windows-ci-builds-v4\nPull-Request: https://github.com/gitgitgadget/git/pull/2213\n\nRange-diff vs v3:\n\n 1:  b70b001f62 ! 1:  6e8648b21c rust: pick a GCC-compatible Cargo target under MSYS2/MinGW\n     @@ Commit message\n          not defined in Git for Windows' minimal SDK that Git uses in its CI\n          runs.\n      \n     -    Note that this _still_ requires an explicit `--target` option to be\n     -    picked up in the way Git's build process calls cargo.\n     -\n          Assisted-by: Claude Opus 4.7\n          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n      \n 2:  76469029ff = 2:  f6c2f52fb3 ci(windows): build with Rust\n\n-- \ngitgitgadget\n"},{"id":"552643","messageId":"6e8648b21cc88d0a79c3fdff51ba5539ff642145.1789315032.git.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.v4.git.1789315032.gitgitgadget@gmail.com","subject":"[PATCH v4 1/2] rust: pick a GCC-compatible Cargo target under MSYS2/MinGW","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-13T15:57:11Z","receivedAt":"2026-09-13T15:57:16Z","isPatch":true,"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen Git is built under MSYS2/MinGW with Rust support enabled, the\nMakefile expects `cargo build` to drop a `target/release/libgitcore.a`\nthat is linkable by the same MinGW GCC used for every other object. With\nRust installed via `rustup` (the way it ships on the GitHub-hosted\n`windows-2022` and `windows-11-arm` runners that build git/git and its\nforks), the default toolchain targets the MSVC ABI; cargo then writes\n`target/release/gitcore.lib` instead, which the MinGW `ld.exe` cannot\nconsume:\n\n    LINK git-shell.exe\n    D:\\git-sdk-64-minimal\\mingw64\\bin/ld.exe: cannot find target/release/libgitcore.a: No such file or directory\n    collect2.exe: error: ld returned 1 exit status\n\nSee https://github.com/microsoft/git/actions/runs/27341625000 for a\nfull example log.\n\nLet's define the correct target, using the `CARGO_BUILD_TARGET` variable\nthat will be picked up by Rust, see\nhttps://dirname.github.io/rust-std-doc/cargo/reference/environment-variables.html#:~:text=CARGO%5FBUILD%5FTARGET\n\nRe-use (and fix) the existing `HOST_CPU` variable to determine the\ncorrect value. Avoid relying on environment variables that are simply\nnot defined in Git for Windows' minimal SDK that Git uses in its CI\nruns.\n\nAssisted-by: Claude Opus 4.7\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile         |  2 +-\n config.mak.uname | 25 ++++++++++++++++++++++++-\n 2 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex fac3e8879c..ad1ba26f91 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib\n else\n RUST_LIB_NAME = libgitcore.a\n endif\n-RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n+RUST_LIB = target$(if $(CARGO_BUILD_TARGET),/$(CARGO_BUILD_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)\n endif\n \n GITLIBS = common-main.o $(LIB_FILE)\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 0b63be10b7..f3f3bcc4ef 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -758,7 +758,30 @@ ifeq ($(uname_S),MINGW)\n \t\t\tMINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z)\n                 endif\n \t\tprefix = $(MINGW_PREFIX)\n-\t\tHOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST))\n+\n+\t\t# A rustup-managed Rust on Windows defaults to the MSVC ABI and\n+\t\t# produces a `gitcore.lib` that the MinGW `ld.exe` cannot link.\n+\t\t# Pick a GCC-compatible Rust target triple matching the MSYS2\n+\t\t# subsystem instead: `*-pc-windows-gnullvm` for the Clang/LLVM\n+\t\t# subsystems (which on Windows is also the only choice for\n+\t\t# ARM64, where no MinGW-GCC port exists) and `*-pc-windows-gnu`\n+\t\t# for the MSVCRT-based MinGW subsystems. For a `staticlib`\n+\t\t# crate-type Cargo does not invoke an external linker, so\n+\t\t# `rustup target add <triple>` is sufficient.\n+                ifneq (,$(filter %ARM64, $(MSYSTEM)))\n+\t\t\tHOST_CPU = aarch64\n+                else ifneq (,$(filter %32, $(MSYSTEM)))\n+\t\t\tHOST_CPU = i686\n+                else\n+\t\t\tHOST_CPU = x86_64\n+                endif\n+                ifneq (,$(filter CLANG%, $(MSYSTEM)))\n+\t\t\tCARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnullvm\n+                else\n+\t\t\tCARGO_BUILD_TARGET = $(HOST_CPU)-pc-windows-gnu\n+                endif\n+\t\texport CARGO_BUILD_TARGET\n+\n \t\tBASIC_LDFLAGS += -Wl,--pic-executable\n \t\tCOMPAT_CFLAGS += -DDETECT_MSYS_TTY \\\n \t\t\t-DENSURE_MSYSTEM_IS_SET=\"\\\"$(MSYSTEM)\\\"\" \\\n-- \ngitgitgadget\n\n"},{"id":"552644","messageId":"f6c2f52fb35944b8b9122e2184645613c57973aa.1789315032.git.gitgitgadget@gmail.com","threadId":"66247","inReplyTo":"pull.2213.v4.git.1789315032.gitgitgadget@gmail.com","subject":"[PATCH v4 2/2] ci(windows): build with Rust","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-09-13T15:57:12Z","receivedAt":"2026-09-13T15:57:17Z","isPatch":true,"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThe Windows runners used by Git's GitHub workflow's `windows-build` job\nship `rustup` plus a `*-pc-windows-msvc` default toolchain (see\nhttps://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md\nand\nhttps://github.com/actions/partner-runner-images/blob/main/images/arm-windows-11-image.md),\nbut no precompiled `std` for `*-pc-windows-gnu` or\n`*-pc-windows-gnullvm`. With the Makefile now picking a GCC-compatible\ntarget triple based on `$(MSYSTEM)`, the build step needs that\nprecompiled `std` to be installed before invoking `make`, otherwise\n`cargo build --target <triple>` fails to find a usable `std` for the\nchosen target.\n\nAdd a step between the SDK setup and the `make` invocation that selects\nthe matching triple from `$MSYSTEM` (which\n`git-for-windows/setup-git-for-windows-sdk` exports for every subsequent\nstep) and runs `rustup target add` for it. The mapping mirrors what\n`config.mak.uname` derives from `$(MSYSTEM)` and `$(HOST_CPU)`, just\nenumerated explicitly here since CI has direct knowledge of which MSYS2\nsubsystems the matrix actually exercises (`CLANGARM64` for the ARM64\nrunner, `MINGW64` for the x86_64 runner). Technically, we only need to\nhandle MINGW64 at present, but the switch to UCRT64 is imminent, and the\nother case arms serve as a very fine documentation of what people should\ndo for other MSYSTEM values.\n\nFor a `staticlib` crate-type `cargo build` does not invoke an external\nlinker, so no further toolchain components (e.g. the `gnullvm` LLVM\nlinker) need to be installed; `rustup target add` alone is sufficient.\n\nAssisted-by: Claude Opus 4.7\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .github/workflows/main.yml | 24 ++++++++++++++++++++++++\n ci/lib.sh                  |  3 ---\n 2 files changed, 24 insertions(+), 3 deletions(-)\n\ndiff --git a/.github/workflows/main.yml b/.github/workflows/main.yml\nindex 85cfedf5b0..0972547395 100644\n--- a/.github/workflows/main.yml\n+++ b/.github/workflows/main.yml\n@@ -114,6 +114,30 @@ jobs:\n     steps:\n     - uses: actions/checkout@v6\n     - uses: git-for-windows/setup-git-for-windows-sdk@v2\n+    - name: Install GCC-compatible Rust target\n+      shell: bash\n+      run: |\n+        # The hosted Windows runners ship a rustup-managed Rust whose\n+        # default toolchain targets the MSVC ABI. That produces a\n+        # `gitcore.lib` which the MinGW GCC used by the rest of the\n+        # build cannot link. Install the precompiled `std` for a\n+        # GCC-compatible target triple matching the MSYS2 subsystem;\n+        # the Makefile selects the same triple via $(MSYSTEM) and\n+        # passes it to `cargo build --target`.\n+        case \"$MSYSTEM\" in\n+        CLANGARM64) target=aarch64-pc-windows-gnullvm ;;\n+        CLANG64)    target=x86_64-pc-windows-gnullvm  ;;\n+        CLANG32)    target=i686-pc-windows-gnullvm    ;;\n+        UCRT64)     target=x86_64-pc-windows-gnu      ;;\n+        MINGW64)    target=x86_64-pc-windows-gnu      ;;\n+        MINGW32)    target=i686-pc-windows-gnu        ;;\n+        *) echo \"::error::Unsupported MSYSTEM: $MSYSTEM\"; exit 1 ;;\n+        esac &&\n+        rustup target add \"$target\" &&\n+\n+        # Ensure that cargo.exe is found even with the minimal SDK's restricted PATH\n+        CARGO=\"$(type -p cargo.exe)\" &&\n+        echo \"export PATH=\\$PATH:${CARGO%/cargo.exe}\" >>/etc/profile\n     - name: build\n       shell: bash\n       env:\ndiff --git a/ci/lib.sh b/ci/lib.sh\nindex 6c52154eac..c6ccbf8c17 100755\n--- a/ci/lib.sh\n+++ b/ci/lib.sh\n@@ -391,9 +391,6 @@ linux-asan-ubsan)\n osx-meson)\n \tMESONFLAGS=\"$MESONFLAGS -Dcredential_helpers=osxkeychain\"\n \t;;\n-windows-*)\n-\texport NO_RUST=UnfortunatelyYes\n-\t;;\n esac\n \n MAKEFLAGS=\"$MAKEFLAGS CC=${CC:-cc}\"\n-- \ngitgitgadget\n"},{"id":"552654","messageId":"xmqq33vc932l.fsf@gitster.g","threadId":"66247","inReplyTo":"pull.2213.v4.git.1789315032.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 0/2] Use Rust in the Windows CI jobs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-13T22:52:34Z","receivedAt":"2026-09-13T22:52:37Z","isPatch":true,"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> GitLab peeps, I still would love to ask for your help: I haven't been able\n> to confirm that GitLab's Windows runners come with Rust preinstalled,\n> https://docs.gitlab.com/ci/runners/hosted_runners/windows/#available-runtimes\n> did not clarify that for me. Patrick (or anyone else with access to GitLab\n> CI), could you see whether this patch series builds on\n> saas-windows-medium-amd64 without need for further changes?\n>\n> Changes since v3:\n>\n>  * Now including the \"Changes since v2\"... (I thought I had edited the PR\n>    comment, but either I forgot to press the \"Update comment\" button, or I\n>    missed one of the many issues I had today with PR comments, caused by\n>    many a 500).\n>  * Removed the now-incorrect paragraph from the commit message that still\n>    talks about --target.\n>  * Sending my humblest apologies for such a quick succession (but I really\n>    think that v3 is ready for next).\n\nYup, and this one also is.  \n\nIt is our practice to cook new patches that people involved in their\ndevelopment agree to be good stil in 'next' for a week just in case,\nbut as I assume that Windows have unusually higher ratio of binary\nusers relative to those who build from the source, it would not\nbenefit as much as other platforms from such a practice, so let's\nmerge it in 'next' and fast track down to 'master' immediately.\n"},{"id":"552853","messageId":"xmqq8q4zosri.fsf@gitster.g","threadId":"66247","inReplyTo":"pull.2213.v4.git.1789315032.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 0/2] Use Rust in the Windows CI jobs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-18T08:42:09Z","receivedAt":"2026-09-18T08:42:12Z","isPatch":true,"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> GitLab peeps, I still would love to ask for your help: I haven't been able\n> to confirm that GitLab's Windows runners come with Rust preinstalled,\n> https://docs.gitlab.com/ci/runners/hosted_runners/windows/#available-runtimes\n> did not clarify that for me. Patrick (or anyone else with access to GitLab\n> CI), could you see whether this patch series builds on\n> saas-windows-medium-amd64 without need for further changes?\n\nI rarely look at failures in individual tasks there, but noticed\nthat a recent run:\n\n  https://gitlab.com/git-scm/git/-/jobs/16576450182#L784\n\nfailed with \"cargo: command not found\".\n"},{"id":"552922","messageId":"ffb1a618-5c6a-871e-c93f-0d4786745635@gmx.de","threadId":"66247","inReplyTo":"xmqq8q4zosri.fsf@gitster.g","subject":"Re: [PATCH v4 0/2] Use Rust in the Windows CI jobs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2026-09-21T07:05:41Z","receivedAt":"2026-09-21T07:06:01Z","isPatch":true,"body":"Hi Junio (and lurkers),\n\nOn Mon, 21 Sep 2026, Junio C Hamano wrote:\n\n> \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n> \n> > GitLab peeps, I still would love to ask for your help: I haven't been able\n> > to confirm that GitLab's Windows runners come with Rust preinstalled,\n> > https://docs.gitlab.com/ci/runners/hosted_runners/windows/#available-runtimes\n> > did not clarify that for me. Patrick (or anyone else with access to GitLab\n> > CI), could you see whether this patch series builds on\n> > saas-windows-medium-amd64 without need for further changes?\n> \n> I rarely look at failures in individual tasks there, but noticed\n> that a recent run:\n> \n>   https://gitlab.com/git-scm/git/-/jobs/16576450182#L784\n> \n> failed with \"cargo: command not found\".\n\nTo close the loop: I am trying to address this in this thread:\n\nhttps://lore.kernel.org/git/6c2bba91-a1a9-3547-4be3-f4f9ce03e696@gmx.de\n\nCiao,\nJohannes\n"},{"id":"552945","messageId":"xmqqbj9qmqik.fsf@gitster.g","threadId":"66247","inReplyTo":"ffb1a618-5c6a-871e-c93f-0d4786745635@gmx.de","subject":"Re: [PATCH v4 0/2] Use Rust in the Windows CI jobs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-09-21T18:02:43Z","receivedAt":"2026-09-21T18:02:46Z","isPatch":true,"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi Junio (and lurkers),\n>\n> On Mon, 21 Sep 2026, Junio C Hamano wrote:\n>\n>> \"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\n>> writes:\n>> \n>> > GitLab peeps, I still would love to ask for your help: I haven't been able\n>> > to confirm that GitLab's Windows runners come with Rust preinstalled,\n>> > https://docs.gitlab.com/ci/runners/hosted_runners/windows/#available-runtimes\n>> > did not clarify that for me. Patrick (or anyone else with access to GitLab\n>> > CI), could you see whether this patch series builds on\n>> > saas-windows-medium-amd64 without need for further changes?\n>> \n>> I rarely look at failures in individual tasks there, but noticed\n>> that a recent run:\n>> \n>>   https://gitlab.com/git-scm/git/-/jobs/16576450182#L784\n>> \n>> failed with \"cargo: command not found\".\n>\n> To close the loop: I am trying to address this in this thread:\n>\n> https://lore.kernel.org/git/6c2bba91-a1a9-3547-4be3-f4f9ce03e696@gmx.de\n\nYup.  I saw Karthik's response as well and consider the issue is now\nin good hands ;-).\n\nThanks.\n\n"}]}