-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Pass --cfg=bootstrap for proc macros built by stage0 #83433
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
src/bootstrap/bin/rustc.rs
Outdated
@@ -126,6 +130,13 @@ fn main() { | |||
} | |||
} | |||
|
|||
if is_proc_macro && stage == "0" { | |||
// Cargo has a bug where it doesn't pass RUSTFLAGS to proc_macros: |
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.. wouldn't call this a bug :) More like 'unexpected behavior'. rust-lang/cargo#4423 seems like the more appropriate issue to cite, though.
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.
Oops, yes, that's the one I meant to link to. The issue title isn't quite right though - we're neither cross-compiling nor building a build script.
This comment has been minimized.
This comment has been minimized.
37104e1
to
2535828
Compare
Hmm, this doesn't actually work - when I pass |
I unfortunately likely won't have too much time to help debug that problem, but I suspect it's either the same problem as noted in the comments (i.e., target-specific magic) or perhaps a separate Cargo bug that could be fixed. I imagine it should be reproducible outside rustbuild though, in which case you could file a new issue on rust-lang/cargo :) |
I don't think this is actually a bug - passing --crate-type=proc-macro breaks unit tests:
I guess I could special case |
Cargo ignores RUSTFLAGS when building proc macro crates. However, sometimes rustc_macro needs to have conditional compilation when there are breaking changes to the `libproc_macro` API (see for example tell the difference between stage 0 and stage 1. Another alternative is to unconditionally build rustc_macros with the master libstd instead of the beta one (i.e. use `--sysroot stage0-sysroot`), but that led to strange and maddening errors: ``` error[E0460]: found possibly newer version of crate `std` which `proc_macro2` depends on --> /home/joshua/.local/lib/cargo/registry/src/github.heygears.com-1ecc6299db9ec823/tracing-attributes-0.1.13/src/lib.rs:90:5 | 90 | use proc_macro2::TokenStream; | ^^^^^^^^^^^ | = note: perhaps that crate needs to be recompiled? = note: the following crate versions were found: crate `std`: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-b3602c301b71cc3d.rmeta crate `proc_macro2`: /home/joshua/rustc2/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps/libproc_macro2-a83c1f01610c129e.rlib ```
2535828
to
dc30258
Compare
This should be ready to go; I tested by rebasing #83363 on top of this and running |
@bors r+ rollup |
📌 Commit dc30258 has been approved by |
…laumeGomez Rollup of 8 pull requests Successful merges: - rust-lang#83433 (Pass --cfg=bootstrap for proc macros built by stage0) - rust-lang#84940 (Don't run sanity checks for `x.py setup`) - rust-lang#85912 (Use `Iterator::any` and `filter_map` instead of open-coding them) - rust-lang#85965 (Remove dead code from `LocalAnalyzer`) - rust-lang#86010 (Fix two ICEs in the parser) - rust-lang#86040 (Fix display for search results) - rust-lang#86058 (Remove `_` from E0121 diagnostic suggestions) - rust-lang#86077 (Fix corrected example in E0759.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Cargo has a bug where it ignores RUSTFLAGS when building proc macro
crates (rust-lang/cargo#4423).
However, sometimes rustc_macro needs to have conditional
compilation when there are breaking changes to the
libproc_macro
API(see for example #83363). Previously, this wasn't possible, because the
crate couldn't tell the difference between stage 0 and stage 1.
Another alternative is to unconditionally build rustc_macros with the
master libstd instead of the beta one (i.e. use
--sysroot stage0-sysroot
), but that led to strange and maddening errors:r? @Mark-Simulacrum cc @jhpratt