Getting Started with the LLVM System using Microsoft Visual Studio¶
Overview¶
Welcome to LLVM on Windows! This document only covers LLVM on Windows using Visual Studio, not mingw or cygwin. In order to get started, you first need to know some basic information.
There are many different projects that compose LLVM. The first piece is the LLVM suite. This contains all of the tools, libraries, and header files needed to use LLVM. It contains an assembler, disassembler, bitcode analyzer and bitcode optimizer. It also contains basic regression tests that can be used to test the LLVM tools and the Clang front end.
The second piece is the Clang front end. This component compiles C, C++, Objective C, and Objective C++ code into LLVM bitcode. Clang typically uses LLVM libraries to optimize the bitcode and emit machine code. LLVM fully supports the COFF object file format, which is compatible with all other existing Windows toolchains.
The last major part of LLVM, the execution Test Suite, does not run on Windows, and this document does not discuss it.
Additional information about the LLVM directory structure and tool chain can be found on the main Getting Started with the LLVM System page.
Requirements¶
Before you begin to use the LLVM system, review the requirements given below. This may save you some trouble by knowing ahead of time what hardware and software you will need.
Hardware¶
Any system that can adequately run Visual Studio 2013 is fine. The LLVM source tree and object files, libraries and executables will consume approximately 3GB.
Software¶
You will need Visual Studio 2013 or higher.
You will also need the CMake build system since it generates the project files you will use to build with.
If you would like to run the LLVM tests you will need Python. Version 2.7 and newer are known to work. You will need GnuWin32 tools, too.
Do not install the LLVM directory tree into a path containing spaces (e.g.
C:\Documents and Settings\...) as the configure step will fail.
Getting Started¶
Here’s the short story for getting up and running quickly with LLVM:
Read the documentation.
Seriously, read the documentation.
Remember that you were warned twice about reading the documentation.
Get the Source Code
With the distributed files:
cd <where-you-want-llvm-to-live>gunzip --stdout llvm-VERSION.tar.gz | tar -xvf -(or use WinZip)cd llvm
With anonymous Subversion access:
cd <where-you-want-llvm-to-live>svn co http://llvm.org/svn/llvm-project/llvm/trunk llvmcd llvm
Use CMake to generate up-to-date project files:
- Once CMake is installed then the simplest way is to just start the
CMake GUI, select the directory where you have LLVM extracted to, and
the default options should all be fine. One option you may really
want to change, regardless of anything else, might be the
CMAKE_INSTALL_PREFIXsetting to select a directory to INSTALL to once compiling is complete, although installation is not mandatory for using LLVM. Another important option isLLVM_TARGETS_TO_BUILD, which controls the LLVM target architectures that are included on the build. - See the LLVM CMake guide for detailed information about how to configure the LLVM build.
- CMake generates project files for all build types. To select a specific
build type, use the Configuration manager from the VS IDE or the
/property:Configurationcommand line option when using MSBuild.
- Once CMake is installed then the simplest way is to just start the
CMake GUI, select the directory where you have LLVM extracted to, and
the default options should all be fine. One option you may really
want to change, regardless of anything else, might be the
Start Visual Studio
- In the directory you created the project files will have an
llvm.slnfile, just double-click on that to open Visual Studio.
- In the directory you created the project files will have an
Build the LLVM Suite:
- The projects may still be built individually, but to build them all do
not just select all of them in batch build (as some are meant as
configuration projects), but rather select and build just the
ALL_BUILDproject to build everything, or theINSTALLproject, which first builds theALL_BUILDproject, t
- The projects may still be built individually, but to build them all do
not just select all of them in batch build (as some are meant as
configuration projects), but rather select and build just the
