Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcauberer/compiler-design-series-init
Example project template for the compiler design article series
https://github.com/marcauberer/compiler-design-series-init
Last synced: about 11 hours ago
JSON representation
Example project template for the compiler design article series
- Host: GitHub
- URL: https://github.com/marcauberer/compiler-design-series-init
- Owner: marcauberer
- Created: 2023-10-28T23:22:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-25T15:14:25.000Z (8 months ago)
- Last Synced: 2024-05-01T16:06:44.277Z (6 months ago)
- Language: CMake
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compiler Design article series - MathExpr toy language template
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](https://github.com/marcauberer/compiler-design-series).
## Setup steps
1. Create repo from this template (Click the green `Use this template` button in the top right corner)
2. Clone it to your machine
3. Get yourself a C++ compiler, e.g. GCC or Clang (e.g. [winlibs.com](https://winlibs.com), not forget to add `bin` dir to system PATH variable)
4. Build LLVM (see below)
5. Set environment variable `LLVM_DIR` to `/lib/cmake/llvm`
6. Try running `./build.sh` (Linux) or `.\build.bat` (Windows)## Build LLVM
### Prerequisites
- 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`)### Setup
Execute the following instructions in a directory, where you have a few spare gigabytes:
**Linux**
```bash
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**
```bash
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