Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-organize the LLVM build instructions #6059

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 35 additions & 16 deletions BUILDING_FROM_SOURCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,34 @@ For any OS, you can use [`zigup`](https://github.com/marler8997/zigup) to manage

If you prefer a package manager, you can try the following:

- For MacOS, you can install with `brew install [email protected]`
- For, Ubuntu, you can use Snap, you can install with `snap install zig --classic --beta`
- For other systems, checkout this [page](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager)
- MacOS: `brew install [email protected]`
- Systems with snap (such as Ubuntu): `snap install zig --classic --beta`
- Other systems: refer to the [zig documentation](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager)

If you want to install it manually, you can also download Zig directly [here](https://ziglang.org/download/). Just make sure you download the right version, the bleeding edge master build is the first download link on this page.
If you want to install it manually, you can [download the binary](https://ziglang.org/download/#release-0.11.0) and place it on your PATH.
Apart from the binary, the archive contains a `lib` folder, which needs to be copied next to the binary.

> WINDOWS NOTE: when you unpack the Zig archive on windows, the result is nested in an extra directory. The instructions on the zig website will seem to not work. So, double-check that the path to zig executable does not include the same directory name twice.

### LLVM

**version: 16.0.x**

For macOS, you can install LLVM 16 using `brew install llvm@16` and then adding
`$(brew --prefix llvm@16)/bin` to your `PATH`. You can confirm this worked by
running `llc --version` - it should mention "LLVM version 16.0.x" at the top.
You may also need to manually specify a prefix env var like so:
See below for operating system specific installation instructions.

### Building

Use `cargo build` to build the whole project.
Use `cargo run help` to see all subcommands.
To use the `repl` subcommand, execute `cargo run repl`.

The default is a developer build. For an optimized build, use:

```sh
export LLVM_SYS_160_PREFIX=/usr/local/opt/llvm@16
```
cargo build --release --bin roc
```

### LLVM installation on Linux

For Ubuntu and Debian:

Expand All @@ -143,13 +151,13 @@ There are also alternative installation options at <http://releases.llvm.org/dow

[Troubleshooting](#troubleshooting)

### Building
For Fedora:

Use `cargo build` to build the whole project.
Use `cargo run help` to see all subcommands.
To use the `repl` subcommand, execute `cargo run repl`.
```sh
sudo dnf install llvm16 llvm16-devel
```

### LLVM installation on Linux
#### LLVM Linux troubleshooting

On some Linux systems we've seen the error "failed to run custom build command for x11".
On Ubuntu, running `sudo apt install pkg-config cmake libx11-dev` fixed this.
Expand All @@ -167,6 +175,17 @@ Add `export LLVM_SYS_160_PREFIX=/usr/lib/llvm-16` to your `~/.bashrc` or equival

### LLVM installation on MacOS

For macOS, you can install LLVM 16 using `brew install llvm@16` and then adding
`$(brew --prefix llvm@16)/bin` to your `PATH`. You can confirm this worked by
running `llc --version` - it should mention "LLVM version 16.0.x" at the top.
You may also need to manually specify a prefix env var like so:

```sh
export LLVM_SYS_160_PREFIX=$(brew --prefix llvm@16)
```

#### LLVM MacOS troubleshooting

If installing LLVM fails, it might help to run `sudo xcode-select -r` before installing again.

It might also be useful to add these exports to your shell:
Expand All @@ -193,7 +212,7 @@ $env:LLVM_SYS_160_PREFIX = 'C:\Users\YOUR_USERNAME\Downloads\LLVM-16.0.6-win64'

Once all that was done, `cargo build` ran successfully for Roc!

#### Build issues on Windows
#### LLVM Windows troubleshooting

If you see the build failing because some internal file is not available, it might be your anti-virus program. Cargo's behavior is kind of similar to a virus (downloading files from the internet, creating many files), and this has been known to cause problems.

Expand Down