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

Re: [PATCH 0/7] RFC: Accelerate xdiff and begin its rustification

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 19, 2025, 21:53 UTC
Message-ID
<ac871bc4-df93-31f4-55f2-d6fc538a422d@gmx.de>
In-Reply-To
<pull.1980.git.git.1752784344.gitgitgadget@gmail.com>

Hi Ezekiel, pleasure to make your acquaintance!

On Thu, 17 Jul 2025, Ezekiel Newren via GitGitGadget wrote:
> 1. Windows fails to build. I don’t know which rust toolchain is even
>    correct for this or if multiple are needed.  Example failed build:
>    https://github.com/git/git/actions/runs/16353209191

There are a couple of problems, not just one. Here are the patches that I would like to ask you to take custody of (for your convenience, I have pushed them to https://github.com/dscho/git as the `xdiff_rust_speedup` branch). Please find them below. They _just_ fix the build, but the tests with win+Meson still fail (and as "win+Meson test" jobs keep the logs of the failed tests a well-guarded secret, due to time constraints I have to stop looking into this for now).

Thank you for working on this, Johannes

-- snipsnap --
From 72c50ee3f9df5ccfe48bf6f44b2c6bba05a680bf Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Sat, 19 Jul 2025 21:24:07 +0200
Subject: [PATCH 1/3] Do support Windows again after requiring Rust

By default, Rust wants to build MS Visual C-compatible libraries on Windows, because that is _the_ native C compiler.

Git is historically lacking in its MSVC support, and the official Git for Windows versions are built using GCC instead. As a consequence, a (subset of a) GCC toolchain is installed as part of the `windows-build` job of every CI build.

Naturally, this requires adjustments in how Rust is called, most importantly it requires installing support for a GCC-compatible build target.

Let's make the necessary adjustment both in the CI-specific code that installs Rust as well as in the Windows-specific configuration in `config.mak.uname`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 ci/install-rust.sh | 3 +++
 config.mak.uname   | 9 +++++++++
 2 files changed, 12 insertions(+)
diff --git a/ci/install-rust.sh b/ci/install-rust.sh
index 141ceddb17cfe..c22baa629ceb7 100644
--- a/ci/install-rust.sh
+++ b/ci/install-rust.sh
@@ -28,6 +28,9 @@ if [ "$BITNESS" = "32" ]; then
   $CARGO_HOME/bin/rustup default --force-non-host $RUST_VERSION || exit $?
 else
   $CARGO_HOME/bin/rustup default $RUST_VERSION || exit $?
+  if [ "$CI_OS_NAME" = "windows" ]; then
+    $CARGO_HOME/bin/rustup target add x86_64-pc-windows-gnu || exit $?
+  fi
 fi
 
 . $CARGO_HOME/env
diff --git a/config.mak.uname b/config.mak.uname
index 3e26bb074a4b5..fbe7cebf40edd 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -727,19 +727,28 @@ ifeq ($(uname_S),MINGW)
 		prefix = /mingw32
 		HOST_CPU = i686
 		BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
+		CARGO_BUILD_TARGET = i686-pc-windows-gnu
         endif
         ifeq (MINGW64,$(MSYSTEM))
 		prefix = /mingw64
 		HOST_CPU = x86_64
 		BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
+		CARGO_BUILD_TARGET = x86_64-pc-windows-gnu
         else ifeq (CLANGARM64,$(MSYSTEM))
 		prefix = /clangarm64
 		HOST_CPU = aarch64
 		BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
+		CARGO_BUILD_TARGET = aarch64-pc-windows-gnu
         else
 		COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
 		BASIC_LDFLAGS += -Wl,--large-address-aware
         endif
+
+	export CARGO_BUILD_TARGET
+	RUST_TARGET_DIR = rust/target/$(CARGO_BUILD_TARGET)/$(RUST_BUILD_MODE)
+	# Unfortunately now needed because of Rust
+	EXTLIBS += -luserenv
+
 	CC = gcc
 	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
 		-fstack-protector-strong
-- 
2.50.1.windows.1


From ef6e4394ae26d8f28cb0d9e456810ce0818e623b Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Sat, 19 Jul 2025 23:08:11 +0200
Subject: [PATCH 2/3] win+Meson: allow for xdiff to be compiled with MSVC

The `build_rust.sh` script is quite opinionated about the naming scheme
of the C compiler: It assumes that the xdiff library file will be named
`libxdiff.a`.

However, MS Visual C generates `xdiff.lib` files instead; This naming
scheme has been in use in a very, very long time.

Let's allow for that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 build_rust.sh |  7 ++++++-
 meson.build   | 12 +++++++++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/build_rust.sh b/build_rust.sh
index 4c12135cd2050..694d48d857a58 100755
--- a/build_rust.sh
+++ b/build_rust.sh
@@ -44,7 +44,12 @@ fi
 
 cd $dir_rust && cargo clean && pwd && cargo build -p $crate $rust_args; cd ..
 
-libfile="lib${crate}.a"
+if grep x86_64-pc-windows-msvc rust/target/.rustc_info.json
+then
+  libfile="${crate}.lib"
+else
+  libfile="lib${crate}.a"
+fi
 dst=$dir_build/$libfile
 
 if [ "$dir_git_root" != "$dir_build" ]; then
diff --git a/meson.build b/meson.build
index 047d7e5b66306..5e89a5dd0e00f 100644
--- a/meson.build
+++ b/meson.build
@@ -277,8 +277,16 @@ else
   rustflags = '-Aunused_imports -Adead_code -C debuginfo=2 -C opt-level=1 -C force-frame-pointers=yes'
 endif
 
+compiler = meson.get_compiler('c')
+
+if compiler.get_id() == 'msvc'
+  xdiff_lib_filename = 'xdiff.lib'
+else
+  xdiff_lib_filename = 'libxdiff.a'
+endif
+
 rust_build_xdiff = custom_target('rust_build_xdiff',
-  output: 'libxdiff.a',
+  output: xdiff_lib_filename,
   build_by_default: true,
   build_always_stale: true,
   command: [
@@ -288,8 +296,6 @@ rust_build_xdiff = custom_target('rust_build_xdiff',
   install: false,
 )
 
-compiler = meson.get_compiler('c')
-
 libgit_sources = [
   'abspath.c',
   'add-interactive.c',
-- 
2.50.1.windows.1


From 9c3b017cfa069211027fbb1f6d3b97c8e7edda81 Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Sat, 19 Jul 2025 23:22:57 +0200
Subject: [PATCH 3/3] win+Meson: do allow linking with the Rust-built xdiff

When linking against the Rust-built `xdiff`, there is now a new required
dependency: Without _also_ linking to the system library `userenv`, the
compile would fail with this error message:

  xdiff.lib(std-c85e9beb7923f636.std.df32d1bc89881d89-cgu.0.rcgu.o) :
  error LNK2019: unresolved external symbol __imp_GetUserProfileDirectoryW
  referenced in function _ZN3std3env8home_dir17hfd1c3b6676cd78f6E

Therefore, just like we do in case of Makefile-based builds on Windows,
we now also link to that library when building with Meson.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meson.build b/meson.build
index 5e89a5dd0e00f..af015f04763fd 100644
--- a/meson.build
+++ b/meson.build
@@ -1260,6 +1260,7 @@ elif host_machine.system() == 'windows'
   ]
 
   libgit_dependencies += compiler.find_library('ntdll')
+  libgit_dependencies += compiler.find_library('userenv')
   libgit_include_directories += 'compat/win32'
   if compiler.get_id() == 'msvc'
     libgit_include_directories += 'compat/vcbuild/include'
-- 
2.50.1.windows.1
Previous: Junio C HamanoNext: Matthias Aßhauer
Message 86 of 204 in “RFC: Accelerate xdiff and begin its rustification”
  1. 0/7 RFC: Accelerate xdiff and begin its rustificationEzekiel Newren via GitGitGadget, Jul 17, 2025
  2. 1/7 xdiff: introduce rustEzekiel Newren via GitGitGadget, Jul 17, 2025
  3. brian m. carlsonJul 17, 2025
  4. Junio C HamanoJul 17, 2025
  5. Taylor BlauJul 17, 2025
  6. Ezekiel NewrenJul 18, 2025
  7. brian m. carlsonJul 23, 2025
  8. Junio C HamanoJul 23, 2025
  9. Ezekiel NewrenJul 28, 2025
  10. brian m. carlsonJul 31, 2025
  11. Mike HommeyJul 22, 2025
  12. brian m. carlsonJul 22, 2025
  13. Taylor BlauJul 17, 2025
  14. 2/7 xdiff/xprepare: remove superfluous forward declarationsEzekiel Newren via GitGitGadget, Jul 17, 2025
  15. Taylor BlauJul 17, 2025
  16. 3/7 xdiff: delete unnecessary fields from xrecord_t and xdfile_tEzekiel Newren via GitGitGadget, Jul 17, 2025
  17. 4/7 xdiff: make fields of xrecord_t Rust friendlyEzekiel Newren via GitGitGadget, Jul 17, 2025
  18. Taylor BlauJul 17, 2025
  19. brian m. carlsonJul 17, 2025
  20. Elijah NewrenJul 17, 2025
  21. Taylor BlauJul 18, 2025
  22. Taylor BlauJul 18, 2025
  23. Phillip WoodJul 18, 2025
  24. Ezekiel NewrenJul 28, 2025
  25. Phillip WoodJul 28, 2025
  26. Ezekiel NewrenJul 28, 2025
  27. Phillip WoodJul 31, 2025
  28. Ezekiel NewrenJul 31, 2025
  29. Phillip WoodAug 1, 2025
  30. Junio C HamanoJul 28, 2025
  31. Collin FunkJul 28, 2025
  32. Johannes SchindelinJul 20, 2025
  33. 5/7 xdiff: separate parsing lines from hashing themEzekiel Newren via GitGitGadget, Jul 17, 2025
  34. Taylor BlauJul 17, 2025
  35. Phillip WoodJul 18, 2025
  36. 6/7 xdiff: conditionally use Rust's implementation of xxhashEzekiel Newren via GitGitGadget, Jul 17, 2025
  37. Taylor BlauJul 17, 2025
  38. Junio C HamanoJul 18, 2025
  39. Ezekiel NewrenJul 31, 2025
  40. Matthias AßhauerAug 2, 2025
  41. Johannes SchindelinJul 19, 2025
  42. Phillip WoodJul 20, 2025
  43. gitoxide-compatible licensing of Git's Rust code, was Re: [PATCH 6/7] xdiff: conditionally use Rust's implementation of xxhashJohannes Schindelin, Sep 23, 2025
  44. Jeff KingSep 23, 2025
  45. Phillip WoodSep 24, 2025
  46. Jeff KingSep 25, 2025
  47. Patrick SteinhardtSep 25, 2025
  48. Phillip WoodSep 26, 2025
  49. Jeff KingOct 3, 2025
  50. Phillip WoodOct 3, 2025
  51. Patrick SteinhardtOct 7, 2025
  52. Johannes SchindelinNov 17, 2025
  53. Yee Cheng ChinOct 5, 2025
  54. 7/7 github_workflows: install rustEzekiel Newren via GitGitGadget, Jul 17, 2025
  55. brian m. carlsonJul 17, 2025
  56. Ezekiel NewrenJul 18, 2025
  57. Ben KnobleJul 25, 2025
  58. Johannes SchindelinJul 19, 2025
  59. brian m. carlsonJul 17, 2025
  60. Taylor BlauJul 17, 2025
  61. brian m. carlsonJul 18, 2025
  62. Patrick SteinhardtJul 22, 2025
  63. Junio C HamanoJul 22, 2025
  64. Sam JamesJul 22, 2025
  65. Elijah NewrenJul 22, 2025
  66. Sam JamesJul 22, 2025
  67. Collin FunkJul 22, 2025
  68. Christian BrabandtJul 18, 2025
  69. Junio C HamanoJul 18, 2025
  70. Elijah NewrenJul 19, 2025
  71. Phillip WoodJul 18, 2025
  72. Eli SchwartzJul 18, 2025
  73. Haelwenn (lanodan) MonnierJul 19, 2025
  74. Patrick SteinhardtJul 22, 2025
  75. Patrick SteinhardtJul 22, 2025
  76. Eli SchwartzJul 22, 2025
  77. Sam JamesJul 22, 2025
  78. Patrick SteinhardtJul 23, 2025
  79. Pierre-Emmanuel PatryJul 24, 2025
  80. Patrick SteinhardtJul 24, 2025
  81. Pierre-Emmanuel PatryJul 28, 2025
  82. Junio C HamanoJul 18, 2025
  83. Ezekiel NewrenJul 18, 2025
  84. Phillip WoodJul 21, 2025
  85. Junio C HamanoJul 21, 2025
  86. Johannes SchindelinJul 19, 2025
  87. Matthias AßhauerJul 20, 2025
  88. 00/17 RFC: Accelerate xdiff and begin its rustificationEzekiel Newren via GitGitGadget, Aug 15, 2025
  89. 01/17 doc: add a policy for using Rustbrian m. carlson via GitGitGadget, Aug 15, 2025
  90. Matthias AßhauerAug 15, 2025
  91. Junio C HamanoAug 15, 2025
  92. Matthias AßhauerAug 16, 2025
  93. Ezekiel NewrenAug 19, 2025
  94. 02/17 xdiff: introduce rustEzekiel Newren via GitGitGadget, Aug 15, 2025
  95. 03/17 xdiff/xprepare: remove superfluous forward declarationsEzekiel Newren via GitGitGadget, Aug 15, 2025
  96. 04/17 xdiff: delete unnecessary fields from xrecord_t and xdfile_tEzekiel Newren via GitGitGadget, Aug 15, 2025
  97. 05/17 xdiff: make fields of xrecord_t Rust friendlyEzekiel Newren via GitGitGadget, Aug 15, 2025
  98. 06/17 xdiff: separate parsing lines from hashing themEzekiel Newren via GitGitGadget, Aug 15, 2025
  99. 07/17 xdiff: conditionally use Rust's implementation of xxhashEzekiel Newren via GitGitGadget, Aug 15, 2025
  100. 08/17 github workflows: install rustEzekiel Newren via GitGitGadget, Aug 15, 2025
  101. 09/17 Do support Windows again after requiring RustJohannes Schindelin via GitGitGadget, Aug 15, 2025
  102. Matthias AßhauerAug 15, 2025
  103. Junio C HamanoAug 15, 2025
  104. Johannes SchindelinAug 15, 2025
  105. Junio C HamanoAug 15, 2025
  106. Junio C HamanoAug 15, 2025
  107. Matthias AßhauerAug 16, 2025
  108. Junio C HamanoAug 17, 2025
  109. Ezekiel NewrenAug 19, 2025
  110. 10/17 win+Meson: allow for xdiff to be compiled with MSVCJohannes Schindelin via GitGitGadget, Aug 15, 2025
  111. 11/17 win+Meson: do allow linking with the Rust-built xdiffJohannes Schindelin via GitGitGadget, Aug 15, 2025
  112. 12/17 github workflows: define rust versions and targets in the same placeEzekiel Newren via GitGitGadget, Aug 15, 2025
  113. 13/17 github workflows: upload Cargo.lockEzekiel Newren via GitGitGadget, Aug 15, 2025
  114. 14/17 xdiff: implement a white space iterator in RustEzekiel Newren via GitGitGadget, Aug 15, 2025
  115. 15/17 xdiff: create line_hash() and line_equal()Ezekiel Newren via GitGitGadget, Aug 15, 2025
  116. 16/17 xdiff: optimize case where --ignore-cr-at-eol is the only whitespace flagEzekiel Newren via GitGitGadget, Aug 15, 2025
  117. 17/17 xdiff: use rust's version of whitespace processingEzekiel Newren via GitGitGadget, Aug 15, 2025
  118. Ramsay JonesAug 15, 2025
  119. Elijah NewrenAug 19, 2025
  120. Patrick SteinhardtAug 24, 2025
  121. Junio C HamanoAug 18, 2025
  122. Ben KnobleAug 18, 2025
  123. Elijah NewrenAug 19, 2025
  124. Junio C HamanoAug 19, 2025
  125. 00/15 RFC: Cleanup xdiff and begin its rustificationEzekiel Newren via GitGitGadget, Aug 23, 2025
  126. 01/15 doc: add a policy for using Rustbrian m. carlson via GitGitGadget, Aug 23, 2025
  127. 02/15 xdiff: introduce rustEzekiel Newren via GitGitGadget, Aug 23, 2025
  128. rsbecker@nexbridge.comAug 23, 2025
  129. Kristoffer HaugsbakkAug 23, 2025
  130. rsbecker@nexbridge.comAug 23, 2025
  131. Elijah NewrenAug 23, 2025
  132. brian m. carlsonAug 23, 2025
  133. rsbecker@nexbridge.comAug 23, 2025
  134. Sam JamesAug 23, 2025
  135. Haelwenn (lanodan) MonnierAug 23, 2025
  136. Taylor BlauAug 27, 2025
  137. rsbecker@nexbridge.comAug 27, 2025
  138. Junio C HamanoAug 27, 2025
  139. rsbecker@nexbridge.comAug 27, 2025
  140. Taylor BlauAug 27, 2025
  141. Junio C HamanoAug 27, 2025
  142. Patrick SteinhardtSep 2, 2025
  143. Sam JamesSep 2, 2025
  144. brian m. carlsonSep 2, 2025
  145. Sam JamesSep 2, 2025
  146. Collin FunkSep 3, 2025
  147. Patrick SteinhardtSep 3, 2025
  148. Ramsay JonesSep 3, 2025
  149. Junio C HamanoSep 3, 2025
  150. Josh SteadmonSep 3, 2025
  151. Patrick SteinhardtSep 4, 2025
  152. Junio C HamanoSep 4, 2025
  153. Patrick SteinhardtSep 5, 2025
  154. brian m. carlsonSep 4, 2025
  155. Patrick SteinhardtSep 4, 2025
  156. Sam JamesSep 4, 2025
  157. Elijah NewrenSep 5, 2025
  158. Ezekiel NewrenSep 4, 2025
  159. Elijah NewrenSep 5, 2025
  160. Patrick SteinhardtSep 5, 2025
  161. Elijah NewrenSep 7, 2025
  162. rsbecker@nexbridge.comSep 7, 2025
  163. Phillip WoodSep 8, 2025
  164. rsbecker@nexbridge.comSep 8, 2025
  165. Ezekiel NewrenSep 8, 2025
  166. rsbecker@nexbridge.comSep 8, 2025
  167. Elijah NewrenSep 8, 2025
  168. rsbecker@nexbridge.comSep 8, 2025
  169. Elijah NewrenSep 8, 2025
  170. rsbecker@nexbridge.comSep 8, 2025
  171. Patrick SteinhardtSep 8, 2025
  172. Phillip WoodSep 5, 2025
  173. Sam JamesSep 5, 2025
  174. Phillip WoodSep 5, 2025
  175. Patrick SteinhardtSep 5, 2025
  176. Junio C HamanoSep 5, 2025
  177. Patrick SteinhardtSep 8, 2025
  178. Ezekiel NewrenAug 23, 2025
  179. 03/15 github workflows: install rustEzekiel Newren via GitGitGadget, Aug 23, 2025
  180. 04/15 win+Meson: do allow linking with the Rust-built xdiffJohannes Schindelin via GitGitGadget, Aug 23, 2025
  181. 05/15 github workflows: upload Cargo.lockEzekiel Newren via GitGitGadget, Aug 23, 2025
  182. 06/15 ivec: create a vector type that is interoperable between C and RustEzekiel Newren via GitGitGadget, Aug 23, 2025
  183. Kristoffer HaugsbakkAug 23, 2025
  184. Ezekiel NewrenAug 23, 2025
  185. Junio C HamanoAug 23, 2025
  186. Ezekiel NewrenAug 23, 2025
  187. Junio C HamanoAug 23, 2025
  188. Ezekiel NewrenAug 23, 2025
  189. Elijah NewrenAug 25, 2025
  190. Junio C HamanoAug 26, 2025
  191. Ben KnobleAug 24, 2025
  192. Ezekiel NewrenAug 25, 2025
  193. D. Ben KnobleAug 26, 2025
  194. Ezekiel NewrenAug 26, 2025
  195. brian m. carlsonAug 26, 2025
  196. 07/15 xdiff/xprepare: remove superfluous forward declarationsEzekiel Newren via GitGitGadget, Aug 23, 2025
  197. 08/15 xdiff: delete unnecessary fields from xrecord_t and xdfile_tEzekiel Newren via GitGitGadget, Aug 23, 2025
  198. 09/15 xdiff: make fields of xrecord_t Rust friendlyEzekiel Newren via GitGitGadget, Aug 23, 2025
  199. 10/15 xdiff: use one definition for freeing xdfile_tEzekiel Newren via GitGitGadget, Aug 23, 2025
  200. 11/15 xdiff: replace chastore with an ivec in xdfile_tEzekiel Newren via GitGitGadget, Aug 23, 2025
  201. 12/15 xdiff: delete nrec field from xdfile_tEzekiel Newren via GitGitGadget, Aug 23, 2025
  202. 14/15 xdiff: make xdfile_t more rust friendlyEzekiel Newren via GitGitGadget, Aug 23, 2025
  203. 13/15 xdiff: delete recs field from xdfile_tEzekiel Newren via GitGitGadget, Aug 23, 2025
  204. 15/15 xdiff: implement xdl_trim_ends() in RustEzekiel Newren via GitGitGadget, Aug 23, 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.