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>
main
brian m. carlson 2026-04-09 22:44:34 +00:00 committed by Junio C Hamano
parent 30e6f7adf6
commit 32d5b90590
6 changed files with 15 additions and 10 deletions

View File

@ -498,9 +498,9 @@ include shared.mak
# #
# == Optional Rust support == # == Optional Rust support ==
# #
# Define WITH_RUST if you want to include features and subsystems written in # Define NO_RUST if you want to disable features and subsystems written in Rust
# Rust into Git. For now, Rust is still an optional feature of the build # from being compiled into Git. For now, Rust is still an optional feature of
# process. With Git 3.0 though, Rust will always be enabled. # the build process. With Git 3.0 though, Rust will always be enabled.
# #
# Building Rust code requires Cargo. # Building Rust code requires Cargo.
# #
@ -1351,7 +1351,7 @@ LIB_OBJS += urlmatch.o
LIB_OBJS += usage.o LIB_OBJS += usage.o
LIB_OBJS += userdiff.o LIB_OBJS += userdiff.o
LIB_OBJS += utf8.o LIB_OBJS += utf8.o
ifndef WITH_RUST ifdef NO_RUST
LIB_OBJS += varint.o LIB_OBJS += varint.o
endif endif
LIB_OBJS += version.o LIB_OBJS += version.o
@ -1590,7 +1590,7 @@ endif
ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND) ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND)
ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND) ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND)


ifdef WITH_RUST ifndef NO_RUST
BASIC_CFLAGS += -DWITH_RUST BASIC_CFLAGS += -DWITH_RUST
GITLIBS += $(RUST_LIB) GITLIBS += $(RUST_LIB)
ifeq ($(uname_S),Windows) ifeq ($(uname_S),Windows)

View File

@ -372,6 +372,9 @@ linux-asan-ubsan)
osx-meson) osx-meson)
MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain" MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain"
;; ;;
windows-*)
export NO_RUST=UnfortunatelyYes
;;
esac esac


MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}" MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"

View File

@ -8,11 +8,12 @@
export TEST_CONTRIB_TOO=yes export TEST_CONTRIB_TOO=yes


case "$jobname" in case "$jobname" in
linux-musl-meson)
MESONFLAGS="$MESONFLAGS -Drust=disabled"
;;
fedora-breaking-changes-musl|linux-breaking-changes) fedora-breaking-changes-musl|linux-breaking-changes)
export WITH_BREAKING_CHANGES=YesPlease export WITH_BREAKING_CHANGES=YesPlease
export WITH_RUST=YesPlease
MESONFLAGS="$MESONFLAGS -Dbreaking_changes=true" MESONFLAGS="$MESONFLAGS -Dbreaking_changes=true"
MESONFLAGS="$MESONFLAGS -Drust=enabled"
;; ;;
linux-TEST-vars) linux-TEST-vars)
export OPENSSL_SHA1_UNSAFE=YesPlease export OPENSSL_SHA1_UNSAFE=YesPlease
@ -30,6 +31,7 @@ linux-TEST-vars)
export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1 export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
;; ;;
linux-clang) linux-clang)
export NO_RUST=UnfortunatelyYes
export GIT_TEST_DEFAULT_HASH=sha1 export GIT_TEST_DEFAULT_HASH=sha1
;; ;;
linux-sha256) linux-sha256)

View File

@ -1745,8 +1745,7 @@ version_def_h = custom_target(
) )
libgit_sources += version_def_h libgit_sources += version_def_h


cargo = find_program('cargo', dirs: program_path, native: true, required: get_option('rust')) rust_option = get_option('rust')
rust_option = get_option('rust').disable_auto_if(not cargo.found())
if rust_option.allowed() if rust_option.allowed()
subdir('src') subdir('src')
libgit_c_args += '-DWITH_RUST' libgit_c_args += '-DWITH_RUST'

View File

@ -77,7 +77,7 @@ option('zlib_backend', type: 'combo', choices: ['auto', 'zlib', 'zlib-ng'], valu
# Build tweaks. # Build tweaks.
option('breaking_changes', type: 'boolean', value: false, option('breaking_changes', type: 'boolean', value: false,
description: 'Enable upcoming breaking changes.') description: 'Enable upcoming breaking changes.')
option('rust', type: 'feature', value: 'auto', option('rust', type: 'feature', value: 'enabled',
description: 'Enable building with Rust.') description: 'Enable building with Rust.')
option('macos_use_homebrew_gettext', type: 'boolean', value: true, option('macos_use_homebrew_gettext', type: 'boolean', value: true,
description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.') description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')

View File

@ -29,6 +29,7 @@ libgit_rs = custom_target('git_rs',
) )
libgit_dependencies += declare_dependency(link_with: libgit_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') if get_option('tests')
test('rust', cargo, test('rust', cargo,
args: [ args: [