Set stack size to at least 128 MB (large stack needed for parsing huge expressions)
authorClifford Wolf <clifford@clifford.at>
Tue, 27 Mar 2018 13:04:10 +0000 (15:04 +0200)
committerClifford Wolf <clifford@clifford.at>
Tue, 27 Mar 2018 13:04:10 +0000 (15:04 +0200)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
kernel/driver.cc

index 97a78cd16c4fd06de3bed395a7d74e97f64a2501..3c16e5fd49b1d71a22ec448eee932b08a673f389 100644 (file)
@@ -35,6 +35,7 @@
 #include <errno.h>
 
 #ifdef __linux__
+#  include <sys/resource.h>
 #  include <sys/types.h>
 #  include <unistd.h>
 #endif
@@ -416,6 +417,18 @@ int main(int argc, char **argv)
        if (print_stats)
                log_hasher = new SHA1;
 
+#if defined(__linux__)
+       // set stack size to >= 128 MB
+       {
+               struct rlimit rl;
+               const rlim_t stack_size = 128L * 1024L * 1024L;
+               if (getrlimit(RLIMIT_STACK, &rl) == 0 && rl.rlim_cur < stack_size) {
+                       rl.rlim_cur = stack_size;
+                       setrlimit(RLIMIT_STACK, &rl);
+               }
+       }
+#endif
+
        yosys_setup();
        log_error_atexit = yosys_atexit;