about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2021-11-08 16:59:36 +0100
committerMichael Woerister <michaelwoerister@posteo>2021-11-08 17:02:40 +0100
commitfefe1e9192696c07f1655ed2726c4e114b70b096 (patch)
tree0beead3daa202ec305dc36e55ed8566d3453cb9a /compiler/rustc_codegen_ssa
parent3e3890c9d4064253aaa8c51f5d5458d2dc6dab77 (diff)
downloadrust-fefe1e9192696c07f1655ed2726c4e114b70b096.tar.gz
rust-fefe1e9192696c07f1655ed2726c4e114b70b096.zip
Record more artifact sizes during self-profiling.
Diffstat (limited to 'compiler/rustc_codegen_ssa')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index 6c02543bd7c..1ba0c4fa05b 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -121,6 +121,19 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
             if sess.opts.json_artifact_notifications {
                 sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename, "link");
             }
+
+            if sess.prof.enabled() {
+                if let Some(artifact_name) = out_filename.file_name() {
+                    // Record size for self-profiling
+                    let file_size = std::fs::metadata(&out_filename).map(|m| m.len()).unwrap_or(0);
+
+                    sess.prof.artifact_size(
+                        "linked_artifact",
+                        artifact_name.to_string_lossy(),
+                        file_size,
+                    );
+                }
+            }
         }
     }