Re: [PATCH RFC v2 0/7] Introduce Rust and announce that it will become mandatorty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Patrick

On 05/09/2025 12:50, Patrick Steinhardt wrote:
Hi,

this small patch series introduces Rust into the core of Git. This patch
series is designed as a test balloon, similar to how we introduced test
balloons for C99 features in the past. The goal is threefold:

   - Give us some time to experiment with Rust and introduce proper build
     infrastructure.

   - Give distributors time to ease into the new toolchain requirements.
     Introducing Rust is impossible for some platforms and hard for
     others.

These sound good

   - Announce that Git 3.0 will make Rust a mandatory part of our build
     infrastructure.

I'm not sure if we really want to wait that long. So far Git 3.0 has been about user facing changes rather than build requirements. In [1] I suggested a period of six months from the initial announcement to making rust mandatory to allow distributors time to either adjust their build procedures or notify their users that they will only be offering security updates in the future.
The test balloon itself is quite uninteresting: I've chosen to convert
the "varint.c" subsystem, mostly because it is trivial and does not have
any dependencies. But it does allow us to verify that C to Rust interop
works as expected, and to play around with tooling. All tests pass with
the "varint.rs" implementation.

For now, the series only contains support for Meson. If we agree to go
down this route I'll also introduce support for Rust into our Makefiles
at a later point in time.

It looks like this version does include the necessary Makefile changes which is great. I do think though, that for the test balloon to be valuable, we need make building with rust the default with an error message that tells people how to build without rust if that fails. Otherwise it is easy for people building on platforms without rust support to miss that we're going to be making it mandatory soon.

Thanks

Phillip

[1] https://lore.kernel.org/git/ba386547-10e0-45e2-95ad-c47e84919abf@xxxxxxxxx

Furthermore missing is additional tooling:

   - At least one CI job to verify that Rust builds and works as
     expected.

   - Tooling and CI jobs to ensure that we have consistent formatting via
     `cargo format`.

And probably lots more. As said, the entire goal is for us to have an
easy playground that we can experiment on and develop the infrastructure
incrementally without yet having to commit to anything.

I'm mostly splitting out the topic of introducing Rust from the larger
series that introduce it into xdiff so that we can focus more on the
actual process of introducing Rust into Git and less on the potential
features that we want to build on top of it.

Changes in v2:
   - Introduce support for building the Rust library via our Makefile.
   - Introduce a '-DWITH_RUST' define. This define is used to print
     whether or not Git is built with Rust via `git version
     --build-options`.
   - Adjust Meson to not depend on v1.9.0 and newer anymore.
   - Introduce a roadmap into our BreakingChanges document to explain how
     we'll iterate towards mandatory Rust support.
   - Rework the Fedora job to do a full compile-and-test run with Meson
     and breaking changes enabled.
   - Adapt our breaking-changes jobs to enable Rust support.
   - Link to v1: https://lore.kernel.org/r/20250904-b4-pks-rust-breaking-change-v1-0-3af1d25e0be9@xxxxxx

Thanks!

Patrick

---
Patrick Steinhardt (7):
       meson: add infrastructure to build internal Rust library
       Makefile: introduce infrastructure to build internal Rust library
       help: report on whether or not Rust is enabled
       rust: implement a test balloon via the "varint" subsystem
       BreakingChanges: announce Rust becoming mandatory
       ci: convert "pedantic" job into full build with breaking changes
       ci: enable Rust for breaking-changes jobs

  .github/workflows/main.yml         |  4 +-
  .gitignore                         |  2 +
  .gitlab-ci.yml                     |  4 +-
  Cargo.toml                         |  9 ++++
  Documentation/BreakingChanges.adoc | 36 +++++++++++++++
  Makefile                           | 47 ++++++++++++++++++-
  ci/install-dependencies.sh         |  4 +-
  ci/run-build-and-tests.sh          | 31 +++++--------
  help.c                             |  6 +++
  meson.build                        | 17 ++++++-
  meson_options.txt                  |  2 +
  src/lib.rs                         |  1 +
  src/meson.build                    | 16 +++++++
  src/varint.rs                      | 92 ++++++++++++++++++++++++++++++++++++++
  14 files changed, 240 insertions(+), 31 deletions(-)

Range-diff versus v1:

1:  4df400823c ! 1:  8f6e89bc7d meson: add infrastructure to build internal Rust library
     @@ meson.build: version_def_h = custom_target(
+libgit_libraries = [ ]
      +
     -+if meson.version().version_compare('>=1.9.0')
     -+  rust_available = add_languages('rust', native: false, required: get_option('rust'))
     -+else
     -+  rust_available = false
     -+endif
     ++rust_available = add_languages('rust', native: false, required: get_option('rust'))
      +rust_option = get_option('rust').disable_auto_if(not rust_available)
     -+
     -+if rust_option.allowed() and meson.version().version_compare('>=1.9.0')
     ++if rust_option.allowed()
      +  subdir('src')
     ++  libgit_c_args += '-DWITH_RUST'
      +endif
      +
       libgit = declare_dependency(
     @@ src/lib.rs (new)
## src/meson.build (new) ##
      @@
     -+rustmod = import('rust')
     -+
      +libgit_rs = static_library('git_rs',
      +  sources: [
      +    'lib.rs',
      +  ],
     -+  rust_abi: 'c',
     ++  rust_crate_type: 'staticlib',
      +)
     -+
     -+rustmod.test('git-rs', libgit_rs)
     -+
      +libgit_libraries += libgit_rs
     ++
     ++# The 'rust' module was only introduced in Meson 1.0. Furthermore, the module
     ++# does not seem to work on macOS as expected right now. As such, we only
     ++# conditionally enable tests.
     ++if meson.version().version_compare('>=1.0.0') and host_machine.system() != 'darwin'
     ++  rustmod = import('rust')
     ++  rustmod.test('rust', libgit_rs)
     ++endif
-:  ---------- > 2:  cd1d642d04 Makefile: introduce infrastructure to build internal Rust library
-:  ---------- > 3:  e60a8353a4 help: report on whether or not Rust is enabled
2:  575f6de44d ! 4:  b27811aea4 rust: implement a test balloon via the "varint" subsystem
     @@ Commit message
Signed-off-by: Patrick Steinhardt <ps@xxxxxx> + ## Makefile ##
     +@@ Makefile: LIB_OBJS += urlmatch.o
     + LIB_OBJS += usage.o
     + LIB_OBJS += userdiff.o
     + LIB_OBJS += utf8.o
     ++ifndef WITH_RUST
     + LIB_OBJS += varint.o
     ++endif
     + LIB_OBJS += version.o
     + LIB_OBJS += versioncmp.o
     + LIB_OBJS += walker.o
     +
       ## meson.build ##
      @@ meson.build: libgit_sources = [
         'usage.c',
     @@ meson.build: libgit_sources = [
         'versioncmp.c',
         'walker.c',
      @@ meson.build: rust_option = get_option('rust').disable_auto_if(not rust_available)
     -
     - if rust_option.allowed() and meson.version().version_compare('>=1.9.0')
     + if rust_option.allowed()
         subdir('src')
     +   libgit_c_args += '-DWITH_RUST'
      +else
      +  libgit_sources += [
      +    'varint.c',
     @@ src/lib.rs
      +pub mod varint;
## src/meson.build ##
     -@@ src/meson.build: rustmod = import('rust')
     +@@
       libgit_rs = static_library('git_rs',
         sources: [
           'lib.rs',
      +    'varint.rs',
         ],
     -   rust_abi: 'c',
     +   rust_crate_type: 'staticlib',
       )
## src/varint.rs (new) ##
3:  e54393392a < -:  ---------- BreakingChanges: announce Rust becoming mandatory
-:  ---------- > 5:  d5946e0114 BreakingChanges: announce Rust becoming mandatory
-:  ---------- > 6:  0d367976de ci: convert "pedantic" job into full build with breaking changes
-:  ---------- > 7:  82086a5328 ci: enable Rust for breaking-changes jobs

---
base-commit: 2462961280690837670d997bde64bd4ebf8ae66d
change-id: 20250904-b4-pks-rust-breaking-change-7167d9d3e37d







[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux