Skip to content

Commit

Permalink
Show files produced by --emit foo in json artifact notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
pacak committed Mar 16, 2024
1 parent 9023f90 commit 0ded519
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_gcc/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,19 @@ pub(crate) unsafe fn codegen(
if config.emit_ir {
let out = cgcx.output_filenames.temp_path(OutputType::LlvmAssembly, module_name);
std::fs::write(out, "").expect("write file");
if config.json_artifact_notifications {
dcx.emit_artifact_notification(&out, "llvm_ir");
}
}

if config.emit_asm {
let _timer =
cgcx.prof.generic_activity_with_arg("GCC_module_codegen_emit_asm", &*module.name);
let path = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
context.compile_to_file(OutputKind::Assembler, path.to_str().expect("path to str"));
if config.json_artifact_notifications {
dcx.emit_artifact_notification(path, "asm");
}
}

match config.emit_obj {
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,10 @@ pub(crate) unsafe fn codegen(
}

result.into_result().map_err(|()| llvm_err(dcx, LlvmError::WriteIr { path: &out }))?;

if config.json_artifact_notifications {
dcx.emit_artifact_notification(&out, "llvm_ir");
}
}

if config.emit_asm {
Expand Down Expand Up @@ -809,6 +813,10 @@ pub(crate) unsafe fn codegen(
&cgcx.prof,
)
})?;

if config.json_artifact_notifications {
dcx.emit_artifact_notification(&path, "asm");
}
}

match config.emit_obj {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub struct ModuleConfig {
pub emit_asm: bool,
pub emit_obj: EmitObj,
pub emit_thin_lto: bool,
pub json_artifact_notifications: bool,
pub bc_cmdline: String,

// Miscellaneous flags. These are mostly copied from command-line
Expand Down Expand Up @@ -276,6 +277,7 @@ impl ModuleConfig {
inline_threshold: sess.opts.cg.inline_threshold,
emit_lifetime_markers: sess.emit_lifetime_markers(),
llvm_plugins: if_regular!(sess.opts.unstable_opts.llvm_plugins.clone(), vec![]),
json_artifact_notifications: sess.opts.json_artifact_notifications,
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/doc/rustc/src/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ flag][option-emit] documentation.
- "link": The generated crate as specified by the crate-type.
- "dep-info": The `.d` file with dependency information in a Makefile-like syntax.
- "metadata": The Rust `.rmeta` file containing metadata about the crate.
- "asm": The `.s` file with generated assembly
- "llvm_ir": The `.ll` file with generated textual LLVM IR
*/
"emit": "link"
}
Expand Down

0 comments on commit 0ded519

Please sign in to comment.