Auto merge of #122597 - pacak:master, r=bjorn3
Show files produced by `--emit foo` in json artifact notifications Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`. Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477 Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: https://github.com/hintron/computer-enhance/issues/35 This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files. Most users won't notice this behavior, to be affected by it all of the following must hold: - user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything) - user must specify both `--emit xxx` and `--json artifacts` - user must refuse to handle unknown artifact types - user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit #88829 / #89149
This commit is contained in:
commit
1689a5a531
7 changed files with 140 additions and 1 deletions
|
@ -106,6 +106,24 @@ pub struct CompiledModule {
|
|||
pub llvm_ir: Option<PathBuf>, // --emit=llvm-ir, llvm-bc is in bytecode
|
||||
}
|
||||
|
||||
impl CompiledModule {
|
||||
/// Call `emit` function with every artifact type currently compiled
|
||||
pub fn for_each_output(&self, mut emit: impl FnMut(&Path, OutputType)) {
|
||||
if let Some(path) = self.object.as_deref() {
|
||||
emit(path, OutputType::Object);
|
||||
}
|
||||
if let Some(path) = self.bytecode.as_deref() {
|
||||
emit(path, OutputType::Bitcode);
|
||||
}
|
||||
if let Some(path) = self.llvm_ir.as_deref() {
|
||||
emit(path, OutputType::LlvmAssembly);
|
||||
}
|
||||
if let Some(path) = self.assembly.as_deref() {
|
||||
emit(path, OutputType::Assembly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CachedModuleCodegen {
|
||||
pub name: String,
|
||||
pub source: WorkProduct,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue