Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-builder: manually set CARGO_TARGET_DIR #1951

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions substrate/utils/wasm-builder/src/prerequisites.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ fn check_wasm_toolchain_installed(
run_cmd.current_dir(&temp);
run_cmd.args(&["run", "--manifest-path", &manifest_path]);

// Unset the `CARGO_TARGET_DIR` to prevent a cargo deadlock
build_cmd.env_remove("CARGO_TARGET_DIR");
run_cmd.env_remove("CARGO_TARGET_DIR");
// manually set the `CARGO_TARGET_DIR` to prevent a cargo deadlock
let target_dir = temp.path().join("target").display().to_string();
build_cmd.env("CARGO_TARGET_DIR", &target_dir);
run_cmd.env("CARGO_TARGET_DIR", &target_dir);

// Make sure the host's flags aren't used here, e.g. if an alternative linker is specified
// in the RUSTFLAGS then the check we do here will break unless we clear these.
Expand Down
4 changes: 2 additions & 2 deletions substrate/utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,10 @@ fn build_project(
.args(&["rustc", "--target=wasm32-unknown-unknown"])
.arg(format!("--manifest-path={}", manifest_path.display()))
.env("RUSTFLAGS", rustflags)
// Unset the `CARGO_TARGET_DIR` to prevent a cargo deadlock (cargo locks a target dir
// Manually set the `CARGO_TARGET_DIR` to prevent a cargo deadlock (cargo locks a target dir
// exclusive). The runner project is created in `CARGO_TARGET_DIR` and executing it will
// create a sub target directory inside of `CARGO_TARGET_DIR`.
.env_remove("CARGO_TARGET_DIR")
.env("CARGO_TARGET_DIR", &project.join("target").display().to_string())
// As we are being called inside a build-script, this env variable is set. However, we set
// our own `RUSTFLAGS` and thus, we need to remove this. Otherwise cargo favors this
// env variable.
Expand Down
Loading