Skip to content

Commit a466cc5

Browse files
authored
Allow configuring arbitrary codegen backends (#15562)
Rather than just builtin codegen backends. This is perma-unstable on the rustc side, but is useful to enable a codegen backend built separately from rustc to be used without overwriting RUSTFLAGS as well as to allow configuring the codegen backend on a per-package basis.
2 parents 5052f88 + 649aca7 commit a466cc5

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,25 +2465,15 @@ pub fn validate_profile(
24652465
features: &Features,
24662466
warnings: &mut Vec<String>,
24672467
) -> CargoResult<()> {
2468-
validate_profile_layer(root, name, cli_unstable, features)?;
2468+
validate_profile_layer(root, cli_unstable, features)?;
24692469
if let Some(ref profile) = root.build_override {
24702470
validate_profile_override(profile, "build-override")?;
2471-
validate_profile_layer(
2472-
profile,
2473-
&format!("{name}.build-override"),
2474-
cli_unstable,
2475-
features,
2476-
)?;
2471+
validate_profile_layer(profile, cli_unstable, features)?;
24772472
}
24782473
if let Some(ref packages) = root.package {
2479-
for (override_name, profile) in packages {
2474+
for profile in packages.values() {
24802475
validate_profile_override(profile, "package")?;
2481-
validate_profile_layer(
2482-
profile,
2483-
&format!("{name}.package.{override_name}"),
2484-
cli_unstable,
2485-
features,
2486-
)?;
2476+
validate_profile_layer(profile, cli_unstable, features)?;
24872477
}
24882478
}
24892479

@@ -2548,26 +2538,17 @@ pub fn validate_profile(
25482538
/// This is a shallow check, which is reused for the profile itself and any overrides.
25492539
fn validate_profile_layer(
25502540
profile: &manifest::TomlProfile,
2551-
name: &str,
25522541
cli_unstable: &CliUnstable,
25532542
features: &Features,
25542543
) -> CargoResult<()> {
2555-
if let Some(codegen_backend) = &profile.codegen_backend {
2544+
if profile.codegen_backend.is_some() {
25562545
match (
25572546
features.require(Feature::codegen_backend()),
25582547
cli_unstable.codegen_backend,
25592548
) {
25602549
(Err(e), false) => return Err(e),
25612550
_ => {}
25622551
}
2563-
2564-
if codegen_backend.contains(|c: char| !c.is_ascii_alphanumeric() && c != '_') {
2565-
bail!(
2566-
"`profile.{}.codegen-backend` setting of `{}` is not a valid backend name.",
2567-
name,
2568-
codegen_backend,
2569-
);
2570-
}
25712552
}
25722553
if profile.rustflags.is_some() {
25732554
match (

0 commit comments

Comments
 (0)