Skip to content

Commit 865220d

Browse files
authored
build-scx-scheds: move to non-meson build (#202)
sched_ext is migrating the ubild process away from meson [1]. Update build-scx-scheds to use preferred build process with make and cargo. Build and install libbpf and bpftool from source. [1] sched-ext/scx#2731 Signed-off-by: Ihor Solodrai <[email protected]>
1 parent a39dd17 commit 865220d

File tree

2 files changed

+48
-31
lines changed

2 files changed

+48
-31
lines changed

build-scx-scheds/build-scheds.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -euo pipefail
44

5-
export LLVM_VERSION=${LLVM_VERSION:-20}
65
export SCX_ROOT=${SCX_ROOT:-}
76
export SCX_REVISION=${SCX_REVISION:-main}
87

@@ -15,10 +14,16 @@ if [[ -z "$SCX_ROOT" ]]; then
1514
fi
1615

1716
pushd $SCX_ROOT
17+
18+
rm -rf $OUTPUT_DIR && mkdir -p $OUTPUT_DIR
19+
20+
# build C scheds
21+
make all -j$(nproc)
22+
mv build $OUTPUT_DIR/c-scheds
23+
24+
# build Rust scheds
1825
. $HOME/.cargo/env
19-
meson setup build
20-
meson compile -C build
21-
rm -rf $OUTPUT_DIR
22-
mv build $OUTPUT_DIR
23-
popd
26+
cargo build --release
27+
mv target/release/build $OUTPUT_DIR/rust-scheds
2428

29+
popd
Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,59 @@
11
#!/bin/bash
22

3-
set -euo pipefail
3+
set -xeuo pipefail
44

5-
export DEBIAN_FRONTEND=noninteractive
6-
export LLVM_VERSION=${LLVM_VERSION:-20}
7-
export PIPX_VERSION=${PIPX_VERSION:-1.7.1}
5+
export LLVM_VERSION=${LLVM_VERSION:-21}
6+
export LIBBPF_REVISION=${LIBBPF_REVISION:-master}
7+
export BPFTOOL_REVISION=${BPFTOOL_REVISION:-main}
88

99
# Assume Ubuntu/Debian
10+
export DEBIAN_FRONTEND=noninteractive
1011
sudo -E apt-get -y update
1112

12-
# Download and install pipx
13-
sudo -E apt-get --no-install-recommends -y install wget python3 python3-pip python3-venv
14-
wget "https://github.com/pypa/pipx/releases/download/${PIPX_VERSION}/pipx.pyz"
15-
chmod +x pipx.pyz && sudo mv pipx.pyz /usr/bin/pipx
16-
17-
# pipx ensurepath is not doing what we need
18-
# install pipx apps to /usr/local/bin manually
19-
export PIPX_BIN_DIR=${PIPX_BIN_DIR:-~/.local/bin}
20-
pipx install meson
21-
pipx install ninja
22-
sudo cp -a "${PIPX_BIN_DIR}/meson" /usr/local/bin
23-
sudo cp -a "${PIPX_BIN_DIR}/ninja" /usr/local/bin
24-
25-
echo "meson --version" && meson --version
26-
echo "ninja --version" && ninja --version
27-
2813
# Install LLVM
29-
sudo -E apt-get --no-install-recommends -y install lsb-release wget software-properties-common gnupg
14+
sudo -E apt-get --no-install-recommends -y install \
15+
curl git gnupg lsb-release software-properties-common wget
3016
wget https://apt.llvm.org/llvm.sh
3117
chmod +x llvm.sh
3218
sudo -E ./llvm.sh ${LLVM_VERSION}
3319
rm llvm.sh
3420

35-
# We have to set up the alternatives because meson expects
36-
# clang and llvm-strip commands to be available
3721
sudo update-alternatives --install \
3822
/usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 10
23+
sudo update-alternatives --set clang /usr/bin/clang-${LLVM_VERSION}
3924
sudo update-alternatives --install \
4025
/usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-${LLVM_VERSION} 10
26+
sudo update-alternatives --set llvm-strip /usr/bin/llvm-strip-${LLVM_VERSION}
27+
sudo update-alternatives --install \
28+
/usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-${LLVM_VERSION} 10
29+
sudo update-alternatives --set llvm-ar /usr/bin/llvm-ar-${LLVM_VERSION}
4130

4231
# Install Rust
4332
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
4433

34+
# Install libs and other deps
4535
sudo -E apt-get --no-install-recommends -y install \
46-
build-essential libssl-dev libelf-dev cmake pkg-config jq \
47-
protobuf-compiler libseccomp-dev
36+
build-essential libssl-dev libelf-dev libzstd-dev libseccomp-dev \
37+
libbfd-dev libcap-dev jq pkg-config protobuf-compiler
38+
39+
# Build and install libbpf
40+
export LIBBPF_ROOT=$(mktemp -d libbpf.XXXX)
41+
git clone https://github.com/libbpf/libbpf.git $LIBBPF_ROOT
42+
pushd $LIBBPF_ROOT
43+
git reset --hard $LIBBPF_REVISION
44+
make -C src -j$(nproc)
45+
make -C src install
46+
sudo ln -s /usr/lib64/pkgconfig/libbpf.pc /usr/lib/pkgconfig/libbpf.pc
47+
popd
48+
rm -rf $LIBBPF_ROOT
49+
50+
# Build and install bpftool
51+
export BPFTOOL_ROOT=$(mktemp -d bpftool.XXXX)
52+
git clone --recurse-submodules https://github.com/libbpf/bpftool.git $BPFTOOL_ROOT
53+
pushd $BPFTOOL_ROOT
54+
git reset --hard $BPFTOOL_REVISION
55+
git submodule update --init
56+
make LLVM=1 LLVM_VERSION=-${LLVM_VERSION} -C src -j$(nproc)
57+
make LLVM=1 LLVM_VERSION=-${LLVM_VERSION} -C src install
58+
popd
59+
rm -rf $BPFTOOL_ROOT

0 commit comments

Comments
 (0)