Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.
Open
Show file tree
Hide file tree
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
78 changes: 39 additions & 39 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
REDBPF_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/redbpf-build

jobs:
build-on-x86_64-ubuntu-2104:
build-on-x86_64-ubuntu-2204:
runs-on: ubuntu-latest
steps:
-
Expand All @@ -31,25 +31,25 @@ jobs:
uname -a
cat /etc/os-release
-
name: Build RedBPF with the kernel headers on x86_64 Ubuntu 21.04
name: Build RedBPF with the kernel headers on x86_64 Ubuntu 22.04
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-x86_64-ubuntu21.04 \
$REDBPF_IMAGE_NAME:latest-x86_64-ubuntu22.04 \
bash -c 'export KERNEL_SOURCE=$(echo /lib/modules/*) \
&& echo KERNEL_SOURCE=$KERNEL_SOURCE \
&& cargo clean \
&& cargo build \
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'
-
name: Build RedBPF with vmlinux on x86_64 Ubuntu 21.04
name: Build RedBPF with vmlinux on x86_64 Ubuntu 22.04
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-x86_64-ubuntu21.04 \
$REDBPF_IMAGE_NAME:latest-x86_64-ubuntu22.04 \
/bin/bash -c 'export REDBPF_VMLINUX=/boot/vmlinux \
&& cargo clean \
&& cargo build \
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'

build-on-x86_64-fedora35:
build-on-x86_64-fedora36:
runs-on: ubuntu-latest
steps:
-
Expand All @@ -109,33 +109,33 @@ jobs:
uname -a
cat /etc/os-release
-
name: Build RedBPF with the kernel headers on x86_64 Fedora 35
name: Build RedBPF with the kernel headers on x86_64 Fedora 36
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-x86_64-fedora35 \
$REDBPF_IMAGE_NAME:latest-x86_64-fedora36 \
/bin/bash -c 'export KERNEL_SOURCE=$(echo /lib/modules/*) \
&& echo KERNEL_SOURCE=$KERNEL_SOURCE \
&& cargo clean \
&& cargo build \
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'
-
name: Build RedBPF with vmlinux on x86_64 Fedora 35
name: Build RedBPF with vmlinux on x86_64 Fedora 36
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-x86_64-fedora35 \
$REDBPF_IMAGE_NAME:latest-x86_64-fedora36 \
/bin/bash -c 'export REDBPF_VMLINUX=/boot/vmlinux \
&& cargo clean \
&& cargo build \
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'

build-on-x86_64-alpine315:
name: Alpine 3.15 is disabled temporarily (LLVM13 unsupported)
build-on-x86_64-alpine-edge:
name: Alpine Edge
if: false
runs-on: ubuntu-latest
steps:
Expand All @@ -150,19 +150,19 @@ jobs:
uname -a
cat /etc/os-release
-
name: Build RedBPF with the kernel headers on x86_64 Alpine 3.15
name: Build RedBPF with the kernel headers on x86_64 Alpine Edge
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-x86_64-alpine3.15 \
$REDBPF_IMAGE_NAME:latest-x86_64-alpine-edge \
/bin/bash -c 'export KERNEL_SOURCE=$(echo /lib/modules/*) \
&& echo KERNEL_SOURCE=$KERNEL_SOURCE \
&& export RUSTFLAGS=-Ctarget-feature=-crt-static \
&& cargo clean \
&& cargo build \
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'
&& cargo build --features="kernel5_8 llvm13" --examples'

build-on-x86_64-archlinux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -257,7 +257,7 @@ jobs:
&& cargo build --bin cargo-bpf \
&& cargo build --examples'

build-on-aarch64-ubuntu-2104:
build-on-aarch64-ubuntu-2204:
runs-on: ubuntu-latest
steps:
-
Expand All @@ -281,25 +281,25 @@ jobs:
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
-
name: Build RedBPF with the kernel headers on aarch64 Ubuntu 21.04
name: Build RedBPF with the kernel headers on aarch64 Ubuntu 22.04
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-aarch64-ubuntu21.04 \
$REDBPF_IMAGE_NAME:latest-aarch64-ubuntu22.04 \
/bin/bash -c 'export KERNEL_SOURCE=$(echo /lib/modules/*) \
&& echo KERNEL_SOURCE=$KERNEL_SOURCE \
&& cargo clean \
&& cargo build \
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'
-
name: Build RedBPF with vmlinux on aarch64 Ubuntu 21.04
name: Build RedBPF with vmlinux on aarch64 Ubuntu 22.04
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-aarch64-ubuntu21.04 \
$REDBPF_IMAGE_NAME:latest-aarch64-ubuntu22.04 \
/bin/bash -c 'export REDBPF_VMLINUX=/boot/vmlinux-btf \
&& cargo clean \
&& cargo build \
Expand Down Expand Up @@ -355,9 +355,9 @@ jobs:
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'

# Split aarch64-fedora35 into two parts because its running time exceeds 6
# Split aarch64-fedora36 into two parts because its running time exceeds 6
# hours, the maximum time for build test.
build-on-aarch64-fedora35-header:
build-on-aarch64-fedora36-header:
runs-on: ubuntu-latest
steps:
-
Expand All @@ -381,20 +381,20 @@ jobs:
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
-
name: Build RedBPF with the kernel headers on aarch64 Fedora 35
name: Build RedBPF with the kernel headers on aarch64 Fedora 36
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-aarch64-fedora35 \
$REDBPF_IMAGE_NAME:latest-aarch64-fedora36 \
/bin/bash -c 'export KERNEL_SOURCE=$(echo /lib/modules/*) \
&& echo KERNEL_SOURCE=$KERNEL_SOURCE \
&& cargo clean \
&& cargo build \
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'

build-on-aarch64-fedora35-vmlinux:
build-on-aarch64-fedora36-vmlinux:
runs-on: ubuntu-latest
steps:
-
Expand All @@ -418,20 +418,20 @@ jobs:
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
-
name: Build RedBPF with vmlinux on aarch64 Fedora 35
name: Build RedBPF with vmlinux on aarch64 Fedora 36
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-aarch64-fedora35 \
$REDBPF_IMAGE_NAME:latest-aarch64-fedora36 \
/bin/bash -c 'export REDBPF_VMLINUX=/boot/vmlinux-btf \
&& cargo clean \
&& cargo build \
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'

build-on-aarch64-alpine315:
name: Alpine 3.15 is disabled temporarily (LLVM13 unsupported)
build-on-aarch64-alpine-edge:
name: Alpine Edge
if: false
runs-on: ubuntu-latest
steps:
Expand All @@ -456,19 +456,19 @@ jobs:
name: Available platforms
run: echo ${{ steps.qemu.outputs.platforms }}
-
name: Build RedBPF with the kernel headers on aarch64 Alpine 3.15
name: Build RedBPF with the kernel headers on aarch64 Alpine Edge
run: |
docker run --privileged \
-v $PWD:/build \
-w /build \
$REDBPF_IMAGE_NAME:latest-aarch64-alpine3.15 \
$REDBPF_IMAGE_NAME:latest-aarch64-alpine-edge \
/bin/bash -c 'export KERNEL_SOURCE=$(echo /lib/modules/*) \
&& echo KERNEL_SOURCE=$KERNEL_SOURCE \
&& export RUSTFLAGS=-Ctarget-feature=-crt-static \
&& cargo clean \
&& cargo build \
&& cargo build --bin cargo-bpf \
&& cargo build --features=kernel5_8 --examples'
&& cargo build --features="kernel5_8 llvm13" --examples'

build-on-aarch64-ubuntu-2004:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -535,20 +535,20 @@ jobs:
runs-on: ubuntu-latest
if: startsWith( github.ref, 'refs/tags/v')
needs:
- build-on-x86_64-ubuntu-2104
- build-on-x86_64-ubuntu-2204
- build-on-x86_64-debian11
- build-on-x86_64-fedora35
# - build-on-x86_64-alpine315
- build-on-x86_64-fedora36
- build-on-x86_64-alpine-edge
- build-on-x86_64-archlinux
- build-on-x86_64-ubuntu-2004
- build-on-x86_64-gentoo
- build-on-x86_64-nix-stable
- build-on-x86_64-nix-unstable
- build-on-aarch64-ubuntu-2104
- build-on-aarch64-ubuntu-2204
- build-on-aarch64-debian11
- build-on-aarch64-fedora35-header
- build-on-aarch64-fedora35-vmlinux
# - build-on-aarch64-alpine315
- build-on-aarch64-fedora36-header
- build-on-aarch64-fedora36-vmlinux
- build-on-aarch64-alpine-edge
- build-on-aarch64-ubuntu-2004

steps:
Expand Down
16 changes: 15 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ programs using Rust. It includes:

`LLVM` is required in your build system to compile BPF bytecode using RedBPF.

- **LLVM 13**
It is needed to compile BPF bytecode.
- **LLVM 14 or 13**
It is needed to compile BPF bytecode. If you're using Rust 1.60 or later, LLVM 14 is required.
If you need to use LLVM 13, use the feature `llvm13`.

- One of the followings:
1. The Linux kernel headers
Expand All @@ -74,7 +75,7 @@ programs using Rust. It includes:

### On Ubuntu 20.04 LTS

Install LLVM 13 and the Linux kernel headers
Install LLVM 14 and the Linux kernel headers
```console
# apt-get update \
&& apt-get -y install \
Expand All @@ -85,12 +86,15 @@ Install LLVM 13 and the Linux kernel headers
libelf-dev \
linux-headers-generic \
pkg-config \
&& wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 13 && rm -f ./llvm.sh
# llvm-config-13 --version | grep 13
&& wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 14 && rm -f ./llvm.sh
# llvm-config-14 --version | grep 14
```

### On Fedora 35

Currently, only LLVM 13 is available in the official Fedora repositories.
Consider building LLVM from source until Fedora 36 is released.

Install LLVM 13 and the Linux kernel headers
```console
# dnf install -y \
Expand Down Expand Up @@ -126,25 +130,28 @@ Install LLVM 13 and the Linux kernel headers
# llvm-config --version | grep -q '^13'
```

At the time of writing, LLVM 14 is not available in the official package repository.
If you need to use Rust 1.60 or later, please build LLVM from source.

### Building LLVM from source

If your Linux distro does not support the latest LLVM as pre-built packages
yet, you may build LLVM from the LLVM source code.

```console
$ tar -xaf llvm-13.0.0.src.tar.xz
$ mkdir -p llvm-13.0.0.src/build
$ cd llvm-13.0.0.src/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/llvm-13-release -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_LLVM_DYLIB=1
$ tar -xaf llvm-14.0.0.src.tar.xz
$ mkdir -p llvm-14.0.0.src/build
$ cd llvm-14.0.0.src/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/llvm-14-release -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_LLVM_DYLIB=1
$ cmake --build . --target install
```

Then you can use your LLVM by specifying the custom installation path when
installing `cargo-bpf` or building RedBPF like this:

```console
$ LLVM_SYS_130_PREFIX=$HOME/llvm-13-release/ cargo install cargo-bpf
$ LLVM_SYS_130_PREFIX=$HOME/llvm-13-release/ cargo build
$ LLVM_SYS_140_PREFIX=$HOME/llvm-14-release/ cargo install cargo-bpf
$ LLVM_SYS_140_PREFIX=$HOME/llvm-14-release/ cargo build
```

Make sure correct `-DCMAKE_BUILD_TYPE` is specified. Typically `Debug` type is
Expand Down Expand Up @@ -235,7 +242,8 @@ There are two LLVM versions involved in compiling BPF programs:

| Rust version | LLVM version of the rustc | Valid LLVM version of system |
|:-------------|:-------------------------:|:-----------------------------|
| 1.56 ~ | LLVM 13 | LLVM 13 and newer |
| 1.56 ~ 1.59 | LLVM 13 | LLVM 13 and newer |
| 1.60 ~ | LLVM 14 | LLVM 14 and newer |

## Docker images for RedBPF build test

Expand Down
10 changes: 5 additions & 5 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ For some reasons, you may want to build LLVM from source code.

When you build LLVM, consider building LLVM with `Release` build mode.

For example, when you build LLVM13 from source code, you can pass
For example, when you build LLVM14 from source code, you can pass
`-DCMAKE_BUILD_TYPE=Release` to the `cmake` command as below:

```console
$ tar -xaf llvm-13.0.0.src.tar.xz
$ mkdir -p llvm-13.0.0.src/build
$ cd llvm-13.0.0.src/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/llvm-13-release -DCMAKE_BUILD_TYPE=Release
$ tar -xaf llvm-14.0.0.src.tar.xz
$ mkdir -p llvm-14.0.0.src/build
$ cd llvm-14.0.0.src/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/llvm-14-release -DCMAKE_BUILD_TYPE=Release
$ cmake --build . --target install
```

Expand Down
Loading