Skip to content

Override custom Cargo build-dir in bootstrap #145156

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

Merged
merged 1 commit into from
Aug 10, 2025
Merged
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
9 changes: 9 additions & 0 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,15 @@ impl Builder<'_> {
let out_dir = self.stage_out(compiler, mode);
cargo.env("CARGO_TARGET_DIR", &out_dir);

// Bootstrap makes a lot of assumptions about the artifacts produced in the target
// directory. If users override the "build directory" using `build-dir`
// (https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-dir), then
// bootstrap couldn't find these artifacts. So we forcefully override that option to our
// target directory here.
// In the future, we could attempt to read the build-dir location from Cargo and actually
// respect it.
cargo.env("CARGO_BUILD_BUILD_DIR", &out_dir);

// Found with `rg "init_env_logger\("`. If anyone uses `init_env_logger`
// from out of tree it shouldn't matter, since x.py is only used for
// building in-tree.
Expand Down
Loading