git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 6/6] rust: support for Windows

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 21, 2025, 08:18 UTC
Message-ID
<dc753c0e-eb93-948c-55f7-bb0e91772c83@gmx.de>
In-Reply-To
<CAH=ZcbB8cRgCTp-Q_CxJ4VFNY1+w+C20zgx9bMre4-hNmPrD7g@mail.gmail.com>
Hi Ezekiel,
On Thu, 20 Nov 2025, Ezekiel Newren wrote:
> This is a retrospective review. I completely missed this patch series,
> and only noticed its existence after it was merged into master. The
> core problem is that these changes assume that windows builds only
> ever use the MSVC compiler, but that's not true.

Correct. I had actually worked on a solution to this in Git for Windows, but due to time constraints (after factoring in the usual time tax, other priorities dictated that I wouldn't have time to see it through) I hadn't had time to contribute it, let alone engage in reviewing Patrick's patches (I had actually not even seen them until I had written the patch and verified that it fixed the issue).

Here is my patch (with proper handling of MSVC, but obviously it no longer applies without conflicts): https://github.com/git-for-windows/git/commit/0949ff2ad5d1d085b10c63029c65293416732851

-- snipsnap --
From 0949ff2ad5d1d085b10c63029c65293416732851 Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Fri, 24 Oct 2025 14:49:22 +0200
Subject: [PATCH] meson(cargo): support Windows again

For over a year, Git has been moved to a more modern build system than it had before (GNU make, or on Windows optionally CMake). Naturally, this new system breaks Windows support left and right.

For example, c184795fc0e (meson: add infrastructure to build internal Rust library, 2025-10-02) added support for building a Rust library, and it fails when Visual C is configured as compiler.

This is the reason that the `win+Meson` job of Git's `master` branch fails for the past 16 days, i.e. the latest 9 pushes of the `master` branch as of time of writing. The symptom is:

  [697/905] Generating src/git_rs with a custom command
  FAILED: [code=1] src/libgitcore.a "C:\Program Files\Git\bin\sh.exe" "D:/a/git/git/src/cargo-meson.sh" "D:/a/git/git" "D:/a/git/git/build/src" "--release"
  cp: cannot stat 'D:/a/git/git/build/src/release/libgitcore.a': No such file or directory

The reason is that Visual C's output is called `gitcore.lib`, not `libgitcore.a`. Let's special-case Visual C and use the correct filename in all cases.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 src/cargo-meson.sh |  7 +++++--
 src/meson.build    | 10 +++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/cargo-meson.sh b/src/cargo-meson.sh
index 99400986d93..c14a08c592d 100755
--- a/src/cargo-meson.sh
+++ b/src/cargo-meson.sh
@@ -5,6 +5,9 @@ then
 	exit 1
 fi
 
+target="$1"
+shift
+
 SOURCE_DIR="$1"
 BUILD_DIR="$2"
 BUILD_TYPE=debug
@@ -26,7 +29,7 @@ then
 	exit $RET
 fi
 
-if ! cmp "$BUILD_DIR/$BUILD_TYPE/libgitcore.a" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1
+if ! cmp "$BUILD_DIR/$BUILD_TYPE/$target" "$BUILD_DIR/$target" >/dev/null 2>&1
 then
-	cp "$BUILD_DIR/$BUILD_TYPE/libgitcore.a" "$BUILD_DIR/libgitcore.a"
+	cp "$BUILD_DIR/$BUILD_TYPE/$target" "$BUILD_DIR/$target"
 fi
diff --git a/src/meson.build b/src/meson.build
index 25b9ad5a147..b2473c46994 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -3,6 +3,13 @@ libgit_rs_sources = [
   'varint.rs',
 ]
 
+# The exact file name depends on the compiler
+if meson.get_compiler('c').get_id() == 'msvc'
+  target = 'gitcore.lib'
+else
+  target = 'libgitcore.a'
+endif
+
 # Unfortunately we must use a wrapper command to move the output file into the
 # current build directory. This can fixed once `cargo build --artifact-dir`
 # stabilizes. See https://github.com/rust-lang/cargo/issues/6790 for that
@@ -10,6 +17,7 @@ libgit_rs_sources = [
 cargo_command = [
   shell,
   meson.current_source_dir() / 'cargo-meson.sh',
+  target,
   meson.project_source_root(),
   meson.current_build_dir(),
 ]
@@ -21,7 +29,7 @@ libgit_rs = custom_target('git_rs',
   input: libgit_rs_sources + [
     meson.project_source_root() / 'Cargo.toml',
   ],
-  output: 'libgitcore.a',
+  output: target,
   command: cargo_command,
 )
 libgit_dependencies += declare_dependency(link_with: libgit_rs)
-- 
2.51.1.windows.1
Previous: Ezekiel NewrenNext: Junio C Hamano
Message 35 of 37 in “ci: improvements to our Rust infrastructure”
  1. 0/6 ci: improvements to our Rust infrastructurePatrick Steinhardt, Oct 7, 2025
  2. 1/6 ci: deduplicate calls to `apt-get update`Patrick Steinhardt, Oct 7, 2025
  3. Karthik NayakOct 7, 2025
  4. Justin ToblerOct 14, 2025
  5. 2/6 ci: check formatting of our Rust codePatrick Steinhardt, Oct 7, 2025
  6. Karthik NayakOct 7, 2025
  7. Patrick SteinhardtOct 7, 2025
  8. Eric SunshineOct 7, 2025
  9. Junio C HamanoOct 7, 2025
  10. Eric SunshineOct 7, 2025
  11. brian m. carlsonOct 7, 2025
  12. Chris TorekOct 7, 2025
  13. Patrick SteinhardtOct 8, 2025
  14. Junio C HamanoOct 8, 2025
  15. Patrick SteinhardtOct 9, 2025
  16. SZEDER GáborOct 29, 2025
  17. brian m. carlsonOct 7, 2025
  18. SZEDER GáborOct 8, 2025
  19. Patrick SteinhardtOct 9, 2025
  20. SZEDER GáborOct 29, 2025
  21. 3/6 rust/varint: add safety commentsPatrick Steinhardt, Oct 7, 2025
  22. brian m. carlsonOct 8, 2025
  23. Patrick SteinhardtOct 8, 2025
  24. 4/6 ci: check for common Rust mistakes via ClippyPatrick Steinhardt, Oct 7, 2025
  25. 5/6 ci: verify minimum supported Rust versionPatrick Steinhardt, Oct 7, 2025
  26. 6/6 rust: support for WindowsPatrick Steinhardt, Oct 7, 2025
  27. 0/6 ci: improvements to our Rust infrastructurePatrick Steinhardt, Oct 15, 2025
  28. 1/6 ci: deduplicate calls to `apt-get update`Patrick Steinhardt, Oct 15, 2025
  29. 2/6 ci: check formatting of our Rust codePatrick Steinhardt, Oct 15, 2025
  30. 3/6 rust/varint: add safety commentsPatrick Steinhardt, Oct 15, 2025
  31. 4/6 ci: check for common Rust mistakes via ClippyPatrick Steinhardt, Oct 15, 2025
  32. 5/6 ci: verify minimum supported Rust versionPatrick Steinhardt, Oct 15, 2025
  33. 6/6 rust: support for WindowsPatrick Steinhardt, Oct 15, 2025
  34. Ezekiel NewrenNov 20, 2025
  35. Johannes SchindelinNov 21, 2025
  36. Junio C HamanoNov 21, 2025
  37. Junio C HamanoOct 15, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.