# Makefile fix for builds when cargo uses a custom target directory

_A user-level cargo setting for the target directory breaks linking of the Rust gitcore library, because the Makefile assumes ./target._

Section: Patches. Edition of 2026-10-19. Written by an AI editor from the thread "[PATCH] Makefile: pin cargo --target-dir to ./target" (7 messages): https://gitlist.dev/t/66580

Andy Koppe says the Makefile assumes cargo places build artifacts under ./target. If the user sets a different target directory, in ~/.cargo/config.toml or through the CARGO_TARGET_DIR environment variable, the build fails with a link error because the gitcore library built by cargo cannot be found.

His patch passes '--target-dir target' to the cargo commands that build gitcore. He adds it directly to the recipes rather than to CARGO_ARGS, so the option is not lost if CARGO_ARGS is overridden.

The contrib/libgit-{sys,rs} targets are left alone, since nothing depends on where their build output goes. The Meson build of gitcore already passes --target-dir explicitly.

The patch is at v1 and has no replies yet.
