Skip to content

cargo-miri generates empty .d file, gets confused about multiple crates of the same name when using shared target dir #2540

Open
@Nemo157

Description

@Nemo157

When testing little ideas I very commonly work with a crate foo in different temp directories. If I haven't recently cleaned my shared target-dir then cargo-miri gets confused about whether it needs to rebuild artifacts and uses the wrong binary to test with.

As an example these two commands create two separate crates that should print different things, but cargo miri run in the second crate doesn't do a rebuild and instead runs the binary from the first crate:

> cd $(mktemp -d) && cargo new foo && cd foo && pwd && echo 'fn main() { println!("foo 1"); }' > src/main.rs && cargo miri run
     Created binary (application) `foo` package
/tmp/tmp.mI8gDBgdqJ/foo
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
   Compiling foo v0.1.0 (/tmp/tmp.mI8gDBgdqJ/foo)
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `/home/nemo157/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner /home/nemo157/.cargo/shared-target/miri/x86_64-unknown-linux-gnu/debug/foo`
foo 1

> cd $(mktemp -d) && cargo new foo && cd foo && pwd && echo 'fn main() { println!("foo 2"); }' > src/main.rs && cargo miri run
     Created binary (application) `foo` package
/tmp/tmp.IHFWjzhAmy/foo
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `/home/nemo157/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner /home/nemo157/.cargo/shared-target/miri/x86_64-unknown-linux-gnu/debug/foo`
foo 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargoArea: affects the cargo wrapper (cargo miri)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions