Re: [PATCH v3 2/2] Makefile: support universal macOS builds via RUST_TARGETS
- From
- Shardul Natu <snatu@google.com>
- Date
- Jul 3, 2026, 17:37 UTC
- Message-ID
- <CABaQWZey-7FKd7FDTKZ5v7jjuRdTXm5cqJUpL8JKAL+Pom1iWw@mail.gmail.com>
- In-Reply-To
- <xmqqldbsk51t.fsf@gitster.g>
Show 7 quoted lines
> > +$(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.
Done!
Show 11 quoted lines
> 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.
Thank you for pointing out the CodingGuidelines rule for Bourne shell snippets in Makefiles. I have updated the condition from "if [" to "if test".
Thanks, Shardul
On Thu, Jul 2, 2026 at 10:36 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 62 quoted lines
> > "Shardul Natu via GitGitGadget" <gitgitgadget@gmail.com> writes: > > > 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. > > > + lipo -create $^ -output $@; \ > > + else \ > > + cp $< $@; \ > > + fi > > +endif > > > > .PHONY: rust > > rust: $(RUST_LIB) > > Other than that, looking good. > > Thanks.