Move codegen_and_build_linker from Queries to Linker

This commit is contained in:
bjorn3 2024-06-30 18:44:11 +00:00
parent 8127461b0e
commit bd2ff518ce
4 changed files with 40 additions and 34 deletions

View file

@ -17,6 +17,7 @@ extern crate rustc_span;
use std::path::{Path, PathBuf};
use rustc_interface::Linker;
use rustc_interface::interface;
use rustc_session::config::{Input, Options, OutFileName, OutputType, OutputTypes};
use rustc_span::FileName;
@ -78,8 +79,10 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf, linker: Option<&Path
interface::run_compiler(config, |compiler| {
let linker = compiler.enter(|queries| {
queries.global_ctxt()?.enter(|tcx| tcx.analysis(()))?;
queries.codegen_and_build_linker()
queries.global_ctxt()?.enter(|tcx| {
tcx.analysis(())?;
Linker::codegen_and_build_linker(tcx, &*compiler.codegen_backend)
})
});
linker.unwrap().link(&compiler.sess, &*compiler.codegen_backend).unwrap();
});