Skip to content

Commit

Permalink
make codegen-backend config warning less noisy
Browse files Browse the repository at this point in the history
If `codegen-backends` is missing "cranelift" and "gcc" (which is common),
bootstrap will now only show this warning during `dist` and `install` steps,
or if codegen-backends was explicitly called for build.

Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Jun 18, 2024
1 parent 66ea4dd commit 8d3f9e8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,15 +1290,21 @@ fn needs_codegen_config(run: &RunConfig<'_>) -> bool {
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) {
let path = path.path.to_str().unwrap();

let is_explicitly_called = |p| -> bool { run.builder.paths.contains(p) };
let should_enforce = run.builder.kind == Kind::Dist || run.builder.kind == Kind::Install;

if path.contains(CODEGEN_BACKEND_PREFIX) {
let mut needs_codegen_backend_config = true;
for backend in run.builder.config.codegen_backends(run.target) {
if path.path.to_str().unwrap().ends_with(&(CODEGEN_BACKEND_PREFIX.to_owned() + backend))
{
if path.ends_with(&(CODEGEN_BACKEND_PREFIX.to_owned() + backend)) {
needs_codegen_backend_config = false;
}
}
if needs_codegen_backend_config {
if (is_explicitly_called(&PathBuf::from(path)) || should_enforce)
&& needs_codegen_backend_config
{
run.builder.info(
"WARNING: no codegen-backends config matched the requested path to build a codegen backend. \
HELP: add backend to codegen-backends in config.toml.",
Expand Down

0 comments on commit 8d3f9e8

Please sign in to comment.