From aa3db5a62e69477a33b70d6bae1b4cb32575d222 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Sat, 20 Jan 2024 11:14:50 +0100 Subject: [PATCH] Downgrade Rust for kernel 5.4 --- rust/Config.in | 15 --- rust/Makefile | 58 +++++----- rust/files/cargo-config | 8 ++ .../0001-Update-xz2-and-use-it-static.patch | 14 +-- rust/patches/0002-Bumped-libc-version.patch | 35 ++++++ rust/patches/0002-rustc-bootstrap-cache.patch | 52 --------- .../0003-bump-libc-deps-to-0.2.146.patch | 100 ------------------ rust/rust-host-build.mk | 44 ++++---- rust/rust-package.mk | 30 +++--- rust/rust-values.mk | 77 +++----------- 10 files changed, 129 insertions(+), 304 deletions(-) delete mode 100644 rust/Config.in create mode 100644 rust/files/cargo-config create mode 100644 rust/patches/0002-Bumped-libc-version.patch delete mode 100644 rust/patches/0002-rustc-bootstrap-cache.patch delete mode 100644 rust/patches/0003-bump-libc-deps-to-0.2.146.patch diff --git a/rust/Config.in b/rust/Config.in deleted file mode 100644 index 62051af139..0000000000 --- a/rust/Config.in +++ /dev/null @@ -1,15 +0,0 @@ -menu "Configuration options (for developers)" - -config RUST_SCCACHE - bool "Use sccache" - help - Shared compilation cache; see https://github.com/mozilla/sccache - -config RUST_SCCACHE_DIR - string "Set sccache directory" if RUST_SCCACHE - default "" - help - Store sccache in this directory. - If not set, uses './.sccache' - -endmenu diff --git a/rust/Makefile b/rust/Makefile index 46ee84e9d1..60df0e5cde 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -3,26 +3,26 @@ # Copyright (C) 2023 Luca Barbato and Donald Hoskins include $(TOPDIR)/rules.mk +include ./rust-values.mk PKG_NAME:=rust -PKG_VERSION:=1.75.0 +PKG_VERSION:=1.71.1 PKG_RELEASE:=1 PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz PKG_SOURCE_URL:=https://static.rust-lang.org/dist/ -PKG_HASH:=5b739f45bc9d341e2d1c570d65d2375591e22c2d23ef5b8a37711a0386abc088 -HOST_BUILD_DIR:=$(BUILD_DIR)/host/rustc-$(PKG_VERSION)-src +PKG_HASH:=6fa90d50d1d529a75f6cc349784de57d7ec0ba2419b09bde7d335c25bd4e472e +HOST_BUILD_DIR:=$(BUILD_DIR)/host/rust-$(RUSTC_TARGET_ARCH)/rustc-$(PKG_VERSION)-src PKG_MAINTAINER:=Luca Barbato PKG_LICENSE:=Apache-2.0 MIT PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT +HOST_BUILD_DEPENDS:=python3/host PKG_HOST_ONLY:=1 -PKG_BUILD_FLAGS:=no-mips16 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/package.mk -include ./rust-values.mk define Package/rust SECTION:=lang @@ -39,12 +39,8 @@ define Package/rust/description guarantee memory safety by using a borrow checker to validate references. endef -define Package/rust/config - source "$(SOURCE)/Config.in" -endef - # Rust-lang has an uninstall script -RUST_UNINSTALL:=$(STAGING_DIR)/host/lib/rustlib/uninstall.sh +RUST_UNINSTALL:=$(CARGO_HOME)/lib/rustlib/uninstall.sh # Target Flags TARGET_CONFIGURE_ARGS = \ @@ -53,24 +49,23 @@ TARGET_CONFIGURE_ARGS = \ --set=target.$(RUSTC_TARGET_ARCH).cxx=$(TARGET_CXX_NOCACHE) \ --set=target.$(RUSTC_TARGET_ARCH).linker=$(TARGET_CC_NOCACHE) \ --set=target.$(RUSTC_TARGET_ARCH).ranlib=$(TARGET_RANLIB) \ - --set=target.$(RUSTC_TARGET_ARCH).crt-static=false \ $(if $(CONFIG_USE_MUSL),--set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_DIR)) # CARGO_HOME is an environmental -HOST_CONFIGURE_VARS += CARGO_HOME="$(CARGO_HOME)" +HOST_CONFIGURE_OPTS += CARGO_HOME="$(CARGO_HOME)" # Rust Configuration Arguments HOST_CONFIGURE_ARGS = \ --build=$(RUSTC_HOST_ARCH) \ --target=$(RUSTC_TARGET_ARCH),$(RUSTC_HOST_ARCH) \ --host=$(RUSTC_HOST_ARCH) \ - --prefix=$(STAGING_DIR)/host \ - --bindir=$(STAGING_DIR)/host/bin \ - --libdir=$(STAGING_DIR)/host/lib \ - --sysconfdir=$(STAGING_DIR)/host/etc \ - --datadir=$(STAGING_DIR)/host/share \ - --mandir=$(STAGING_DIR)/host/man \ - --dist-compression-formats=gz \ + --prefix=$(CARGO_HOME) \ + --bindir=$(CARGO_HOME)/bin \ + --libdir=$(CARGO_HOME)/lib \ + --sysconfdir=$(CARGO_HOME)/etc \ + --datadir=$(CARGO_HOME)/share \ + --mandir=$(CARGO_HOME)/man \ + --dist-compression-formats=xz \ --enable-missing-tools \ --disable-sanitizers \ --release-channel=stable \ @@ -85,24 +80,23 @@ define Host/Uninstall endef define Host/Compile - $(RUST_SCCACHE_VARS) \ - CARGO_HOME=$(CARGO_HOME) \ - TARGET_CFLAGS="$(TARGET_CFLAGS)" \ - OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \ - $(PYTHON) $(HOST_BUILD_DIR)/x.py \ - --build-dir $(HOST_BUILD_DIR)/build \ - --config $(HOST_BUILD_DIR)/config.toml \ - dist build-manifest cargo llvm-tools rustc rust-std rust-src + ( \ + cd $(HOST_BUILD_DIR) ; \ + $(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \ + rustc rust-std rust-src ; \ + ) endef define Host/Install ( \ cd $(HOST_BUILD_DIR)/build/dist ; \ - for targz in *.tar.gz; do \ - $(STAGING_DIR_HOST)/bin/libdeflate-gzip -dc "$$$$targz" | tar -xf - ; \ - done ; \ - find . -mindepth 2 -maxdepth 2 -type f -name install.sh \ - -execdir bash '{}' --prefix=$(STAGING_DIR)/host --disable-ldconfig \; ; \ + find -iname "*.xz" -exec tar -xJf {} \; ; \ + find ./* -type f -name install.sh -execdir sh {} --prefix=$(CARGO_HOME) --disable-ldconfig \; ; \ + \ + sed -e 's|@RUSTC_TARGET_ARCH@|$(RUSTC_TARGET_ARCH)|g' \ + -e 's|@TARGET_CC_NOCACHE@|$(TARGET_CC_NOCACHE)|g' \ + -e 's|@RUSTC_LDFLAGS@|$(RUSTC_LDFLAGS)|g' \ + $(CURDIR)/files/cargo-config > $(CARGO_HOME)/config ; \ ) endef diff --git a/rust/files/cargo-config b/rust/files/cargo-config new file mode 100644 index 0000000000..2ed5129317 --- /dev/null +++ b/rust/files/cargo-config @@ -0,0 +1,8 @@ +[target.@RUSTC_TARGET_ARCH@] +linker = "@TARGET_CC_NOCACHE@" +rustflags = ["-Ctarget-feature=-crt-static", "-Clink-args=@RUSTC_LDFLAGS@"] + +[profile.stripped] +inherits = "release" +opt-level = "s" +strip = true diff --git a/rust/patches/0001-Update-xz2-and-use-it-static.patch b/rust/patches/0001-Update-xz2-and-use-it-static.patch index 2360136a74..8d0c4b042a 100644 --- a/rust/patches/0001-Update-xz2-and-use-it-static.patch +++ b/rust/patches/0001-Update-xz2-and-use-it-static.patch @@ -11,7 +11,7 @@ Subject: [PATCH] Update xz2 and use it static --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock -@@ -391,9 +391,9 @@ dependencies = [ +@@ -443,9 +443,9 @@ dependencies = [ [[package]] name = "lzma-sys" @@ -23,7 +23,7 @@ Subject: [PATCH] Update xz2 and use it static dependencies = [ "cc", "libc", -@@ -834,9 +834,9 @@ dependencies = [ +@@ -912,9 +912,9 @@ dependencies = [ [[package]] name = "xz2" @@ -37,12 +37,12 @@ Subject: [PATCH] Update xz2 and use it static ] --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml -@@ -57,7 +57,7 @@ tar = "0.4" - termcolor = "1.2.0" - toml = "0.5" - walkdir = "2" +@@ -50,7 +50,7 @@ toml = "0.5" + ignore = "0.4.10" + opener = "0.5" + once_cell = "1.7.2" -xz2 = "0.1" +xz2 = { version = "0.1", features = ["static"] } + walkdir = "2" # Dependencies needed by the build-metrics feature - sysinfo = { version = "0.26.0", optional = true } diff --git a/rust/patches/0002-Bumped-libc-version.patch b/rust/patches/0002-Bumped-libc-version.patch new file mode 100644 index 0000000000..52c8a245c3 --- /dev/null +++ b/rust/patches/0002-Bumped-libc-version.patch @@ -0,0 +1,35 @@ +From 032857e7e403f654129c45dc7e6718a9ad49e377 Mon Sep 17 00:00:00 2001 +From: Nikolay Arhipov +Date: Tue, 6 Jun 2023 16:09:05 +0300 +Subject: [PATCH] Bumped libc version + +--- + Cargo.lock | 4 ++-- + library/std/Cargo.toml | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -1988,9 +1988,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0e + + [[package]] + name = "libc" +-version = "0.2.143" ++version = "0.2.146" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024" ++checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" + dependencies = [ + "rustc-std-workspace-core", + ] +--- a/library/std/Cargo.toml ++++ b/library/std/Cargo.toml +@@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = [ + panic_unwind = { path = "../panic_unwind", optional = true } + panic_abort = { path = "../panic_abort" } + core = { path = "../core" } +-libc = { version = "0.2.143", default-features = false, features = ['rustc-dep-of-std'] } ++libc = { version = "0.2.146", default-features = false, features = ['rustc-dep-of-std'] } + compiler_builtins = { version = "0.1.92" } + profiler_builtins = { path = "../profiler_builtins", optional = true } + unwind = { path = "../unwind" } diff --git a/rust/patches/0002-rustc-bootstrap-cache.patch b/rust/patches/0002-rustc-bootstrap-cache.patch deleted file mode 100644 index 959e234871..0000000000 --- a/rust/patches/0002-rustc-bootstrap-cache.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- a/src/bootstrap/bootstrap.py -+++ b/src/bootstrap/bootstrap.py -@@ -557,7 +557,7 @@ class RustBuild(object): - shutil.rmtree(bin_root) - - key = self.stage0_compiler.date -- cache_dst = os.path.join(self.build_dir, "cache") -+ cache_dst = os.getenv('OPENWRT_RUSTC_BOOTSTRAP_CACHE', os.path.join(self.build_dir, "cache")) - rustc_cache = os.path.join(cache_dst, key) - if not os.path.exists(rustc_cache): - os.makedirs(rustc_cache) ---- a/src/bootstrap/src/core/download.rs -+++ b/src/bootstrap/src/core/download.rs -@@ -208,7 +208,13 @@ impl Config { - Some(other) => panic!("unsupported protocol {other} in {url}"), - None => panic!("no protocol in {url}"), - } -- t!(std::fs::rename(&tempfile, dest_path)); -+ match std::fs::rename(&tempfile, dest_path) { -+ Ok(v) => v, -+ Err(_) => { -+ t!(std::fs::copy(&tempfile, dest_path)); -+ t!(std::fs::remove_file(&tempfile)); -+ } -+ } - } - - fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) { -@@ -544,7 +550,10 @@ impl Config { - key: &str, - destination: &str, - ) { -- let cache_dst = self.out.join("cache"); -+ let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") { -+ Some(v) => PathBuf::from(v), -+ None => self.out.join("cache"), -+ }; - let cache_dir = cache_dst.join(key); - if !cache_dir.exists() { - t!(fs::create_dir_all(&cache_dir)); -@@ -671,7 +680,10 @@ download-rustc = false - let llvm_assertions = self.llvm_assertions; - - let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}"); -- let cache_dst = self.out.join("cache"); -+ let cache_dst = match env::var_os("OPENWRT_RUSTC_BOOTSTRAP_CACHE") { -+ Some(v) => PathBuf::from(v), -+ None => self.out.join("cache"), -+ }; - let rustc_cache = cache_dst.join(cache_prefix); - if !rustc_cache.exists() { - t!(fs::create_dir_all(&rustc_cache)); diff --git a/rust/patches/0003-bump-libc-deps-to-0.2.146.patch b/rust/patches/0003-bump-libc-deps-to-0.2.146.patch deleted file mode 100644 index bb131d23f3..0000000000 --- a/rust/patches/0003-bump-libc-deps-to-0.2.146.patch +++ /dev/null @@ -1,100 +0,0 @@ -This patch bumps all libc dependencies and checksums to 0.2.147, which includes the fix for musl 1.2.4. - ---- a/vendor/addr2line-0.19.0/Cargo.lock -+++ b/vendor/addr2line-0.19.0/Cargo.lock -@@ -235,9 +235,9 @@ checksum = "e2abad23fbc42b3700f2f279844d - - [[package]] - name = "libc" --version = "0.2.126" -+version = "0.2.147" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" -+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - - [[package]] - name = "memchr" ---- a/vendor/backtrace-0.3.67/Cargo.lock -+++ b/vendor/backtrace-0.3.67/Cargo.lock -@@ -64,9 +64,9 @@ checksum = "dec7af912d60cdbd3677c1af9352 - - [[package]] - name = "libc" --version = "0.2.138" -+version = "0.2.147" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" -+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - - [[package]] - name = "libloading" ---- a/vendor/crossbeam-channel/Cargo.lock -+++ b/vendor/crossbeam-channel/Cargo.lock -@@ -50,9 +50,9 @@ dependencies = [ - - [[package]] - name = "libc" --version = "0.2.141" -+version = "0.2.147" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" -+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - - [[package]] - name = "num_cpus" ---- a/vendor/elasticlunr-rs/Cargo.lock -+++ b/vendor/elasticlunr-rs/Cargo.lock -@@ -555,9 +555,9 @@ checksum = "e2abad23fbc42b3700f2f279844d - - [[package]] - name = "libc" --version = "0.2.140" -+version = "0.2.147" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" -+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - - [[package]] - name = "lindera" ---- a/vendor/handlebars/Cargo.lock -+++ b/vendor/handlebars/Cargo.lock -@@ -550,9 +550,9 @@ checksum = "e2abad23fbc42b3700f2f279844d - - [[package]] - name = "libc" --version = "0.2.140" -+version = "0.2.147" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" -+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - - [[package]] - name = "lock_api" ---- a/vendor/libffi/Cargo.lock -+++ b/vendor/libffi/Cargo.lock -@@ -10,9 +10,9 @@ checksum = "50d30906286121d95be3d479533b - - [[package]] - name = "libc" --version = "0.2.140" -+version = "0.2.147" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" -+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - - [[package]] - name = "libffi" ---- a/vendor/tracing-tree/Cargo.lock -+++ b/vendor/tracing-tree/Cargo.lock -@@ -296,9 +296,9 @@ checksum = "e2abad23fbc42b3700f2f279844d - - [[package]] - name = "libc" --version = "0.2.141" -+version = "0.2.147" - source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" -+checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - - [[package]] - name = "linux-raw-sys" diff --git a/rust/rust-host-build.mk b/rust/rust-host-build.mk index e562929376..39cf1f23c5 100644 --- a/rust/rust-host-build.mk +++ b/rust/rust-host-build.mk @@ -2,42 +2,36 @@ # # Copyright (C) 2023 Luca Barbato and Donald Hoskins -# Variables (all optional) to be set in package Makefiles: -# -# RUST_HOST_FEATURES - list of options, default empty -# -# Space or comma separated list of features to activate -# -# e.g. RUST_HOST_FEATURES:=enable-foo,with-bar - ifeq ($(origin RUST_INCLUDE_DIR),undefined) RUST_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST))) endif include $(RUST_INCLUDE_DIR)/rust-values.mk -CARGO_HOST_VARS= \ - $(CARGO_HOST_CONFIG_VARS) \ - CC=$(HOSTCC_NOCACHE) \ - MAKEFLAGS="$(HOST_JOBS)" - # $(1) path to the package (optional) # $(2) additional arguments to cargo (optional) define Host/Compile/Cargo - +$(CARGO_HOST_VARS) \ - cargo install -v \ - --profile $(CARGO_HOST_PROFILE) \ - $(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \ - --root $(HOST_INSTALL_DIR) \ - --path "$(HOST_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)))" \ - $(if $(filter --jobserver%,$(HOST_JOBS)),,-j1) \ - $(2) + ( \ + cd $(HOST_BUILD_DIR) ; \ + export PATH="$(CARGO_HOME)/bin:$(PATH)" ; \ + CARGO_HOME=$(CARGO_HOME) \ + CC=$(HOSTCC_NOCACHE) \ + cargo install -v \ + --profile stripped \ + $(if $(RUST_PKG_FEATURES),--features "$(RUST_PKG_FEATURES)") \ + --root $(HOST_INSTALL_DIR) \ + --path "$(if $(strip $(1)),$(strip $(1)),.)" $(2) ; \ + ) endef define Host/Uninstall/Cargo - +$(CARGO_HOST_VARS) \ - cargo uninstall -v \ - --root $(HOST_INSTALL_DIR) \ - || true + ( \ + cd $(HOST_BUILD_DIR) ; \ + export PATH="$(CARGO_HOME)/bin:$(PATH)" ; \ + CARGO_HOME=$(CARGO_HOME) \ + CC=$(HOSTCC_NOCACHE) \ + cargo uninstall -v \ + --root $(HOST_INSTALL_DIR) || true ; \ + ) endef define RustBinHostBuild diff --git a/rust/rust-package.mk b/rust/rust-package.mk index 24341d7063..955b37c29e 100644 --- a/rust/rust-package.mk +++ b/rust/rust-package.mk @@ -15,22 +15,28 @@ ifeq ($(origin RUST_INCLUDE_DIR),undefined) endif include $(RUST_INCLUDE_DIR)/rust-values.mk -CARGO_PKG_VARS= \ - $(CARGO_PKG_CONFIG_VARS) \ - CC=$(HOSTCC_NOCACHE) \ - MAKEFLAGS="$(PKG_JOBS)" +# Support only a subset for now. +RUST_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mipsel||mips64||mips64el||mipsel||powerpc64||riscv64||x86_64) # $(1) path to the package (optional) # $(2) additional arguments to cargo (optional) define Build/Compile/Cargo - +$(CARGO_PKG_VARS) \ - cargo install -v \ - --profile $(CARGO_PKG_PROFILE) \ - $(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \ - --root $(PKG_INSTALL_DIR) \ - --path "$(PKG_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)))" \ - $(if $(filter --jobserver%,$(PKG_JOBS)),,-j1) \ - $(2) + ( \ + cd $(PKG_BUILD_DIR) ; \ + export PATH="$(CARGO_HOME)/bin:$(PATH)" ; \ + CARGO_HOME=$(CARGO_HOME) \ + TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUST_CFLAGS)" \ + TARGET_CC=$(TARGET_CC_NOCACHE) \ + CC=$(HOSTCC_NOCACHE) \ + $(CARGO_VARS) \ + cargo install -v \ + --profile stripped \ + --target $(RUSTC_TARGET_ARCH) \ + $(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \ + --root $(PKG_INSTALL_DIR) \ + --path "$(if $(strip $(1)),$(strip $(1)),.)" \ + $(2) ; \ + ) endef define RustBinPackage diff --git a/rust/rust-values.mk b/rust/rust-values.mk index 534aaa02a0..aaa520d573 100644 --- a/rust/rust-values.mk +++ b/rust/rust-values.mk @@ -2,32 +2,25 @@ # # Copyright (C) 2023 Luca Barbato and Donald Hoskins -# Clear environment variables which should be handled internally, -# as users might configure their own env on the host - -# CCache -unexport RUSTC_WRAPPER - # Rust Environmental Vars -RUSTC_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME))) -RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(RUSTC_HOST_SUFFIX) -CARGO_HOME:=$(DL_DIR)/cargo +CONFIG_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME))) +RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(CONFIG_HOST_SUFFIX) +CARGO_HOME:=$(STAGING_DIR)/host/cargo +CARGO_VARS:= 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 +# Force linking of the SSP library for musl +ifdef CONFIG_PKG_CC_STACKPROTECTOR_REGULAR + ifeq ($(strip $(PKG_SSP)),1) + RUSTC_LDFLAGS += -lssp_nonshared endif - ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG - ifeq ($(strip $(PKG_SSP)),1) - RUSTC_LDFLAGS+=-lssp_nonshared - endif +endif +ifdef CONFIG_PKG_CC_STACKPROTECTOR_STRONG + ifeq ($(strip $(PKG_SSP)),1) + TARGET_CFLAGS += -lssp_nonshared endif endif - -CARGO_RUSTFLAGS+=-Ctarget-feature=-crt-static $(RUSTC_LDFLAGS) +endif ifeq ($(HOST_OS),Darwin) ifeq ($(HOST_ARCH),arm64) @@ -58,47 +51,9 @@ ifeq ($(ARCH),arm) ifeq ($(CONFIG_HAS_FPU),y) RUSTC_TARGET_ARCH:=$(subst musleabi,musleabihf,$(RUSTC_TARGET_ARCH)) - RUSTC_TARGET_ARCH:=$(subst gnueabi,gnueabihf,$(RUSTC_TARGET_ARCH)) endif endif -ifeq ($(ARCH),aarch64) - RUSTC_CFLAGS:=-mno-outline-atomics -endif - -# Support only a subset for now. -RUST_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mipsel||mips64||mips64el||mipsel||powerpc64||riscv64||x86_64) - -ifneq ($(CONFIG_RUST_SCCACHE),) - RUST_SCCACHE_DIR:=$(if $(call qstrip,$(CONFIG_RUST_SCCACHE_DIR)),$(call qstrip,$(CONFIG_RUST_SCCACHE_DIR)),$(TOPDIR)/.sccache) - - RUST_SCCACHE_VARS:= \ - CARGO_INCREMENTAL=0 \ - RUSTC_WRAPPER=sccache \ - SCCACHE_DIR=$(RUST_SCCACHE_DIR) -endif - -CARGO_HOST_CONFIG_VARS= \ - $(RUST_SCCACHE_VARS) \ - CARGO_HOME=$(CARGO_HOME) - -CARGO_HOST_PROFILE:=release - -CARGO_PKG_CONFIG_VARS= \ - $(RUST_SCCACHE_VARS) \ - CARGO_BUILD_TARGET=$(RUSTC_TARGET_ARCH) \ - CARGO_HOME=$(CARGO_HOME) \ - CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 \ - CARGO_PROFILE_RELEASE_DEBUG=false \ - CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS=false \ - CARGO_PROFILE_RELEASE_LTO=true \ - CARGO_PROFILE_RELEASE_OPT_LEVEL=z \ - CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS=true \ - CARGO_PROFILE_RELEASE_PANIC=unwind \ - CARGO_PROFILE_RELEASE_RPATH=false \ - CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_LINKER=$(TARGET_CC_NOCACHE) \ - RUSTFLAGS="$(CARGO_RUSTFLAGS)" \ - TARGET_CC=$(TARGET_CC_NOCACHE) \ - TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)" - -CARGO_PKG_PROFILE:=$(if $(CONFIG_DEBUG),dev,release) +#ifeq ($(ARCH),aarch64) +# RUST_CFLAGS:=-mno-outline-atomics +#endif