Skip to content

Commit

Permalink
fix(build): Install bpftool from the source (#96)
Browse files Browse the repository at this point in the history
- use compiled bpftool instead of binaries from the tree
  • Loading branch information
rafaeldtinoco authored Jul 24, 2023
1 parent 7e35e26 commit 6b9ef63
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 18 deletions.
59 changes: 53 additions & 6 deletions .github/actions/build-dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
runs:
using: composite
steps:
- name: Install Base Packages
- name: Install ubuntu packages
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
Expand All @@ -20,19 +20,66 @@ runs:
sudo apt-get install -y software-properties-common
sudo apt-get install -y devscripts ubuntu-dev-tools
shell: bash
- name: Install Recent Pahole
run: |
./3rdparty/pahole.sh
shell: bash
- name: Install Golang
- name: Install golang
run: |
rm -rf /usr/local/go
curl -L -o /tmp/go.tar.xz https://go.dev/dl/go${{ inputs.go-version }}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf /tmp/go.tar.xz
sudo update-alternatives --remove-all go || true
sudo update-alternatives --remove-all gofmt || true
sudo update-alternatives --install /usr/bin/go go /usr/local/go/bin/go 1
sudo update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/bin/gofmt 1
shell: bash
- name: Install llvm
run: |
export DEBIAN_FRONTEND=noninteractive
cd /tmp
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 14
sudo apt-get install -y clang-14 clangd-14 clang-tools-14 clang-format-14
sudo apt-get install -y llvm-14 llvm-14-runtime llvm-14-tools
sudo update-alternatives --remove-all cc || true
sudo update-alternatives --remove-all clang || true
sudo update-alternatives --remove-all clang++ || true
sudo update-alternatives --remove-all llc || true
sudo update-alternatives --remove-all lld || true
sudo update-alternatives --remove-all clangd || true
sudo update-alternatives --remove-all clang-format || true
sudo update-alternatives --remove-all llvm-strip || true
sudo update-alternatives --remove-all llvm-config || true
sudo update-alternatives --remove-all ld.lld || true
sudo update-alternatives --remove-all llvm-ar || true
sudo update-alternatives --remove-all llvm-nm || true
sudo update-alternatives --remove-all llvm-objcopy || true
sudo update-alternatives --remove-all llvm-objdump || true
sudo update-alternatives --remove-all llvm-readelf || true
sudo update-alternatives --remove-all opt || true
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 140 \
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-14 \
--slave /usr/bin/clangd clangd /usr/bin/clangd-14 \
--slave /usr/bin/clang-format clang-format /usr/bin/clang-format-14 \
--slave /usr/bin/lld lld /usr/bin/lld-14 \
--slave /usr/bin/llc llc /usr/bin/llc-14 \
--slave /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-14 \
--slave /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 \
--slave /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-14 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-14 \
--slave /usr/bin/llvm-nm llvm-nm /usr/bin/llvm-nm-14 \
--slave /usr/bin/llvm-objcopy llvm-objcopy /usr/bin/llvm-objcopy-14 \
--slave /usr/bin/llvm-objdump llvm-objdump /usr/bin/llvm-objdump-14 \
--slave /usr/bin/llvm-readelf llvm-readelf /usr/bin/llvm-readelf-14 \
--slave /usr/bin/opt opt /usr/bin/opt-14 \
--slave /usr/bin/cc cc /usr/bin/clang-14
shell: bash
- name: Install pahole
run: |
./3rdparty/pahole.sh
shell: bash
- name: Install bpftool
run: |
./3rdparty/bpftool.sh
shell: bash
- name: Install staticchecker
run: |
GOROOT=/usr/local/go GOPATH=$HOME/go go install honnef.co/go/tools/cmd/staticcheck@latest
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ jobs:
gh auth login --with-token <<<'${{ secrets.PAT_RAFAEL }}'
#
- name: Install Dependencies
run: |
apt-get update -y
apt-get install -y pahole ubuntu-dev-tools
uses: ./.github/actions/build-dependencies
#
- name: Check out BTFHub
uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "3rdparty/dwarves"]
path = 3rdparty/dwarves
url = https://github.com/acmel/dwarves.git
[submodule "3rdparty/libbpf"]
path = 3rdparty/libbpf
url = https://github.com/libbpf/libbpf.git
[submodule "3rdparty/bpftool"]
path = 3rdparty/bpftool
url = https://github.com/libbpf/bpftool/
1 change: 1 addition & 0 deletions 3rdparty/bpftool
Submodule bpftool added at 88156a
9 changes: 9 additions & 0 deletions 3rdparty/bpftool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -e

git submodule update --init --recursive 3rdparty/bpftool
cd ./3rdparty/bpftool
sudo apt-get -y install build-essential libelf-dev libz-dev libcap-dev binutils-dev pkg-config libelf1
make -C src clean
CC=clang make -C src all
sudo cp ./src/bpftool /usr/sbin/bpftool
make -C src clean
6 changes: 3 additions & 3 deletions 3rdparty/debian.dwarves/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
include /usr/share/dpkg/default.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export DH_VERBOSE=1
export CC = clang
export CFLAGS = -gdwarf-4

%:
@true
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/pahole.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

git submodule update --init
git submodule update --init --recursive 3rdparty/dwarves
export DEBIAN_FRONTEND=noninteractive
rm -f *.deb
cd ./3rdparty/dwarves
Expand Down
Binary file removed tools/bin/bpftool.aarch64
Binary file not shown.
Binary file removed tools/bin/bpftool.x86_64
Binary file not shown.
4 changes: 2 additions & 2 deletions tools/btfgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fi

cd ${basedir}

btfgen=./tools/bin/bpftool.$(uname -m)
btfgen=/usr/sbin/bpftool
if [ ! -x "${btfgen}" ]; then
echo "error: could not find bpftool (w/ btfgen patch) tool"
exit 1
Expand Down Expand Up @@ -79,4 +79,4 @@ for dir in $(find ./archive/ -iregex ".*${a}.*" -type d | sed 's:\.\/archive\/::
$btfgen gen min_core_btf ${extracted} ${out_dir}/${extracted} ${obj_cmdline}
[[ $ret -eq 0 ]] && [[ -f ./${extracted} ]] && rm ./${extracted}
done
done
done

0 comments on commit 6b9ef63

Please sign in to comment.