Merge branch 'bc/rust-by-default'

Rust support is enabled by default (but still allows opting out) in
some future version of Git.

* bc/rust-by-default:
  Enable Rust by default
  Linux: link against libdl
  ci: install cargo on Alpine
  docs: update version with default Rust support
main
Junio C Hamano 2026-05-11 10:05:54 +09:00
commit bd5c2827b2
8 changed files with 17 additions and 11 deletions

View File

@ -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)

View File

@ -29,7 +29,7 @@ alpine-*)
apk add --update shadow sudo meson ninja-build gcc libc-dev curl-dev openssl-dev expat-dev gettext \
zlib-ng-dev pcre2-dev python3 musl-libintl perl-utils ncurses \
apache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \
bash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty >/dev/null
bash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty cargo >/dev/null
;;
fedora-*|almalinux-*)
case "$jobname" in

View File

@ -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}"

View File

@ -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)

View File

@ -63,6 +63,7 @@ ifeq ($(uname_S),Linux)
PROCFS_EXECUTABLE_PATH = /proc/self/exe
HAVE_PLATFORM_PROCINFO = YesPlease
COMPAT_OBJS += compat/linux/procinfo.o
EXTLIBS += -ldl
# centos7/rhel7 provides gcc 4.8.5 and zlib 1.2.7.
ifneq ($(findstring .el7.,$(uname_R)),)
BASIC_CFLAGS += -std=c99

View File

@ -1744,8 +1744,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'

View File

@ -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.')

View File

@ -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: [