Skip to content

Empty target_features confuses Miri #1438

Closed
@y21

Description

@y21

Running RUSTFLAGS="-Zcodegen-backend=cranelift" cargo miri test on the following test trips up Miri.

#[test]
fn f() {
    std::hint::spin_loop();
}
$ RUSTFLAGS="-Zcodegen-backend=cranelift" cargo miri test
test f ... error: Undefined Behavior: attempted to call intrinsic `llvm.x86.sse2.pause` that requires missing target feature sse2
  --> /home/timo/.rustup/toolchains/nightly-2023-12-16-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/x86/sse2.rs:25:5
   |
25 |     pause()
   |     ^^^^^^^ attempted to call intrinsic `llvm.x86.sse2.pause` that requires missing target feature sse2

I'm guessing the problem is this FIXME here?

fn target_features(&self, _sess: &Session, _allow_unstable: bool) -> Vec<rustc_span::Symbol> {
vec![] // FIXME necessary for #[cfg(target_feature]
}

spin_loop has a #[cfg(target_arch = "x86_64")] (which evaluates to true) in which it executes an sse2 instruction

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-core-archArea: Necessary for full core::arch support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions