Skip to content

Commit

Permalink
Totally exclude nix::setStackSize on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
puffnfresh committed Jan 31, 2025
1 parent b644e57 commit 7c8c71f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libutil/current-process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ unsigned int getMaxCPU()
//////////////////////////////////////////////////////////////////////


#ifndef _WIN32
size_t savedStackSize = 0;

void setStackSize(size_t stackSize)
{
#ifndef _WIN32
struct rlimit limit;
if (getrlimit(RLIMIT_STACK, &limit) == 0 && limit.rlim_cur < stackSize) {
savedStackSize = limit.rlim_cur;
Expand All @@ -73,8 +73,8 @@ void setStackSize(size_t stackSize)
);
}
}
#endif
}
#endif

void restoreProcessContext(bool restoreMounts)
{
Expand Down
3 changes: 3 additions & 0 deletions src/libutil/current-process.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ namespace nix {
*/
unsigned int getMaxCPU();

// It does not seem possible to dynamically change stack size on Windows.
#ifndef _WIN32
/**
* Change the stack size.
*/
void setStackSize(size_t stackSize);
#endif

/**
* Restore the original inherited Unix process context (such as signal
Expand Down
2 changes: 2 additions & 0 deletions src/nix/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,11 @@ void mainWrapped(int argc, char * * argv)

int main(int argc, char * * argv)
{
#ifndef _WIN32
// Increase the default stack size for the evaluator and for
// libstdc++'s std::regex.
nix::setStackSize(64 * 1024 * 1024);
#endif

return nix::handleExceptions(argv[0], [&]() {
nix::mainWrapped(argc, argv);
Expand Down

0 comments on commit 7c8c71f

Please sign in to comment.