diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-08-10 19:45:53 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-10 19:45:53 +1000 |
| commit | 53eab6bc75fa2ed38210d5e73c7686d3781293ab (patch) | |
| tree | bb70d34a38978439f7dd2f5adb1647e9b52c8de5 | |
| parent | b30fe4bb8b009c0e9aa0b9d2713bd30a53531720 (diff) | |
| parent | a5ddf5da582d2f1810af7045772bd5934884fdc1 (diff) | |
| download | rust-53eab6bc75fa2ed38210d5e73c7686d3781293ab.tar.gz rust-53eab6bc75fa2ed38210d5e73c7686d3781293ab.zip | |
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 https://github.com/rust-lang/rust/issues/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: https://github.com/rust-lang/rust/issues/145107
| -rw-r--r-- | src/bootstrap/src/core/builder/cargo.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index e10af2b55f9..39f46bf43af 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -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. |
