Skip to content

Commit 193c89c

Browse files
committed
miri-script: also overwrite CARGO_BUILD_BUILD_DIR
1 parent 4632c61 commit 193c89c

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

miri-script/src/util.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ impl MiriEnv {
6262
}
6363

6464
// Hard-code the target dir, since we rely on all binaries ending up in the same spot.
65-
sh.set_var("CARGO_TARGET_DIR", path!(miri_dir / "target"));
65+
// Cargo provides multiple ways to adjust this and we need to overwrite all of them.
66+
let target_dir = path!(miri_dir / "target");
67+
sh.set_var("CARGO_TARGET_DIR", &target_dir);
68+
sh.set_var("CARGO_BUILD_BUILD_DIR", &target_dir);
6669

6770
// We configure dev builds to not be unusably slow.
6871
let devel_opt_level =

test-cargo-miri/run-test.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,18 @@ def test_cargo_miri_test():
183183
cargo_miri("test") + ["--target-dir=custom-test"],
184184
default_ref, "test.empty.ref",
185185
)
186-
del os.environ["CARGO_TARGET_DIR"] # this overrides `build.target-dir` passed by `--config`, so unset it
187-
test("`cargo miri test` (config-cli)",
188-
cargo_miri("test") + ["--config=build.target-dir=\"config-cli\""],
189-
default_ref, "test.empty.ref",
190-
)
191186
if ARGS.multi_target:
192-
test_cargo_miri_multi_target()
193-
194-
195-
def test_cargo_miri_multi_target():
196-
test("`cargo miri test` (multiple targets)",
187+
test("`cargo miri test` (multiple targets)",
197188
cargo_miri("test", targets = ["aarch64-unknown-linux-gnu", "s390x-unknown-linux-gnu"]),
198189
"test.multiple_targets.stdout.ref", "test.empty.ref",
199190
)
191+
# This must be the last test since we are chaning `os.environ`.
192+
del os.environ["CARGO_TARGET_DIR"] # this overrides `build.target-dir` passed by `--config`, so unset it
193+
del os.environ["CARGO_BUILD_BUILD_DIR"]
194+
test("`cargo miri test` (config-cli)",
195+
cargo_miri("test") + ["--config=build.target-dir=\"config-cli\"", "--config=build.build-dir=\"config-cli\""],
196+
default_ref, "test.empty.ref",
197+
)
200198

201199
args_parser = argparse.ArgumentParser(description='`cargo miri` testing')
202200
args_parser.add_argument('--target', help='the target to test')

0 commit comments

Comments
 (0)