|
1 | 1 | # LLVM fork to work on RISC-V V-ext vectorizing issues |
2 | 2 |
|
3 | | -## Repository layout |
4 | | -TODO |
| 3 | +## Working on LLVM |
5 | 4 |
|
6 | | -## Getting dev shell |
| 5 | +### Getting dev shell |
7 | 6 | * Install `nix`: |
8 | 7 | ``` |
9 | 8 | sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --no-daemon |
10 | 9 | ``` |
11 | 10 | * Enable flakes experimental feature: |
12 | 11 | ``` |
13 | 12 | mkdir ~/.config/nix/ |
14 | | -echo "experimental-features = nix-command flakes" > ~/.config/nix/nix.conf |
| 13 | +echo "experimental-features = nix-command flakes impure-derivations ca-derivations" > ~/.config/nix/nix.conf |
15 | 14 | ``` |
16 | 15 | * Enter to nix shell |
17 | 16 | ``` |
18 | | -nix develop |
| 17 | +nix develop '.#toolchain' |
19 | 18 | ``` |
20 | 19 | * (Optional) Setup [direnv](https://github.com/direnv/direnv) to enter into nix shell automatically |
21 | 20 |
|
| 21 | +### Setup connection to binary cache |
| 22 | +#### Why is that necessary? |
| 23 | +Every nix package have unique hash, which can be computed before building process. |
| 24 | +When you build any thing, nix firstly tries to find built package across connected binary caches. |
| 25 | +Cross LLVM build process requires a lot of tools, |
| 26 | +not all of which are available as binary package in public package repositories. |
| 27 | +After first LLVM build (which I'am already done) all of this packages become available in our binary package cache. |
22 | 28 |
|
23 | | -## Building |
| 29 | +#### Setup ssh access |
| 30 | +Firstly, you need setup ssh access to specified user **for `root` user in your system**. |
| 31 | +``` |
| 32 | +host vityaman-nix-storage |
| 33 | + user nix-storage |
| 34 | + hostname 62.84.116.90 |
| 35 | + port 22 |
| 36 | + identityfile ~/.ssh/nix-storage_id_rsa |
| 37 | +``` |
| 38 | +Private key can be found in telegram developers chat. |
| 39 | +#### Setup nix substituters |
| 40 | +Next, you need add our host into *substituters*. |
| 41 | +Usually, it can be done by adding following line into `~/.config/nix/nix.conf`: |
| 42 | +``` |
| 43 | +substituters = ssh://vityaman-nix-storage |
| 44 | +``` |
| 45 | + |
| 46 | +### Building LLVM |
| 47 | +Enter into nix shell: |
| 48 | +``` |
| 49 | +nix develop |
| 50 | +``` |
24 | 51 |
|
25 | | -Inside nix shell: |
| 52 | +Then build libllvm in normal way: |
26 | 53 | ``` |
27 | 54 | cmake $cmakeFlags -S llvm -B build |
28 | 55 | ninja -C build |
29 | 56 | ``` |
| 57 | + |
| 58 | +After that, you can use built libllvm with upstream clang, which preinstalled in nix shell. |
| 59 | +Minimal example to compile code for Linux/RISC-V environment. |
| 60 | +``` |
| 61 | +// inside `nix develop` shell |
| 62 | +riscv64-unknown-linux-gnu-clang++ hello.cpp -emit-llvm -S -o hello.ll |
| 63 | +../build/bin/llc -march=riscv64 --relocation-model=pic hello.ll -o hello.s |
| 64 | +riscv64-unknown-linux-gnu-clang++ hello.s hello.o |
| 65 | +``` |
| 66 | +For details see [LLVM docs](https://llvm.org/docs/GettingStarted.html). |
| 67 | + |
| 68 | +### Running performance testing |
| 69 | +TODO[khaser]: not implemented yet |
| 70 | + |
| 71 | +### Running regression testing |
| 72 | +TODO[khaser]: not implemented yet |
| 73 | + |
| 74 | +### Misc |
| 75 | +Original LLVM readme can be found in [./README-llvm.md](./README-llvm.md) |
| 76 | + |
| 77 | +### Infra notes |
| 78 | +TODO[khaser]: write notes |
| 79 | + |
0 commit comments