diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-02-27 10:59:10 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-02-27 11:28:05 +0100 |
| commit | 7ad4297a4960c657932885173bef77fde0f26ccd (patch) | |
| tree | b54c17185b0191108d3f7b011e579f03787e8d83 /compiler/rustc_interface/src | |
| parent | 3d127e2040b57157936f5f24e114a8b4c9a505ef (diff) | |
| download | rust-7ad4297a4960c657932885173bef77fde0f26ccd.tar.gz rust-7ad4297a4960c657932885173bef77fde0f26ccd.zip | |
Use the first codegen backend in the config.toml as default
It is currently hard coded to llvm if enabled and cranelift otherwise. This made some sense when cranelift was the only alternative codegen backend. Since the introduction of the gcc backend this doesn't make much sense anymore. Before this PR bootstrapping rustc using a backend other than llvm or cranelift required changing the source of rustc_interface. With this PR it becomes a matter of putting the right backend as first enabled backend in config.toml.
Diffstat (limited to 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 83b54810db2..046f4f9451f 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -236,13 +236,9 @@ pub fn get_codegen_backend( static LOAD: SyncOnceCell<unsafe fn() -> Box<dyn CodegenBackend>> = SyncOnceCell::new(); let load = LOAD.get_or_init(|| { - #[cfg(feature = "llvm")] - const DEFAULT_CODEGEN_BACKEND: &str = "llvm"; + let default_codegen_backend = option_env!("CFG_DEFAULT_CODEGEN_BACKEND").unwrap_or("llvm"); - #[cfg(not(feature = "llvm"))] - const DEFAULT_CODEGEN_BACKEND: &str = "cranelift"; - - match backend_name.unwrap_or(DEFAULT_CODEGEN_BACKEND) { + match backend_name.unwrap_or(default_codegen_backend) { filename if filename.contains('.') => load_backend_from_dylib(filename.as_ref()), #[cfg(feature = "llvm")] "llvm" => rustc_codegen_llvm::LlvmCodegenBackend::new, |
