Open
Description
In code like this as noted here
#![feature(global_asm)]
#![feature(asm)]
global_asm!(r"
.macro foo, arg, size
add \arg, \arg, \size
.endm");
const BAR: u64 = 10;
pub fn bar(mut v: u64) -> u64 {
unsafe {
asm!("foo {v}, {}", const(BAR), v = inout(reg) v);
}
v
}
the macro will leak into the inline asm!
, but this is likely extremely brittle. For instance, Rust is free to split this module into 2 distinct CGUs, making the code like this mysteriously work or break.
This could probably be mitigated by isolating all the global_asm!
into its own CGU – that way none of the inline asm invocations would be able to observe the global_asm!
stuff. Alternatively, if we find we want to support this behaviour we would be forced to collect all uses of global_asm!
and items containing inline asm in a crate into a single CGU. Supporting this would also have implications to alternative backend support.
cc #35119