Git development
 help / color / mirror / Atom feed
* [PATCH] Makefile: pin cargo --target-dir to ./target
@ 2026-10-18 20:53 Andy Koppe
  2026-10-19  6:45 ` Patrick Steinhardt
  2026-10-19 16:07 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Koppe @ 2026-10-18 20:53 UTC (permalink / raw)
  To: git
  Cc: Patrick Steinhardt  , brian m . carlson  ,
	Shardul Natu  , Andy Koppe

The Makefile assumes that cargo places build artifacts under ./target.
That assumption breaks if the user has a custom target dir setting, e.g.
in their ~/.cargo/config.toml file or in the CARGO_TARGET_DIR env var.
This results in a link error due to failing to find the gitcore library
built with cargo.

To fix this, pass '--target-dir target' to the cargo commands that build
gitcore. Add it directly to the recipes rather than to CARGO_ARGS, so
that it isn't lost if CARGO_ARGS is overridden.

Leave the contrib/libgit-{sys,rs} targets alone, as nothing depends on
the location of their build output.

The Meson build of gitcore already passes --target-dir explicitly.

Signed-off-by: Andy Koppe <andy.koppe@gmail.com>
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index c649c93c51..aea99a3639 100644
--- a/Makefile
+++ b/Makefile
@@ -3039,7 +3039,7 @@ $(LIB_FILE): $(LIB_OBJS)
 ifndef NO_RUST
 ifeq ($(RUST_TARGETS),)
 $(RUST_LIB): Cargo.toml $(RUST_SOURCES) $(LIB_FILE)
-	$(QUIET_CARGO)cargo build $(CARGO_ARGS)
+	$(QUIET_CARGO)cargo build $(CARGO_ARGS) --target-dir target
 else
 ifneq ($(words $(RUST_TARGETS)),1)
 ifneq ($(uname_S),Darwin)
@@ -3049,7 +3049,7 @@ endif
 
 RUST_MEMBER_LIBS = $(foreach target,$(RUST_TARGETS),target/$(target)/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME))
 $(RUST_MEMBER_LIBS): target/%/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME): Cargo.toml $(RUST_SOURCES) $(LIB_FILE)
-	$(QUIET_CARGO)cargo build $(CARGO_ARGS) --target $*
+	$(QUIET_CARGO)cargo build $(CARGO_ARGS) --target-dir target --target $*
 
 $(RUST_LIB): $(RUST_MEMBER_LIBS)
 	$(call mkdir_p_parent_template)
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-19 19:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-18 20:53 [PATCH] Makefile: pin cargo --target-dir to ./target Andy Koppe
2026-10-19  6:45 ` Patrick Steinhardt
2026-10-19 16:07 ` Junio C Hamano
2026-10-19 19:43   ` Andy Koppe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox