• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: build
2
3on:
4  pull_request:
5    paths:
6      - '.github/workflows/build.yaml'
7      - 'docs/**'
8      - 'include/**'
9      - 'libbpf/**'
10      - 'src/**'
11  push:
12    branches:
13      - master
14
15concurrency:
16  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
17  cancel-in-progress: true
18
19jobs:
20  build:
21    strategy:
22      fail-fast: false
23      matrix:
24        os: [ubuntu-20.04, ubuntu-22.04]
25    runs-on: ${{ matrix.os }}
26    env:
27      FEATURES: .llvm and .skeletons
28
29    steps:
30      - name: Checkout repository
31        uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
32        with:
33          submodules: true
34
35      - name: Use clang-12 and not clang-11 for older Ubuntu
36        if: matrix.os == 'ubuntu-20.04'
37        run: |
38          sudo apt-get remove -y clang-11 llvm-11
39          sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 50
40
41      - name: Install dependencies
42        run: |
43          sudo apt-get update
44          sudo apt-get install -y \
45              libbfd-dev libcap-dev libelf-dev libiberty-dev python3-docutils
46          # clang/LLVM are already installed, but we're missing some aliases.
47          CLANG_VERSION="$(echo '__clang_major__' | clang -E - | tail -n 1)"
48          sudo update-alternatives \
49              --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-"${CLANG_VERSION}" 50 \
50              --slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-"${CLANG_VERSION}" \
51              --slave /usr/bin/llvm-strip llvm-strip /usr/bin/llvm-strip-"${CLANG_VERSION}"
52          echo "CLANG_VERSION=${CLANG_VERSION}" >> "${GITHUB_ENV}"
53
54      - name: Build bpftool (default LLVM disassembler)
55        run: |
56          make -j -C src V=1
57          ./src/bpftool 2>&1 | grep -q Usage
58          ./src/bpftool -p version | \
59              tee /dev/stderr | \
60              jq --exit-status ".features | ${FEATURES}"
61
62      - name: Build bpftool, with clang
63        run: |
64          make -C src clean
65          LLVM=1 make -j -C src V=1
66          ./src/bpftool 2>&1 | grep -q Usage
67          ./src/bpftool -p version | \
68              tee /dev/stderr | \
69              jq --exit-status ".features | ${FEATURES}"
70
71      - name: Build bpftool, with fallback to libbfd disassembler
72        run: |
73          sudo apt-get remove -y llvm-"${CLANG_VERSION}"-dev
74          make -C src clean
75          make -j -C src V=1
76          ./src/bpftool 2>&1 | grep -q Usage
77          ./src/bpftool -p version | \
78              tee /dev/stderr | \
79              jq --exit-status ".features | .libbfd and (.llvm | not)"
80
81      - name: Build bpftool, with libbfd, static build
82        run: |
83          make -C src clean
84          EXTRA_CFLAGS=--static make -j -C src V=1
85          ./src/bpftool 2>&1 | grep -q Usage
86          ./src/bpftool -p version | \
87              tee /dev/stderr | \
88              jq --exit-status ".features | .libbfd and (.llvm | not)"
89          ldd ./src/bpftool 2>&1 | \
90              tee /dev/stderr | \
91              grep -q 'not a dynamic executable'
92
93      - name: Build bpftool's documentation
94        run: |
95          make -j -C docs
96          grep -q '.TH "\?BPFTOOL"\? 8' ./docs/bpftool.8
97