2

I've got a Clang-based project which uses MinGW (w64). I'm in the process of updating it to Clang 3.6. Apparently MinGW changed their ABI in 4.7 and Clang now uses that new ABI, so I'm updating MinGW at the same time.

However, now I'm having a slight problem. Using Clang to load the libstdc++ headers results in a great many compilation errors- particularly stuff about constant expressions never being constant. I have enabled C++14 and C++1y support.

Furthermore, I'm unable to get Clang to recognize that the target is MinGW. It seems that their triple support for MinGW was removed in 3.6 and now I don't know how to communicate to Clang that they should emit code compatible with the MinGW ABI.

How can I make Clang be compatible with MinGW w64?

Puppy
  • 144,682
  • 38
  • 256
  • 465
  • possibly helpful http://stackoverflow.com/questions/25170594/changing-compiler-from-mingw32-to-clang-in-codelite-windows-results-in-compila – OMGtechy Jul 11 '15 at 08:55
  • I've seen a few results like that, but they all apply to Clang 3.5 or earlier, which I already had successfully working. I need stuff for 3.6 specifically. – Puppy Jul 11 '15 at 09:10

1 Answers1

5

You can make clang target MinGW-w64 via -target, i.e.:

$ clang -v 2>&1|grep Target
Target: i386-pc-windows-cygnus

$ clang -target i686-w64-mingw32 -v 2>&1|grep Target
Target: i686-w64-windows-gnu

Simply renaming the clang executable to i686-w64-mingw32-clang++.exe may also do what you want.

Thomas
  • 3,074
  • 1
  • 25
  • 39
  • It took an excessively long time, but my tests indicate that this solution resolved 9 of my 22 problematic tests. I will comment further and possibly accept this answer once I've looked at the remaining 13 failures. – Puppy Jul 11 '15 at 20:05
  • I've investigated my remaining tests and fixed most of them. There is no reason for me to conclude the remainder are broken for any Clang-MinGW compatibility reason. Therefore, I will accept this as the correct solution. – Puppy Jul 12 '15 at 16:21
  • Does the `-target x86_64-w64-mingw32` actually uses MinGW64? or there is `-target x86_64-w64-mingw64`? – Royi Apr 09 '18 at 07:29