https://github.com/junlarsen/xd
Toy compiler
https://github.com/junlarsen/xd
compiler llvm
Last synced: 3 months ago
JSON representation
Toy compiler
- Host: GitHub
- URL: https://github.com/junlarsen/xd
- Owner: junlarsen
- License: other
- Created: 2024-12-10T12:17:39.000Z (over 1 year ago)
- Default Branch: trunk
- Last Pushed: 2025-04-12T12:00:31.000Z (12 months ago)
- Last Synced: 2025-04-12T13:22:00.294Z (12 months ago)
- Topics: compiler, llvm
- Language: C++
- Homepage:
- Size: 1.32 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XD Programming Language
This is a toy compiler for a tiny programming language.
> The compiler is currently undergoing a C++ rewrite. Visit
> https://github.com/junlarsen/xd/tree/rust to see the Rust codebase. The
> motivation for the C++ rewrite is direct access to MLIR and LLVM C++ APIs.
## Building
The project is built using the LLVM toolchain and is not tested against
gcc/libstdc++. We require a build of LLVM 20.1.0 that has been built with
LLVM libc++. In addition, we use LLVM and MLIR libraries.
- XD_LLVM_INSTALL_PREFIX: This is the location where LLVM 20.1.0 is expected to
be available on the system. This defaults to `/usr/lib/llvm-20`. Read the next
section on how to build a compatible LLVM 20.1.0 build.
Building a compatible LLVM distribution
```bash
# Assuming llvm/llvm-project checked out at llvmorg-20.1.0
cmake \
-G "Ninja" \
-DCMAKE_INSTALL_PREFIX="/usr/lib/llvm-20" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_CXX_COMPILER="clang++-18" \
-DCMAKE_C_COMPILER="clang-18" \
-DLLVM_ENABLE_LIBCXX="ON" \
-DLLVM_USE_LINKER="/usr/lib/llvm-18/bin/ld.lld" \
-DLLVM_CCACHE_BUILD="ON" \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt" \
-DLLVM_ENABLE_PROJECTS="llvm;clang;lld;mlir" \
-DLLVM_INSTALL_UTILS="ON" \
-DLLVM_BUILD_TOOLS="ON" \
-DLLVM_TARGETS_TO_BUILD="X86" \
../llvm
cmake --build .
sudo cmake --install .
```
## License & Attribution
Everything in the repository is licensed under the Apache 2.0 License with LLVM exception.