Enable Rust by default

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Apr 9, 2026 at 22:44 UTC 32d5b905909e781786c4735e6bd71503b23e4fb1
6 files changed +15 -10
Makefile
+5 -5
@@ -498,9 +498,9 @@ include shared.mak
498 #
499 # == Optional Rust support ==
500 #
501 -# Define WITH_RUST if you want to include features and subsystems written in
502 -# Rust into Git. For now, Rust is still an optional feature of the build
503 -# process. With Git 3.0 though, Rust will always be enabled.
501 +# Define NO_RUST if you want to disable features and subsystems written in Rust
502 +# from being compiled into Git. For now, Rust is still an optional feature of
503 +# the build process. With Git 3.0 though, Rust will always be enabled.
504 #
505 # Building Rust code requires Cargo.
506 #
@@ -1351,7 +1351,7 @@ LIB_OBJS += urlmatch.o
1351 LIB_OBJS += usage.o
1352 LIB_OBJS += userdiff.o
1353 LIB_OBJS += utf8.o
1354 -ifndef WITH_RUST
1354 +ifdef NO_RUST
1355 LIB_OBJS += varint.o
1356 endif
1357 LIB_OBJS += version.o
@@ -1590,7 +1590,7 @@ endif
1590 ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND)
1591 ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND)
1592
1593 -ifdef WITH_RUST
1593 +ifndef NO_RUST
1594 BASIC_CFLAGS += -DWITH_RUST
1595 GITLIBS += $(RUST_LIB)
1596 ifeq ($(uname_S),Windows)
ci/lib.sh
+3
@@ -372,6 +372,9 @@ linux-asan-ubsan)
372 osx-meson)
373 MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain"
374 ;;
375 +windows-*)
376 + export NO_RUST=UnfortunatelyYes
377 + ;;
378 esac
379
380 MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
ci/run-build-and-tests.sh
+4 -2
@@ -8,11 +8,12 @@
8 export TEST_CONTRIB_TOO=yes
9
10 case "$jobname" in
11 +linux-musl-meson)
12 + MESONFLAGS="$MESONFLAGS -Drust=disabled"
13 + ;;
14 fedora-breaking-changes-musl|linux-breaking-changes)
15 export WITH_BREAKING_CHANGES=YesPlease
13 - export WITH_RUST=YesPlease
16 MESONFLAGS="$MESONFLAGS -Dbreaking_changes=true"
15 - MESONFLAGS="$MESONFLAGS -Drust=enabled"
17 ;;
18 linux-TEST-vars)
19 export OPENSSL_SHA1_UNSAFE=YesPlease
@@ -30,6 +31,7 @@ linux-TEST-vars)
31 export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
32 ;;
33 linux-clang)
34 + export NO_RUST=UnfortunatelyYes
35 export GIT_TEST_DEFAULT_HASH=sha1
36 ;;
37 linux-sha256)
meson.build
+1 -2
@@ -1745,8 +1745,7 @@ version_def_h = custom_target(
1745 )
1746 libgit_sources += version_def_h
1747
1748 -cargo = find_program('cargo', dirs: program_path, native: true, required: get_option('rust'))
1749 -rust_option = get_option('rust').disable_auto_if(not cargo.found())
1748 +rust_option = get_option('rust')
1749 if rust_option.allowed()
1750 subdir('src')
1751 libgit_c_args += '-DWITH_RUST'
meson_options.txt
+1 -1
@@ -77,7 +77,7 @@ option('zlib_backend', type: 'combo', choices: ['auto', 'zlib', 'zlib-ng'], valu
77 # Build tweaks.
78 option('breaking_changes', type: 'boolean', value: false,
79 description: 'Enable upcoming breaking changes.')
80 -option('rust', type: 'feature', value: 'auto',
80 +option('rust', type: 'feature', value: 'enabled',
81 description: 'Enable building with Rust.')
82 option('macos_use_homebrew_gettext', type: 'boolean', value: true,
83 description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
src/meson.build
+1
@@ -29,6 +29,7 @@ libgit_rs = custom_target('git_rs',
29 )
30 libgit_dependencies += declare_dependency(link_with: libgit_rs)
31
32 +cargo = find_program('cargo', dirs: program_path, native: true, required: get_option('rust'))
33 if get_option('tests')
34 test('rust', cargo,
35 args: [