From ad3a034a689a2374ee3a57dbb1e759a62def4062 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Tue, 15 Oct 2024 20:46:46 -0700 Subject: [PATCH] refactor: improve cargo build reproducibility (#1647) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Garillot --- crates/build/src/command/docker.rs | 3 +++ crates/build/src/command/local.rs | 2 ++ crates/build/src/command/utils.rs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/crates/build/src/command/docker.rs b/crates/build/src/command/docker.rs index bd5ce5d23d..f208b41bd4 100644 --- a/crates/build/src/command/docker.rs +++ b/crates/build/src/command/docker.rs @@ -81,6 +81,9 @@ pub(crate) fn create_docker_command( format!("CARGO_TARGET_DIR={}", target_dir), "-e".to_string(), "RUSTUP_TOOLCHAIN=succinct".to_string(), + // TODO: remove once trim-paths is supported - https://github.com/rust-lang/rust/issues/111540 + "-e".to_string(), + "RUSTC_BOOTSTRAP=1".to_string(), // allows trim-paths. "-e".to_string(), format!("CARGO_ENCODED_RUSTFLAGS={}", get_rust_compiler_flags()), "--entrypoint".to_string(), diff --git a/crates/build/src/command/local.rs b/crates/build/src/command/local.rs index 313aaf368a..7d22194436 100644 --- a/crates/build/src/command/local.rs +++ b/crates/build/src/command/local.rs @@ -42,6 +42,8 @@ pub(crate) fn create_local_command( .env("CARGO_ENCODED_RUSTFLAGS", get_rust_compiler_flags()) .env_remove("RUSTC") .env("CARGO_TARGET_DIR", program_metadata.target_directory.join(HELPER_TARGET_SUBDIR)) + // TODO: remove once trim-paths is supported - https://github.com/rust-lang/rust/issues/111540 + .env("RUSTC_BOOTSTRAP", "1") // allows trim-paths. .args(get_program_build_args(args)); command } diff --git a/crates/build/src/command/utils.rs b/crates/build/src/command/utils.rs index 014cb0e47f..7ddcd00336 100644 --- a/crates/build/src/command/utils.rs +++ b/crates/build/src/command/utils.rs @@ -20,6 +20,8 @@ pub(crate) fn get_program_build_args(args: &BuildArgs) -> Vec { build_args.push("--ignore-rust-version".to_string()); } + build_args.push("-Ztrim-paths".to_string()); + if !args.binary.is_empty() { build_args.push("--bin".to_string()); build_args.push(args.binary.clone());