简体   繁体   中英

Getting LLVM and Clang from downloaded sources and Visual Studio 2013

I just downloaded the sources of LLVM and Clang as compressed files.

The files I have so far are:

  • cfe-3.5.0.src.tar
  • compiler-rt-3.5.0.src.tar
  • libcxx-3.5.0.src.tar
  • libcxxabi-3.5.0.src.tar
  • llvm-3.5.0.src.tar

I need to configure LLVM and Clang using Windows 8.1 using Visual Studio 2013.

I ask this question because the tutorials I have consulted so far uses svn, but having the sources from compressed files I not have a clear vision of what should be the directory tree in order to cmake work properly.

The directory structure should be:

llvm/
  projects/
    compiler-rt/
    libcxx/
    libcxxabi/
  tools/
    clang/

I'm not sure how far along libc++ support for Windows is, as I just use MSVC's implementation for ABI compatibility.

Compiling llvm framework (llvm, clang, libc++, etc...) with Visual Studio 2013 is not so dificult.

  1. Download the sources
  2. Descompress the sources
  3. Move the decompressed folders to their place in the llvm source tree. (ex: cfe-version goes in llvm\\tools directory with name clang. This king of info could be obtained from the CMakeFile.txt files (ex: add_llvm_external_project(clang) in the file `llvm\\tools\\CMakeFile.txt). The CMakeFile.txt are the files that instruct cmake program how to generate the projects (ex: Makefile, VS projects, XCode projects... for compile llvm)
  4. Create a directory where to save the vs2013 projects
  5. Generate the VS2013 projects (ex: being inside the previous directory execute: cmake llvm_sources -G "Visual Studio 12" where llvm_sources is the root directory of the llvm sources.
  6. Open the project and compile (could take long to compile 30min or more)

Notes: some projects (ex: lldb) could need additional dependencies (ex: python c headers for bindings).

One of the problems of clang when compiling from sources is that the directory path of the include headers that clang use (ex: std library headers), are fixed in the source code in: llvm\\tools\\clang\\lib\\FrontEnd\\InitHeaderSearch.cpp , in the case of compiling llvm with VS2013, by default it use the MS std headers.

Compiling almost every mid size program with clang using the MS header would give you error with MS extensions not supported yet by clang, with non-conforming c++ (that vc++ accept as valid) and other sort of problems, this is the case of various libraries of boost also (when using the MS headers).

Better success history for me was compile using this same procedure with MinGW for windows and using the MinGW headers. In this case most probably need to modify by hand the HeaderSearch file for clang to search for the header (the last versions of clang don't have search path for the last versions of gcc, at least in the stable version 3.5.0).

Using this method, I successfully compile clang 3.5.0 with MinGW with GCC 4.9.1 in Windows 8.1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM