Skip to content

Commit b4c7fc4

Browse files
authored
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
2 parents 96f4497 + 04dfedb commit b4c7fc4

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/bootstrap/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4747
- Add `--keep-stage-std`, which behaves like `keep-stage` but allows the stage
4848
0 compiler artifacts (i.e., stage1/bin/rustc) to be rebuilt if changed
4949
[#77120](https://github.com/rust-lang/rust/pull/77120).
50+
- 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.
5051

5152

5253
## [Version 1] - 2020-09-11

src/bootstrap/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ test = false
3232
[dependencies]
3333
build_helper = { path = "../tools/build_helper" }
3434
cmake = "0.1.38"
35-
fd-lock = "3.0.8"
3635
filetime = "0.2"
3736
getopts = "0.2.19"
3837
cc = "1.0.69"
@@ -56,6 +55,10 @@ walkdir = "2"
5655
# Dependencies needed by the build-metrics feature
5756
sysinfo = { version = "0.26.0", optional = true }
5857

58+
# Solaris doesn't support flock() and thus fd-lock is not option now
59+
[target.'cfg(not(target_os = "solaris"))'.dependencies]
60+
fd-lock = "3.0.8"
61+
5962
[target.'cfg(windows)'.dependencies.winapi]
6063
version = "0.3"
6164
features = [

src/bootstrap/bin/main.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77
88
use std::env;
99

10-
use bootstrap::{t, Build, Config, Subcommand, VERSION};
10+
#[cfg(all(any(unix, windows), not(target_os = "solaris")))]
11+
use bootstrap::t;
12+
use bootstrap::{Build, Config, Subcommand, VERSION};
1113

1214
fn main() {
1315
let args = env::args().skip(1).collect::<Vec<_>>();
1416
let config = Config::parse(&args);
1517

16-
let mut build_lock;
17-
let _build_lock_guard;
18-
if cfg!(any(unix, windows)) {
18+
#[cfg(all(any(unix, windows), not(target_os = "solaris")))]
19+
{
20+
let mut build_lock;
21+
let _build_lock_guard;
1922
let path = config.out.join("lock");
2023
build_lock = fd_lock::RwLock::new(t!(std::fs::File::create(&path)));
2124
_build_lock_guard = match build_lock.try_write() {
@@ -30,9 +33,9 @@ fn main() {
3033
t!(build_lock.write())
3134
}
3235
};
33-
} else {
34-
println!("warning: file locking not supported for target, not locking build directory");
3536
}
37+
#[cfg(any(not(any(unix, windows)), target_os = "solaris"))]
38+
println!("warning: file locking not supported for target, not locking build directory");
3639

3740
// check_version warnings are not printed during setup
3841
let changelog_suggestion =
@@ -125,7 +128,7 @@ fn get_lock_owner(f: &std::path::Path) -> Option<u64> {
125128
})
126129
}
127130

128-
#[cfg(not(target_os = "linux"))]
131+
#[cfg(not(any(target_os = "linux", target_os = "solaris")))]
129132
fn get_lock_owner(_: &std::path::Path) -> Option<u64> {
130133
// FIXME: Implement on other OS's
131134
None

0 commit comments

Comments
 (0)