summaryrefslogtreecommitdiff
path: root/lang/rust
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2023-10-02 04:52:32 +0800
committerJeffery To <jeffery.to@gmail.com>2023-10-11 15:50:22 +0800
commit35768bf31e5867046874dc6fd0374ff8fe575da2 (patch)
tree03a20d7a3c40f7aaac72a62ee840fe64a4e40ba8 /lang/rust
parentd24095b8fc5b8d4e509d59f73d6901842b50c4bd (diff)
rust: Cache bootstrap downloads to $(DL_DIR)/rustc
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'lang/rust')
-rw-r--r--lang/rust/Makefile1
-rw-r--r--lang/rust/patches/0002-rustc-bootstrap-cache.patch37
2 files changed, 38 insertions, 0 deletions
diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 63c587beb..37fe20aeb 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -82,6 +82,7 @@ endef
define Host/Compile
( \
cd $(HOST_BUILD_DIR) ; \
+ OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \
$(PYTHON) x.py --config ./config.toml dist build-manifest cargo llvm-tools \
rustc rust-std rust-src ; \
)
diff --git a/lang/rust/patches/0002-rustc-bootstrap-cache.patch b/lang/rust/patches/0002-rustc-bootstrap-cache.patch
new file mode 100644
index 000000000..670ba1162
--- /dev/null
+++ b/lang/rust/patches/0002-rustc-bootstrap-cache.patch
@@ -0,0 +1,37 @@
+--- a/src/bootstrap/bootstrap.py
++++ b/src/bootstrap/bootstrap.py
+@@ -543,7 +543,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/download.rs
++++ b/src/bootstrap/download.rs
+@@ -507,7 +507,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));
+@@ -627,7 +630,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));