Skip to content

Commit cdc47da

Browse files
authored
Use UCRT-based mingw-w64 GCC toolchain on Windows (#2171)
* Avoid mingw-w64 GCC linker compatibility issues(?) with lld
1 parent 3b404b6 commit cdc47da

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

.evergreen/generated_configs/legacy-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ functions:
139139
set -o errexit
140140
# Build libmongoc with CMake and compile a program that links
141141
# dynamically to it, using variables from pkg-config.exe.
142+
"PATH="/cygdrive/c/ProgramData/chocolatey/lib/winlibs/tools/mingw64/bin:${PATH:-}" # mingw-w64 GCC
142143
cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw.cmd
143144
link sample program MSVC bson:
144145
- command: shell.exec
@@ -165,6 +166,7 @@ functions:
165166
set -o errexit
166167
# Build libmongoc with CMake and compile a program that links
167168
# dynamically to it, using variables from pkg-config.exe.
169+
"PATH="/cygdrive/c/ProgramData/chocolatey/lib/winlibs/tools/mingw64/bin:${PATH:-}" # mingw-w64 GCC
168170
cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw-bson.cmd
169171
update codecov.io:
170172
- command: shell.exec

.evergreen/legacy_config_generator/evergreen_config_lib/functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
r"""
158158
# Build libmongoc with CMake and compile a program that links
159159
# dynamically to it, using variables from pkg-config.exe.
160+
"PATH="/cygdrive/c/ProgramData/chocolatey/lib/winlibs/tools/mingw64/bin:${PATH:-}" # mingw-w64 GCC
160161
cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw.cmd
161162
""",
162163
)
@@ -185,6 +186,7 @@
185186
r"""
186187
# Build libmongoc with CMake and compile a program that links
187188
# dynamically to it, using variables from pkg-config.exe.
189+
"PATH="/cygdrive/c/ProgramData/chocolatey/lib/winlibs/tools/mingw64/bin:${PATH:-}" # mingw-w64 GCC
188190
cmd.exe /c .\\.evergreen\\scripts\\link-sample-program-mingw-bson.cmd
189191
""",
190192
)

.evergreen/scripts/compile-windows.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,19 @@ build_dir="cmake-build"
8484
find_ccache_and_export_vars "$(pwd)" || true
8585

8686
if [[ "${CC}" =~ 'gcc' ]]; then
87+
PATH="/cygdrive/c/ProgramData/chocolatey/lib/winlibs/tools/mingw64/bin:${PATH:-}" # mingw-w64 GCC
88+
8789
export CMAKE_GENERATOR="Ninja"
8890

8991
# MinGW has trouble compiling src/cpp-check.cpp without some assistance.
9092
configure_flags_append "-DCMAKE_CXX_STANDARD=11"
9193

92-
cmake \
93-
-S . \
94-
-B "${build_dir:?}" \
95-
-G "Ninja" \
96-
"${configure_flags[@]}" \
97-
"${extra_configure_flags[@]}"
94+
# mingw-w64 doesn't like lld (hangs indefinitely?).
95+
configure_flags_append "-DMONGO_USE_LLD=OFF"
96+
97+
cmake "${configure_flags[@]}" "${extra_configure_flags[@]}" -B "${build_dir:?}"
9898

99-
cmake --build "${build_dir:?}"
100-
cmake --build "${build_dir:?}" --target mongo_c_driver_tests
101-
cmake --build "${build_dir:?}" --target mongo_c_driver_examples
99+
cmake --build "${build_dir:?}" --target all mongo_c_driver_tests mongo_c_driver_examples
102100
else
103101
# MSBuild task-based parallelism (VS 2019 16.3 and newer).
104102
export UseMultiToolTask=true

.evergreen/scripts/link-sample-program-mingw-bson.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set version=1.31.0
2525
cd %BUILD_DIR% || goto :error
2626

2727
rem Build libmongoc, with flags that the downstream R driver mongolite uses
28-
uvx cmake -G "Ninja" DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_C_FLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DENABLE_STATIC=ON .. || goto :error
28+
uvx cmake -G "Ninja" -DMONGO_USE_LLD=OFF -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_C_FLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake -DENABLE_STATIC=ON .. || goto :error
2929
uvx cmake --build . --parallel || goto :error
3030
uvx cmake --build . --target install || goto :error
3131

.evergreen/scripts/link-sample-program-mingw.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set major=1
2525
cd %BUILD_DIR% || goto :error
2626

2727
rem Build libmongoc, with flags that the downstream R driver mongolite uses
28-
uvx cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_C_FLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %CMAKE_FLAGS% .. || goto :error
28+
uvx cmake -G "Ninja" -DMONGO_USE_LLD=OFF -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_C_FLAGS="-pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %CMAKE_FLAGS% .. || goto :error
2929
uvx cmake --build . --parallel || goto :error
3030
uvx cmake --build . --target install || goto :error
3131

0 commit comments

Comments
 (0)