Build Instructions
We currently have scripts for the following platforms with their own instructions to get you up and running faster:
-
Note: Unlike the manual instructions for Windows below, this only supports the
feature/metaprogramming
branch in release mode. It is however, still recommended as this is the easiest way to experiment with the complete reflection and metaprogramming compiler.
If you prefer manual instructions, or we do not have a script for your platform, please use one of the following guides.
Initial build instructions:
- Get the required tools.
- See Getting Started with the LLVM System - Requirements.
- Standard build process uses CMake. Get it at: http://www.cmake.org/download
- Note also that Python is needed for running the test suite. Get it at: http://www.python.org/download
- We highly recommend using the gold linker (or lld) for memory efficiency reasons. We recommend gold over lld as we've experienced problems debugging binaries using gdb when clang is compiled using lld. If you've overcome these problems and are happy building and developing with lld feel free to reach out and let us know!
- We only support Ninja for the build system, make is not supported by llvm's
LLVM_PARALLEL_LINK_JOBS
orLLVM_PARALLEL_COMPILE_JOBS
build flags. Without these flags it is much harder to control the jobs in a way which prevents your system from running out of memory. - If you do run into problems with system instability caused by too much RAM being used oomd is an excellent tool for user space out of memory management which can intervene to maintain system stability.
- Clone the project
- Change directory to where you want the llvm directory placed.
git clone https://github.com/lock3/meta.git llvm-project
- If interested in a branch other than
feature/reflect
:cd llvm-project
git checkout <branch name>
cd ..
- Build llvm and clang
-
mkdir build
(in-tree build is not supported) cd build
- Figure out how many linkers you can run concurrently,
we recommend min { CPU Threads, GB RAM / 4 }, we'll call this
LINK_NUM
- Figure out how many compilers + linkers you can run concurrently,
we recommend min { CPU Threads, GB RAM / 1.5 }, we'll call this
JOB_NUM
- If you want a release build (gold):
cmake -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" -G Ninja -DLLVM_USE_LINKER=gold -DLLVM_USE_SPLIT_DWARF=ON -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=gold" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold" -DCMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_LINK_JOBS=<LINK_NUM> -DLLVM_PARALLEL_COMPILE_JOBS=<JOB_NUM> ../llvm-project/llvm
- If you want a debug build (gold):
cmake -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" -G Ninja -DLLVM_USE_LINKER=gold -DLLVM_USE_SPLIT_DWARF=ON -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=gold -Wl,--gdb-index" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold -Wl,--gdb-index" -DLLVM_PARALLEL_LINK_JOBS=<LINK_NUM> -DLLVM_PARALLEL_COMPILE_JOBS=<JOB_NUM> ../llvm-project/llvm/
- If you want a release build without gold (ld - not recommend, see step 1: Get the required tools):
cmake -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_LINK_JOBS=<LINK_NUM / 2> -DLLVM_PARALLEL_COMPILE_JOBS=<JOB_NUM> ../llvm-project/llvm
ninja
- Note: For subsequent Clang builds/development, you can just run make clang.
-
Update instructions:
- Update the project
cd llvm-project
git pull
cd ..
- Build llvm and clang
cd build
ninja
Initial build instructions:
- Get the required tools.
- See Getting Started with the LLVM System - Requirements.
- Standard build process uses CMake. Get it at: http://www.cmake.org/download
- Note also that Python is needed for running the test suite. Get it at: http://www.python.org/download
- Clone the project
- Change directory to where you want the llvm directory placed.
git clone https://github.com/lock3/meta.git llvm-project
- If interested in a branch other than
feature/reflect
:cd llvm-project
git checkout <branch name>
cd ..
- Build llvm and clang
-
mkdir build
(in-tree build is not supported) cd build
- If you want a release build:
cmake -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ../llvm-project/llvm
- If you want a debug build:
cmake -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" -G "Unix Makefiles" ../llvm-project/llvm
make -j
- Note: For subsequent Clang development, you can just run make clang.
-
Update instructions:
- Update the project
cd llvm-project
git pull
cd ..
- Build llvm and clang
cd build
make -j
Initial build instructions:
- Make sure you have installed
- Visual Studio 2015 or higher
- Git. Get it at: https://git-scm.com/downloads
- CMake 3.12 or higher. Get it at: https://cmake.org/download/
- Note also that Python is needed for running the test suite. Get it at: http://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 at http://getgnuwin32.sourceforge.net/.
- Clone the project
git clone https://github.com/lock3/meta.git llvm-project
- If interested in a branch other than
feature/reflect
:cd llvm-project
git checkout <branch name>
cd ..
- Build llvm and clang
-
md build
(in-tree build is not supported) cd build
cmake -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi" -G "Visual Studio 15 2017" -A x64 -Thost=x64 -DLLVM_TARGETS_TO_BUILD="X86" ..\llvm
- If you want to build a debug build
cmake --build . --target ALL_BUILD --config Debug
- If you want to build a release build
cmake --build . --target ALL_BUILD --config Release
-
Update instructions:
- Update clang
cd llvm-project
git pull
cd ..
- Build llvm and clang
cd build
cmake --build . --target ALL_BUILD --config Debug
Due to a recent update, even with everything correctly installed, finding
the system's C headers can be problematic. To resolve this we recommend
adding the following to your .bash_profile
or .zprofile
depending
on your shell:
export CFLAGS="-I/usr/local/include -I$(xcrun --show-sdk-path)/usr/include"
This will allow the C header path to be found "dynamically" based off
information provided by xcrun
, and it is the most stable solution we've found.
Additionally, if using the built compiler you may benefit from a wrapper script
in your build directory to run the compiler (run_clang.sh
):
#!/bin/sh
./bin/clang++ -I/usr/local/include -I$(xcrun --show-sdk-path)/usr/include $@
You can then use ./run_clang.sh scratch.cpp
in place of the usual
./bin/clang++ scratch.cpp
. This allows the built compiler to find the C headers
in the same way the CFLAGS environment variable works.