-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Do not get proc_macro from the sysroot in rustc #141595
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
Conversation
rustbot has assigned @compiler-errors. Use |
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
@@ -776,7 +776,8 @@ impl Step for RustcDev { | |||
copy_src_dirs( | |||
builder, | |||
&builder.src, | |||
&["compiler"], | |||
// The compiler has a path dependency on proc_macro, so make sure to include it. | |||
&["compiler", "library/proc_macro"], |
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've tested that cargo metadata
and cargo check
still work in the built rustc-dev tarball. It may be possible to do the same trick for rustc-literal-escaper
to pull it back into this repo.
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.
The rustup component was not the only problem; the other problem are out-of-tree consumers -- RA has to be able to import some of the rustc crates, and IIRC the literal-escaper occurred in the dependency tree.
It'd be good to involve them here as well in case rustc_builtin_macros is in their dependency tree -- Cc @Veykril
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.
It is not so that should be fine
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 am also iffy about the fact that the compiler tree relies on this somewhat magical hack, but it looks fairly simple/maintainable and works perfectly fine. It seems like no one in the project is bothered by it (yet), so I would say let's move forward and revisit it if someone raises an issue.
@@ -8,6 +8,9 @@ doctest = false | |||
|
|||
[dependencies] | |||
# tidy-alphabetical-start | |||
# We must use the proc_macro version that we will compile proc-macros against, | |||
# not the one from our own sysroot. | |||
proc_macro = { path = "../../library/proc_macro", default-features = false } |
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.
Will this work in the sources as they are distributed by rustup? IIRC last time we tried to share a file between library and compiler, a bunch of stuff broke.
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.
Issue from last time this happened: #138647.
That was the exact same thing, a path dependency from compiler
to library
-- so it'll almost certainly fail in the exact same way this time again.
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.
EDIT: I didn't look closely, the rustc-dev
dist component was addressed by #141595 (comment)
This comment has been minimized.
This comment has been minimized.
r? @onur-ozkan |
@rustbot author |
This comment has been minimized.
This comment has been minimized.
883ce51
to
df1477d
Compare
I had to switch from using a path dependency for proc_macro to creating a separate package which includes the same source as the proc_macro package. @rustbot ready |
This comment has been minimized.
This comment has been minimized.
df1477d
to
72951e3
Compare
This comment has been minimized.
This comment has been minimized.
72951e3
to
6c78091
Compare
edition = "2024" | ||
|
||
[lib] | ||
path = "../../library/proc_macro/src/lib.rs" |
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.
This will break for the same reason, no? That path just doesn't exist when rustc-dev is distributed via rustup.
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 explicitly added it to the rustc-dev component. See #141595 (comment).
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.
Hm... if you do that then you can go back to making it a regular path dependency, you don't need this separate crate, do you?
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.
That didn't work. Building two crates both named proc_macro (once as part of stdlib and once as part of rustc) causes ambiguity for extern crate proc_macro;
when the rustc libraries are part of the sysroot. Because of this I'm forced to build the rustc copy with a different crate name, which requires a separate Cargo.toml.
This comment has been minimized.
This comment has been minimized.
With the stage0 refactor the proc_macro version found in the sysroot will no longer always match the proc_macro version that proc-macros get compiled with by the rustc executable that uses this proc_macro. This will cause problems as soon as the ABI of the bridge gets changed to implement new features or change the way existing features work. To fix this, this commit changes rustc crates to depend directly on the local version of proc_macro which will also be used in the sysroot that rustc will build.
6c78091
to
026baa1
Compare
@bors r+ rollup=never (to make it easier to revert if any issues come up) |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 8afd710 (parent) -> 13718eb (this PR) Test differencesNo test diffs found Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 13718eb788622ef8c998650451174570230d2971 --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (13718eb): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary 0.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 0.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 777.423s -> 780.508s (0.40%) |
…r=onur-ozkan Do not get proc_macro from the sysroot in rustc With the stage0 refactor the proc_macro version found in the sysroot will no longer always match the proc_macro version that proc-macros get compiled with by the rustc executable that uses this proc_macro. This will cause problems as soon as the ABI of the bridge gets changed to implement new features or change the way existing features work. To fix this, this commit changes rustc crates to depend directly on the local version of proc_macro which will also be used in the sysroot that rustc will build.
With the stage0 refactor the proc_macro version found in the sysroot will no longer always match the proc_macro version that proc-macros get compiled with by the rustc executable that uses this proc_macro. This will cause problems as soon as the ABI of the bridge gets changed to implement new features or change the way existing features work.
To fix this, this commit changes rustc crates to depend directly on the local version of proc_macro which will also be used in the sysroot that rustc will build.