diff options
| author | bors <bors@rust-lang.org> | 2024-05-15 12:43:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-15 12:43:34 +0000 |
| commit | ade234d5743795423db6cc7cd52541390a088eab (patch) | |
| tree | 162aa1667fea17a9ea7200db43923c1d1c16de34 /src | |
| parent | 3cb0030fe9de01eeacb7c03eeef0c51420798cfb (diff) | |
| parent | 8d38f2fb11d3536639d1aa0d641e60e1f7dfe64e (diff) | |
| download | rust-ade234d5743795423db6cc7cd52541390a088eab.tar.gz rust-ade234d5743795423db6cc7cd52541390a088eab.zip | |
Auto merge of #125144 - fmease:rollup-4uft293, r=fmease
Rollup of 6 pull requests Successful merges: - #124307 (Optimize character escaping.) - #124975 (Use an helper to move the files) - #125027 (Migrate `run-make/c-link-to-rust-staticlib` to `rmake`) - #125038 (Invert comparison in `uN::checked_sub`) - #125104 (Migrate `run-make/no-cdylib-as-rdylib` to `rmake`) - #125137 (MIR operators: clarify Shl/Shr handling of negative offsets) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/dist.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/src/core/download.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/helpers.rs | 15 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/tarball.rs | 4 | ||||
| -rw-r--r-- | src/tools/tidy/src/allowed_run_make_makefiles.txt | 2 |
5 files changed, 24 insertions, 9 deletions
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 5bc9d7615e2..1f006e1453f 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -26,7 +26,9 @@ use crate::core::build_steps::tool::{self, Tool}; use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; use crate::core::config::TargetSelection; use crate::utils::channel::{self, Info}; -use crate::utils::helpers::{exe, is_dylib, output, t, target_supports_cranelift_backend, timeit}; +use crate::utils::helpers::{ + exe, is_dylib, move_file, output, t, target_supports_cranelift_backend, timeit, +}; use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball}; use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS}; @@ -2024,7 +2026,7 @@ impl Step for Extended { builder.run(&mut cmd); if !builder.config.dry_run() { - t!(fs::rename(exe.join(&filename), distdir(builder).join(&filename))); + t!(move_file(exe.join(&filename), distdir(builder).join(&filename))); } } } diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index a074d53aa36..60f48c5923e 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -12,7 +12,7 @@ use build_helper::ci::CiEnv; use build_helper::stage0_parser::VersionMetadata; use xz2::bufread::XzDecoder; -use crate::utils::helpers::{check_run, exe, program_out_of_date}; +use crate::utils::helpers::{check_run, exe, move_file, program_out_of_date}; use crate::{core::build_steps::llvm::detect_llvm_sha, utils::helpers::hex_encode}; use crate::{t, Config}; @@ -209,7 +209,7 @@ impl Config { None => panic!("no protocol in {url}"), } t!( - std::fs::rename(&tempfile, dest_path), + move_file(&tempfile, dest_path), format!("failed to rename {tempfile:?} to {dest_path:?}") ); } @@ -313,7 +313,7 @@ impl Config { if src_path.is_dir() && dst_path.exists() { continue; } - t!(fs::rename(src_path, dst_path)); + t!(move_file(src_path, dst_path)); } let dst_dir = dst.join(directory_prefix); if dst_dir.exists() { diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 0d2ff4f951b..278359cb08e 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -150,6 +150,21 @@ pub fn symlink_dir(config: &Config, original: &Path, link: &Path) -> io::Result< } } +/// Rename a file if from and to are in the same filesystem or +/// copy and remove the file otherwise +pub fn move_file<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<()> { + match fs::rename(&from, &to) { + // FIXME: Once `ErrorKind::CrossesDevices` is stabilized use + // if e.kind() == io::ErrorKind::CrossesDevices { + #[cfg(unix)] + Err(e) if e.raw_os_error() == Some(libc::EXDEV) => { + std::fs::copy(&from, &to)?; + std::fs::remove_file(&from) + } + r => r, + } +} + pub fn forcing_clang_based_tests() -> bool { if let Some(var) = env::var_os("RUSTBUILD_FORCE_CLANG_BASED_TESTS") { match &var.to_string_lossy().to_lowercase()[..] { diff --git a/src/bootstrap/src/utils/tarball.rs b/src/bootstrap/src/utils/tarball.rs index 2a950e669b9..57cdf7473a1 100644 --- a/src/bootstrap/src/utils/tarball.rs +++ b/src/bootstrap/src/utils/tarball.rs @@ -13,7 +13,7 @@ use std::{ use crate::core::builder::Builder; use crate::core::{build_steps::dist::distdir, builder::Kind}; use crate::utils::channel; -use crate::utils::helpers::t; +use crate::utils::helpers::{move_file, t}; #[derive(Copy, Clone)] pub(crate) enum OverlayKind { @@ -284,7 +284,7 @@ impl<'a> Tarball<'a> { // name, not "image". We rename the image directory just before passing // into rust-installer. let dest = self.temp_dir.join(self.package_name()); - t!(std::fs::rename(&self.image_dir, &dest)); + t!(move_file(&self.image_dir, &dest)); self.run(|this, cmd| { let distdir = distdir(this.builder); diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index c2358eff617..b84c147395d 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -8,7 +8,6 @@ run-make/branch-protection-check-IBT/Makefile run-make/c-dynamic-dylib/Makefile run-make/c-dynamic-rlib/Makefile run-make/c-link-to-rust-dylib/Makefile -run-make/c-link-to-rust-staticlib/Makefile run-make/c-static-dylib/Makefile run-make/c-static-rlib/Makefile run-make/c-unwind-abi-catch-lib-panic/Makefile @@ -179,7 +178,6 @@ run-make/native-link-modifier-whole-archive/Makefile run-make/no-alloc-shim/Makefile run-make/no-builtins-attribute/Makefile run-make/no-builtins-lto/Makefile -run-make/no-cdylib-as-rdylib/Makefile run-make/no-duplicate-libs/Makefile run-make/no-intermediate-extras/Makefile run-make/obey-crate-type-flag/Makefile |
