git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Makefile: pin cargo --target-dir to ./target

From
Andy Koppe <andy.koppe@gmail.com>
Date
Oct 19, 2026, 19:43 UTC
Message-ID
<CAHWeT-Z5OhJLYx21V417DoL3xOQJj6viUzCm+04iDe0zu=jVWw@mail.gmail.com>
In-Reply-To
<xmqq33u165dp.fsf@gitster.g>
On Mon, 19 Oct 2026 at 17:07, Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
> Andy Koppe <andy.koppe@gmail.com> writes:
> > 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.
>
> The change might make sense, but these areas are touched by other
> topics in flight.
>
> Given that they both appear on the same line as $(CARGO_ARGS)
> appears, I have to wonder if we want to instead just add a single
>
>     CARGO_ARGS += --target-dir target
>
> somewhere early that are unreleated to these individual rules?

The problem I see with that approach is that CARGO_ARGS looks like it is intended for build preferences similar to CFLAGS or LDFLAGS that could be overridden on the make command line, whereas the target dir is a hard requirement of the subsequent link step.

I suppose `override CARGO_ARGS += --target-dir target` would avoid that concern, but also set a trap because any subsequent modifications of the variable without `override` would be quietly ignored.

The conflicting topic apparently is mh/rust-crate-subdir by Mike Hommey, which moves things into a 'rust' subdirectory, but is looking somewhat stalled: https://lore.kernel.org/git/20260917060415.2986259-1-mh@glandium.org/

I'd of course be happy to reapply the --target-dir tweak here on top of that if it does go ahead, or for Mike to just add it there.

Andy
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 7 in “Makefile: pin cargo --target-dir to ./target”
  1. Makefile: pin cargo --target-dir to ./targetAndy Koppe, Oct 18, 2026
  2. Patrick SteinhardtOct 19, 2026
  3. Junio C HamanoOct 19, 2026
  4. Andy KoppeOct 19, 2026
  5. Junio C HamanoOct 20, 2026
  6. Andy KoppeOct 20, 2026
  7. Junio C HamanoOct 20, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.