aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2023-10-02 02:16:22 +0800
committerJeffery To <jeffery.to@gmail.com>2023-10-11 15:50:23 +0800
commit5c5123f0f63cfda1d4f17a5d315356883fd82923 (patch)
tree097c5475d8b17040edfa142d9a63ab205ee080f7
parent49aaf19c65a35c37725ead7a438684411b512d6f (diff)
rust: Move cargo config options into environment variables
This also: * Modify the "release" profile in place of adding the "stripped" profile Only the profile for target is modified; there are no file size constraints for host. * For host, build with the "release" profile * For target, build with either the "dev" or "release" profile based on CONFIG_DEBUG There is no environment variable to specify the "strip" option, but enabling this option is not necessary as the build system will already strip binaries based on CONFIG_NO_STRIP / CONFIG_USE_STRIP / CONFIG_USE_SSTRIP. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
5 files changed, 8 insertions, 13 deletions
diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 67513d180..8f99f4144 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -97,10 +97,6 @@ define Host/Install
done ; \
find . -mindepth 2 -maxdepth 2 -type f -name install.sh \
-execdir bash '{}' --prefix=$(STAGING_DIR)/host --disable-ldconfig \; ; \
- \
- sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \
- -e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \
- $(CURDIR)/files/cargo-config > $(CARGO_HOME)/config.toml ; \
)
endef
diff --git a/lang/rust/files/cargo-config b/lang/rust/files/cargo-config
deleted file mode 100644
index 2f490dc58..000000000
--- a/lang/rust/files/cargo-config
+++ /dev/null
@@ -1,7 +0,0 @@
-[target.@RUSTC_TARGET_ARCH@]
-linker = "@TARGET_CC_NOCACHE@"
-
-[profile.stripped]
-inherits = "release"
-opt-level = "s"
-strip = true
diff --git a/lang/rust/rust-host-build.mk b/lang/rust/rust-host-build.mk
index 29ecc42a5..a03df2493 100644
--- a/lang/rust/rust-host-build.mk
+++ b/lang/rust/rust-host-build.mk
@@ -23,7 +23,7 @@ define Host/Compile/Cargo
CARGO_HOME=$(CARGO_HOME) \
CC=$(HOSTCC_NOCACHE) \
cargo install -v \
- --profile stripped \
+ --profile $(CARGO_HOST_PROFILE) \
$(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \
--root $(HOST_INSTALL_DIR) \
--path "$(if $(strip $(1)),$(strip $(1)),.)" $(2) ; \
diff --git a/lang/rust/rust-package.mk b/lang/rust/rust-package.mk
index 231828bab..713d37d5b 100644
--- a/lang/rust/rust-package.mk
+++ b/lang/rust/rust-package.mk
@@ -21,13 +21,15 @@ define Build/Compile/Cargo
( \
cd $(PKG_BUILD_DIR) ; \
CARGO_HOME=$(CARGO_HOME) \
+ CARGO_PROFILE_RELEASE_OPT_LEVEL=s \
+ CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_LINKER=$(TARGET_CC_NOCACHE) \
TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)" \
TARGET_CC=$(TARGET_CC_NOCACHE) \
CC=$(HOSTCC_NOCACHE) \
RUSTFLAGS="$(CARGO_RUSTFLAGS)" \
$(CARGO_VARS) \
cargo install -v \
- --profile stripped \
+ --profile $(CARGO_PKG_PROFILE) \
--target $(RUSTC_TARGET_ARCH) \
$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \
--root $(PKG_INSTALL_DIR) \
diff --git a/lang/rust/rust-values.mk b/lang/rust/rust-values.mk
index dfd417340..02a68d48f 100644
--- a/lang/rust/rust-values.mk
+++ b/lang/rust/rust-values.mk
@@ -62,3 +62,7 @@ endif
# Support only a subset for now.
RUST_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mipsel||mips64||mips64el||mipsel||powerpc64||riscv64||x86_64)
+
+CARGO_HOST_PROFILE:=release
+
+CARGO_PKG_PROFILE:=$(if $(CONFIG_DEBUG),dev,release)