Skip to content

miri ignores -Ctarget-cpu since nightly-2025-11-10 #149314

@usamoi

Description

@usamoi

I tried this code:

fn main() {
    dbg!(cfg!(target_feature = "avx2"));
}
RUSTFLAGS="-Ctarget-cpu=x86-64-v3" cargo miri run

I expected to see this happen:

[src/main.rs:2:5] cfg!(target_feature = "avx2") = true

Instead, this happened:

[src/main.rs:2:5] cfg!(target_feature = "avx2") = false

If -Ctarget-feature is used:

RUSTFLAGS="-Ctarget-feature=+avx2" cargo miri run
[src/main.rs:2:5] cfg!(target_feature = "avx2") = true

If -Zcodegen-backend=llvm is used:

RUSTFLAGS="-Ctarget-cpu=x86-64-v3 -Zcodegen-backend=llvm" cargo miri run
[src/main.rs:2:5] cfg!(target_feature = "avx2") = true

Meta

rustc 1.93.0-nightly (6647be936 2025-11-09)
binary: rustc
commit-hash: 6647be93640686a2a443a49f15c3390b68c8b5dd
commit-date: 2025-11-09
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.3

nightly-2025-11-09 works but nightly-2025-11-10 doesn't. So probably it's caused by #148734.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-miriArea: The miri toolA-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.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