diff --git a/compiler/rustc_codegen_gcc/src/back/write.rs b/compiler/rustc_codegen_gcc/src/back/write.rs index 76a619a1af782..dd262f4245238 100644 --- a/compiler/rustc_codegen_gcc/src/back/write.rs +++ b/compiler/rustc_codegen_gcc/src/back/write.rs @@ -79,6 +79,9 @@ 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 { @@ -86,6 +89,9 @@ pub(crate) unsafe fn codegen( 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 { diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 031bbd6336116..76d76d99eedea 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -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 { @@ -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 { diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 4eda4c2f08c69..1fe876e259918 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -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 @@ -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, } } diff --git a/src/doc/rustc/src/json.md b/src/doc/rustc/src/json.md index 9daa0810126b7..8624637f522fa 100644 --- a/src/doc/rustc/src/json.md +++ b/src/doc/rustc/src/json.md @@ -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" }