This is the template repository to start off leaning about compilers and implementing one yourself, without worrying about the setup stuff.
If you want to see, how the finished compiler for MathExpr looks like, check out the main repo.
- Create repo from this template (Click the green
Use this templatebutton in the top right corner) - Clone it to your machine
- Get yourself a C++ compiler, e.g. GCC or Clang (e.g. winlibs.com, not forget to add
bindir to system PATH variable) - Build LLVM (see below)
- Set environment variable
LLVM_DIRto<llvm-build-dir>/lib/cmake/llvm - Try running
./build.sh(Linux) or.\build.bat(Windows)
- CMake
- C++ Compiler and Linker
- Generator, e.g. Ninja
- Optional: CCache (add this to the cmake command below:
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
Execute the following instructions in a directory, where you have a few spare gigabytes:
Linux
git clone --depth 1 --branch llvmorg-18.1.2 https://github.com/llvm/llvm-project llvm
mkdir ./llvm/build-release
cd ./llvm/build-release
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2" -GNinja ../llvm
cmake --build .Windows
git clone --depth 1 --branch llvmorg-18.1.2 https://github.com/llvm/llvm-project llvm
mkdir .\llvm\build-release
cd .\llvm\build-release
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2" -GNinja ..\llvm
cmake --build .© Marc Auberer 2023-2024