bgfx icon indicating copy to clipboard operation
bgfx copied to clipboard

Mingw-clang

Open jazzbre opened this issue 7 years ago • 16 comments

Just a query, is Windows mingw-clang actually compilable (which would be awesome by the way) or is this still experimental? Because I tried it but I couldn't get it to compile.

Here's a sample output:

c:\My Projects\Research\bgfx\.build\projects\gmake-mingw-clang>c:\LLVM/bin/clang++    -MMD -MP -MP -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -D_DEBUG -DWIN32 -DMINGW_HAS_SECURE_API=1 -I../../../../bx/include/compat/mingw -I../../../../bx/include   -Wall -Wextra -fomit-frame-pointer -g -m32 -fno-rtti -fno-exceptions -Wunused-value -fdata-sections -ffunction-sections -msse2 -Wundef -isystemc:\TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++ -isystemc:\TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32 -isystemc:\TDM-GCC-64/x86_64-w64-mingw32/include -m32 -std=c++11  -o "../../win32_mingw-clang/obj/x32/Debug/bx/bx/src/bx.o" -c "../../../../bx/src/bx.cpp
In file included from ../../../../bx/src/bx.cpp:6:
In file included from ../../../../bx/include\bx/debug.h:9:
In file included from ../../../../bx/include\bx/bx.h:9:
In file included from ../../../../bx/include/compat/mingw\alloca.h:4:
c:\TDM-GCC-64/x86_64-w64-mingw32/include\malloc.h:147:28: error: use of undeclared identifier '_ALLOCA_S_MARKER_SIZE'
      _Ptr = (char*)_Ptr + _ALLOCA_S_MARKER_SIZE;
                           ^
c:\TDM-GCC-64/x86_64-w64-mingw32/include\malloc.h:166:34: error: use of undeclared identifier '_ALLOCA_S_MARKER_SIZE'
      _Memory = (char*)_Memory - _ALLOCA_S_MARKER_SIZE;
                                 ^
In file included from ../../../../bx/src/bx.cpp:6:
In file included from ../../../../bx/include\bx/debug.h:9:
In file included from ../../../../bx/include\bx/bx.h:12:
c:\TDM-GCC-64/x86_64-w64-mingw32/include\stdlib.h:306:47: error: expected ';' after top level declarator
  void __cdecl __MINGW_NOTHROW exit(int _Code) __MINGW_ATTRIB_NORETURN;

Thanks!

jazzbre avatar Apr 13 '17 17:04 jazzbre

It compiled at some point, but I didn't test it in long time.

bkaradzic avatar Apr 13 '17 21:04 bkaradzic

Alright, which mingw repo did yo use? http://tdm-gcc.tdragon.net?

jazzbre avatar Apr 14 '17 05:04 jazzbre

Yes TDM. But this is probably more important, this clang: http://llvm.org/builds/ (it can work with both MSVC or MinGW runtime)

bkaradzic avatar Apr 14 '17 05:04 bkaradzic

Wait, is this any different to http://releases.llvm.org/4.0.0/LLVM-4.0.0-win64.exe which I installed? Oh, that snapshot build is LLVM 5.0... but still the same error. I've tried both 32 & 64 bit installs.

jazzbre avatar Apr 14 '17 06:04 jazzbre

@bkaradzic do you remember maybe exactly which LLVM version you used to test this?

jazzbre avatar Apr 16 '17 11:04 jazzbre

One that's in VS plugin: https://github.com/bkaradzic/bx/blob/master/scripts/toolchain.lua#L89

If you can genie --vs=vs2015-clang you should use the same LLVM to do mingw-clang

bkaradzic avatar Apr 16 '17 17:04 bkaradzic

Alright, did a test with llvm 3.9 and vs2015-clang does indeed work but mingw still doesn't compile.

jazzbre avatar Apr 18 '17 16:04 jazzbre

Can you post some of errors?

bkaradzic avatar Apr 18 '17 16:04 bkaradzic

They are the same ones posted above basically.

jazzbre avatar Apr 18 '17 16:04 jazzbre

I'll post full error dump tomorrow.

jazzbre avatar Apr 18 '17 17:04 jazzbre

  • Freshly cloned bx, bgfx, bimg
  • Installed http://releases.llvm.org/3.9.0/LLVM-3.9.0-win64.exe
  • Run:
set PATH=%PATH%;..\gnumake
set MINGW=c:\TDM-GCC-64
set CLANG=c:\LLVM
..\bx\tools\bin\windows\genie --with-examples --gcc=mingw-clang gmake
make mingw-clang-debug64

Here's the full output: clang_mingw_error_output.txt

jazzbre avatar Apr 19 '17 07:04 jazzbre

This part:

In file included from ../../../../bx/include\bx/bx.h:15:
../../../../bx/include\bx/platform.h:158:51: warning: '_USING_V110_SDK71_' is not defined, evaluates to 0 [-Wundef]
#       if defined(_MSC_VER) && (_MSC_VER >= 1700) && (!_USING_V110_SDK71_)
                                                        ^

suggests that _MSC_VER is defined and that clang might think it's compiling for MSVC... This definitely wasn't case when I built with it.

bkaradzic avatar Apr 19 '17 07:04 bkaradzic

Ok, finally figured out how to get mingw & clang work together with LLVM 4.0. You just have to add: -target x86_64-w64-mingw32 to all clang calls. Didn't have time to try bgfx with it yet thought.

jazzbre avatar Jun 22 '17 18:06 jazzbre

I have compiled bgfx with mingw clang toolchain. It needs some tiny fixes. Would you like to accept those patches? If possible I can try to add some GitHub Actions so that you don't have to test the build manually.

Biswa96 avatar Sep 17 '22 15:09 Biswa96

It needs some tiny fixes. Would you like to accept those patches?

Sure.

If possible I can try to add some GitHub Actions so that you don't have to test the build manually.

I would like to have GH actions for other targets too. You should come to Discord chat to discuss this further.

bkaradzic avatar Sep 17 '22 17:09 bkaradzic

I think this issue can be closed. mingw-clang target can be built successfully.

Biswa96 avatar Sep 19 '22 07:09 Biswa96