From: James Le Cuirot <chewi@gentoo.org>
To: gitster@pobox.com
Cc: chewi@gentoo.org, git@vger.kernel.org
Subject: [PATCH v3] rust: respect CARGO_BUILD_TARGET when locating build output
Date: Thu, 10 Sep 2026 11:20:14 +0100 [thread overview]
Message-ID: <20260910102013.1235066-2-chewi@gentoo.org> (raw)
In-Reply-To: <xmqq4ifyqjdi.fsf@gitster.g>
When cross-compiling, Cargo always writes to a target-tuple subdirectory
determined by CARGO_BUILD_TARGET, even when it matches the native tuple.
The build looked in $BUILD_DIR/$BUILD_TYPE directly, so it failed to
locate the freshly built library.
Respect CARGO_BUILD_TARGET in the output path so the correct artifact
is located.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---
> This seems to be based on a bit stale codebase. Specifically you
> would want to build on top of post-924dfced6b (Makefile: support
> universal macOS builds via RUST_TARGETS, 2026-07-08) version of
> Makefile.
Apologies, I had used the maint branch. Now rebased on master.
> When CARGO_BUILD_TARGET is not defined, this leaves double slashes
> in the resulting pathname, which may not be incorrect per-se, but
> still is not what you meant to say, which is probably a lot closer
> to
>
> ${CARGO_BUILD_TARGET+$CARGO_BUILD_TARGET/}
I believed this would not cause an issue, so I intentionally went with
simplicity over correctness. It's not a big difference though, so this
revision goes with correctness.
Makefile | 2 +-
src/cargo-meson.sh | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index d4b7759..f0ca2e4 100644
--- a/Makefile
+++ b/Makefile
@@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib
else
RUST_LIB_NAME = libgitcore.a
endif
-RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)
+RUST_LIB = target/$(if $(CARGO_BUILD_TARGET),$(CARGO_BUILD_TARGET)/)$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)
endif
GITLIBS = common-main.o $(LIB_FILE)
diff --git a/src/cargo-meson.sh b/src/cargo-meson.sh
index 75f3cd1..83c7e7b 100755
--- a/src/cargo-meson.sh
+++ b/src/cargo-meson.sh
@@ -38,7 +38,7 @@ then
exit $RET
fi
-if ! cmp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1
+if ! cmp "$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a" >/dev/null 2>&1
then
- cp "$BUILD_DIR/$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a"
+ cp "$BUILD_DIR/${CARGO_BUILD_TARGET:+$CARGO_BUILD_TARGET/}$BUILD_TYPE/$LIBNAME" "$BUILD_DIR/libgitcore.a"
fi
--
2.55.0
prev parent reply other threads:[~2026-09-10 10:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 15:24 [PATCH] rust: respect CARGO_BUILD_TARGET when locating build output James Le Cuirot
2026-09-08 16:18 ` Junio C Hamano
2026-09-08 21:53 ` [PATCH v2] " James Le Cuirot
2026-09-09 20:07 ` Junio C Hamano
2026-09-10 10:20 ` James Le Cuirot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260910102013.1235066-2-chewi@gentoo.org \
--to=chewi@gentoo.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox