build: add Rust package build helpers

Add rust-package.mk for target packages written in Rust. The Cargo
environment carries the target triple, CPU flags, the C and C++ flags
for cc-rs, the linker and the ABI-specific sysroot of libstd-rust,
while native build scripts and proc macros keep the host sysroot and
linker. Builds run in the crate's working directory with an explicit
target and offline from the vendor tarball; with a source tree override
(git-src, USE_SOURCE_DIR), which has none, Cargo fetches the locked
crates. Target packages depend on libstd-rust at build time and track
its configuration inputs for rebuilds.

rustc runs the linker with arguments of its own, without TARGET_LDFLAGS.
The linker selection and the -z options that hardening.mk and
package.mk set for every package are passed to rustc, for packages and
for libstd-rust.

When the target triple is the build host's, cc-rs takes the host
compiler for target C code as well. For that triple the C and C++
compiler of cc-rs is scripts/rust-cc-wrapper.sh, linked into
$(STAGING_DIR_HOST)/bin by tools/rust. It runs the target compiler with
the target flags for build scripts whose OUT_DIR lies in the target
triple's directory, and the host compiler for the others.

RUST_PREFER_DYNAMIC is available with any Rust toolchain, controls the
default userspace standard-library linkage and defaults to shared
linking. Packages can override it. Release builds use LTO either way;
rustc runs LTO next to -Cprefer-dynamic only with the unstable
-Zdylib-lto. RUST_PKG_DEPENDS carries the architecture dependencies
and, with shared linking, the libstd-rust runtime dependency. For
packages that keep the default, that dependency is conditional on
RUST_PREFER_DYNAMIC, as .config is not read while package metadata is
collected.

Release builds emit no unwind tables and take the size options of
unstable rustc that libstd-rust is built with: panics without location,
derived Debug output reduced to type names and, with
RUST_PANIC_IMMEDIATE_ABORT, -Cpanic=immediate-abort. Permitting unstable
options for every crate with RUSTC_BOOTSTRAP=1 changes the code of
dependencies: the build scripts of anyhow, thiserror and proc-macro2
then detect unstable features and use them.
scripts/rust-target-wrapper.sh, the RUSTC_WRAPPER of package builds,
adds the options, and -Zdylib-lto with a shared libstd, only to the
target crates cargo compiles, recognised by --target, -C metadata and
--error-format=json, and permits unstable options for that crate alone.
Build scripts and their probes see neither. A package keeps panic
locations with RUST_PKG_LOCATION_DETAIL:=1 and selects the Debug output
with RUST_PKG_FMT_DEBUG. None of this applies with CONFIG_DEBUG.
Packages build the release profile, as maturin, CMake and autotools
projects do, and CONFIG_DEBUG gives it the settings of the dev profile,
ahead of the profile settings of the package. Build paths are mapped out
of packages as out of libstd-rust.

Without a Rust toolchain of the build system, Rust packages build with
rust/host of the packages feed, which installs to $(STAGING_DIR)/host,
so that packages can move from the Rust support of the packages feed
one at a time. RUSTC and CARGO point there, there is neither a sysroot
of libstd-rust nor a shared libstd, the mips64 triples are those its
std is built for, and on the build host's triple the target linker is
set through the Cargo variable. The build dependencies, on libstd-rust
or rust/host, follow USE_RUST_TOOLCHAIN in the package metadata, also
for host builds through rust-host-build.mk. After a switch from None to
a Rust toolchain, the cargo of rust/host still comes first in PATH, so
the help of the toolchain choice names its clean-up.

The file is derived from lang/rust in the packages feed by Luca Barbato
and Donald Hoskins.

Reported-by: Andre Heider <a.heider@gmail.com>
Co-developed-by: Brian Redbeard <redbeard@dead-city.org>
Signed-off-by: Brian Redbeard <redbeard@dead-city.org>
Co-developed-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Aditya Nugraha <vortexilation@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
Daniel Golle committed 2026-10-30 12:06:08 +02:00
1 parent db310ff0fb
commit 32f1c26eb6
8 files changed
+292 -7

No files matched your search

+1
View File
@@ -24,6 +24,7 @@ endif
include $(RUST_INCLUDE_DIR)/rust-values.mk
RUST_HOST_LOCKED ?= 1
HOST_BUILD_DEPENDS += $(RUST_HOST_BUILD_DEPENDS)
ifeq ($(strip $(HOST_BUILD_PARALLEL)),)
HOST_BUILD_PARALLEL:=1
+85
View File
@@ -0,0 +1,85 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
# Variables (all optional) to be set in package Makefiles:
#
# RUST_PKG_FEATURES - list of options, default empty
#
# Space or comma separated list of features to activate
#
# e.g. RUST_PKG_FEATURES:=enable-foo,with-bar
#
#
# RUST_PKG_LOCKED - Assert that `Cargo.lock` will remain unchanged
# (Enabled by default)
#
# Disable it if you want to have up-to-date dependencies
#
# e.g. RUST_PKG_LOCKED:=0
ifeq ($(origin RUST_INCLUDE_DIR),undefined)
RUST_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
endif
include $(RUST_INCLUDE_DIR)/rust-values.mk
RUST_PKG_LOCKED ?= 1
PKG_BUILD_DEPENDS += $(RUST_PKG_BUILD_DEPENDS)
PKG_CONFIG_DEPENDS += $(RUST_PKG_CONFIG_DEPENDS)
ifeq ($(strip $(PKG_BUILD_PARALLEL)),)
PKG_BUILD_PARALLEL:=1
endif
CARGO_PKG_VARS= \
$(CARGO_PKG_CONFIG_VARS) \
CC=$(TARGET_CC_NOCACHE) \
HOST_CC=$(HOSTCC_NOCACHE) \
CXX=$(TARGET_CXX_NOCACHE) \
HOST_CXX=$(HOSTCXX_NOCACHE) \
MAKEFLAGS="$(PKG_JOBS)"
CARGO_PKG_ARGS = $(if $(PKG_SKIP_DOWNLOAD),,--offline)
ifeq ($(strip $(RUST_PKG_LOCKED)),1)
CARGO_PKG_ARGS += --locked
endif
# $(1) path within PKG_BUILD_DIR (optional, defaults to MAKE_PATH)
# $(2) additional arguments to cargo (optional)
#
# Cargo builds use --offline; packages must supply a vendor tarball with
# .cargo/config.toml pointing to vendor/. Generate vendor tarballs with
# scripts/gen-cargo-vendor-tarball.sh. A source tree override (git-src,
# USE_SOURCE_DIR) has no vendor tarball, so Cargo fetches the crates then.
define Build/Compile/Cargo/Default
+cd "$(PKG_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)),$(strip $(MAKE_PATH)))" && \
$(CARGO_PKG_VARS) \
$(CARGO) $(3) -v \
--target $(RUSTC_TARGET_ARCH) \
--profile $(CARGO_PKG_PROFILE) \
$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \
$(if $(filter --jobserver%,$(PKG_JOBS)),,-j1) \
$(CARGO_PKG_ARGS) \
$(2)
endef
define Build/Compile/Cargo
$(call Build/Compile/Cargo/Default,$(1),$(2),install --root $(PKG_INSTALL_DIR) --path .)
endef
define Build/Compile/Cargo/Build
$(call Build/Compile/Cargo/Default,$(1),$(2),build --manifest-path Cargo.toml)
endef
define RustBinPackage
ifndef Package/$(1)/install
define Package/$(1)/install
$$(INSTALL_DIR) $$(1)/usr/bin/
$$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/bin/* $$(1)/usr/bin/
endef
endif
endef
Build/Compile=$(call Build/Compile/Cargo)
+123 -7
View File
@@ -9,10 +9,16 @@ __inc_rust_values:=1
RUST_VERSION:=1.99.1
RUST_SRC_TARBALL_HASH:=6451598a99e77f07571960f6b21d577399d3a30f33e80cbd2e3a4aae6535d265
# Paths to host Rust toolchain binaries
RUSTC:=$(STAGING_DIR_HOST)/bin/rustc
CARGO:=$(STAGING_DIR_HOST)/bin/cargo
RUSTC_ID:=$(shell $(RUSTC) --version --verbose 2>/dev/null)
# Paths to host Rust toolchain binaries. Without a toolchain of its own, the
# build uses rust/host of the packages feed, installed in $(STAGING_DIR)/host.
ifdef CONFIG_USE_RUST_TOOLCHAIN
RUSTC:=$(STAGING_DIR_HOST)/bin/rustc
CARGO:=$(STAGING_DIR_HOST)/bin/cargo
RUSTC_ID:=$(shell $(RUSTC) --version --verbose 2>/dev/null)
else
RUSTC:=$(STAGING_DIR)/host/bin/rustc
CARGO:=$(STAGING_DIR)/host/bin/cargo
endif
# Directory holding libclang for bindgen: the host LLVM, the one built by
# tools/llvm-bpf or the prebuilt one unpacked into the source tree, as
@@ -37,6 +43,23 @@ RUSTC_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME)))
RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(RUSTC_HOST_SUFFIX)
CARGO_HOME:=$(STAGING_DIR_HOSTPKG)/cargo
ifeq ($(CONFIG_USE_MUSL),y)
# Force linking of the SSP library for musl
ifdef CONFIG_PKG_CC_STACKPROTECTOR_REGULAR
ifeq ($(strip $(PKG_SSP)),1)
RUSTC_LDFLAGS+=-lssp_nonshared
endif
endif
ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG
ifeq ($(strip $(PKG_SSP)),1)
RUSTC_LDFLAGS+=-lssp_nonshared
endif
endif
endif
CARGO_RUSTFLAGS+=-Ctarget-feature=-crt-static $(RUSTC_LDFLAGS) \
$(if $(CONFIG_DEBUG),,-Cpanic=abort -Cforce-unwind-tables=no)
ifeq ($(HOST_OS),Darwin)
ifeq ($(HOST_ARCH),arm64)
RUSTC_HOST_ARCH:=aarch64-apple-darwin
@@ -103,6 +126,15 @@ else
RUSTC_TARGET_ARCH:=$(subst openwrt,unknown,$(REAL_GNU_TARGET_NAME))
endif
# rust/host of the packages feed builds its mips64 std for these triples
ifndef CONFIG_USE_RUST_TOOLCHAIN
ifeq ($(ARCH),mips64)
RUSTC_TARGET_ARCH:=$(REAL_GNU_TARGET_NAME)
else ifeq ($(ARCH),mips64el)
RUSTC_TARGET_ARCH:=$(subst openwrt,unknown,$(REAL_GNU_TARGET_NAME))
endif
endif
RUSTC_TARGET_ARCH:=$(subst muslgnueabi,musleabi,$(RUSTC_TARGET_ARCH))
ifeq ($(ARCH),i386)
@@ -126,9 +158,16 @@ ifeq ($(ARCH),arm)
endif
# Cargo also links build scripts with the target linker when the target triple
# is the host's, but keeps target rustflags off them.
ifeq ($(RUSTC_TARGET_ARCH),$(RUSTC_HOST_ARCH))
# is the host's, but keeps target rustflags off them. cc-rs then compiles
# target C code with the host compiler, see scripts/rust-cc-wrapper.sh.
ifeq ($(CONFIG_USE_RUST_TOOLCHAIN)$(RUSTC_TARGET_ARCH),y$(RUSTC_HOST_ARCH))
RUSTC_TARGET_LINKER_FLAGS:=-Clinker=$(TARGET_CC_NOCACHE)
RUSTC_TARGET_CC_VARS:= \
CC_$(subst -,_,$(RUSTC_TARGET_ARCH))=$(STAGING_DIR_HOST)/bin/rust-cc-wrapper \
CXX_$(subst -,_,$(RUSTC_TARGET_ARCH))=$(STAGING_DIR_HOST)/bin/rust-cxx-wrapper \
TARGET_CXX=$(TARGET_CXX_NOCACHE) \
HOST_CC=$(HOSTCC_NOCACHE) \
HOST_CXX=$(HOSTCXX_NOCACHE)
else
RUSTC_TARGET_LINKER_VARS:= \
CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_LINKER=$(TARGET_CC_NOCACHE)
@@ -178,8 +217,24 @@ RUST_LLVM_TARGETS:=AArch64;ARM;LoongArch;Mips;PowerPC;RISCV;X86
# Defaults to AVR;M68k;CSKY;Xtensa, none of which are relevant to OpenWrt.
RUST_LLVM_EXPERIMENTAL_TARGETS:=
# Link against libstd-HASH.so (shipped by package/libs/libstd-rust) instead of
# bundling libstd. Override per package with RUST_PREFER_DYNAMIC:=0 or 1.
# rust/host of the packages feed has no shared libstd.
RUST_LIBSTD_DYNAMIC = $(if $(CONFIG_USE_RUST_TOOLCHAIN), \
$(or $(RUST_PREFER_DYNAMIC),$(if $(CONFIG_RUST_PREFER_DYNAMIC),1,0)),0)
RUST_IMMEDIATE_ABORT:=$(if $(CONFIG_DEBUG),,$(CONFIG_RUST_PANIC_IMMEDIATE_ABORT))
# Size options of unstable rustc, for libstd-rust and, through
# scripts/rust-target-wrapper.sh, for the crates of packages. A package keeps
# panic locations with RUST_PKG_LOCATION_DETAIL:=1, and selects the Debug
# output with RUST_PKG_FMT_DEBUG:=full or none. immediate-abort applies to all
# crates or none, std included.
RUST_UNSTABLE_FLAGS = $(if $(CONFIG_DEBUG),, \
$(if $(filter 1,$(RUST_PKG_LOCATION_DETAIL)),,-Zlocation-detail=none) \
-Zfmt-debug=$(or $(RUST_PKG_FMT_DEBUG),shallow) \
$(if $(RUST_IMMEDIATE_ABORT),-Zunstable-options -Cpanic=immediate-abort))
RUST_LIBSTD_FEATURES:=$(if $(RUST_IMMEDIATE_ABORT),,panic-unwind) \
$(if $(CONFIG_DEBUG),,optimize_for_size)
RUST_LIBSTD_FLAGS= \
@@ -216,11 +271,39 @@ LIBSTD_RUST_INPUTS = $(strip \
$(RUST_LIBSTD_FLAGS) $(RUST_LIBSTD_FEATURES) $(RUSTC_CFLAGS) \
$(foreach v,$(RUST_LIBSTD_CONFIG),$(v)=$($(v))))
LIBSTD_RUST_ID = $(shell printf '%s' '$(subst ','\'',$(LIBSTD_RUST_INPUTS))' | $(MKHASH) sha256)
RUST_TARGET_SYSROOT = $(STAGING_DIR)/usr/lib/rust/$(LIBSTD_RUST_ID)
RUSTLIB_TARGET_PATH = /usr/lib/rust/$(LIBSTD_RUST_ID)/lib/rustlib/$(RUSTC_TARGET_ARCH)/lib
RUST_PKG_BUILD_DEPENDS:=USE_RUST_TOOLCHAIN:libstd-rust !USE_RUST_TOOLCHAIN:rust/host
RUST_HOST_BUILD_DEPENDS:=!USE_RUST_TOOLCHAIN:rust/host
RUST_PKG_CONFIG_DEPENDS:= \
$(RUST_LIBSTD_CONFIG) \
LIBSTD_RUST_ID
CONFIG_USE_RUST_TOOLCHAIN \
$(if $(CONFIG_USE_RUST_TOOLCHAIN),CONFIG_RUST_PREFER_DYNAMIC LIBSTD_RUST_ID)
CARGO_RUSTFLAGS+= \
$(RUSTC_TARGET_FLAGS) \
$(RUSTC_TARGET_LINKER_FLAGS) \
$(if $(CONFIG_USE_RUST_TOOLCHAIN),--sysroot=$(RUST_TARGET_SYSROOT)) \
$(if $(filter 1,$(RUST_LIBSTD_DYNAMIC)),-Cprefer-dynamic) \
$(RUST_PATH_REMAP)
# RUST_PKG_DEPENDS: use in Package/foo DEPENDS for all cargo-built target packages.
# Includes arch constraint and the libstd-rust runtime dependency when the
# package links libstd dynamically. The default is a Kconfig condition, as
# .config is not read when metadata is collected.
ifdef CONFIG_USE_RUST_TOOLCHAIN
# rustc runs LTO next to -Cprefer-dynamic only with -Zdylib-lto.
RUST_TARGET_WRAPPER_VARS = \
RUSTC_WRAPPER=$(SCRIPT_DIR)/rust-target-wrapper.sh \
RUST_TARGET_WRAPPER_FLAGS="$(RUST_UNSTABLE_FLAGS)" \
RUST_TARGET_WRAPPER_LTO_FLAGS="$(if $(filter 1,$(RUST_LIBSTD_DYNAMIC)),-Zdylib-lto)"
endif
RUST_PKG_DEPENDS = $(RUST_ARCH_DEPENDS) \
$(if $(RUST_PREFER_DYNAMIC), \
$(if $(filter 1,$(RUST_PREFER_DYNAMIC)),+USE_RUST_TOOLCHAIN:libstd-rust), \
+RUST_PREFER_DYNAMIC:libstd-rust)
CARGO_HOST_CONFIG_VARS= \
RUSTC=$(RUSTC) \
@@ -228,4 +311,37 @@ CARGO_HOST_CONFIG_VARS= \
CARGO_HOST_PROFILE:=release
# Packages build the release profile, as maturin, CMake and autotools projects
# do, or one inheriting from it. CONFIG_DEBUG gives it the settings of dev;
# these take precedence over the profile settings of the package.
CARGO_PKG_CONFIG_VARS= \
RUSTC=$(RUSTC) \
CARGO_BUILD_TARGET=$(RUSTC_TARGET_ARCH) \
CARGO_HOME=$(CARGO_HOME) \
$(if $(CONFIG_DEBUG),,CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1) \
CARGO_PROFILE_RELEASE_DEBUG=$(if $(CONFIG_DEBUG),true,false) \
CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS=$(if $(CONFIG_DEBUG),true,false) \
CARGO_PROFILE_RELEASE_LTO=$(if $(CONFIG_DEBUG),false,true) \
$(RUST_TARGET_WRAPPER_VARS) \
CARGO_PROFILE_RELEASE_OPT_LEVEL=$(if $(CONFIG_DEBUG),0,z) \
CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS=true \
CARGO_PROFILE_RELEASE_PANIC=$(if $(CONFIG_DEBUG),unwind,abort) \
CARGO_PROFILE_RELEASE_RPATH=false \
$(RUSTC_TARGET_LINKER_VARS) \
$(RUSTC_TARGET_CC_VARS) \
CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_RUSTFLAGS="$(CARGO_RUSTFLAGS)" \
TARGET_CC=$(TARGET_CC_NOCACHE) \
TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)" \
TARGET_CXXFLAGS="$(TARGET_CXXFLAGS) $(RUSTC_CFLAGS)"
CARGO_PKG_PROFILE:=release
# rustc drives the linker itself, without TARGET_LDFLAGS: pass the linker, and
# the -z options hardening.mk and package.mk set for the package.
RUSTC_TARGET_LINK_ARGS = \
-Clink-arg=-fuse-ld=$(TARGET_LINKER) \
$(addprefix -Clink-arg=,$(filter -z%,$(TARGET_LDFLAGS)))
CARGO_RUSTFLAGS+=$(RUSTC_TARGET_LINK_ARGS)
endif # __inc_rust_values
+1
View File
@@ -31,6 +31,7 @@ LIBSTD_BUILD_DIR:=$(LIBSTD_TARGET_DIR)/$(RUSTC_TARGET_ARCH)/release/deps
LIBSTD_RUSTFLAGS:= \
$(RUST_LIBSTD_FLAGS) \
$(RUSTC_TARGET_LINKER_FLAGS) \
$(RUSTC_TARGET_LINK_ARGS) \
$(RUST_PATH_REMAP) \
-Clink-arg=-Wl,-soname,libstd-$(LIBSTD_RUST_ID).so
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# C and C++ compiler for cc-rs when the target triple is the build host's:
# cc-rs then takes the host compiler for target code as well. Cargo runs the
# build scripts of target units with OUT_DIR in
# <target-dir>/<triple>/<profile>/build/<unit>/out.
kind=target
if [ -n "$OUT_DIR" ]; then
triple_dir="${OUT_DIR%/*/*/*/*}"
[ "${triple_dir##*/}" = "$TARGET" ] || kind=host
fi
case "$kind:${0##*/}" in
target:*cxx*) exec $TARGET_CXX $TARGET_CXXFLAGS "$@" ;;
target:*) exec $TARGET_CC $TARGET_CFLAGS "$@" ;;
host:*cxx*) exec $HOST_CXX "$@" ;;
*) exec $HOST_CC "$@" ;;
esac
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# rustc wrapper for package builds. It passes options of unstable rustc to the
# target crates cargo compiles, and allows them for that crate alone: build
# scripts probe for unstable features, under the crate's own name, and change
# their code when they find them. A target crate of cargo carries --target,
# -C metadata and --error-format=json; probes and build scripts do not, and
# pass through unchanged.
#
# RUST_TARGET_WRAPPER_FLAGS options for every target crate
# RUST_TARGET_WRAPPER_LTO_FLAGS further options when the crate runs LTO
# RUST_TARGET_WRAPPER_NEXT wrapper to run rustc with, such as sccache
rustc="$1"
shift
target=
metadata=
json=
lto=
crate=
prev=
for arg in "$@"; do
case "$prev:$arg" in
--target:*|*:--target=*) target=1 ;;
-C:metadata=*|*:-Cmetadata=*) metadata=1 ;;
*:--error-format=json) json=1 ;;
--crate-name:*) crate="$arg" ;;
-C:lto=off|-C:lto=no|-C:lto=false|*:-Clto=off|*:-Clto=no|*:-Clto=false) ;;
-C:lto|-C:lto=*|*:-Clto|*:-Clto=*) lto=1 ;;
esac
prev="$arg"
done
if [ -z "$target" ] || [ -z "$metadata" ] || [ -z "$json" ] || [ -z "$crate" ]; then
exec $RUST_TARGET_WRAPPER_NEXT "$rustc" "$@"
fi
exec env RUSTC_BOOTSTRAP="$crate" $RUST_TARGET_WRAPPER_NEXT "$rustc" "$@" \
$RUST_TARGET_WRAPPER_FLAGS ${lto:+$RUST_TARGET_WRAPPER_LTO_FLAGS}
+17
View File
@@ -344,6 +344,12 @@ choice
default RUST_TOOLCHAIN_BUILD if EXPERIMENTAL && TARGET_mpc85xx
default RUST_TOOLCHAIN_PREBUILT if EXPERIMENTAL
default RUST_TOOLCHAIN_NONE
help
With None, Rust packages build with rust/host of the packages
feed. After switching from None to a Rust toolchain in a tree
where rust/host was built, run "make package/rust/host/clean":
its cargo comes first in PATH and is otherwise used by tools
that run cargo from PATH, such as maturin.
config RUST_TOOLCHAIN_NONE
bool "None"
@@ -386,6 +392,17 @@ config RUST_TOOLCHAIN_HOST_PATH
Prefix of the host Rust toolchain. If empty, the sysroot of the
rustc found in PATH is used.
config RUST_PREFER_DYNAMIC
bool
prompt "Link Rust packages to the shared standard library" if RUST_TOOLCHAINOPTS
depends on USE_RUST_TOOLCHAIN
default y
help
Link Rust packages to libstd-rust by default. Disable this for
static linking. Cargo release builds use LTO either way; with
the shared libstd through the unstable -Zdylib-lto of rustc.
Individual packages can override this default.
config RUST_PANIC_IMMEDIATE_ABORT
bool
prompt "Abort on panic without a panic message" if RUST_TOOLCHAINOPTS
+4
View File
@@ -32,6 +32,8 @@ TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
RUST_PREFIX_DIR:=$(HOST_BUILD_DIR)/prefix
RUST_FILE_LIST:=$(STAGING_DIR_HOST)/stamp/.rust_files
RUST_DIR_LIST:=$(STAGING_DIR_HOST)/stamp/.rust_dirs
RUST_CC_WRAPPER:=$(subst $(space),,$(foreach dir, \
$(subst /, ,$(patsubst $(TOPDIR)/%,%,$(STAGING_DIR_HOST)/bin)),../))scripts/rust-cc-wrapper.sh
# The rust-installer manifests name absolute paths, which its uninstaller
# and the next install.sh into the same prefix delete.
@@ -218,6 +220,8 @@ endif
define Host/Install
$(call Host/Install/Prefix)
$(call Host/Install/RemoveInstallerData)
ln -sf $(RUST_CC_WRAPPER) $(RUST_PREFIX_DIR)/bin/rust-cc-wrapper
ln -sf $(RUST_CC_WRAPPER) $(RUST_PREFIX_DIR)/bin/rust-cxx-wrapper
$(call Host/Uninstall)
$(INSTALL_DIR) $(STAGING_DIR_HOST)/stamp
cd $(RUST_PREFIX_DIR) && \