⚠️ Issues not using this template will be systematically closed.
Describe the bug
Filament cannot be built under MSYS2 (MinGW-w64) on Windows. While CMake configuration succeeds, the build fails at compile time due to:
- The bluegl library requires the MASM assembler (
ml/ml64.exe) which is not available under MSYS2.
- Several source files use
#if defined(WIN32) guards which are not triggered because MinGW Clang does not define the WIN32 macro (only _WIN32). This causes the wrong code paths to be taken throughout the codebase.
To Reproduce
-
Install MSYS2 with the UCRT64 environment:
pacman -S mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-clang cmake ninja
-
Clone Filament and configure:
cmake -B build -G Ninja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++
Configuration succeeds.
-
Build:
Build fails with multiple errors.
Expected behavior
Filament should either:
- Support building with MinGW-w64 (MSYS2) toolchains, or
- Explicitly reject MinGW at the compiler check stage with a clear error message.
Screenshots
N/A
Logs
--- bluegl: MASM assembler missing ---
[1/4] Building ASM_MASM object libs/bluegl/CMakeFiles/bluegl.dir/src/BlueGLCoreWindowsImpl.S.obj
FAILED: libs/bluegl/CMakeFiles/bluegl.dir/src/BlueGLCoreWindowsImpl.S.obj
ml ... -c -Fo ... D:/filament/libs/bluegl/src/BlueGLCoreWindowsImpl.S
CreateProcess failed: The system cannot find the file specified.
--- CallStack.cpp: execinfo.h not found (WIN32 not defined by MinGW Clang) ---
libs/utils/src/CallStack.cpp:31:10: fatal error: 'execinfo.h' file not found
31 | #include <execinfo.h>
--- memalign.h: posix_memalign not found (WIN32 not defined by MinGW Clang) ---
libs/utils/include/utils/memalign.h:43:14: error: no member named 'posix_memalign' in the global namespace
43 | (void) ::posix_memalign(&p, align, size);
--- ashmem.cpp: MSVC-specific CRT functions not available ---
libs/utils/src/ashmem.cpp:155:35: error: cannot initialize a parameter of type 'wchar_t *'
155 | const char* tmpPath = _mktemp(template_path);
libs/utils/src/ashmem.cpp:156:29: error: use of undeclared identifier '_O_BINARY'
156 | int fd = _open(tmpPath, _O_BINARY);
libs/utils/src/ashmem.cpp:159:9: error: use of undeclared identifier '_chsize'
159 | if (_chsize(fd, size) == -1) {
Desktop (please complete the following information):
- OS: Windows 11 64-bit (MSYS2 UCRT64)
- GPU: NVIDIA GeForce RTX 4060 Max-Q (8GB VRAM)
- Backend: Vulkan
Additional context
Root cause: WIN32 vs _WIN32
Under MSVC, the compiler defines WIN32. Under MinGW Clang, only _WIN32, __WIN32, and __WIN32__ are defined — WIN32 (without underscore) is NOT defined:
$ echo 'int x;' | clang++ -std=c++20 -dM -E -x c++ - | grep -i win32
#define _WIN32 1
#define __WIN32 1
#define __WIN32__ 1
Filament uses #if defined(WIN32) in multiple places. Under MinGW these guards silently fail, causing the code to take Unix/POSIX code paths:
| File |
Guard |
Effect |
libs/utils/include/utils/memalign.h:40 |
#if defined(WIN32) |
Falls through to posix_memalign() which MinGW does not provide |
libs/utils/src/CallStack.cpp:30 |
#if !defined(WIN32) |
Includes <execinfo.h> (glibc-only) instead of using the Windows stub |
libs/utils/src/ashmem.cpp:150 |
(implicit via WIN32) |
Takes the MSVC CRT branch (_mktemp, _chsize) instead of the POSIX branch (mkstemp) |
filament/backend/src/opengl/platforms/PlatformWGL.cpp:21 |
#ifdef _MSC_VER |
FILAMENT_PLATFORM_WGL is not defined for MinGW |
bluegl MASM requirement
libs/bluegl/CMakeLists.txt:13-16 enables MASM on 64-bit Windows:
if (WIN32 AND IS_64_BIT)
enable_language(ASM_MASM)
set_property(SOURCE src/BlueGLCoreWindowsImpl.S PROPERTY LANGUAGE ASM_MASM)
endif()
CMake finds a virtual ml entry but the binary does not exist in MSYS2, so it fails at build time with CreateProcess failed.
Why build on MSYS2?
I'm porting a cross-platform project to Windows, and the author made a MSYS2 build script. While it's possible to use MSVC to build the whole project, the build process just got failed on Filament, and other libraries have no issues.
Describe the bug
Filament cannot be built under MSYS2 (MinGW-w64) on Windows. While CMake configuration succeeds, the build fails at compile time due to:
ml/ml64.exe) which is not available under MSYS2.#if defined(WIN32)guards which are not triggered because MinGW Clang does not define theWIN32macro (only_WIN32). This causes the wrong code paths to be taken throughout the codebase.To Reproduce
Install MSYS2 with the UCRT64 environment:
Clone Filament and configure:
Configuration succeeds.
Build:
Build fails with multiple errors.
Expected behavior
Filament should either:
Screenshots
N/A
Logs
--- bluegl: MASM assembler missing ---
--- CallStack.cpp: execinfo.h not found (WIN32 not defined by MinGW Clang) ---
--- memalign.h: posix_memalign not found (WIN32 not defined by MinGW Clang) ---
--- ashmem.cpp: MSVC-specific CRT functions not available ---
Desktop (please complete the following information):
Additional context
Root cause:
WIN32vs_WIN32Under MSVC, the compiler defines
WIN32. Under MinGW Clang, only_WIN32,__WIN32, and__WIN32__are defined —WIN32(without underscore) is NOT defined:Filament uses
#if defined(WIN32)in multiple places. Under MinGW these guards silently fail, causing the code to take Unix/POSIX code paths:libs/utils/include/utils/memalign.h:40#if defined(WIN32)posix_memalign()which MinGW does not providelibs/utils/src/CallStack.cpp:30#if !defined(WIN32)<execinfo.h>(glibc-only) instead of using the Windows stublibs/utils/src/ashmem.cpp:150_mktemp,_chsize) instead of the POSIX branch (mkstemp)filament/backend/src/opengl/platforms/PlatformWGL.cpp:21#ifdef _MSC_VERFILAMENT_PLATFORM_WGLis not defined for MinGWbluegl MASM requirement
libs/bluegl/CMakeLists.txt:13-16enables MASM on 64-bit Windows:CMake finds a virtual
mlentry but the binary does not exist in MSYS2, so it fails at build time withCreateProcess failed.Why build on MSYS2?
I'm porting a cross-platform project to Windows, and the author made a MSYS2 build script. While it's possible to use MSVC to build the whole project, the build process just got failed on Filament, and other libraries have no issues.