Skip to content

Commit 429d9ea

Browse files
committed
amend! mingw: rely on MSYS2's metadata instead of hard-coding it
mingw: rely on MSYS2's metadata instead of hard-coding it MSYS2 defines some helpful environment variables, e.g. `MSYSTEM`. There is code in Git for Windows to ensure that that `MSYSTEM` variable is set, hard-coding a default. However, the existing solution jumps through hoops to reconstruct the proper default, and is even incomplete doing so, as we found out when we extended it to support CLANGARM64. This is absolutely unnecessary because there is already a perfectly valid `MSYSTEM` value we can use at build time. This is even true when building the MINGW32 variant on a MINGW64 system because `makepkg-mingw` will override the `MSYSTEM` value as per the `MINGW_ARCH` array. The same is equally true for the `/mingw64`, `/mingw32` and `/clangarm64` prefix: those values are already available via the `MINGW_PREFIX` environment variable, and we just need to pass that setting through. Only when `MINGW_PREFIX` is not set (as is the case in Git for Windows' minimal SDK, where only `MSYSTEM` is guaranteed to be set correctly), we use as fall-back the top-level directory whose name is the down-cased value of the `MSYSTEM` variable. Incidentally, this also broadens the support to all the configurations supported by the MSYS2 project, i.e. clang64 & ucrt64, too. Unfortunately, this incidentally _narrows_ the support when building with CMake or Meson, but this change's benefit outweighs this downside. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 0c97bb6 commit 429d9ea

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

contrib/buildsystems/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
283283
NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
284284
USE_NED_ALLOCATOR OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
285285
HAVE_WPGMPTR HAVE_RTLGENRANDOM)
286+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x64")
287+
add_compile_definitions(ENSURE_MSYSTEM_IS_SET="MINGW64" MINGW_PREFIX="/mingw64")
288+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
289+
add_compile_definitions(ENSURE_MSYSTEM_IS_SET="CLANGARM64" MINGW_PREFIX="/clangarm64")
290+
endif()
286291
list(APPEND compat_SOURCES
287292
compat/mingw.c
288293
compat/winansi.c

0 commit comments

Comments
 (0)