From f76c3b7fb971fb7d8a0909f107378416bb2d2029 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 17 Jun 2024 22:43:44 +0300 Subject: [PATCH 1/2] replace `remove_dir` with `remove_dir_all` in `helpers::symlink_dir` When using `symlink_dir`, it first removes the existing link with `remove_dir`. However, if the path isn't a link and contains files, `remove_dir` fails with "DirectoryNotEmpty", which causes the symbolic linking to fail as well. We have this problem on linking 'rustlib/rust' because it contains files as an actual directory. Signed-off-by: onur-ozkan --- src/bootstrap/src/utils/helpers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 13d1346b3d9a6..55cb05f864a76 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -135,7 +135,7 @@ pub fn symlink_dir(config: &Config, original: &Path, link: &Path) -> io::Result< if config.dry_run() { return Ok(()); } - let _ = fs::remove_dir(link); + let _ = fs::remove_dir_all(link); return symlink_dir_inner(original, link); #[cfg(not(windows))] From 521e707d7acf3f85389bbcfe53670638ef00c32a Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Tue, 18 Jun 2024 07:42:40 +0300 Subject: [PATCH 2/2] make codegen-backend config warning less noisy 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 --- src/bootstrap/src/core/build_steps/compile.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index cc5b007321350..5b18cb3f7e1e6 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -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.",