-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# We need to use a separate crate including library/proc_macro as opposed to a | ||
# direct path dependency on library/proc_macro because doing the latter will | ||
# cause two copies of libproc_macro.rlib to end up in the sysroot, breaking | ||
# proc-macro crates. In addition it confuses the workspace_members function of | ||
# bootstrap. | ||
|
||
[package] | ||
name = "rustc_proc_macro" | ||
version = "0.0.0" | ||
edition = "2024" | ||
|
||
[lib] | ||
path = "../../library/proc_macro/src/lib.rs" | ||
test = false | ||
doctest = false | ||
|
||
[dependencies] | ||
rustc-literal-escaper = "0.0.2" | ||
|
||
[features] | ||
rustc-dep-of-std = [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I've tested that There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||
&[], | ||
&tarball.image_dir().join("lib/rustlib/rustc-src/rust"), | ||
); | ||
|
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.