Rollup merge of #108607 - psumbera:solaris-no-flock-bootstrap, r=albertlarsan68

Don't use fd-lock on Solaris in bootstrap

...as Solaris is missing flock()

fixes #103630
This commit is contained in:
Matthias Krüger 2023-03-13 21:55:36 +01:00 committed by GitHub
commit b4c7fc4ea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View File

@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add `--keep-stage-std`, which behaves like `keep-stage` but allows the stage - Add `--keep-stage-std`, which behaves like `keep-stage` but allows the stage
0 compiler artifacts (i.e., stage1/bin/rustc) to be rebuilt if changed 0 compiler artifacts (i.e., stage1/bin/rustc) to be rebuilt if changed
[#77120](https://github.com/rust-lang/rust/pull/77120). [#77120](https://github.com/rust-lang/rust/pull/77120).
- File locking is now used to avoid collisions between multiple running instances of `x.py` (e.g. when using `rust-analyzer` and `x.py` at the same time). Note that Solaris and possibly other non Unix and non Windows systems don't support it [#108607](https://github.com/rust-lang/rust/pull/108607). This might possibly lead to build data corruption.
## [Version 1] - 2020-09-11 ## [Version 1] - 2020-09-11

View File

@ -32,7 +32,6 @@ test = false
[dependencies] [dependencies]
build_helper = { path = "../tools/build_helper" } build_helper = { path = "../tools/build_helper" }
cmake = "0.1.38" cmake = "0.1.38"
fd-lock = "3.0.8"
filetime = "0.2" filetime = "0.2"
getopts = "0.2.19" getopts = "0.2.19"
cc = "1.0.69" cc = "1.0.69"
@ -56,6 +55,10 @@ walkdir = "2"
# Dependencies needed by the build-metrics feature # Dependencies needed by the build-metrics feature
sysinfo = { version = "0.26.0", optional = true } sysinfo = { version = "0.26.0", optional = true }
# Solaris doesn't support flock() and thus fd-lock is not option now
[target.'cfg(not(target_os = "solaris"))'.dependencies]
fd-lock = "3.0.8"
[target.'cfg(windows)'.dependencies.winapi] [target.'cfg(windows)'.dependencies.winapi]
version = "0.3" version = "0.3"
features = [ features = [

View File

@ -7,15 +7,18 @@
use std::env; use std::env;
use bootstrap::{t, Build, Config, Subcommand, VERSION}; #[cfg(all(any(unix, windows), not(target_os = "solaris")))]
use bootstrap::t;
use bootstrap::{Build, Config, Subcommand, VERSION};
fn main() { fn main() {
let args = env::args().skip(1).collect::<Vec<_>>(); let args = env::args().skip(1).collect::<Vec<_>>();
let config = Config::parse(&args); let config = Config::parse(&args);
let mut build_lock; #[cfg(all(any(unix, windows), not(target_os = "solaris")))]
let _build_lock_guard; {
if cfg!(any(unix, windows)) { let mut build_lock;
let _build_lock_guard;
let path = config.out.join("lock"); let path = config.out.join("lock");
build_lock = fd_lock::RwLock::new(t!(std::fs::File::create(&path))); build_lock = fd_lock::RwLock::new(t!(std::fs::File::create(&path)));
_build_lock_guard = match build_lock.try_write() { _build_lock_guard = match build_lock.try_write() {
@ -30,9 +33,9 @@ fn main() {
t!(build_lock.write()) t!(build_lock.write())
} }
}; };
} else {
println!("warning: file locking not supported for target, not locking build directory");
} }
#[cfg(any(not(any(unix, windows)), target_os = "solaris"))]
println!("warning: file locking not supported for target, not locking build directory");
// check_version warnings are not printed during setup // check_version warnings are not printed during setup
let changelog_suggestion = let changelog_suggestion =
@ -125,7 +128,7 @@ fn get_lock_owner(f: &std::path::Path) -> Option<u64> {
}) })
} }
#[cfg(not(target_os = "linux"))] #[cfg(not(any(target_os = "linux", target_os = "solaris")))]
fn get_lock_owner(_: &std::path::Path) -> Option<u64> { fn get_lock_owner(_: &std::path::Path) -> Option<u64> {
// FIXME: Implement on other OS's // FIXME: Implement on other OS's
None None