1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-13 10:59:13 +02:00
openwrt-packages/lang/rust/patches/0002-rustc-bootstrap-cache.patch
Tianling Shen 11279e54ed rust: Update to 1.74.0
- Bumped libc to 0.2.147 to align deps.
- Refreshed patches.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
2023-11-22 22:38:23 +08:00

53 lines
2.1 KiB
Diff

--- 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/download.rs
+++ b/src/bootstrap/download.rs
@@ -211,7 +211,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) {
@@ -529,7 +535,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));
@@ -656,7 +665,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));