This results in a build failure of LLVM/Clang with:
--- How to re-produce
$ git clone https://git.llvm.org/git/llvm.git/
$ cd llvm/tools
$ git clone https://git.llvm.org/git/clang.git/
$ cd ../..
$ mkdir llvm-build
$ cd llvm-build
$ cmake -G "MinGW Makefiles" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=..\llvm-install ..\llvm
$ mingw32-make.exe -j4 install-libclang install-libclang-headers install-clang-headers install-llvm-config
The build process includes building a tool llvm-tblgen.exe and then calling
it to build other artefacts. If I understand correctly, llvm-tblgen.exe is
miscompiled and crashes at run time as can be seen from the log [4] below
(paths are slightly different than for the recipe above).
[1] LLVM/Clang build failure bug report: https://bugs.llvm.org/show_bug.cgi?id=32018
[2] GCC bug about a miscompilation that is possibly related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78936
[3] LLVM/Clang changes that workaround the miscompilation: https://reviews.llvm.org/rL310905 https://reviews.llvm.org/rL310994
[4] Crash of llvm-tblgen.exe when building LLVM/Clang:
"""
mingw32-make.exe[3]: Entering directory 'D:/dev/llvm/4.0/builds/mingw492'
[ 26%] Building X86GenSubtargetInfo.inc...
cd /d D:\dev\llvm\4.0\builds\mingw492\lib\Target\X86 && ......\bin\llvm-tblgen.exe -gen-subtarget -I D:/dev/llvm/
4.0/source/lib/Target/X86 -I D:/dev/llvm/4.0/source/include -I D:/dev/llvm/4.0/source/lib/Target D:/dev/llvm/4.0/so
urce/lib/Target/X86/X86.td -o D:/dev/llvm/4.0/builds/mingw492/lib/Target/X86/X86GenSubtargetInfo.inc.tmp
Wrote crash dump file "C:\Users\nik\AppData\Local\Temp\llvm-tblgen.exe-447764.dmp"
0x005382D2 (0x0840D550 0x086F8D10 0x086FB358 0x086FCA50)
0x0840D4FC (0x0162FD60 0x034B263C 0x0000000D 0x00000000) <unknown module="">
0x004CF3D5 (0x017B8F30 0x0000000B 0x00152AD0 0x00000000)
0x77666D3C (0x00000001 0x00000000 0x00000001 0x0162FE14), LdrLoadDll() + 0x91 bytes(s)
0x7634D076 (0x00152AD0 0x004D2620 0x005B8E9A 0x00000000), GetProcAddressForCaller() + 0x47 bytes(s)
0x0059D6C1 (0x0000000B 0x00152A98 0x00151730 0x00000000)
0x004013DE (0x7FFDE000 0x0162FFD4 0x7766BD99 0x7FFDE000)
0x767F86E3 (0x7FFDE000 0xC3825040 0x00000000 0x00000000), BaseThreadInitThunk() + 0xE bytes(s)
0x7766BD99 (0x004014E0 0x7FFDE000 0xFFFFFFFF 0x776E220F), RtlInitializeExceptionChain() + 0x85 bytes(s)
0x7766BD6C (0x004014E0 0x7FFDE000 0x00000000 0x3D3D2F2F), RtlInitializeExceptionChain() + 0x58 bytes(s)
lib\Target\X86\CMakeFiles\X86CommonTableGen.dir\build.make:704: recipe for target 'lib/Target/X86/X86GenSubtargetIn
fo.inc.tmp' failed
mingw32-make.exe[3]: *** [lib/Target/X86/X86GenSubtargetInfo.inc.tmp] Error -1073741819
mingw32-make.exe[3]: *** Deleting file 'lib/Target/X86/X86GenSubtargetInfo.inc.tmp'
mingw32-make.exe[3]: Leaving directory 'D:/dev/llvm/4.0/builds/mingw492'
CMakeFiles\Makefile2:4430: recipe for target 'lib/Target/X86/CMakeFiles/X86CommonTableGen.dir/all' failed
mingw32-make.exe[2]: *** [lib/Target/X86/CMakeFiles/X86CommonTableGen.dir/all] Error 2
mingw32-make.exe[2]: Leaving directory 'D:/dev/llvm/4.0/builds/mingw492'
CMakeFiles\Makefile2:12530: recipe for target 'tools/clang/tools/libclang/CMakeFiles/install-libclang.dir/rule' fai
led
mingw32-make.exe[1]: *** [tools/clang/tools/libclang/CMakeFiles/install-libclang.dir/rule] Error 2
mingw32-make.exe[1]: Leaving directory 'D:/dev/llvm/4.0/builds/mingw492'
makefile:3121: recipe for target 'install-libclang' failed
mingw32-make.exe: *** [install-libclang] Error 2
"""</unknown>
As I can see this bug is occurs in the llvm-tblgen.exe proc. Can you please rebuild clang as release+debug_info and debug it?
And, this bug also occurs when MinGW-W64-7.1/7.2 is used?
Also, please provide the full link to the MinGW-W64-GCC build used.
Correction to the "Get the LLVM/Clang sources" section above: You need also to
"git checkout release_40" after the git clone command.
Correct.
I cannot reproduce with i686-7.2.0-posix-dwarf-rt_v5-rev0, which I've installed
with mingw-w64-install.exe. I've still provided the stack strace below for
reference.
I don't have that link as I've installed with mingw-w64-install.exe
Sure.
To build llvm-tblgen in release+debug_info I've applied the patch [1] below.
The compiler invocations did look fine (... -O2 -g -DNDEBUG ...).
Note that this is with i686-4.9.3-posix-dwarf-rt_v4-rev1 since I don't have
4.9.2 around.
See gdb output [2].
[1] Patch to build llvm-tblgen in release+debuginfo mode.
[2] gdb output
del