From: Orne Brocaar Date: Sat, 15 Jul 2023 17:16:44 +0000 (+0800) Subject: rust: compile host package per target X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=26de69a8f0f7dd4d5e6f81faf820169ac02f0d62;p=feed%2Fpackages.git rust: compile host package per target While the compiled binaries are intended to run on the host system, the rust/host package does include the target matching the configured OpenWrt target. If using (for example) ./scripts/env to switch between different OpenWrt configurations, this will cause issues if the different configuration is for a different target. In such case there will be a mismatch between the available Rust target and OpenWrt target and the following error will be printed: > error[E0463]: can't find crate for `core` > note: the `XXX` target may not be installed This fix will add the RUSTC_TARGET_ARCH as HOST_BUILD_DIR and CARGO_HOME suffix, such that rust/host will be compiled in case an OpenWrt configuration change causes the RUSTC_TARGET_ARCH to change. Fixes: #21530 Signed-off-by: Orne Brocaar [Applied Jeffery To's suggestion for build and install path] Signed-off-by: Tianling Shen (cherry picked from commit f489e019ac4a15e974518d9928ef913a157d135a) --- diff --git a/lang/rust/Makefile b/lang/rust/Makefile index 0dedfc16f4..3b44e5a4dc 100644 --- a/lang/rust/Makefile +++ b/lang/rust/Makefile @@ -3,15 +3,16 @@ # Copyright (C) 2023 Luca Barbato and Donald Hoskins include $(TOPDIR)/rules.mk +include ./rust-values.mk PKG_NAME:=rust PKG_VERSION:=1.70.0 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz PKG_SOURCE_URL:=https://static.rust-lang.org/dist/ PKG_HASH:=b2bfae000b7a5040e4ec4bbc50a09f21548190cb7570b0ed77358368413bd27c -HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/rustc-$(PKG_VERSION)-src +HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/rust-$(RUSTC_TARGET_ARCH)/rustc-$(PKG_VERSION)-src PKG_MAINTAINER:=Luca Barbato PKG_LICENSE:=Apache-2.0 MIT @@ -22,7 +23,6 @@ PKG_HOST_ONLY:=1 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/package.mk -include ./rust-values.mk define Package/rust SECTION:=lang diff --git a/lang/rust/rust-values.mk b/lang/rust/rust-values.mk index 7ae3798234..27e7f08064 100644 --- a/lang/rust/rust-values.mk +++ b/lang/rust/rust-values.mk @@ -5,7 +5,7 @@ # Rust Environmental Vars CONFIG_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME))) RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(CONFIG_HOST_SUFFIX) -CARGO_HOME:=$(STAGING_DIR_HOSTPKG)/cargo +CARGO_HOME:=$(STAGING_DIR)/host/cargo CARGO_VARS:= ifeq ($(CONFIG_USE_MUSL),y)