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

[PATCH v2 4/4] Enable Rust by default

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 9, 2026, 22:44 UTC
Message-ID
<20260409224434.1861422-5-sandals@crustytoothpaste.net>
In-Reply-To
<20260409224434.1861422-1-sandals@crustytoothpaste.net>

Our breaking changes document says that we'll enable Rust by default in Git 2.54. Adjust the Makefile to switch the option from WITH_RUST to NO_RUST to enable it by default and update the help text accordingly. Similarly, for Meson, enable the option by default and do not automatically disable it if Cargo is missing, since the goal is to help users find where they are likely to have problems in the future.

Update our CI tests to swap out the single Linux job with Rust to a single job without, both for Makefile and Meson. Similarly, update the Windows Makefile job to not use Rust, while the Meson job (which does not build with ci/lib.sh) will default to having it enabled.

Move the check for Cargo in the Meson build because it is no longer needed in the main script.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Makefile                  | 10 +++++-----
 ci/lib.sh                 |  3 +++
 ci/run-build-and-tests.sh |  6 ++++--
 meson.build               |  3 +--
 meson_options.txt         |  2 +-
 src/meson.build           |  1 +
 6 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 5d22394c2e..945adb9aa5 100644
--- a/Makefile
+++ b/Makefile
@@ -498,9 +498,9 @@ include shared.mak
 #
 # == Optional Rust support ==
 #
-# Define WITH_RUST if you want to include features and subsystems written in
-# Rust into Git. For now, Rust is still an optional feature of the build
-# process. With Git 3.0 though, Rust will always be enabled.
+# Define NO_RUST if you want to disable features and subsystems written in Rust
+# from being compiled into Git. For now, Rust is still an optional feature of
+# the build process. With Git 3.0 though, Rust will always be enabled.
 #
 # Building Rust code requires Cargo.
 #
@@ -1351,7 +1351,7 @@ LIB_OBJS += urlmatch.o
 LIB_OBJS += usage.o
 LIB_OBJS += userdiff.o
 LIB_OBJS += utf8.o
-ifndef WITH_RUST
+ifdef NO_RUST
 LIB_OBJS += varint.o
 endif
 LIB_OBJS += version.o
@@ -1590,7 +1590,7 @@ endif
 ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND)
 ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND)
 
-ifdef WITH_RUST
+ifndef NO_RUST
 BASIC_CFLAGS += -DWITH_RUST
 GITLIBS += $(RUST_LIB)
 ifeq ($(uname_S),Windows)
diff --git a/ci/lib.sh b/ci/lib.sh
index 42a2b6a318..1cfc8c6efc 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -372,6 +372,9 @@ linux-asan-ubsan)
 osx-meson)
 	MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain"
 	;;
+windows-*)
+	export NO_RUST=UnfortunatelyYes
+	;;
 esac
 
 MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
index 28cfe730ee..e2d783d90b 100755
--- a/ci/run-build-and-tests.sh
+++ b/ci/run-build-and-tests.sh
@@ -8,11 +8,12 @@
 export TEST_CONTRIB_TOO=yes
 
 case "$jobname" in
+linux-musl-meson)
+	MESONFLAGS="$MESONFLAGS -Drust=disabled"
+	;;
 fedora-breaking-changes-musl|linux-breaking-changes)
 	export WITH_BREAKING_CHANGES=YesPlease
-	export WITH_RUST=YesPlease
 	MESONFLAGS="$MESONFLAGS -Dbreaking_changes=true"
-	MESONFLAGS="$MESONFLAGS -Drust=enabled"
 	;;
 linux-TEST-vars)
 	export OPENSSL_SHA1_UNSAFE=YesPlease
@@ -30,6 +31,7 @@ linux-TEST-vars)
 	export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
 	;;
 linux-clang)
+	export NO_RUST=UnfortunatelyYes
 	export GIT_TEST_DEFAULT_HASH=sha1
 	;;
 linux-sha256)
diff --git a/meson.build b/meson.build
index 8309942d18..deff129cf6 100644
--- a/meson.build
+++ b/meson.build
@@ -1745,8 +1745,7 @@ version_def_h = custom_target(
 )
 libgit_sources += version_def_h
 
-cargo = find_program('cargo', dirs: program_path, native: true, required: get_option('rust'))
-rust_option = get_option('rust').disable_auto_if(not cargo.found())
+rust_option = get_option('rust')
 if rust_option.allowed()
   subdir('src')
   libgit_c_args += '-DWITH_RUST'
diff --git a/meson_options.txt b/meson_options.txt
index 659cbb218f..80a8025f20 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -77,7 +77,7 @@ option('zlib_backend', type: 'combo', choices: ['auto', 'zlib', 'zlib-ng'], valu
 # Build tweaks.
 option('breaking_changes', type: 'boolean', value: false,
   description: 'Enable upcoming breaking changes.')
-option('rust', type: 'feature', value: 'auto',
+option('rust', type: 'feature', value: 'enabled',
   description: 'Enable building with Rust.')
 option('macos_use_homebrew_gettext', type: 'boolean', value: true,
   description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
diff --git a/src/meson.build b/src/meson.build
index 45739957b4..41a4b231e6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -29,6 +29,7 @@ libgit_rs = custom_target('git_rs',
 )
 libgit_dependencies += declare_dependency(link_with: libgit_rs)
 
+cargo = find_program('cargo', dirs: program_path, native: true, required: get_option('rust'))
 if get_option('tests')
   test('rust', cargo,
     args: [
Previous: brian m. carlsonNext: brian m. carlson
Message 4 of 14 in “Enable Rust by default”
  1. 0/4 Enable Rust by defaultbrian m. carlson, Apr 9, 2026
  2. 1/4 docs: update version with default Rust supportbrian m. carlson, Apr 9, 2026
  3. 3/4 Linux: link against libdlbrian m. carlson, Apr 9, 2026
  4. 4/4 Enable Rust by defaultbrian m. carlson, Apr 9, 2026
  5. 2/4 ci: install cargo on Alpinebrian m. carlson, Apr 9, 2026
  6. Derrick StoleeApr 10, 2026
  7. Re*: [PATCH v2 0/4] Enable Rust by defaultJunio C Hamano, Apr 10, 2026
  8. Derrick StoleeApr 10, 2026
  9. brian m. carlsonApr 10, 2026
  10. Junio C HamanoApr 10, 2026
  11. brian m. carlsonApr 10, 2026
  12. Junio C HamanoApr 10, 2026
  13. brian m. carlsonApr 10, 2026
  14. Derrick StoleeApr 10, 2026

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.