-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Static variables have different addresses in different crates #8179
Comments
Nominating for production-ready, this prevents conditions from being used cross-crate. I would love for this to be higher priority like backwards-compatible though. I think that the internal libraries would make much more heavy use of conditions if they worked cross-crate (and those changes would be backwards-compatible) |
It's possible to make the value available without creating a new symbol/address as far as I know. Maybe with |
Right now this isn't even an LLVM or linkage problem, this is simply that we re-run Although for linkage we might need those or other fancy llvm attributes. |
The |
Oh that's perfect! Do we also have to inform LLVM that it's an external symbol as well? |
@alexcrichton: I think
|
Awesome! I'll see if I can test this out... |
…Frednet Extend unused_io_amount to cover async io. Clippy helpfully warns about code like this, telling you that you probably meant "write_all": fn say_hi<W:Write>(w: &mut W) { w.write(b"hello").unwrap(); } This patch attempts to extend the lint so it also covers this case: async fn say_hi<W:AsyncWrite>(w: &mut W) { w.write(b"hello").await.unwrap(); } (I've run into this second case several times in my own programming, and so have my coworkers, so unless we're especially accident-prone in this area, it's probably worth addressing?) Since this is my first attempt at a clippy patch, I've probably made all kinds of mistakes: please help me fix them? I'd like to learn more here. Open questions I have: * Should this be a separate lint from unused_io_amount? Maybe unused_async_io_amount? If so, how should I structure their shared code? * Should this cover tokio's AsyncWrite too? * Is it okay to write lints for stuff that isn't part of the standard library? I see that "regex" also has lints, and I figure that "futures" is probably okay too, since it's an official rust-lang repository. * What other tests are needed? * How should I improve the code? Thanks for your time! --- changelog: [`unused_io_amount`] now supports async read and write traits
Currently it appears that whenever a static value is referenced from another crate, a local translation is made and then the address of that is taken instead. This means that every static referenced from another crate will be re-translated into the current crate, thereby giving it a different address than ones in other crates.
For optimizations, I can see where this is nice to know the value of the static, but this breaks any usage of cross-crate TLS apis. Namely, this prevents conditions from working cross-crate. I can think of two fixes for this:
extern
references are.#[]
attribute meaning that their address is significant or that they basically shouldn't be re-translated into other crates.I would prefer option 1 over option 2, but I'm not sure if performance for optimizations would suffer as a result. I think that the fix might go into
trans_addr_of
, but I'm not sure where the best place for this would be.cc @graydon (you were interested in cross-crate conditions not working)
The text was updated successfully, but these errors were encountered: