From 0b7da099d112cf4bebc49844405ab5556c1a1ea4 Mon Sep 17 00:00:00 2001 From: PoweredByPie Date: Thu, 23 May 2024 03:55:25 -0700 Subject: [PATCH] Commit more stack size in some windows binaries This way we can commit the same amount of stack size (64 MB) without a conditional. Includes nix, libnixexpr-tests, libnixfetchers-tests, libnixstore-tests, libnixutil-tests. --- src/nix/local.mk | 5 +++++ src/nix/main.cc | 5 ----- tests/unit/libexpr/local.mk | 5 +++++ tests/unit/libfetchers/local.mk | 5 +++++ tests/unit/libstore/local.mk | 5 +++++ tests/unit/libutil/local.mk | 5 +++++ 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/nix/local.mk b/src/nix/local.mk index 305b0e9df..9883509fb 100644 --- a/src/nix/local.mk +++ b/src/nix/local.mk @@ -30,6 +30,11 @@ nix_LIBS = libexpr libmain libfetchers libstore libutil libcmd nix_LDFLAGS = $(THREAD_LDFLAGS) $(SODIUM_LIBS) $(EDITLINE_LIBS) $(BOOST_LDFLAGS) $(LOWDOWN_LIBS) +ifdef HOST_WINDOWS + # Increase the default reserved stack size to 65 MB so Nix doesn't run out of space + nix_LDFLAGS += -Wl,--stack,$(shell echo $$((65 * 1024 * 1024))) +endif + $(foreach name, \ nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-url nix-shell nix-store, \ $(eval $(call install-symlink, nix, $(bindir)/$(name)))) diff --git a/src/nix/main.cc b/src/nix/main.cc index d3f3324ac..541d1a1b3 100644 --- a/src/nix/main.cc +++ b/src/nix/main.cc @@ -522,14 +522,9 @@ 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); -#else - // Windows' default stack reservation is 1 MB, going over will fail - nix::setStackSize(1 * 1024 * 1024); -#endif return nix::handleExceptions(argv[0], [&]() { nix::mainWrapped(argc, argv); diff --git a/tests/unit/libexpr/local.mk b/tests/unit/libexpr/local.mk index c59191db4..09a7dfca1 100644 --- a/tests/unit/libexpr/local.mk +++ b/tests/unit/libexpr/local.mk @@ -38,3 +38,8 @@ libexpr-tests_LIBS = \ libexpr libexprc libfetchers libstore libstorec libutil libutilc libexpr-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) -lgmock + +ifdef HOST_WINDOWS + # Increase the default reserved stack size to 65 MB so Nix doesn't run out of space + libexpr-tests_LDFLAGS += -Wl,--stack,$(shell echo $$((65 * 1024 * 1024))) +endif diff --git a/tests/unit/libfetchers/local.mk b/tests/unit/libfetchers/local.mk index e9f659fd7..d576d28f3 100644 --- a/tests/unit/libfetchers/local.mk +++ b/tests/unit/libfetchers/local.mk @@ -30,3 +30,8 @@ libfetchers-tests_LIBS = \ libfetchers libstore libutil libfetchers-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) + +ifdef HOST_WINDOWS + # Increase the default reserved stack size to 65 MB so Nix doesn't run out of space + libfetchers-tests_LDFLAGS += -Wl,--stack,$(shell echo $$((65 * 1024 * 1024))) +endif diff --git a/tests/unit/libstore/local.mk b/tests/unit/libstore/local.mk index b8f895fad..0af1d2622 100644 --- a/tests/unit/libstore/local.mk +++ b/tests/unit/libstore/local.mk @@ -31,3 +31,8 @@ libstore-tests_LIBS = \ libstore libstorec libutil libutilc libstore-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) + +ifdef HOST_WINDOWS + # Increase the default reserved stack size to 65 MB so Nix doesn't run out of space + libstore-tests_LDFLAGS += -Wl,--stack,$(shell echo $$((65 * 1024 * 1024))) +endif diff --git a/tests/unit/libutil/local.mk b/tests/unit/libutil/local.mk index 39b4c0782..b9bddc24d 100644 --- a/tests/unit/libutil/local.mk +++ b/tests/unit/libutil/local.mk @@ -27,6 +27,11 @@ libutil-tests_LIBS = libutil-test-support libutil libutilc libutil-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) +ifdef HOST_WINDOWS + # Increase the default reserved stack size to 65 MB so Nix doesn't run out of space + libutil-tests_LDFLAGS += -Wl,--stack,$(shell echo $$((65 * 1024 * 1024))) +endif + check: $(d)/data/git/check-data.sh.test $(eval $(call run-test,$(d)/data/git/check-data.sh))