Skip to content

Build under MSYS2 failed #9968

@GT-610

Description

@GT-610

⚠️ 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:

  1. The bluegl library requires the MASM assembler (ml/ml64.exe) which is not available under MSYS2.
  2. 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

  1. Install MSYS2 with the UCRT64 environment:

    pacman -S mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-clang cmake ninja
  2. Clone Filament and configure:

    cmake -B build -G Ninja \
      -DCMAKE_C_COMPILER=clang \
      -DCMAKE_CXX_COMPILER=clang++

    Configuration succeeds.

  3. Build:

    cmake --build 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.

Metadata

Metadata

Assignees

Labels

buildBuild & build system issueslow priorityLow priority issuewindowsIssue/feature request for Windows only

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions