better error handling for rust.codegen-backends
on deserialization
Signed-off-by: ozkanonur <work@onurozkan.dev>
This commit is contained in:
parent
dfc9d3fee6
commit
b602cf527f
@ -1109,7 +1109,7 @@ fn needs_codegen_config(run: &RunConfig<'_>) -> bool {
|
||||
needs_codegen_cfg
|
||||
}
|
||||
|
||||
const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";
|
||||
pub(crate) const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";
|
||||
|
||||
fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
|
||||
if path.path.to_str().unwrap().contains(&CODEGEN_BACKEND_PREFIX) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
use crate::cache::{Interned, INTERNER};
|
||||
use crate::cc_detect::{ndk_compiler, Language};
|
||||
use crate::channel::{self, GitInfo};
|
||||
use crate::compile::CODEGEN_BACKEND_PREFIX;
|
||||
pub use crate::flags::Subcommand;
|
||||
use crate::flags::{Color, Flags, Warnings};
|
||||
use crate::util::{exe, output, t};
|
||||
@ -1452,8 +1453,21 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
|
||||
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
|
||||
|
||||
if let Some(ref backends) = rust.codegen_backends {
|
||||
config.rust_codegen_backends =
|
||||
backends.iter().map(|s| INTERNER.intern_str(s)).collect();
|
||||
let available_backends = vec!["llvm", "cranelift", "gcc"];
|
||||
|
||||
config.rust_codegen_backends = backends.iter().map(|s| {
|
||||
if let Some(backend) = s.strip_prefix(CODEGEN_BACKEND_PREFIX) {
|
||||
if available_backends.contains(&backend) {
|
||||
panic!("Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'.");
|
||||
} else {
|
||||
println!("help: '{s}' for 'rust.codegen-backends' might fail. \
|
||||
Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \
|
||||
In this case, it would be referred to as '{backend}'.");
|
||||
}
|
||||
}
|
||||
|
||||
INTERNER.intern_str(s)
|
||||
}).collect();
|
||||
}
|
||||
|
||||
config.rust_codegen_units = rust.codegen_units.map(threads_from_config);
|
||||
|
Loading…
Reference in New Issue
Block a user