From 7d7078f1267b3a35f5f7f9f0cf51f820a3d54d3e Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 16 Jul 2019 12:14:18 +0200 Subject: [PATCH] Makefile/dmake: Increase stack size to 8M for Cygwin builds to avoid segfaults (#2001) * Makefile: Increase stack size to 8M for Cygwin builds to avoid segfaults See https://github.com/danmar/cppcheck/pull/1988 and https://github.com/danmar/cppcheck/pull/1998 * dmake.cpp: Add parameter to CXXFLAGS for increased stack size in Cygwin --- Makefile | 9 +++++++++ tools/dmake.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/Makefile b/Makefile index 780bfe4e3..be2d85adf 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,15 @@ ifndef CXXFLAGS CXXFLAGS=-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar $(CPPCHK_GLIBCXX_DEBUG) -g endif +# Increase stack size for Cygwin builds to avoid segmentation fault in limited recursive tests. +ifdef COMSPEC + uname_S := $(shell uname -s) + + ifneq (,$(findstring CYGWIN,$(uname_S))) + CXXFLAGS+=-Wl,--stack,8388608 + endif # CYGWIN +endif # COMSPEC + ifeq (g++, $(findstring g++,$(CXX))) override CXXFLAGS += -std=c++0x else ifeq (clang++, $(findstring clang++,$(CXX))) diff --git a/tools/dmake.cpp b/tools/dmake.cpp index 298cb98bf..21043cd6b 100644 --- a/tools/dmake.cpp +++ b/tools/dmake.cpp @@ -320,6 +320,16 @@ int main(int argc, char **argv) "-g"); } + fout << "# Increase stack size for Cygwin builds to avoid segmentation fault in limited recursive tests.\n" + << "ifdef COMSPEC\n" + << " uname_S := $(shell uname -s)\n" + << "\n" + << " ifneq (,$(findstring CYGWIN,$(uname_S)))\n" + << " CXXFLAGS+=-Wl,--stack,8388608\n" + << " endif # CYGWIN\n" + << "endif # COMSPEC\n" + << "\n"; + fout << "ifeq (g++, $(findstring g++,$(CXX)))\n" << " override CXXFLAGS += -std=c++0x\n" << "else ifeq (clang++, $(findstring clang++,$(CXX)))\n"