Skip to content

cargo miri setup failing on custom target  #2771

@bindsdev

Description

@bindsdev

I am attempting to use Miri in a bare metal project using my custom target. When I run cargo miri setup --target MY_TARGET, it prepares a sysroot for the target, but fails with:

error[E0464]: multiple candidates for `rmeta` dependency `core` found
 --> /home/binds/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core/lib.rs:4:9
  |
4 | pub use core::*;
  |         ^^^^
  |
  = note: candidate #1: /tmp/.tmpSCntaC/target/x86_64-prestige/release/deps/libcore-5484c1dfc1494680.rmeta
  = note: candidate #2: /tmp/.tmpSCntaC/target/x86_64-prestige/release/deps/libcore-fe8fccd3bdf8e7b3.rmeta

For more information about this error, try `rustc --explain E0464`.
error: could not compile `rustc-std-workspace-core` due to previous error
fatal error: failed to build sysroot: sysroot build failed

I am at a loss for what could be causing this. Even if I cargo clean, the same error occurs. I will put anything I believe relevant to help solve this:

rustc -vV:

rustc 1.69.0-nightly (e972bc808 2023-01-29)
binary: rustc
commit-hash: e972bc8083d5228536dfd42913c8778b6bb04c8e
commit-date: 2023-01-29
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

My custom target:

{
    "llvm-target": "x86_64-unknown-none",
    "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
    "arch": "x86_64",
    "target-endian": "little",
    "target-pointer-width": "64",
    "target-c-int-width": "32",
    "os": "none",
    "executables": true,
    "linker-flavor": "ld.lld",
    "linker": "rust-lld",
    "panic-strategy": "abort",
    "disable-redzone": true,
    "features": "-mmx,-sse,+soft-float",
    "code-model": "kernel",
    "pre-link-args": {
        "ld.lld": [
            "--gc-sections",
            "-T.cargo/linker.ld"
        ]
    }
}

It seems like JSON targets began to be supported as of #2744, so I don't think its an issue with Miri's support for it.

.cargo/config.toml:

[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
build-std-features = ["compiler-builtins-mem"]

rust-toolchain.toml:

[toolchain]
channel = "nightly"
components = ["rust-src", "rustfmt", "clippy", "miri"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions