Skip to content

Commit

Permalink
refactor: improve cargo build reproducibility (#1647)
Browse files Browse the repository at this point in the history
Co-authored-by: François Garillot <[email protected]>
  • Loading branch information
jtguibas and huitseeker authored Oct 16, 2024
1 parent 3d91a90 commit ad3a034
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/build/src/command/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 2 additions & 0 deletions crates/build/src/command/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions crates/build/src/command/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub(crate) fn get_program_build_args(args: &BuildArgs) -> Vec<String> {
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());
Expand Down

0 comments on commit ad3a034

Please sign in to comment.