GHA: Fix CMake tests on MinGW

The runners have MinGW installed in 2 locations:
- C:\Program Files\Git\mingw64 uses msvcrt.dll and ucrtbase.dll
- C:\mingw64 uses only (the new) ucrtbase.dll

CMake is using the compiler from C:\mingw64 but at runtime it is still loading the
`libstdc++-6.dll` from the Git-MinGW as it is started from the Git bash.

This causes conflicts with functions compiled into the executable and those used by the runtime.
Most notably the string from `abi::__cxa_demangle` is allocated on a different heap
so freeing it with `free` called from the executable corrupts the heap leading to a SIGSEGV / Exit code 0xc0000374 in the tests.

B2 doesn't suffer from this as it modifies `$PATH` when running each test such that the right libraries are used.
Do it similarly in the GHA-CI config.
This commit is contained in:
Alexander Grund 2026-07-03 17:49:07 +02:00
parent 888cdde37a
commit 64fa700f2d
No known key found for this signature in database
GPG key ID: AA48A0760367A42B

View file

@ -226,7 +226,14 @@ jobs:
extra_args+=(-G "${{matrix.generator}}") extra_args+=(-G "${{matrix.generator}}")
fi fi
if [[ "${{matrix.generator}}" == "MinGW"* ]]; then if [[ "${{matrix.generator}}" == "MinGW"* ]]; then
# Avoid "Fatal error: can't write 1214 bytes to section .text of [...] 'file too big' [...] too many sections"
extra_args+=(-DCMAKE_CXX_FLAGS="-Wa,-mbig-obj") extra_args+=(-DCMAKE_CXX_FLAGS="-Wa,-mbig-obj")
# GHA has 2 MinGWs installed which must not be mixed,
# so make sure the executables pick up the libraries/DLLs matching the compiler
gcc_folder=$(dirname "$(which g++)")
prefix=${gcc_folder%/bin}
echo "GCC prefix: $prefix"
export PATH="$prefix/bin:$prefix/lib:$PATH"
fi fi
if [[ -n $B2_CXXFLAGS ]]; then if [[ -n $B2_CXXFLAGS ]]; then
extra_args+=(-DCMAKE_CXX_FLAGS="$B2_CXXFLAGS") extra_args+=(-DCMAKE_CXX_FLAGS="$B2_CXXFLAGS")
@ -242,7 +249,7 @@ jobs:
if [[ -n "$CXX_STD" ]]; then if [[ -n "$CXX_STD" ]]; then
extra_args+=(-DCMAKE_CXX_STANDARD="$CXX_STD") extra_args+=(-DCMAKE_CXX_STANDARD="$CXX_STD")
fi fi
echo "Using extra args: ${extra_args[*]}" set +x
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBoost_ROOT="$BOOST_ROOT/stage" "${extra_args[@]}" -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON cmake .. -DCMAKE_BUILD_TYPE=Debug -DBoost_ROOT="$BOOST_ROOT/stage" "${extra_args[@]}" -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON
cmake --build . --config Debug --parallel 3 cmake --build . --config Debug --parallel 3
ctest --output-on-failure --build-config Debug ctest --output-on-failure --build-config Debug