Skip to content

Commit 901352a

Browse files
committed
Show files produced by --emit foo in json artifact notifications
1 parent 9023f90 commit 901352a

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

compiler/rustc_codegen_gcc/src/back/write.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,20 @@ pub(crate) unsafe fn codegen(
7878

7979
if config.emit_ir {
8080
let out = cgcx.output_filenames.temp_path(OutputType::LlvmAssembly, module_name);
81-
std::fs::write(out, "").expect("write file");
81+
std::fs::write(&out, "").expect("write file");
82+
if config.json_artifact_notifications {
83+
dcx.emit_artifact_notification(&out, "llvm_ir");
84+
}
8285
}
8386

8487
if config.emit_asm {
8588
let _timer =
8689
cgcx.prof.generic_activity_with_arg("GCC_module_codegen_emit_asm", &*module.name);
8790
let path = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
8891
context.compile_to_file(OutputKind::Assembler, path.to_str().expect("path to str"));
92+
if config.json_artifact_notifications {
93+
dcx.emit_artifact_notification(&path, "asm");
94+
}
8995
}
9096

9197
match config.emit_obj {

compiler/rustc_codegen_llvm/src/back/write.rs

+8
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,10 @@ pub(crate) unsafe fn codegen(
781781
}
782782

783783
result.into_result().map_err(|()| llvm_err(dcx, LlvmError::WriteIr { path: &out }))?;
784+
785+
if config.json_artifact_notifications {
786+
dcx.emit_artifact_notification(&out, "llvm_ir");
787+
}
784788
}
785789

786790
if config.emit_asm {
@@ -809,6 +813,10 @@ pub(crate) unsafe fn codegen(
809813
&cgcx.prof,
810814
)
811815
})?;
816+
817+
if config.json_artifact_notifications {
818+
dcx.emit_artifact_notification(&path, "asm");
819+
}
812820
}
813821

814822
match config.emit_obj {

compiler/rustc_codegen_ssa/src/back/write.rs

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub struct ModuleConfig {
106106
pub emit_asm: bool,
107107
pub emit_obj: EmitObj,
108108
pub emit_thin_lto: bool,
109+
pub json_artifact_notifications: bool,
109110
pub bc_cmdline: String,
110111

111112
// Miscellaneous flags. These are mostly copied from command-line
@@ -276,6 +277,7 @@ impl ModuleConfig {
276277
inline_threshold: sess.opts.cg.inline_threshold,
277278
emit_lifetime_markers: sess.emit_lifetime_markers(),
278279
llvm_plugins: if_regular!(sess.opts.unstable_opts.llvm_plugins.clone(), vec![]),
280+
json_artifact_notifications: sess.opts.json_artifact_notifications,
279281
}
280282
}
281283

src/doc/rustc/src/json.md

+2
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ flag][option-emit] documentation.
229229
- "link": The generated crate as specified by the crate-type.
230230
- "dep-info": The `.d` file with dependency information in a Makefile-like syntax.
231231
- "metadata": The Rust `.rmeta` file containing metadata about the crate.
232+
- "asm": The `.s` file with generated assembly
233+
- "llvm_ir": The `.ll` file with generated textual LLVM IR
232234
*/
233235
"emit": "link"
234236
}

0 commit comments

Comments
 (0)