Re: [PATCH v2] Makefile: link osxkeychain & support universal Rust
From: Junio C Hamano <hidden>
Date: 2026-07-02 01:35:47
"Shardul Natu via GitGitGadget" [off-list ref] writes:
From: Shnatu <redacted> Signed-off-by: Shardul Natu <redacted>
You'd want to make sure these two match.
To implement this cleanly without complex shell scripting in recipes:
1. We introduce a declarative Make pattern rule (target/%/...) to
compile each target-specific library slice (e.g.,
target/aarch64-apple-darwin/...).
2. We update the $(RUST_LIB) recipe to depend on the list of
compiled target-specific member libraries ($(RUST_MEMBER_LIBS)).
3. On macOS, if multiple targets are specified, we use lipo to
combine them into a single Universal static library at
target/release/libgitcore.a.
4. If only one target is specified, we copy it to the standard
path.
5. We enforce that building for multiple targets requires macOS
(as lipo is only available there), raising a clear make error
on other platforms.
This is a highly elegant and native Makefile solution that avoids
complex shell scripting in recipes and fully supports macOS Universal
Binaries.You're the second person on this list I saw who calls their own creation "elegant" ;-).
+$(RUST_LIB): $(RUST_MEMBER_LIBS) + $(QUIET_GEN)\ + if [ $(words $(RUST_TARGETS)) -gt 1 ]; then \ + lipo -create $^ -output $@; \ + else \ + cp $< $@; \ + fi +endif
Do we know that leading directories to $(RUST_LIB) target has
already been created at this point? If not, we may want to have
$(RUST_LIB): $(RUST_MEMBER_LIBS)
+ $(call mkdir_p_parent_template)
$(QUIET_GEN)\
if [ $(words $(RUST_TARGETS)) -gt 1 ]; then \
lipo -create $^ -output $@; \
on top.
Thanks for making the build procedure better.