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

Fix Bazel build instructions and elaborated them #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,54 @@ Extremely experimental interop tooling for C++ and Rust.
Please don't use, this is an experiment and we don't yet know where will it take
us. There will be breaking changes without warning. Unfortunately, we can't take contributions at this point.

## Building Crubit
## Build

There are two supported ways to build Crubit.

* **Option 1: Local LLVM installation**. This option is recommended for most use cases. It involves building a local copy of LLVM code which will enable one to easily stay in sync with the latest version.

* **Option 2: Basel provided LLVM installation**. This option is recommended for developers that need to track an older version of LLVM.

### Install system dependencies

#### Install Bazelisk

Install Bazelisk following [these instructions](https://github.com/bazelbuild/bazelisk/blob/master/README.md).

#### Install system packages

```
$ apt install clang lld bazel
$ git clone [email protected]:google/crubit.git
$ cd crubit
$ bazel build --linkopt=-fuse-ld=/usr/bin/ld.lld //rs_bindings_from_cc:rs_bindings_from_cc_impl
$ apt install clang lld
```

### Using a prebuilt LLVM tree
#### Build local LLVM installation (**Option 1** only)

```
$ git clone https://github.com/llvm/llvm-project
$ cd llvm-project
$ CC=clang CXX=clang++ cmake -S llvm -B build -DLLVM_ENABLE_PROJECTS='clang' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install
$ CC=clang CXX=clang++ cmake -S llvm -B build -DLLVM_ENABLE_PROJECTS='clang;lld' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install
$ cmake --build build -j
$ # wait...
$ cmake --install build
$ cd ../crubit
$ LLVM_INSTALL_PATH=../llvm-project/install bazel build //rs_bindings_from_cc:rs_bindings_from_cc_impl
$ cd ..
```

### Build Crubit

#### Build with local LLVM installation (**Option 1** only)

```
$ export LLVM_INSTALL_PATH=$PWD/llvm-project/install
$ export PATH="$LLVM_INSTALL_PATH/bin:$PATH"
$ cd crubit
$ bazel build --linkopt=-fuse-ld=$LLVM_INSTALL_PATH/bin/ld.lld //rs_bindings_from_cc:rs_bindings_from_cc_impl
```

#### Build with Basel provided LLVM installation (**Option 2** only)

```
$ apt install clang lld bazel
$ git clone [email protected]:google/crubit.git
$ cd crubit
$ bazel build --linkopt=-fuse-ld=/usr/bin/ld.lld //rs_bindings_from_cc:rs_bindings_from_cc_impl
```