一,下载源代码
方法一:根据官方文档,使用git 下载;
方法二:到github上去下载压缩好的release代码 SourceCode.zip
https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0
文档导航到:https://releases.llvm.org/12.0.0/docs/index.html
二,编译
Windows机器的内存最好大于8GB,剩余硬盘最好大于20GB
根据官网文档编译: https://clang.llvm.org/get_started.html
摘录windows部分如下:
Using Visual Studio
The following details setting up for and building Clang on Windows using Visual Studio:
- Get the required tools:
- Git. Source code control program. Get it from: https://git-scm.com/download
- CMake. This is used for generating Visual Studio solution and project files. Get it from: https://cmake.org/download/
- Visual Studio 2017 or later
- Python. It is used to run the clang test suite. Get it from: https://www.python.org/download/
- GnuWin32 tools The Clang and LLVM test suite use various GNU core utilities, such as grep, sed, and find. The gnuwin32 packages are the oldest and most well-tested way to get these tools. However, the MSys utilities provided by git for Windows have been known to work. Cygwin has worked in the past, but is not well tested. If you don't already have the core utilies from some other source, get gnuwin32 from http://getgnuwin32.sourceforge.net/.
- Check out LLVM and Clang:
- git clone https://github.com/llvm/llvm-project.git
Note: Some Clang tests are sensitive to the line endings. Ensure that checking out the files does not convert LF line endings to CR+LF. If you're using git on Windows, make sure your core.autocrlf setting is false.
- Run CMake to generate the Visual Studio solution and project files:
- cd llvm-project
- mkdir build (for building without polluting the source dir)
- cd build
- If you are using Visual Studio 2017: cmake -DLLVM_ENABLE_PROJECTS=clang -G "Visual Studio 15 2017" -A x64 -Thost=x64 ..\llvm
-Thost=x64 is required, since the 32-bit linker will run out of memory. - To generate x86 binaries instead of x64, pass -A Win32.
- See the LLVM CMake guide for more information on other configuration options for CMake.
- The above, if successful, will have created an LLVM.sln file in the build directory.
- Build Clang:
- Open LLVM.sln in Visual Studio.
- Build the "clang" project for just the compiler driver and front end, or the "ALL_BUILD" project to build everything, including tools.
- Try it out (assuming you added llvm/debug/bin to your path). (See the running examples from above.)
- See Hacking on clang - Testing using Visual Studio on Windows for information on running regression tests on Windows.