public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/2] cargo.eclass: Drop EAPI 7 support
@ 2024-06-07 16:59 James Le Cuirot
  2024-06-07 16:59 ` [gentoo-dev] [PATCH 2/2] cargo.eclass: Enable cross-compiling by setting environment variables James Le Cuirot
  0 siblings, 1 reply; 2+ messages in thread
From: James Le Cuirot @ 2024-06-07 16:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: James Le Cuirot

It is going to inherit rust-toolchain, which is EAPI 8 only.

Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---

There are still some EAPI 7 ebuilds left right now, but I'm working on that!

 eclass/cargo.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index a685cd99fb38b..ef55e0613e61c 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -7,11 +7,11 @@
 # @AUTHOR:
 # Doug Goldstein <cardoe@gentoo.org>
 # Georgy Yakovlev <gyakovlev@gentoo.org>
-# @SUPPORTED_EAPIS: 7 8
+# @SUPPORTED_EAPIS: 8
 # @BLURB: common functions and variables for cargo builds

 case ${EAPI} in
-	7|8) ;;
+	8) ;;
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac

--
2.45.1


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

* [gentoo-dev] [PATCH 2/2] cargo.eclass: Enable cross-compiling by setting environment variables
  2024-06-07 16:59 [gentoo-dev] [PATCH 1/2] cargo.eclass: Drop EAPI 7 support James Le Cuirot
@ 2024-06-07 16:59 ` James Le Cuirot
  0 siblings, 0 replies; 2+ messages in thread
From: James Le Cuirot @ 2024-06-07 16:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: James Le Cuirot

CARGO_BUILD_TARGET and CARGO_TARGET_<triple>_LINKER are enough for pure
Rust. The linker otherwise defaults to `cc`. This doesn't respect any
linker specified in LDFLAGS, but this is also true for native builds. We
would need to do something with RUSTFLAGS.

The HOST_* variables are for the cc-rs crate, which is often used to
build non-Rust code. It uses the usual variables (CC, CFLAGS, etc) for
the target.

Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---
 eclass/cargo.eclass | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index ef55e0613e61c..9390d488f8327 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -38,7 +38,7 @@ case ${EAPI} in
 		;;
 esac
 
-inherit flag-o-matic multiprocessing toolchain-funcs
+inherit flag-o-matic multiprocessing rust-toolchain toolchain-funcs
 
 [[ ! ${CARGO_OPTIONAL} ]] && BDEPEND="${RUST_DEPEND}"
 
@@ -529,6 +529,21 @@ cargo_src_compile() {
 	filter-lto
 	tc-export AR CC CXX PKG_CONFIG
 
+	if tc-is-cross-compiler; then
+		export CARGO_BUILD_TARGET=$(rust_abi)
+		local TRIPLE=${CARGO_BUILD_TARGET//-/_}
+		export CARGO_TARGET_"${TRIPLE^^}"_LINKER=$(tc-getCC)
+
+		# Set vars for cc-rs crate.
+		tc-export_build_env
+		export \
+			HOST_AR=$(tc-getBUILD_AR)
+			HOST_CC=$(tc-getBUILD_CC)
+			HOST_CXX=$(tc-getBUILD_CXX)
+			HOST_CFLAGS=${BUILD_CFLAGS}
+			HOST_CXXFLAGS=${BUILD_CXXFLAGS}
+	fi
+
 	set -- cargo build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@"
 	einfo "${@}"
 	"${@}" || die "cargo build failed"
-- 
2.45.1



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

end of thread, other threads:[~2024-06-07 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-07 16:59 [gentoo-dev] [PATCH 1/2] cargo.eclass: Drop EAPI 7 support James Le Cuirot
2024-06-07 16:59 ` [gentoo-dev] [PATCH 2/2] cargo.eclass: Enable cross-compiling by setting environment variables James Le Cuirot

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