CMake no longer excludes libgcc_eh from the implicit link libraries
Commit d59e3509 removed gcc.*
from the list of filtered implicit link libraries. This causes CMake to add -lgcc_eh
to the linker flags when compiling a mixed C/C++ project on mingw, which means libgcc_eh.a
is statically linked into every binary. This means that each dll has its own copy of exception handling and TLS code, which can cause problems (see https://public.kitware.com/pipermail/cmake/2017-August/066128.html for an example). In addition, the GCC developers recommend against having multiple copies of libgcc_eh at runtime (see https://gcc.gnu.org/ml/gcc/2012-03/msg00104.html).
As a workaround, adding list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_LIBRARIES gcc_eh)
will stop it from being implicitly linked.
gcc_eh.*
should be added to the list of filtered implicit link libraries to fix this problem.