-
Couldn't load subscription status.
- Fork 399
[WIP] Use the dummy codegen backend #4648
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
base: master
Are you sure you want to change the base?
Conversation
| // `exported_non_generic_symbols` and `reachable_non_generics` provided by rustc always returns | ||
| // an empty result if `tcx.sess.opts.output_types.should_codegen()` is false. | ||
| // In addition we need to add #[used] symbols to exported_symbols for `lookup_link_section`. | ||
| local_providers.exported_non_generic_symbols = |tcx, LocalCrate| { |
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.
On second thought we may still need this for #[used].
| /// Also disable the MIR pass that inserts an alignment check on every pointer dereference. Miri | ||
| /// does that too, and with a better error message. | ||
| pub const MIRI_DEFAULT_ARGS: &[&str] = &[ | ||
| "-Zcodegen-backend=dummy", |
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 dummy codegen backend is a builtin codegen backend that is only capable of emitting rlibs containing the crate metadata. For every other crate type it emits an error after codegen. This is fine for miri as for --crate-type bin, miri exits before codegen.
…apkin Allow codegen backends to indicate which crate types they support This way cargo will drop the unsupported crate types for crates that specify multiple crate types. This is a prerequisite for rust-lang/miri#4648.
…, r=WaffleLapkin Allow codegen backends to indicate which crate types they support This way cargo will drop the unsupported crate types for crates that specify multiple crate types. This is a prerequisite for rust-lang/miri#4648.
Rollup merge of #148177 - bjorn3:codegen_backend_crate_types, r=WaffleLapkin Allow codegen backends to indicate which crate types they support This way cargo will drop the unsupported crate types for crates that specify multiple crate types. This is a prerequisite for rust-lang/miri#4648.
This allows getting rid of all the argument mangling hacks as well as the exported_non_generic_symbols override hack by doing cargo build instead of cargo check. This is also a prerequisite for using native jit mode support in miri that I hope to add to rustc in the future to be used with cg_clif too. Currently this still has two issues: The dummy backend can't build dylibs, but cargo tries to build libstd as dylib. And required target features are not set by the dummy backend. Both of these require rustc side changes.
|
☔ The latest upstream changes made this pull request unmergeable. Please resolve the merge conflicts. |
| } else { | ||
| // For all other kinds of tests, we can just add our flag. | ||
| cmd.arg("--emit=metadata"); | ||
| cmd.arg("--emit=metadata,link"); |
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.
Is this still needed in the first place?
The library workspace sets this already nowadays.
…es, r=JonathanBrouwer Handle default features and -Ctarget-features in the dummy backend This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend. Required for rust-lang/miri#4648
This allows getting rid of all the argument mangling hacks as well as the exported_non_generic_symbols override hack by doing cargo build instead of cargo check. This is also a prerequisite for using native jit mode support in miri that I hope to add to rustc in the future to be used with cg_clif too.
Currently this still has two issues:
The dummy backend can't build dylibs, but cargo tries to build libstd as dylib.(rust-lang/rust#148177) And required target features are not set by the dummy backend. Both of these require rustc side changes.I'm opening this draft PR for early feedback on this approach before I spent time fixing these issues on the rustc side.