Skip to content

Commit e011f5f

Browse files
committed
github: rework clang-compilation CI
Signed-off-by: Jerry Zhang Jian <[email protected]>
1 parent d0669e2 commit e011f5f

File tree

1 file changed

+108
-46
lines changed

1 file changed

+108
-46
lines changed
Lines changed: 108 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,123 @@
11
name: Clang (LLVM) intrinsic test case compilation
2-
on: [push]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
workflow_dispatch: # Allows manual triggering of the workflow
310

411
jobs:
5-
build:
12+
build-and-test:
613
runs-on: ubuntu-latest
714
strategy:
815
matrix:
9-
llvm-version: ["main", "latest-rel"]
16+
llvm-version: [latest-rel]
17+
18+
env:
19+
COMPILER: llvm-project/build/bin/clang
20+
EXTRA_CFLAGS: "-target riscv64"
21+
1022
steps:
11-
- uses: actions/checkout@v4
12-
- uses: actions/setup-python@v5
23+
- name: Checkout rvv-intrinsic-doc
24+
uses: actions/checkout@v4
1325
with:
14-
python-version: '3.11'
15-
- name: Prerequisites
16-
run: |
17-
sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev dejagnu
18-
- name: Install dependencies
19-
run: |
20-
pip install --user junitparser
21-
- name: Download LLVM
26+
repository: riscv-non-isa/rvv-intrinsic-doc
27+
path: rvv-intrinsic-doc
28+
29+
- name: Setup Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.x'
33+
34+
- name: Install Python dependencies
2235
run: |
23-
cd ..
24-
rm -rf llvm-project
25-
git clone https://github.com/llvm/llvm-project -j `nproc`
26-
- name: Checkout LLVM version
36+
pip install junitparser
37+
working-directory: ${{ github.workspace }}
38+
39+
- name: Set up LLVM (latest release)
40+
if: matrix.llvm-version == 'latest-rel'
2741
run: |
28-
cd ../llvm-project
29-
if [ "${{ matrix.llvm-version }}" = "latest-rel" ]; then
30-
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
31-
git checkout $latestTag
42+
latest_release=$(curl -sL https://api.github.com/repos/llvm/llvm-project/releases/latest)
43+
download_url=$(echo "$latest_release" | jq -r '.assets[] | select(.name | endswith("Linux-X64.tar.xz")) | .browser_download_url')
44+
if [ -z "$download_url" ]; then
45+
echo "Error: Could not find Linux X64 tarball URL"
46+
exit 1
3247
fi
33-
- name: Build LLVM with Ninja
34-
run: |
35-
cd ../llvm-project
36-
mkdir build && cd build
37-
cmake -G Ninja \
38-
-DCMAKE_C_COMPILER=gcc \
39-
-DCMAKE_CXX_COMPILER=g++ \
40-
-DLLVM_TARGETS_TO_BUILD="RISCV" \
41-
-DLLVM_PARALLEL_LINK_JOBS=12 \
42-
-DCMAKE_BUILD_TYPE=Release \
43-
-DBUILD_SHARED_LIBS=OFF \
44-
-DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-linux-gnu" \
45-
-DLLVM_ENABLE_PROJECTS="clang;lld" \
46-
../llvm
47-
ninja -j `nproc`
48-
echo $(pwd)
49-
ls bin
50-
- name: Run compilation test, non-overloaded intrinsics (default (TAMA) policy)
48+
filename=$(basename "$download_url")
49+
echo "Downloading $filename..."
50+
curl -sL -o "$filename" "$download_url"
51+
tar xf "$filename"
52+
extracted_dir=$(tar tf "$filename" | head -1 | cut -f1 -d"/")
53+
# Set the COMPILER environment variable
54+
echo "COMPILER=${{ github.workspace }}/$extracted_dir/bin/clang" >> $GITHUB_ENV
55+
working-directory: ${{ github.workspace }}
56+
57+
- name: Install prerequisites (main)
58+
if: matrix.llvm-version == 'main'
5159
run: |
52-
make -C rvv-intrinsic-generator run-api-testing run-bfloat16-api-testing run-vector-crypto-api-testing COMPILER=$(pwd)/../llvm-project/build/bin/clang EXTRA_CFLAGS="-target riscv64"
53-
- name: Run compilation test, overloaded intrinsics (default (TAMA) policy)
60+
sudo apt-get update
61+
sudo apt-get install -y ninja-build
62+
working-directory: ${{ github.workspace }}
63+
64+
- name: Checkout LLVM (main)
65+
if: matrix.llvm-version == 'main'
66+
uses: actions/checkout@v4
67+
with:
68+
repository: llvm/llvm-project
69+
path: llvm-project
70+
fetch-depth: 1
71+
72+
- name: Configure & Build LLVM (main)
73+
if: matrix.llvm-version == 'main'
5474
run: |
55-
make -C rvv-intrinsic-generator run-overloaded-api-testing run-bfloat16-overloaded-api-testing run-vector-crypto-overloaded-api-testing COMPILER=$(pwd)/../llvm-project/build/bin/clang EXTRA_CFLAGS="-target riscv64"
56-
- name: Run compilation test, non-overloaded intrinsics (non-default policy)
75+
mkdir -p build && cd build
76+
cmake -G Ninja ../llvm \
77+
-DCMAKE_C_COMPILER=`which clang` \
78+
-DCMAKE_CXX_COMPILER=`which clang++` \
79+
-DCMAKE_BUILD_TYPE=Release \
80+
-DLLVM_ENABLE_PROJECTS="clang" \
81+
-DLLVM_TARGETS_TO_BUILD="RISCV" \
82+
-DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-linux-gnu"
83+
ninja
84+
working-directory: llvm-project
85+
86+
- name: Test
87+
shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"'
88+
# shell: bash
5789
run: |
58-
make -C rvv-intrinsic-generator run-policy-api-testing run-bfloat16-policy-api-testing run-vector-crypto-policy-api-testing COMPILER=$(pwd)/../llvm-project/build/bin/clang EXTRA_CFLAGS="-target riscv64"
59-
- name: Run compilation test, overloaded intrinsics (non-default policy)
90+
stdbuf -oL -eL make -C rvv-intrinsic-generator run-vector-crypto-api-testing
91+
working-directory: rvv-intrinsic-doc
92+
93+
- name: show log
94+
# shell: 'script --return --quiet --log-out /dev/null --command "bash -e {0}"'
95+
shell: bash
6096
run: |
61-
make -C rvv-intrinsic-generator run-policy-overloaded-api-testing run-bfloat16-policy-overloaded-api-testing run-vector-crypto-policy-overloaded-api-testing COMPILER=$(pwd)/../llvm-project/build/bin/clang EXTRA_CFLAGS="-target riscv64"
97+
ls -al auto-generated/vector-crypto/api-testing/
98+
cat auto-generated/vector-crypto/api-testing/*.log
99+
working-directory: rvv-intrinsic-doc
100+
101+
# - name: Run compilation test, non-overloaded intrinsics (default (TAMA) policy)
102+
# run: |
103+
# set -e # Exit on any error
104+
# make -C rvv-intrinsic-generator run-api-testing run-bfloat16-api-testing run-vector-crypto-api-testing
105+
# working-directory: rvv-intrinsic-doc
106+
107+
# - name: Run compilation test, overloaded intrinsics (default (TAMA) policy)
108+
# run: |
109+
# set -e # Exit on any error
110+
# make -C rvv-intrinsic-generator run-overloaded-api-testing run-bfloat16-overloaded-api-testing run-vector-crypto-overloaded-api-testing
111+
# working-directory: rvv-intrinsic-doc
112+
113+
# - name: Run compilation test, non-overloaded intrinsics (non-default policy)
114+
# run: |
115+
# set -e # Exit on any error
116+
# make -C rvv-intrinsic-generator run-policy-api-testing run-bfloat16-policy-api-testing run-vector-crypto-policy-api-testing
117+
# working-directory: rvv-intrinsic-doc
118+
119+
# - name: Run compilation test, overloaded intrinsics (non-default policy)
120+
# run: |
121+
# set -e # Exit on any error
122+
# make -C rvv-intrinsic-generator run-policy-overloaded-api-testing run-bfloat16-policy-overloaded-api-testing run-vector-crypto-policy-overloaded-api-testing
123+
# working-directory: rvv-intrinsic-doc

0 commit comments

Comments
 (0)