about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-06-30 18:01:55 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-06-30 18:01:55 +0000
commit8127461b0ed54dea8ca9cf430b1d231611e1b477 (patch)
treeaa4d6f37cb53e4d74e9d20c8b7a821111e2b384a /compiler
parent2975a21b5d6e4718cf219349d3cb37d45c20f84d (diff)
downloadrust-8127461b0ed54dea8ca9cf430b1d231611e1b477.tar.gz
rust-8127461b0ed54dea8ca9cf430b1d231611e1b477.zip
Move -Zprint-type-sizes and -Zprint-vtable-sizes into codegen_and_build_linker
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_driver_impl/src/lib.rs17
-rw-r--r--compiler/rustc_interface/src/queries.rs12
2 files changed, 13 insertions, 16 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index bbe9741bf44..3780e575b93 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -41,7 +41,6 @@ use rustc_session::getopts::{self, Matches};
 use rustc_session::lint::{Lint, LintId};
 use rustc_session::output::collect_crate_types;
 use rustc_session::{config, filesearch, EarlyDiagCtxt, Session};
-use rustc_span::def_id::LOCAL_CRATE;
 use rustc_span::source_map::FileLoader;
 use rustc_span::symbol::sym;
 use rustc_span::FileName;
@@ -448,21 +447,7 @@ fn run_compiler(
                 return early_exit();
             }
 
-            let linker = queries.codegen_and_build_linker()?;
-
-            // This must run after monomorphization so that all generic types
-            // have been instantiated.
-            if sess.opts.unstable_opts.print_type_sizes {
-                sess.code_stats.print_type_sizes();
-            }
-
-            if sess.opts.unstable_opts.print_vtable_sizes {
-                let crate_name = queries.global_ctxt()?.enter(|tcx| tcx.crate_name(LOCAL_CRATE));
-
-                sess.code_stats.print_vtable_sizes(crate_name);
-            }
-
-            Ok(Some(linker))
+            Ok(Some(queries.codegen_and_build_linker()?))
         })?;
 
         // Linking is done outside the `compiler.enter()` so that the
diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs
index cfd4304e893..5f00d7a76b2 100644
--- a/compiler/rustc_interface/src/queries.rs
+++ b/compiler/rustc_interface/src/queries.rs
@@ -121,6 +121,18 @@ impl<'tcx> Queries<'tcx> {
         self.global_ctxt()?.enter(|tcx| {
             let ongoing_codegen = passes::start_codegen(&*self.compiler.codegen_backend, tcx)?;
 
+            // This must run after monomorphization so that all generic types
+            // have been instantiated.
+            if tcx.sess.opts.unstable_opts.print_type_sizes {
+                tcx.sess.code_stats.print_type_sizes();
+            }
+
+            if tcx.sess.opts.unstable_opts.print_vtable_sizes {
+                let crate_name = tcx.crate_name(LOCAL_CRATE);
+
+                tcx.sess.code_stats.print_vtable_sizes(crate_name);
+            }
+
             Ok(Linker {
                 dep_graph: tcx.dep_graph.clone(),
                 output_filenames: tcx.output_filenames(()).clone(),