Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/phodal/rust-llvm-practises

Rust LLVM Practises
https://github.com/phodal/rust-llvm-practises

Last synced: 3 days ago
JSON representation

Rust LLVM Practises

Awesome Lists containing this project

README

        

# Rust LLVM Practise

```
├── helloworld // hello, world demo
└── stdlib // Rust call c libs demo
```

## Setup

0. Rust 1.39+ + LLVM 10.0
1. use [llvmenv](https://github.com/termoshtt/llvmenv) to Manage multiple LLVM/Clang builds
2. Rust LLVM wrapper use [inkwell](https://github.com/TheDan64/inkwell)
3. generated LLVM IR code see in [main.ll](main.ll)

### Install LLVM

```
brew install cmake ninja
```

Homebrew 11

```
brew install llvm
```

#### remote

```bash
cargo install llvmenv
```

usage

```
llvmenv init
llvmenv entries
local-llvm 10.0.0
```

about `1.5 hours` in my MBP 2018

#### local

Add local llvm for build to: `$XDG_CONFIG_HOME/llvmenv/entry.toml

docs: https://docs.rs/llvmenv/0.3.0/llvmenv/entry/index.html

````
[local-llvm]
path = "/path/to/your/src"
target = ["X86"]
```

**build**

```
llvmenv build-entry local-llvm
```

### run & build

```
LLVM_SYS_101_PREFIX=$HOME/llvm/llvm-10.0.1.src/build cargo build
LLVM_SYS_101_PREFIX=$HOME/llvm/llvm-10.0.1.src/build cargo run
````