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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 21, 2025, 21:39 UTC
Message-ID
<xmqq34673w22.fsf@gitster.g>
In-Reply-To
<dc753c0e-eb93-948c-55f7-bb0e91772c83@gmx.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Here is my patch (with proper handling of MSVC, but obviously it no longer
> applies without conflicts):
Thanks.  Here is my attempt to make it apply to 'master'.
It seems to pass win+Meson build & test for 'master'.
  https://github.com/git/git/actions/runs/19583133885

But curiously, the tip of 'master' has been happy without this fix, and it does not help when brian's SHA-256 interop topic merged further on top, but I didn't look any further.

--- >8 ---
Subject: [PATCH] meson(cargo): Visual C produces gitcore.lib, not libgitcore.a

On Windows, when Visual C compiler is used to compile, the resulting library that is created is called gitcore.lib instead of libgitcore.a library archive.

Johannes sent a fix in <dc753c0e-eb93-948c-55f7-bb0e91772c83@gmx.de> that was based on an older code base, which I attempted to forward port it to apply to today's codebase.

Based-on-the-patch-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 src/cargo-meson.sh | 14 ++++----------
 src/meson.build    | 11 ++++++++++-
 2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/cargo-meson.sh b/src/cargo-meson.sh
index 3998db0435..4a46f731d8 100755
--- a/src/cargo-meson.sh
+++ b/src/cargo-meson.sh
@@ -7,9 +7,10 @@ fi
 
 SOURCE_DIR="$1"
 BUILD_DIR="$2"
+LIBNAME="$3"
 BUILD_TYPE=debug
 
-shift 2
+shift 3
 
 for arg
 do
@@ -26,14 +27,7 @@ then
 	exit $RET
 fi
 
-case "$(cargo -vV | sed -s 's/^host: \(.*\)$/\1/')" in
-	*-windows-*)
-		LIBNAME=gitcore.lib;;
-	*)
-		LIBNAME=libgitcore.a;;
-esac
-
-if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1
+if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/$LIBNAME" >/dev/null 2>&1
 then
-	cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a"
+	cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/$LIBNAME"
 fi
diff --git a/src/meson.build b/src/meson.build
index 25b9ad5a14..f37f0a5f58 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -3,6 +3,14 @@ libgit_rs_sources = [
   'varint.rs',
 ]
 
+# The exact file name depends on the compiler
+if meson.get_compiler('c').get_id() == 'msvc'
+  libname = 'gitcore.lib'
+else
+  libname = '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
@@ -12,6 +20,7 @@ cargo_command = [
   meson.current_source_dir() / 'cargo-meson.sh',
   meson.project_source_root(),
   meson.current_build_dir(),
+  libname,
 ]
 if get_option('buildtype') == 'release'
   cargo_command += '--release'
@@ -21,7 +30,7 @@ libgit_rs = custom_target('git_rs',
   input: libgit_rs_sources + [
     meson.project_source_root() / 'Cargo.toml',
   ],
-  output: 'libgitcore.a',
+  output: libname,
   command: cargo_command,
 )
 libgit_dependencies += declare_dependency(link_with: libgit_rs)
-- 
2.52.0-168-gcf2c56d51e
Previous: Johannes SchindelinNext: Junio C Hamano
Message 36 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.