From 25cdde5a269c058f245a8f80283668da83847232 Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Tue, 24 Sep 2024 02:28:45 +0800 Subject: [PATCH] fix: rust 1.81 toolchain build issue (#1534) --- crates/cli/src/commands/build_toolchain.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/cli/src/commands/build_toolchain.rs b/crates/cli/src/commands/build_toolchain.rs index 86a604d128..1a71f0b118 100644 --- a/crates/cli/src/commands/build_toolchain.rs +++ b/crates/cli/src/commands/build_toolchain.rs @@ -64,8 +64,16 @@ impl BuildToolchainCmd { std::fs::write(&config_file, config_toml) .with_context(|| format!("while writing configuration to {:?}", config_file))?; + // Work around target sanity check added in rust-lang/rust@09c076810cb7649e5817f316215010d49e78e8d7. + let temp_dir = std::env::temp_dir().join("rustc-targets"); + if !temp_dir.exists() { + std::fs::create_dir_all(&temp_dir)?; + } + std::fs::File::create(temp_dir.join("riscv32im-succinct-zkvm-elf.json"))?; + // Build the toolchain (stage 1). Command::new("python3") + .env("RUST_TARGET_PATH", &temp_dir) .env("CARGO_TARGET_RISCV32IM_SUCCINCT_ZKVM_ELF_RUSTFLAGS", "-Cpasses=loweratomic") .args(["x.py", "build"]) .current_dir(&rust_dir) @@ -73,6 +81,7 @@ impl BuildToolchainCmd { // Build the toolchain (stage 2). Command::new("python3") + .env("RUST_TARGET_PATH", &temp_dir) .env("CARGO_TARGET_RISCV32IM_SUCCINCT_ZKVM_ELF_RUSTFLAGS", "-Cpasses=loweratomic") .args(["x.py", "build", "--stage", "2"]) .current_dir(&rust_dir)