diff options
| author | Niels Sascha Reedijk <niels.reedijk@gmail.com> | 2018-07-05 07:12:24 +0200 |
|---|---|---|
| committer | Niels Sascha Reedijk <niels.reedijk@gmail.com> | 2018-07-06 07:19:11 +0200 |
| commit | 90e32e2ac67a3bfa5388c49def90712385f504cb (patch) | |
| tree | 75c524fac255c88ccb5ac65f111bb9c394f1f8bb | |
| parent | a8403e1cda2e0cba4f2c7282ab5adb5392bef473 (diff) | |
| download | rust-90e32e2ac67a3bfa5388c49def90712385f504cb.tar.gz rust-90e32e2ac67a3bfa5388c49def90712385f504cb.zip | |
Haiku: work around the lack of setrlimit
By default, Haiku has the desired 16 MB stack, therefore in general we do not have to spawn a new thread. The code has been written in such a way that any changes in Haiku or in Rust will be adapted to.
| -rw-r--r-- | src/librustc_driver/lib.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 84f7b35d21f..1078dadce25 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1493,7 +1493,7 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>> // Temporarily have stack size set to 16MB to deal with nom-using crates failing const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB - #[cfg(unix)] + #[cfg(all(unix,not(target_os = "haiku")))] let spawn_thread = unsafe { // Fetch the current resource limits let mut rlim = libc::rlimit { @@ -1525,6 +1525,26 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>> #[cfg(windows)] let spawn_thread = false; + #[cfg(target_os = "haiku")] + let spawn_thread = unsafe { + // Haiku does not have setrlimit implemented for the stack size. + // By default it does have the 16 MB stack limit, but we check this in + // case the minimum STACK_SIZE changes or Haiku's defaults change. + let mut rlim = libc::rlimit { + rlim_cur: 0, + rlim_max: 0, + }; + if libc::getrlimit(libc::RLIMIT_STACK, &mut rlim) != 0 { + let err = io::Error::last_os_error(); + error!("in_rustc_thread: error calling getrlimit: {}", err); + true + } else if rlim.rlim_cur >= STACK_SIZE { + false + } else { + true + } + }; + #[cfg(not(any(windows,unix)))] let spawn_thread = true; |
