Skip to content

Commit 49cd383

Browse files
author
hyd-dev
committed
Create stub .d files
1 parent 74b7714 commit 49cd383

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

cargo-miri/bin.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,14 @@ fn phase_cargo_rustc(mut args: env::Args) {
609609
let print = get_arg_flag_value("--print").is_some(); // whether this is cargo passing `--print` to get some infos
610610

611611
let store_json = |info: CrateRunInfo| {
612+
// Create a stub .d file to stop Cargo from "rebuilding" the crate:
613+
// https://github.com/rust-lang/miri/issues/1724#issuecomment-787115693
614+
// As we store a JSON file instead of building the crate here, an empty file is fine.
615+
let dep_info_name = out_filename("", ".d");
616+
if verbose {
617+
eprintln!("[cargo-miri rustc] writing dep-info to `{}`", dep_info_name.display());
618+
}
619+
File::create(dep_info_name).expect("failed to create fake .d file");
612620
let filename = out_filename("", "");
613621
if verbose {
614622
eprintln!("[cargo-miri rustc] writing run info to `{}`", filename.display());

test-cargo-miri/run-test.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
5050
print("--- END stderr ---")
5151
fail("exit code was {}".format(p.returncode))
5252

53-
def test_no_rebuild(name, cmd):
53+
def test_no_rebuild(name, cmd, env={}):
5454
print("Testing {}...".format(name))
55+
p_env = os.environ.copy()
56+
p_env.update(env)
5557
p = subprocess.Popen(
5658
cmd,
5759
stdout=subprocess.PIPE,
5860
stderr=subprocess.PIPE,
61+
env=p_env,
5962
)
6063
(stdout, stderr) = p.communicate()
6164
stdout = stdout.decode("UTF-8")
@@ -70,14 +73,20 @@ def test_no_rebuild(name, cmd):
7073
fail("Something was being rebuilt when it should not be (or we got no output)");
7174

7275
def test_cargo_miri_run():
76+
default_env={
77+
'MIRIFLAGS': "-Zmiri-disable-isolation",
78+
'MIRITESTVAR': "wrongval", # make sure the build.rs value takes precedence
79+
}
7380
test("`cargo miri run` (no isolation)",
7481
cargo_miri("run"),
7582
"run.default.stdout.ref", "run.default.stderr.ref",
7683
stdin=b'12\n21\n',
77-
env={
78-
'MIRIFLAGS': "-Zmiri-disable-isolation",
79-
'MIRITESTVAR': "wrongval", # make sure the build.rs value takes precedence
80-
},
84+
env=default_env,
85+
)
86+
# Special test: run it again *without* `-q` to make sure nothing is being rebuilt (Miri issue #1722)
87+
test_no_rebuild("`cargo miri run` (no rebuild, no isolation)",
88+
cargo_miri("run", quiet=False) + ["--", ""],
89+
env=default_env,
8190
)
8291
test("`cargo miri run` (with arguments and target)",
8392
cargo_miri("run") + ["--bin", "cargo-miri-test", "--", "hello world", '"hello world"'],
@@ -88,12 +97,6 @@ def test_cargo_miri_run():
8897
"run.subcrate.stdout.ref", "run.subcrate.stderr.ref",
8998
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
9099
)
91-
# Special test: run it again *without* `-q` to make sure nothing is being rebuilt (Miri issue #1722)
92-
# FIXME: move this test up to right after the first `test`
93-
# (currently that fails, only the 3rd and later runs are really clean... see Miri issue #1722)
94-
test_no_rebuild("`cargo miri run` (no rebuild)",
95-
cargo_miri("run", quiet=False) + ["--", ""],
96-
)
97100

98101
def test_cargo_miri_test():
99102
# rustdoc is not run on foreign targets

0 commit comments

Comments
 (0)