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

Re: [PATCH v3 02/15] xdiff: introduce rust

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Sep 4, 2025, 00:57 UTC
Message-ID
<aLjj9cG9_K6YLfeA@fruit.crustytoothpaste.net>
In-Reply-To
<aLfU5sEa-RE3X4G2@pks.im>
On 2025-09-03 at 05:40:54, Patrick Steinhardt wrote:
> If I had the choice, I'd much rather adopt an ancient version of Rust if
> it means that more platforms can support it.

I think you may be assuming that gccrs targeting Rust 1.49 will magically make it work on more platforms than upstream Rust will. That's not the case.

gccrs targeting Rust 1.49 will use libstd (the standard library) and libcore (the library for freestanding implementations) from Rust 1.49 and that means it will only support those platforms that Rust 1.49 did. For instance, Rust added support for Apache NuttX relatively recently. Even if it has stellar support in GCC, it won't work with that version of gccrs because the underlying libraries don't support any of those platforms. The only thing you can target that you couldn't before are systems that use neither libstd nor libcore—which essentially means the Linux kernel. It's like using a glibc from 2009 and expecting to work on RISC-V—it simply won't[0].

If you need support for new platforms, that requires a much _newer_ version of Rust. Thus, to be able to use gccrs, porters need to use the existing gcc codegen backend and get that code in immediately so that when gccrs is out and supports Rust 1.91, the standard library will work with those platforms. The fastest way to getting platforms supported is to port LLVM and then add them to upstream Rust that way.

I know there has been much complaint about the six-week lifespan of Rust releases. I myself dislike that. But the situation is that LTS releases require extensive amounts of work and nobody has stepped up to do that or pay for it to be done. Without dedicated staffing, it's not going to happen. That also means that individual projects decide what versions of Rust they do and don't want to support.

We're already supporting the version in Debian stable for a year after the new release comes out, so we're already far behind what everyone else is doing. For comparison, Rust 1.48 is in Debian 11, so we'd be supporting an effectively five-year-old compiler instead of a three-year-old compiler.

Requiring Rust 1.49 instead of Rust 1.63 makes it harder to use tools like bindgen and cbindgen, which exist to automatically create types and functions in one language in the other. That, in turn, will hinder our ability to effectively write code that crosses the boundary and introduce hard-to-find bugs, since we'll have to do that work manually. My experience is that these kinds of bugs tend to actually show up more frequently on less common platforms, like big-endian systems, so we'll be worsening the platform experience for those systems.

For context, when we ported a core service from C to Rust at work, we used bindgen to generate C struct definitions, which made the process much easier and avoided random crashes. As a result, nobody noticed the fact that we ported it incrementally over a couple of years. If we hadn't used bindgen, we probably would have had lots of random segfaults due to failing to maintain compatibility between Rust and C definitions of the same structures, which users would not have appreciated and would not have helped our goal of making our software more reliable and easier to maintain.

> The gccrs maintainers are actively working on that backend, and as far
> as I understand the main difference between LLVM and gccrs is that the
> latter doesn't have to be ported over to every single platform
> individually.

I don't think that's the case. gccrs has to be compiled for every platform just like LLVM does. LLVM is actually easier to support because it can cross-compile from any platform to any platform without recompilation. For instance, I can target riscv64gc-unknown-openbsd on my Debian amd64 laptop assuming I can provide the necessary libraries for OpenBSD when compiling, but GCC requires me to specifically compile a compiler for that platform.

In any event, any portability changes will also likely need to go into libstd and libcore, which is used identically with both compilers.

It is, however, the case that GCC supports more architectures (and possibly more architecture/OS combinations) than LLVM. For instance, DEC Alpha and IA64 are only supported by GCC at the moment.

> I think adopting Rust as a mandatory dependency out of nowhere would not
> be playing nice. It may require significant effort from distros to adapt
> to the new reality, so we should give them time to do so.

We've actually had this discussion on the list several times where we've proposed the inclusion of Rust. This is not the first time it's come up, or the second. It was explicitly mentioned a year ago on the list that we wanted to adopt Rust in the notes from the Contributor Summit.

There has been plenty of notice that this is coming down the line. It's not accurate to claim it's "out of nowhere" nor to claim that people have not had plenty of time to port their systems.

Distros and porters should not be insensible to the increasing use of Rust or the need for them to get their systems working. For instance, you cannot run a GNOME or MATE desktop environment without librsvg2, which is written in Rust. Python's cryptography package adopted Rust over four years ago and there was the same gnashing of teeth[1], yet little progress has been made by porters on the same affected architectures since that time. In that time, Debian has bootstrapped and released an entire RISC-V port, complete with Rust.

I want to be clear I'm not opposed to supporting less common operating systems or architectures. For many years, my laptop was a PowerPC Mac, and I've owned UltraSPARC, MIPS, and ARM hardware. For personal code, I try to test it in CI on at least Linux, macOS, FreeBSD, and NetBSD. But also, when a Debian package has not worked properly on PowerPC or UltraSPARC, I've stepped up and fixed it. My requests to other projects when porting have been things like asking to write valid C or C++ (by not making unaligned accesses or avoiding endianness assumptions, for instance) and not to refrain from adding new languages or features.

It should be stated that there is a very easy way to get Rust working, and that's to port LLVM to the platform in question. IA-64 was removed in 2009, but it might be possible to resurrect that out of tree if there's interest and maybe even get it re-accepted upstream. I'll point out that AIX, Solaris, and QNX have done the necessary porting work to get LLVM and Rust working over the past couple years, so it's not out of the question for other platforms to do so as well. And, for the avoidance of doubt, I would be absolutely delighted if we were able to support additional platforms with Rust as well.

Also, the approach of making it an optional component directly contradicts the proposed policy I wrote up. That's a recipe for additional burdensome work maintaining two implementations, when we actually want to make it easier for people to contribute functionality. It also doesn't provide any of the memory safety benefits or address any of the concerns from governments, security professionals, and other parties about the real and substantial risks of continuing to develop in C.

For example, there is zero chance I will implement any of the SHA-1/SHA-256 compatibility code twice. I'm already doing that in my free time without any compensation at all and it's unreasonable to expect me to do it twice or even to #ifdef out all the places it would need to go. I am happy to let someone else take responsibility for the project instead, however, if they would like to do those things.

> It would be a shame, but right now it's a risky bet to build anything on
> top of Rust given that we don't officially accept it in Git yet. We need
> to first make the decision whether or not we want to have it right now,
> and if so how that's supposed to look like.

I think we had made the decision at the 2024 Contributor's Summit that we wanted to adopt Rust in Git, so it was more of a matter of sending the patches than actually making that decision. As I recall, the decision was unanimous.

[0] RISC-V was developed in 2010. [1] https://www.reddit.com/r/rust/comments/lfysy9/pythons_cryptography_package_introduced_build/

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 154 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.