Add option to pass a custom codegen backend from a driver

This commit is contained in:
bjorn3
2020-09-08 13:44:41 +02:00
parent 956e06c6c8
commit 71bc62b9f6
8 changed files with 37 additions and 5 deletions

View File

@@ -154,6 +154,10 @@ pub struct Config {
pub override_queries:
Option<fn(&Session, &mut ty::query::Providers, &mut ty::query::Providers)>,
/// This is a callback from the driver that is called to create a codegen backend.
pub make_codegen_backend:
Option<Box<dyn FnOnce(&config::Options) -> Box<dyn CodegenBackend> + Send>>,
/// Registry of diagnostics codes.
pub registry: Registry,
}
@@ -167,6 +171,7 @@ pub fn create_compiler_and_run<R>(config: Config, f: impl FnOnce(&Compiler) -> R
config.file_loader,
config.input_path.clone(),
config.lint_caps,
config.make_codegen_backend,
registry.clone(),
);