-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit unnamed_addr on statics #18297
Comments
cc the discussion on rust-lang/rfcs#362 |
I know next to nothing about llvm attributes, but pub static mut X: i32 = 5; gives
llvm says https://llvm.org/docs/LangRef.html
I'm not sure if the |
This is ; in debug
@_ZN10playground12RUSTY_STATIC17h7d2abb51a94403c7E =
global <{ [4 x i8] }> <{ [4 x i8] c"\05\00\00\00" }>, align 4, !dbg !0
; in --release
@_ZN10playground12RUSTY_STATIC17hd7ab9ec18434d12fE =
local_unnamed_addr constant <{ [4 x i8] }> <{ [4 x i8] c"\05\00\00\00" }>, align 4 So we do not appear to emit any such annotation on |
…=davidbarsky minor: `ra-salsa` in `profile.dev.package` Since `ra-salsa`'s package name is actually `salsa` it makes the following warning in `cargo` commands; ``` warning: profile package spec `ra-salsa` in profile `dev` did not match any packages ``` and the opt level isn't applied to it.
Always emit `unnamed_addr` for statics Fixes rust-lang#18297 Mostly to see if anything breaks/perf r? `@ghost`
Rust code should definitely be able to rely on the address of a static. That's one of their defining features. So, closing this issue. |
The reference there says that a static has a precise memory location, I cannot see where it says that the following must hold: static ZERO: u8 = 0;
static ZER0: u8 = 0;
assert_ne!(&raw const ZERO, &raw const ZER0); |
I would say if a static has a wibbly wobbly address not equal to itself, that's not a "precise memory location". We don't even have addresses that are not equal to themselves.
|
Note, those two statics are not the same, one of them is static A: u8 = 0;
static B: u8 = 0;
assert_ne!(&raw const A, raw const B); |
Mutable globals still work with
unnamed_addr
, and Rust code shouldn't rely on the significance of addresses.The text was updated successfully, but these errors were encountered: