Skip to content

Commit e87dff7

Browse files
liu-song-6chantra
authored andcommitted
Add inputs.llvm-version
Since we always build BPF programs with clang, ci also installs llvm when inputs.toolchain is gcc. llvm_version(). Instead of parsing llvm version from inputs.toolchain, add a separate input field of llvm-version. Signed-off-by: Song Liu <[email protected]>
1 parent 915b075 commit e87dff7

File tree

9 files changed

+42
-40
lines changed

9 files changed

+42
-40
lines changed

build-linux/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ inputs:
1313
max-make-jobs:
1414
description: 'Maximum number of jobs to use when running make (e.g argument to -j). Default: 4*nproc'
1515
default: ''
16+
llvm-version:
17+
description: 'llvm version'
18+
required: false
19+
default: '16'
1620
runs:
1721
using: "composite"
1822
steps:
1923
- name: build linux
2024
shell: bash
2125
run: |
2226
kbuild_output="$(realpath ${{ inputs.kbuild-output }})"
27+
export LLVM_VERSION=${{ inputs.llvm-version }}
2328
${GITHUB_ACTION_PATH}/build.sh "${{ inputs.arch }}" "${{ inputs.toolchain }}" "${kbuild_output}"
2429
env:
2530
MAX_MAKE_JOBS: ${{ inputs.max-make-jobs }}

build-linux/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ ARCH="$1"
1010
TOOLCHAIN="$2"
1111
export KBUILD_OUTPUT="$3"
1212

13-
LLVM_VER="$(llvm_version $TOOLCHAIN)" && :
14-
if [ $? -eq 0 ]; then
15-
export LLVM="-$LLVM_VER"
13+
if [ $TOOLCHAIN = "llvm" ]; then
14+
export LLVM="-$LLVM_VERSION"
15+
TOOLCHAIN="llvm-$LLVM_VERSION"
1616
fi
1717

1818
foldable start build_kernel "Building kernel with $TOOLCHAIN"

build-samples/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
max-make-jobs:
1414
description: 'Maximum number of jobs to use when running make (e.g argument to -j). Default: 4*nproc'
1515
default: ''
16+
llvm-version:
17+
description: 'llvm version'
18+
required: false
19+
default: '16'
1620

1721
runs:
1822
using: "composite"
@@ -21,6 +25,7 @@ runs:
2125
shell: bash
2226
run: |
2327
kbuild_output="$(realpath ${{ inputs.kbuild-output }})"
28+
export LLVM_VERSION=${{ inputs.llvm-version }}
2429
${GITHUB_ACTION_PATH}/build_samples.sh "${{ inputs.kernel }}" "${{ inputs.toolchain }}" "${kbuild_output}"
2530
env:
2631
MAX_MAKE_JOBS: ${{ inputs.max-make-jobs }}

build-samples/build_samples.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ KERNEL="$1"
1010
TOOLCHAIN="$2"
1111
export KBUILD_OUTPUT="$3"
1212

13-
LLVM_VER="$(llvm_version $TOOLCHAIN)" && :
14-
if [ $? -eq 0 ]; then
15-
export LLVM="-$LLVM_VER"
13+
if [ $TOOLCHAIN = "llvm" ]; then
14+
export LLVM="-$LLVM_VERSION"
15+
TOOLCHAIN="llvm-$LLVM_VERSION"
1616
fi
1717

1818
foldable start build_samples "Building samples with $TOOLCHAIN"
@@ -25,13 +25,13 @@ fi
2525

2626
make headers_install
2727
make \
28-
CLANG=clang-${LLVM_VER} \
29-
OPT=opt-${LLVM_VER} \
30-
LLC=llc-${LLVM_VER} \
31-
LLVM_DIS=llvm-dis-${LLVM_VER} \
32-
LLVM_OBJCOPY=llvm-objcopy-${LLVM_VER} \
33-
LLVM_READELF=llvm-readelf-${LLVM_VER} \
34-
LLVM_STRIP=llvm-strip-${LLVM_VER} \
28+
CLANG=clang-${LLVM_VERSION} \
29+
OPT=opt-${LLVM_VERSION} \
30+
LLC=llc-${LLVM_VERSION} \
31+
LLVM_DIS=llvm-dis-${LLVM_VERSION} \
32+
LLVM_OBJCOPY=llvm-objcopy-${LLVM_VERSION} \
33+
LLVM_READELF=llvm-readelf-${LLVM_VERSION} \
34+
LLVM_STRIP=llvm-strip-${LLVM_VERSION} \
3535
VMLINUX_BTF="${KBUILD_OUTPUT}/vmlinux" \
3636
VMLINUX_H="${VMLINUX_H}" \
3737
-C "${REPO_ROOT}/${REPO_PATH}/samples/bpf" \

build-selftests/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ inputs:
1313
max-make-jobs:
1414
description: 'Maximum number of jobs to use when running make (e.g argument to -j). Default: 4*nproc'
1515
default: ''
16+
llvm-version:
17+
description: 'llvm version'
18+
required: false
19+
default: '16'
1620
runs:
1721
using: "composite"
1822
steps:
1923
- name: build selftests
2024
shell: bash
2125
run: |
2226
kbuild_output="$(realpath ${{ inputs.kbuild-output }})"
27+
export LLVM_VERSION=${{ inputs.llvm-version }}
2328
${GITHUB_ACTION_PATH}/build_selftests.sh "${{ inputs.kernel }}" "${{ inputs.toolchain }}" "${kbuild_output}"
2429
env:
2530
MAX_MAKE_JOBS: ${{ inputs.max-make-jobs }}

build-selftests/build_selftests.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ KERNEL="$1"
1010
TOOLCHAIN="$2"
1111
export KBUILD_OUTPUT="$3"
1212

13-
LLVM_VER="$(llvm_version $TOOLCHAIN)" && :
14-
if [ $? -eq 0 ]; then
15-
export LLVM="-$LLVM_VER"
13+
if [[ $TOOLCHAIN = "llvm" ]]; then
14+
export LLVM="-$LLVM_VERSION"
15+
TOOLCHAIN="llvm-$LLVM_VERSION"
1616
fi
1717

1818
foldable start build_selftests "Building selftests with $TOOLCHAIN"
@@ -32,9 +32,9 @@ fi
3232

3333
cd ${REPO_ROOT}/${REPO_PATH}
3434
make \
35-
CLANG=clang-${LLVM_VER} \
36-
LLC=llc-${LLVM_VER} \
37-
LLVM_STRIP=llvm-strip-${LLVM_VER} \
35+
CLANG=clang-${LLVM_VERSION} \
36+
LLC=llc-${LLVM_VERSION} \
37+
LLVM_STRIP=llvm-strip-${LLVM_VERSION} \
3838
VMLINUX_BTF="${KBUILD_OUTPUT}/vmlinux" \
3939
VMLINUX_H="${VMLINUX_H}" \
4040
-C "${REPO_ROOT}/${REPO_PATH}/tools/testing/selftests/bpf" \

helpers.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,6 @@ llvm_latest_version() {
4747
echo "17"
4848
}
4949

50-
# $1 - toolchain name
51-
llvm_version() {
52-
local toolchain="$1"
53-
local toolchain_name="$(echo $toolchain | cut -d '-' -f 1)"
54-
local toolchain_version="$(echo $toolchain | cut -d '-' -f 2)"
55-
56-
if [ "$toolchain_name" == "llvm" ]; then
57-
echo "$toolchain_version"
58-
return 0
59-
else
60-
llvm_default_version
61-
return 1
62-
fi
63-
}
64-
6550
# No arguments
6651
kernel_build_make_jobs() {
6752
# returns the number of processes to use when building kernel/selftests/samples

setup-build-env/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ inputs:
99
description: 'pahole repo'
1010
required: true
1111
default: 'https://git.kernel.org/pub/scm/devel/pahole/pahole.git'
12+
llvm-version:
13+
description: 'llvm version'
14+
required: false
15+
default: '16'
1216
runs:
1317
using: "composite"
1418
steps:
@@ -22,6 +26,7 @@ runs:
2226
- name: Install clang
2327
shell: bash
2428
run: |
29+
export LLVM_VERSION=${{ inputs.llvm-version }}
2530
${GITHUB_ACTION_PATH}/install_clang.sh
2631
- name: Install pahole
2732
shell: bash

setup-build-env/install_clang.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ foldable start install_clang "Installing Clang/LLVM"
88
sudo apt-get update
99
sudo apt-get install -y g++ libelf-dev
1010

11-
LLVM_VERSION=$(llvm_default_version)
12-
13-
REPO_DISTRO_SUFFIX="-${LLVM_VERSION}"
14-
15-
if [[ "${LLVM_VERSION}" == $(llvm_latest_version) ]]
16-
then
11+
if [[ "${LLVM_VERSION}" == $(llvm_latest_version) ]] ; then
1712
REPO_DISTRO_SUFFIX=""
13+
else
14+
REPO_DISTRO_SUFFIX="-${LLVM_VERSION}"
1815
fi
1916

2017
echo "deb https://apt.llvm.org/focal/ llvm-toolchain-focal${REPO_DISTRO_SUFFIX} main" | sudo tee /etc/apt/sources.list.d/llvm.list

0 commit comments

Comments
 (0)