-
Notifications
You must be signed in to change notification settings - Fork 1.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
Introduce proc-macro-srv/sysroot-abi #12835
Conversation
This now builds (with many stubs). It can be tested locally with: cd crates/proc-macro-srv
PROC_MACRO_SRV_SYSROOT_ABI=1 PROC_MACRO_TEST_TOOLCHAIN=stage1 cargo test --features sysroot-abi Setting
Useful
|
b34ad3f
to
d25b610
Compare
Otherwise, fall back to the multi ABI scheme, except in testing, where it becomes a hard error. This should make it possible to use a rustup-provided rust-analyzer with proc macro dylibs compiled by older rustcs, and it'll also catch changes to the format of `rustc --version` or the `.rustc` section that would make them impossible to compare for equality.
On @bjorn3's suggestion, I added a "full version string exact comparison" when the sysroot ABI is enabled. In testing, it fails noisily if there's a mismatch - this should only show up in-tree ( As a binary, if there's a mismatch, it should fall back to numbered ABI implementations gracefully, in case someone has a rustup-provided rust-analyzer binary set as their "RA binary" or "RA proc macro server binary" and expects backwards compatibility. |
This PR is now ready for review. It passes all existing When using the "numbered ABIs" (via
This will prevent The sysroot-abi is not built in RA's own CI — that would require a pinned nightly and it would be a sync nightmare. It'll only be be built in-tree: the This doesn't introduce any breaking changes for rust-analyzer users, even if they use the rustup-provided version: the exact version match assertion is only enabled in tests. In production, if there's a sysroot ABI version mismatch, it'll fall back to "numbered ABI" selection, so the situation will at least not be worse (until we teach RA to be smarter about which proc macro srv to use). The recent changes in proc_macro bridge made some of the "shortcuts" taken by RA more obvious (idents & literals aren't lexed, but they should be). These should be addressed later - the current state of (For the curious: the only way to notice RA's shortcuts from a proc macro right now is to use the When we merge this, we're good to go for opening another "Re-add rust-analyzer as a subtree" PR to |
rustc has a concept of "session globals" - their interner is a session global. We don't really have the same concept. I don't know how long-lived instances of Ideally we'd use one symbol interner per "expand" call, and that's it. I'm not sure how to make this happen (short of spawning a separate proc macro server for every call) right now. cc @bjorn3 @Veykril @jonas-schievink edit: This wasn't needed before because before, any function that could intern a symbol had a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't review the actual abi implementation, but the version selection logic LGTM modulo a small nit.
After chatting with @mystor: all the shortcuts in here are "fine until ra is a subtree" except the Literal formatting, which needs to do something like this: (Even though the ra server only ever builds |
@bors d+ |
When will I remember... |
✌️ @fasterthanlime can now approve this pull request |
Nit addressed, @bors r+ |
☀️ Test successful - checks-actions |
Thanks a lot for pushing on this, @fasterthanlime! |
Still a WIP.
This change is tracked by: