Review remarks

This commit is contained in:
Jakub Beránek 2025-08-06 15:35:10 +02:00
parent ca6e367e19
commit b92b35204b
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
3 changed files with 23 additions and 26 deletions

View file

@ -1606,7 +1606,7 @@ impl Step for GccCodegenBackend {
let _guard = builder.msg_rustc_tool(
Kind::Build,
build_compiler.stage,
format_args!("codegen backend gcc"),
"codegen backend gcc",
build_compiler.host,
target,
);
@ -1690,7 +1690,7 @@ impl Step for CraneliftCodegenBackend {
let _guard = builder.msg_rustc_tool(
Kind::Build,
build_compiler.stage,
format_args!("codegen backend cranelift"),
"codegen backend cranelift",
build_compiler.host,
target,
);
@ -1712,32 +1712,28 @@ fn write_codegen_backend_stamp(
files: Vec<PathBuf>,
dry_run: bool,
) -> BuildStamp {
if !dry_run {
let mut files = files.into_iter().filter(|f| {
let filename = f.file_name().unwrap().to_str().unwrap();
is_dylib(f) && filename.contains("rustc_codegen_")
});
let codegen_backend = match files.next() {
Some(f) => f,
None => panic!("no dylibs built for codegen backend?"),
};
if let Some(f) = files.next() {
panic!(
"codegen backend built two dylibs:\n{}\n{}",
codegen_backend.display(),
f.display()
);
}
let codegen_backend = codegen_backend.to_str().unwrap();
stamp = stamp.add_stamp(codegen_backend);
t!(stamp.write());
if dry_run {
return stamp;
}
let mut files = files.into_iter().filter(|f| {
let filename = f.file_name().unwrap().to_str().unwrap();
is_dylib(f) && filename.contains("rustc_codegen_")
});
let codegen_backend = match files.next() {
Some(f) => f,
None => panic!("no dylibs built for codegen backend?"),
};
if let Some(f) = files.next() {
panic!("codegen backend built two dylibs:\n{}\n{}", codegen_backend.display(), f.display());
}
let codegen_backend = codegen_backend.to_str().unwrap();
stamp = stamp.add_stamp(codegen_backend);
t!(stamp.write());
stamp
}
pub(crate) const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";
/// Creates the `codegen-backends` folder for a compiler that's about to be
/// assembled as a complete compiler.
///

View file

@ -1401,7 +1401,7 @@ impl Step for CraneliftCodegenBackend {
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
// We only want to build the cranelift backend in `x dist` if the backend was enabled
// in rust.codegen-backends.
// Sadly, we don't have access to the actual for which we're disting clif here..
// Sadly, we don't have access to the actual target for which we're disting clif here..
// So we just use the host target.
let clif_enabled_by_default = run
.builder

View file

@ -3,7 +3,6 @@
use serde::{Deserialize, Deserializer};
use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX;
use crate::core::config::toml::TomlConfig;
use crate::core::config::{DebuginfoLevel, Merge, ReplaceOpt, StringOrBool};
use crate::{BTreeSet, CodegenBackendKind, HashSet, PathBuf, TargetSelection, define_config, exit};
@ -391,6 +390,8 @@ pub(crate) fn parse_codegen_backends(
backends: Vec<String>,
section: &str,
) -> Vec<CodegenBackendKind> {
const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";
let mut found_backends = vec![];
for backend in &backends {
if let Some(stripped) = backend.strip_prefix(CODEGEN_BACKEND_PREFIX) {