diff options
| author | Jeffery To <jeffery.to@gmail.com> | 2023-09-25 10:00:58 +0800 |
|---|---|---|
| committer | Jeffery To <jeffery.to@gmail.com> | 2023-10-11 15:50:24 +0800 |
| commit | b4ec01739865770e3d0432683406844f7fd8e707 (patch) | |
| tree | 90ae88c7946cb34952312ac3847968be13919dd0 /lang/rust | |
| parent | 0dfc1b508d5e5b361978ef9783cb63775176c305 (diff) | |
rust: Add option to use sccache
Using sccache makes recompilation of rustc and Rust packages faster.
This also makes the rust package visible in menuconfig, in order for the
sccache options to be accessible.
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'lang/rust')
| -rw-r--r-- | lang/rust/Config.in | 15 | ||||
| -rw-r--r-- | lang/rust/Makefile | 6 | ||||
| -rw-r--r-- | lang/rust/rust-values.mk | 11 |
3 files changed, 31 insertions, 1 deletions
diff --git a/lang/rust/Config.in b/lang/rust/Config.in new file mode 100644 index 000000000..62051af13 --- /dev/null +++ b/lang/rust/Config.in @@ -0,0 +1,15 @@ +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/lang/rust/Makefile b/lang/rust/Makefile index d0a9ef48d..7785e95f1 100644 --- a/lang/rust/Makefile +++ b/lang/rust/Makefile @@ -30,7 +30,6 @@ define Package/rust TITLE:=Rust Programming Language Compiler URL:=https://www.rust-lang.org/ DEPENDS:=$(RUST_ARCH_DEPENDS) - BUILDONLY:=1 endef define Package/rust/description @@ -39,6 +38,10 @@ 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 @@ -80,6 +83,7 @@ define Host/Uninstall endef define Host/Compile + $(RUST_SCCACHE_VARS) \ CARGO_HOME=$(CARGO_HOME) \ OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \ $(PYTHON) $(HOST_BUILD_DIR)/x.py \ diff --git a/lang/rust/rust-values.mk b/lang/rust/rust-values.mk index 8f2017af6..0a18cd17f 100644 --- a/lang/rust/rust-values.mk +++ b/lang/rust/rust-values.mk @@ -62,12 +62,23 @@ 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_OPT_LEVEL=s \ |
