Skip to content

Commit 53eab6b

Browse files
authored
Rollup merge of #145156 - Kobzol:cargo-build-dir, r=lqd,jieyouxu
Override custom Cargo `build-dir` in bootstrap The context for this issue is in #145107. The issue is that if people configure `build-dir`, it would break bootstrap. For now, we just hard-code it to our self-contained target directories inside the build directory. Tested by putting the following: ```toml [build] build-dir = "/tmp/foo" [unstable] build-dir = true ``` into `<rustc-checkout>/.cargo/config.toml`. `x build` works with this PR, doesn't work without this PR. Fixes: #145107
2 parents b30fe4b + a5ddf5d commit 53eab6b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,15 @@ impl Builder<'_> {
433433
let out_dir = self.stage_out(compiler, mode);
434434
cargo.env("CARGO_TARGET_DIR", &out_dir);
435435

436+
// Bootstrap makes a lot of assumptions about the artifacts produced in the target
437+
// directory. If users override the "build directory" using `build-dir`
438+
// (https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-dir), then
439+
// bootstrap couldn't find these artifacts. So we forcefully override that option to our
440+
// target directory here.
441+
// In the future, we could attempt to read the build-dir location from Cargo and actually
442+
// respect it.
443+
cargo.env("CARGO_BUILD_BUILD_DIR", &out_dir);
444+
436445
// Found with `rg "init_env_logger\("`. If anyone uses `init_env_logger`
437446
// from out of tree it shouldn't matter, since x.py is only used for
438447
// building in-tree.

0 commit comments

Comments
 (0)