Remove morestack support
This commit removes all morestack support from the compiler which entails: * Segmented stacks are no longer emitted in codegen. * We no longer build or distribute libmorestack.a * The `stack_exhausted` lang item is no longer required The only current use of the segmented stack support in LLVM is to detect stack overflow. This is no longer really required, however, because we already have guard pages for all threads and registered signal handlers watching for a segfault on those pages (to print out a stack overflow message). Additionally, major platforms (aka Windows) already don't use morestack. This means that Rust is by default less likely to catch stack overflows because if a function takes up more than one page of stack space it won't hit the guard page. This is what the purpose of morestack was (to catch this case), but it's better served with stack probes which have more cross platform support and no runtime support necessary. Until LLVM supports this for all platform it looks like morestack isn't really buying us much. cc #16012 (still need stack probes) Closes #26458 (a drive-by fix to help diagnostics on stack overflow)
This commit is contained in:
@@ -11,14 +11,12 @@
|
||||
use prelude::v1::*;
|
||||
|
||||
use alloc::boxed::FnBox;
|
||||
use cmp;
|
||||
use io;
|
||||
use libc::{self, c_void, DWORD};
|
||||
use mem;
|
||||
use ptr;
|
||||
use sys::c;
|
||||
use sys::handle::Handle;
|
||||
use sys_common::stack::RED_ZONE;
|
||||
use sys_common::thread::*;
|
||||
use time::Duration;
|
||||
|
||||
@@ -36,11 +34,9 @@ impl Thread {
|
||||
// PTHREAD_STACK_MIN bytes big. Windows has no such lower limit, it's
|
||||
// just that below a certain threshold you can't do anything useful.
|
||||
// That threshold is application and architecture-specific, however.
|
||||
// For now, the only requirement is that it's big enough to hold the
|
||||
// red zone. Round up to the next 64 kB because that's what the NT
|
||||
// kernel does, might as well make it explicit. With the current
|
||||
// 20 kB red zone, that makes for a 64 kB minimum stack.
|
||||
let stack_size = (cmp::max(stack, RED_ZONE) + 0xfffe) & (-0xfffe - 1);
|
||||
// Round up to the next 64 kB because that's what the NT kernel does,
|
||||
// might as well make it explicit.
|
||||
let stack_size = (stack + 0xfffe) & (!0xfffe);
|
||||
let ret = c::CreateThread(ptr::null_mut(), stack_size as libc::size_t,
|
||||
thread_start, &*p as *const _ as *mut _,
|
||||
0, ptr::null_mut());
|
||||
@@ -52,7 +48,6 @@ impl Thread {
|
||||
Ok(Thread { handle: Handle::new(ret) })
|
||||
};
|
||||
|
||||
#[no_stack_check]
|
||||
extern "system" fn thread_start(main: *mut libc::c_void) -> DWORD {
|
||||
unsafe { start_thread(main); }
|
||||
0
|
||||
|
||||
Reference in New Issue
Block a user