Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tgymnich/outoftreellvmpass
🧾Template for creating an out of tree llvm pass that can be built with pre compiled llvm binaries or from llvm source.
https://github.com/tgymnich/outoftreellvmpass
llvm llvm-pass out-of-tree template
Last synced: 21 days ago
JSON representation
🧾Template for creating an out of tree llvm pass that can be built with pre compiled llvm binaries or from llvm source.
- Host: GitHub
- URL: https://github.com/tgymnich/outoftreellvmpass
- Owner: tgymnich
- License: other
- Created: 2020-01-16T00:43:24.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-17T00:42:24.000Z (over 3 years ago)
- Last Synced: 2024-10-26T14:52:39.033Z (2 months ago)
- Topics: llvm, llvm-pass, out-of-tree, template
- Language: CMake
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OutOfTreeLLVMPass
Template for creating an out of tree llvm pass that can be built with pre-compiled llvm binaries or from llvm source.
## Setup the build system
### llvm sources
Clone this repository and the llvm source next to each other and create a build folder.
Run cmake from within the build folder:
```
git clone https://github.com/tgymnich/OutOfTreeLLVMPass.git
git clone https://github.com/llvm/llvm-project.git
mkdir build
cd build
cmake -DPATH_TO_LLVM=../llvm-project/llvm ../OutOfTreeLLVMPass
```### pre-compiled llvm
Clone this repoitory and install or download a pre-compiled version of llvm for your system. The example uses macOS and llvm 9.0.0.
Run cmake from within the build folder.
```
git clone https://github.com/tgymnich/OutOfTreeLLVMPass.git
wget http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-darwin-apple.tar.xz
tar xzf clang+llvm-9.0.0-x86_64-darwin-apple.tar.xz
mkdir build
cd build
cmake -DPATH_TO_LLVM=../clang+llvm-9.0.0-x86_64-darwin-apple ../OutOfTreeLLVMPass
```## Build the pass
```
cmake --build .
```## Run the pass
Make sure to provide some bitcode or LLVM IR in `hello.bc` / `hello.ll`. If your are not using macOS make sure to adapt the file ending for the compiled module to `.so` or `.dll`.
### llvm source
```
./llvm-build/bin/opt -load OutOfTreeLLVMPass.dylib -hello < hello.ll > /dev/null```
### pre-compiled llvm
```
../clang+llvm-9.0.0-x86_64-darwin-apple/bin/opt -load OutOfTreeLLVMPass.dylib -hello < hello.ll > /dev/null```