diff --git a/CMakeLists.txt b/CMakeLists.txt index ae57d5b2f4..aa9bfcad9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,7 +197,11 @@ elseif (WIN32) message(STATUS "Platform: Windows") list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_WINDOWS") # workaround for #7420 - list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR") + list(APPEND Z3_COMPONENT_CXX_DEFINES "-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR") + # dbghelp is used in debug.cpp for stack backtraces on Windows. + # With MSVC this is handled by #pragma comment(lib, "dbghelp.lib") in debug.cpp, + # but MinGW does not support that pragma, so we add it explicitly here. + list(APPEND Z3_DEPENDENT_LIBS dbghelp) elseif (EMSCRIPTEN) message(STATUS "Platform: Emscripten") list(APPEND Z3_DEPENDENT_EXTRA_CXX_LINK_FLAGS diff --git a/src/util/debug.cpp b/src/util/debug.cpp index 4a2141c024..a95b8358d4 100644 --- a/src/util/debug.cpp +++ b/src/util/debug.cpp @@ -39,7 +39,9 @@ bool assertions_enabled() { #if defined(_WINDOWS) #include #include +#ifdef _MSC_VER #pragma comment(lib, "dbghelp.lib") +#endif static void print_windows_backtrace() { HANDLE process = GetCurrentProcess(); SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME);