summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffery To2023-09-23 12:24:37 +0000
committerJeffery To2023-10-11 07:50:24 +0000
commit0dfc1b508d5e5b361978ef9783cb63775176c305 (patch)
tree87d123b9d63916b84de9d88e81502e38a6bf4a0b
parent9db7284d589dc8490f8c7dbe56af731fce953eda (diff)
downloadpackages-0dfc1b508d5e5b361978ef9783cb63775176c305.tar.gz
rust: Use make's jobserver when building packages
This allows cargo to use make's jobserver when building packages, by marking the cargo command as recursive (with the + prefix[1]) and setting MAKEFLAGS. This also: * Give cargo/x.py the build directory instead of having to change the current directory (and opening subshells) * Set PKG_BUILD_PARALLEL/HOST_BUILD_PARALLEL for Rust packages to enable the use of make's jobserver [1]: https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html Signed-off-by: Jeffery To <jeffery.to@gmail.com>
-rw-r--r--admin/bottom/Makefile1
-rw-r--r--lang/maturin/Makefile1
-rw-r--r--lang/rust/Makefile13
-rw-r--r--lang/rust/rust-host-build.mk30
-rw-r--r--lang/rust/rust-package.mk21
-rw-r--r--net/aardvark-dns/Makefile1
-rw-r--r--net/netavark/Makefile1
-rw-r--r--utils/arp-whisper/Makefile1
-rw-r--r--utils/procs/Makefile1
-rw-r--r--utils/ripgrep/Makefile1
10 files changed, 37 insertions, 34 deletions
diff --git a/admin/bottom/Makefile b/admin/bottom/Makefile
index bdd049a29a..556b11b23d 100644
--- a/admin/bottom/Makefile
+++ b/admin/bottom/Makefile
@@ -17,6 +17,7 @@ PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=rust/host
+PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include ../../lang/rust/rust-package.mk
diff --git a/lang/maturin/Makefile b/lang/maturin/Makefile
index e1c7ca50f2..220e31fbad 100644
--- a/lang/maturin/Makefile
+++ b/lang/maturin/Makefile
@@ -17,6 +17,7 @@ PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=license-apache license-mit
HOST_BUILD_DEPENDS:=rust/host
+HOST_BUILD_PARALLEL:=1
PKG_HOST_ONLY:=1
include $(INCLUDE_DIR)/host-build.mk
diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 8f99f4144b..d0a9ef48d5 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -80,13 +80,12 @@ define Host/Uninstall
endef
define Host/Compile
- ( \
- cd $(HOST_BUILD_DIR) ; \
- CARGO_HOME=$(CARGO_HOME) \
- OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \
- $(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
- rustc rust-std rust-src ; \
- )
+ CARGO_HOME=$(CARGO_HOME) \
+ 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
endef
define Host/Install
diff --git a/lang/rust/rust-host-build.mk b/lang/rust/rust-host-build.mk
index 38ce963e0f..e562929376 100644
--- a/lang/rust/rust-host-build.mk
+++ b/lang/rust/rust-host-build.mk
@@ -17,29 +17,27 @@ include $(RUST_INCLUDE_DIR)/rust-values.mk
CARGO_HOST_VARS= \
$(CARGO_HOST_CONFIG_VARS) \
- CC=$(HOSTCC_NOCACHE)
+ CC=$(HOSTCC_NOCACHE) \
+ MAKEFLAGS="$(HOST_JOBS)"
# $(1) path to the package (optional)
# $(2) additional arguments to cargo (optional)
define Host/Compile/Cargo
- ( \
- cd $(HOST_BUILD_DIR) ; \
- $(CARGO_HOST_VARS) \
- cargo install -v \
- --profile $(CARGO_HOST_PROFILE) \
- $(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \
- --root $(HOST_INSTALL_DIR) \
- --path "$(if $(strip $(1)),$(strip $(1)),.)" $(2) ; \
- )
+ +$(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)
endef
define Host/Uninstall/Cargo
- ( \
- cd $(HOST_BUILD_DIR) ; \
- $(CARGO_HOST_VARS) \
- cargo uninstall -v \
- --root $(HOST_INSTALL_DIR) || true ; \
- )
+ +$(CARGO_HOST_VARS) \
+ cargo uninstall -v \
+ --root $(HOST_INSTALL_DIR) \
+ || true
endef
define RustBinHostBuild
diff --git a/lang/rust/rust-package.mk b/lang/rust/rust-package.mk
index 6deb859fb6..24341d7063 100644
--- a/lang/rust/rust-package.mk
+++ b/lang/rust/rust-package.mk
@@ -17,21 +17,20 @@ include $(RUST_INCLUDE_DIR)/rust-values.mk
CARGO_PKG_VARS= \
$(CARGO_PKG_CONFIG_VARS) \
- CC=$(HOSTCC_NOCACHE)
+ CC=$(HOSTCC_NOCACHE) \
+ MAKEFLAGS="$(PKG_JOBS)"
# $(1) path to the package (optional)
# $(2) additional arguments to cargo (optional)
define Build/Compile/Cargo
- ( \
- cd $(PKG_BUILD_DIR) ; \
- $(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 "$(if $(strip $(1)),$(strip $(1)),.)" \
- $(2) ; \
- )
+ +$(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)
endef
define RustBinPackage
diff --git a/net/aardvark-dns/Makefile b/net/aardvark-dns/Makefile
index 6131a4a07a..b7ea0e5d98 100644
--- a/net/aardvark-dns/Makefile
+++ b/net/aardvark-dns/Makefile
@@ -13,6 +13,7 @@ PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=rust/host
+PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include ../../lang/rust/rust-package.mk
diff --git a/net/netavark/Makefile b/net/netavark/Makefile
index 9d5c5f4054..da04a5e9dc 100644
--- a/net/netavark/Makefile
+++ b/net/netavark/Makefile
@@ -15,6 +15,7 @@ PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:= \
rust/host \
protobuf/host
+PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include ../../lang/rust/rust-package.mk
diff --git a/utils/arp-whisper/Makefile b/utils/arp-whisper/Makefile
index 23461f9984..207ed5f1b5 100644
--- a/utils/arp-whisper/Makefile
+++ b/utils/arp-whisper/Makefile
@@ -17,6 +17,7 @@ PKG_LICENSE:=GPL-3.0-or-later
PKG_LICENSE_FILES:=LICENCE
PKG_BUILD_DEPENDS:=rust/host
+PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include ../../lang/rust/rust-package.mk
diff --git a/utils/procs/Makefile b/utils/procs/Makefile
index 9f1f11fb2a..41eeb9c18e 100644
--- a/utils/procs/Makefile
+++ b/utils/procs/Makefile
@@ -17,6 +17,7 @@ PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENCE
PKG_BUILD_DEPENDS:=rust/host
+PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include ../../lang/rust/rust-package.mk
diff --git a/utils/ripgrep/Makefile b/utils/ripgrep/Makefile
index 56658540f9..bad9f95e24 100644
--- a/utils/ripgrep/Makefile
+++ b/utils/ripgrep/Makefile
@@ -17,6 +17,7 @@ PKG_LICENSE:=MIT Unlicense
PKG_LICENSE_FILES:=LICENSE-MIT UNLICENSE
PKG_BUILD_DEPENDS:=rust/host
+PKG_BUILD_PARALLEL:=1
RUST_PKG_FEATURES:=pcre2