[PATCH] D103165: Threading: use independent llvm::thread implementation on Apple platforms to increase stack size

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 26 07:06:34 PDT 2021


t.p.northover created this revision.
Herald added subscribers: dexonsmith, mcrosier.
t.p.northover requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Darwin's libpthread creates threads with only 512KB of stack space, as opposed to the main thread's 8MB. 512KB often isn't enough to compile properly, so we get stack overflows during ThinLTO.

Unfortunately, with Posix threads the stack size can only be set during creation so there's no way to use the real `std::thread` to overcome this limit (even with the native handle).

So this patch adds a real implementation of `llvm::thread` (with the same interface as `std::thread`) when compiling for Apple that does request the full 8MB stack size. Most of the implementation is cribbed from libc++, with abstractions removed because we know the underlying implementation and target standard (and because we can tell users not to be daft and `#define Thread 0`).


https://reviews.llvm.org/D103165

Files:
  llvm/include/llvm/Support/thread.h
  llvm/unittests/Support/Threading.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103165.347949.patch
Type: text/x-patch
Size: 3575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210526/9cd713cb/attachment.bin>


More information about the llvm-commits mailing list