summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap/bin')
-rw-r--r--src/bootstrap/bin/main.rs25
-rw-r--r--src/bootstrap/bin/rustc.rs52
2 files changed, 44 insertions, 33 deletions
diff --git a/src/bootstrap/bin/main.rs b/src/bootstrap/bin/main.rs
index 3856bb64f..912d875e4 100644
--- a/src/bootstrap/bin/main.rs
+++ b/src/bootstrap/bin/main.rs
@@ -7,15 +7,18 @@
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() {
let args = env::args().skip(1).collect::<Vec<_>>();
let config = Config::parse(&args);
- let mut build_lock;
- let _build_lock_guard;
- if cfg!(any(unix, windows)) {
+ #[cfg(all(any(unix, windows), not(target_os = "solaris")))]
+ {
+ let mut build_lock;
+ let _build_lock_guard;
let path = config.out.join("lock");
build_lock = fd_lock::RwLock::new(t!(std::fs::File::create(&path)));
_build_lock_guard = match build_lock.try_write() {
@@ -30,9 +33,9 @@ fn main() {
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
let changelog_suggestion =
@@ -44,8 +47,8 @@ fn main() {
if suggest_setup {
println!("warning: you have not made a `config.toml`");
println!(
- "help: consider running `./x.py setup` or copying `config.toml.example` by running \
- `cp config.toml.example config.toml`"
+ "help: consider running `./x.py setup` or copying `config.example.toml` by running \
+ `cp config.example.toml config.toml`"
);
} else if let Some(suggestion) = &changelog_suggestion {
println!("{}", suggestion);
@@ -57,8 +60,8 @@ fn main() {
if suggest_setup {
println!("warning: you have not made a `config.toml`");
println!(
- "help: consider running `./x.py setup` or copying `config.toml.example` by running \
- `cp config.toml.example config.toml`"
+ "help: consider running `./x.py setup` or copying `config.example.toml` by running \
+ `cp config.example.toml config.toml`"
);
} else if let Some(suggestion) = &changelog_suggestion {
println!("{}", 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> {
// FIXME: Implement on other OS's
None
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index 9611c866d..040fec361 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -281,41 +281,49 @@ fn format_rusage_data(_child: Child) -> Option<String> {
#[cfg(windows)]
fn format_rusage_data(child: Child) -> Option<String> {
use std::os::windows::io::AsRawHandle;
- use winapi::um::{processthreadsapi, psapi, timezoneapi};
- let handle = child.as_raw_handle();
- macro_rules! try_bool {
- ($e:expr) => {
- if $e != 1 {
- return None;
- }
- };
- }
+
+ use windows::{
+ Win32::Foundation::HANDLE,
+ Win32::System::ProcessStatus::{
+ K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS, PROCESS_MEMORY_COUNTERS_EX,
+ },
+ Win32::System::Threading::GetProcessTimes,
+ Win32::System::Time::FileTimeToSystemTime,
+ };
+
+ let handle = HANDLE(child.as_raw_handle() as isize);
let mut user_filetime = Default::default();
let mut user_time = Default::default();
let mut kernel_filetime = Default::default();
let mut kernel_time = Default::default();
- let mut memory_counters = psapi::PROCESS_MEMORY_COUNTERS::default();
+ let mut memory_counters = PROCESS_MEMORY_COUNTERS::default();
unsafe {
- try_bool!(processthreadsapi::GetProcessTimes(
+ GetProcessTimes(
handle,
&mut Default::default(),
&mut Default::default(),
&mut kernel_filetime,
&mut user_filetime,
- ));
- try_bool!(timezoneapi::FileTimeToSystemTime(&user_filetime, &mut user_time));
- try_bool!(timezoneapi::FileTimeToSystemTime(&kernel_filetime, &mut kernel_time));
-
- // Unlike on Linux with RUSAGE_CHILDREN, this will only return memory information for the process
- // with the given handle and none of that process's children.
- try_bool!(psapi::GetProcessMemoryInfo(
- handle as _,
- &mut memory_counters as *mut _ as _,
- std::mem::size_of::<psapi::PROCESS_MEMORY_COUNTERS_EX>() as u32,
- ));
+ )
+ }
+ .ok()
+ .ok()?;
+ unsafe { FileTimeToSystemTime(&user_filetime, &mut user_time) }.ok().ok()?;
+ unsafe { FileTimeToSystemTime(&kernel_filetime, &mut kernel_time) }.ok().ok()?;
+
+ // Unlike on Linux with RUSAGE_CHILDREN, this will only return memory information for the process
+ // with the given handle and none of that process's children.
+ unsafe {
+ K32GetProcessMemoryInfo(
+ handle,
+ &mut memory_counters,
+ std::mem::size_of::<PROCESS_MEMORY_COUNTERS_EX>() as u32,
+ )
}
+ .ok()
+ .ok()?;
// Guide on interpreting these numbers:
// https://docs.microsoft.com/en-us/windows/win32/psapi/process-memory-usage-information