rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.47k stars 12.73k forks source link

`asm!` lints based on `cfg` rather than target #127938

Open tgross35 opened 3 months ago

tgross35 commented 3 months ago

For example:

#[cfg(target_arch = "x86")]
fn foo() {
    unsafe { asm!("0: jmp 0b") };
}

This currently raises binary_asm_labels only if targeting x86. Ideally we would be able to raise the lint regardless of what the current target is.

Requested in https://github.com/rust-lang/rust/issues/127821 and https://github.com/rust-lang/rust/pull/127935

tgross35 commented 3 months ago

@estebank I'm a bit light on the details here, and not sure I understand it fully. Do we do anything like this at the current time? It would be great if we could validate assembly for all targets (actual correctness, not just lints), but block-level cfg seems to make that difficult.

tgross35 commented 3 months ago

Oh, did you mean if cfg!(...) rather than attribute config? That seems potentially easier, but I have no clue what level of support these things have.

tgross35 commented 3 months ago

More info in https://github.com/rust-lang/rust/pull/127935#issuecomment-2237780263