Re: [PATCH v3 2/2] Makefile: support universal macOS builds via RUST_TARGETS
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 3, 2026, 05:36 UTC
- Message-ID
- <xmqqldbsk51t.fsf@gitster.g>
- In-Reply-To
- <257f5ef42fbb2841036591657e740872635df49b.1783030971.git.gitgitgadget@gmail.com>
"Shardul Natu via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 20 quoted lines
> From: Shardul Natu <snatu@google.com> > > 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").
This is much easier to understand for those of us unfamiliar with the macOS ecosystem. Very much appreciated.
> +$(RUST_LIB): $(RUST_MEMBER_LIBS) > + @$(call mkdir_p_parent_template)
The leading @ is a bit curious because among ~20 existing use of this pattern, nobody adds it to squelch "mkdir -p". In fact, the macro uses the standard pattern to define $(QUIET_MKDIR_P_PARENT) that does the squelching when $(V) is unset.
> + $(QUIET_GEN)\ > + if [ $(words $(RUST_TARGETS)) -gt 1 ]; then \
Recipe parts in our Makefile that are written in bourne shell, the CodingGuidelines apply.
$ git grep -n -e 'if \[' ':(glob)**/Makefile'
gives empty. Probably,
if test $(words $(RUST_TARGETS)) -gt 1; \ then \
would fit better.
Show 8 quoted lines
> + lipo -create $^ -output $@; \ > + else \ > + cp $< $@; \ > + fi > +endif > > .PHONY: rust > rust: $(RUST_LIB)
Other than that, looking good.
Thanks.