]> git.99rst.org Git - git.git/commit
Makefile: support universal macOS builds via RUST_TARGETS
authorShardul Natu <redacted>
Wed, 8 Jul 2026 03:21:18 +0000 (03:21 +0000)
committerJunio C Hamano <redacted>
Wed, 8 Jul 2026 04:58:54 +0000 (21:58 -0700)
commit924dfced6b811d1bbe76485d225c789853bef553
tree4ba03f5d49afb1715a7279bdedbbcef9830b37ab
parent87bd9bd40ee6e7f9fb80686e2d7526c524add195
Makefile: support universal macOS builds via RUST_TARGETS

On macOS, Universal Binaries contain native executable code for
multiple architectures (such as Intel x86_64 and Apple Silicon arm64)
bundled into a single file. This is standard practice for macOS
distribution and CI packaging (such as internal distribution packages
or tooling like Burrito/Homebrew), allowing a single build artifact
to run natively across all Macs without Rosetta emulation or
maintaining separate packages.

When building Git C code for multiple architectures on macOS, the
Apple toolchain (clang) natively supports universal builds via
CFLAGS/LDFLAGS. When "-arch x86_64 -arch arm64" is passed, clang
automatically compiles and links universal binaries for all C object
files and executables out of the box.

Cargo and rustc, however, do not support multiple "-arch" flags or
emitting universal binaries in a single invocation. Instead, Cargo
requires invoking each target triple independently (e.g., passing
"--target x86_64-apple-darwin" and "--target aarch64-apple-darwin").

To bridge this gap when Rust is enabled:
  1. Allow specifying space-separated target triples in RUST_TARGETS.
  2. Introduce declarative pattern rules (target/%/...) to compile
     each target-specific library slice via Cargo.
  3. On macOS, if multiple targets are specified, use "lipo" (part of
     the mandatory Xcode Command Line Tools) to combine the resulting
     static libraries into target/release/libgitcore.a.

Once $(RUST_LIB) is compiled into a universal static archive, the
standard C linker seamlessly links it with the C object files to
produce universal Git executables.

Signed-off-by: Shardul Natu <redacted>
Signed-off-by: Junio C Hamano <redacted>
Makefile
git clone https://git.99rst.org/PROJECT