diff --git a/kythe/cxx/verifier/verifier_main.cc b/kythe/cxx/verifier/verifier_main.cc index 98ad7ca7a7..3966f44266 100644 --- a/kythe/cxx/verifier/verifier_main.cc +++ b/kythe/cxx/verifier/verifier_main.cc @@ -15,6 +15,7 @@ */ #include +#include #include #include @@ -69,6 +70,11 @@ ABSL_FLAG(bool, use_fast_solver, false, ABSL_FLAG(bool, print_timing_information, false, "Print timing information for profiling."); +namespace { +// The fast solver needs extra stack space for modest programs. +constexpr rlim_t kSolverStack = 64L * 1024L * 1024L; +} // namespace + int main(int argc, char** argv) { GOOGLE_PROTOBUF_VERIFY_VERSION; kythe::InitializeProgram(argv[0]); @@ -139,6 +145,23 @@ invocation and rule syntax. v.UseFastSolver(absl::GetFlag(FLAGS_use_fast_solver)); + if (absl::GetFlag(FLAGS_use_fast_solver)) { + struct rlimit rl; + int r = getrlimit(RLIMIT_STACK, &rl); + if (r != 0) { + perror("failed getting solver stack size"); + return 1; + } + if (rl.rlim_cur < kSolverStack) { + rl.rlim_cur = kSolverStack; + r = setrlimit(RLIMIT_STACK, &rl); + if (r != 0) { + perror("failed increasing solver stack size"); + return 1; + } + } + } + std::string dbname = "database"; size_t facts = 0; auto start_read_time = absl::Now();