[cfe-dev] Building with mingw64 on Windows issue

Maarten Verhage via cfe-dev cfe-dev at lists.llvm.org
Sat Dec 8 10:27:10 PST 2018


Hi Martin,

Thanks a lot for your advice. I really appreciate that you specifically 
address the situation that I was describing in your post. I don't see that 
very often on forums. Sorry for the delay in my reply. I was busy with 
another project.



> Hi Maarten,
>
> On Fri, 30 Nov 2018, Maarten Verhage wrote:
>
>> Hi Martin,
>>
>>> On Wed, 28 Nov 2018, Maarten Verhage via cfe-dev wrote:
>>>
>>>> Ok, my desire is to be able to build the LLVM/clang system with mingw64
>>>> on
>>>> Windows 7, 64bit.
>
> Btw, if your intent with this is just to have a setup of LLVM/clang with
> mingw64 headers/libs, you can download the prebuilt toolchains from
> https://github.com/mstorsjo/llvm-mingw/releases. If the intent is to be
> able to build it all from scratch yourself, let's keep digging.
>

Yes, I would like to go for the digging approach :)

>>>> I’m currently stuck on an error that the shared library
>>>> c++abi cannot be found. Below is shown how I got there.
>>>> I wasn’t able to find build guidelines specific for mingw64. But left 
>>>> to
>>>> my
>>>> own devices I believe I made some progress.
>>>
>>> FWIW, I regularly compile libcxx/libcxxabi for mingw, mainly with clang 
>>> as
>>> a cross compiler from linux though, but the same build process also 
>>> mostly
>>> works on msys/mingw.
>>>
>>> I don't build libcxx/libcxxabi as part of the main llvm build, but I 
>>> build
>>> them standalone outside of this, when I have clang set up as a cross
>>> compiler (building them for a number of different architectures). Here's
>>> the script I use for building that:
>>> https://github.com/mstorsjo/llvm-mingw/blob/master/build-libcxx.sh
>>>
>>> I'm told it's supposed to be possible to cross-build the runtime 
>>> libraries
>>> inside of the llvm tree with the newly built clang as cross compiler, 
>>> but
>>> I haven't tried to figure out how to make this work for my setup yet.
>>
>> Thanks for sharing your advice as well as that build script. I’m able to
>> copy-and-paste the relevant portions to make progress in building 
>> llvm/clang
>> in the windows command prompt.
>>
>> First I tried to build llvm with clang in the tools folder but with an 
>> empty
>> projects folder. This failed because mingw64 gcc-8.1.0 doesn’t have 
>> support
>> for std::mutex. But libcxx does contain std::mutex so I decided to get
>> libcxx to build before this. As libcxx needs to link against libcxxabi I
>> decided to build libcxxabi first.
>
> Ah, I see.
>
> So in this case, you're intending to amend your mingw64 gcc-8.1.0 with
> libcxx in order to be able to build LLVM.
>
> I'm not sure if anybody else actually has tested libcxx on windows with
> gcc. (In practice it probably shouldn't be impossible to fix in case it
> doesn't work though, I think.)
>
> The common remedy to this would be to use a gcc/libstdc++ setup that uses
> winpthreads as threading backend for libstdc++.With such a gcc/libstdc++,
> it's rather straightforward to build llvm+clang. Based on quotes, it looks
> like you're using an installer from
> https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/
> somewhere. If you pick threads-posix instead of threads-win32 you should
> be all set.

Yes, good idea. Going for x86_64-8.1.0-release-posix-seh-rt_v6-rev0! Also I 
did realize I made a mistake in my windows command prompt script. The reason 
it wasn't able to find std::mutex was that I didn't specify the include 
folders for the gcc includes. The header file mutex certainly is present in 
the mingw64 folder tree. It is also present in the win32 threads variant so 
I might try that too, when I see the posix variant is building LLVM/clang 
correctly.

Currently I'm just going for builing LLVM/clang with an empty projects 
folder.

set 
gcc_include_path=../../x86_64-8.1.0-release-posix-seh-rt_v6-rev0/mingw64\lib\gcc\x86_64-w64-mingw32\8.1.0\include
cmake -G "MinGW Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_SYSTEM_NAME=Windows ^
-DCMAKE_CXX_FLAGS="-I%gcc_include_path% -I%gcc_include_path%\c++ -D_WIN32_WINNT=0x0600" 
^
-S C:\dev\llvm -B T:\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\build 
 > cmake_result.txt 2>&1
pause

Then:
mingw32-make --directory=T:\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\build 
 -f Makefile > build_result.txt 2>&1
pause

It builds a fair bit more. I wasn't sure if previous attempts did make the 
folder: T:\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\mingw64\build\NATIVE. 
But at least this is what I see now.

But as I'm now stuck at:
No rule to make target 'NATIVE/bin/llvm-tblgen', needed by 
'include/llvm/IR/Attributes.inc.tmp'.  Stop.

seen on the end of the build_result.txt file. I find it hard to decide what 
I could try next. The reason is that I'm missing a bit of a "build 
rationale". With that I mean some documentation that explains in general 
terms how the building process is designed. In it I hope to learn the reason 
for the NATIVE folder, what it contains and what llvm-tblgen.exe is designed 
to do. With that understanding I'm able to make an educated guess to try to 
set a define that might solve the specific issue I'm facing now with that 
"No rule to make target "

Would there be some documentation on that topic on the internet or are you 
willing to explain this to me? I'd love to learn.

Best regards,
Maarten Verhage 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: build_result.txt
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181208/de2d3b1e/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cmake_result.txt
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181208/de2d3b1e/attachment-0001.txt>


More information about the cfe-dev mailing list