Skip to content

Commit 07cf32d

Browse files
authored
[RISCV] Move clang-riscv-rva23-evl-vec-2stage to annotated builder (#374)
The intent is for the rest of the RISE RISC-V builders to follow, but this starts the process. Previously the builders used the framework provided by ClangBuilder.py. As the build has required more customisation (with more to come - such as building the llvm-test-suite with the stage1 compiler which isn't support by ClangBuilder) this is requiring more and more changes to increase configurability of ClangBuilder, but this makes the logic harder to follow and I think we've reached the limit of what's reasonable. The AnnotatedBuilder infrastructure allows the build logic to just be put in a shell script. The latest version of llvm-zorg is checked out and the script is executed. This has the additional advantage of decoupling script updates from needing to wait for buildmaster redeploys. With that in mind, I've avoided putting any configuration through options or environment variables defined by the builder instantiation in builders.py so there's no need to reason about cases where e.g. a script update was committed but the buildmaster may or may not have been updated with a new builders.py. rise-riscv-build.sh is written with the philosophy that "A little copying is better than a little dependency." We could look to share more logic, but we'd end up with the same configurability issue as ClangBuilder. Instead, the script provides only the configurability needed for this set of builders. A future improvement would be to make rise-riscv-build.sh more friendly to running outside of the buildbot environment (e.g. for local testing). This is left to future work, as it's not a regression vs the current approach. This change has been tested locally along the lines of the instructions I wrote in <https://llvm.org/docs/HowToAddABuilder.html#testing-a-builder-config-locally>. Something like the following is sufficient to use a local downstream testing llvm-zorg branch for the annotated builder scripts temporarily: ``` --- a/zorg/buildbot/builders/AnnotatedBuilder.py +++ b/zorg/buildbot/builders/AnnotatedBuilder.py @@ -77,6 +77,8 @@ def getAnnotatedBuildFactory( # Check out zorg so we can run the annotator scripts. f.addGetSourcecodeForProject( name='update-annotated-scripts', + repourl='file:///home/asb/llvm-zorg', + branch='synced-worktree', project='zorg', src_dir='llvm-zorg', alwaysUseLatest=True) ```
1 parent 3c627f0 commit 07cf32d

File tree

2 files changed

+112
-40
lines changed

2 files changed

+112
-40
lines changed

buildbot/osuosl/master/config/builders.py

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3362,46 +3362,11 @@
33623362
{'name' : "clang-riscv-rva23-evl-vec-2stage",
33633363
'workernames' : ["rise-clang-riscv-rva23-evl-vec-2stage"],
33643364
'builddir':"clang-riscv-rva23-evl-vec-2stage",
3365-
'factory' : ClangBuilder.getClangCMakeBuildFactory(
3366-
clean=True,
3367-
useTwoStage=True,
3368-
runTestSuite=False,
3369-
testStage1=False,
3370-
checkout_compiler_rt=False,
3371-
checkout_zorg=True,
3372-
extra_cmake_args=[
3373-
"-DCMAKE_C_COMPILER=clang",
3374-
"-DCMAKE_CXX_COMPILER=clang++",
3375-
"-DLLVM_ENABLE_LLD=True",
3376-
"-DLLVM_TARGETS_TO_BUILD=RISCV",
3377-
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
3378-
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache"],
3379-
extra_stage2_cmake_args=[
3380-
util.Interpolate("-DLLVM_NATIVE_TOOL_DIR=%(prop:builddir)s/stage1.install/bin"),
3381-
"-DLLVM_BUILD_TESTS=True",
3382-
"-DPython3_EXECUTABLE=/usr/bin/python3",
3383-
"-DLLVM_HOST_TRIPLE=riscv64-linux-gnu",
3384-
util.Interpolate("-DLLVM_EXTERNAL_LIT=%(prop:builddir)s/llvm-zorg/buildbot/riscv-rise/lit-on-qemu")],
3385-
stage2_toolchain_options=[
3386-
"set(CMAKE_SYSTEM_NAME Linux)",
3387-
"set(CMAKE_SYSROOT %(prop:builddir)s/../rvsysroot)",
3388-
"set(CMAKE_C_COMPILER_TARGET riscv64-linux-gnu)",
3389-
"set(CMAKE_CXX_COMPILER_TARGET riscv64-linux-gnu)",
3390-
"set(CMAKE_C_FLAGS_INIT \"-march=rva23u64 -mllvm -force-tail-folding-style=data-with-evl -mllvm -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue\")",
3391-
"set(CMAKE_CXX_FLAGS_INIT \"-march=rva23u64 -mllvm -force-tail-folding-style=data-with-evl -mllvm -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue\")",
3392-
"set(CMAKE_LINKER_TYPE LLD)",
3393-
"set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)",
3394-
"set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)",
3395-
"set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)",
3396-
"set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)"],
3397-
env={
3398-
"BB_IMG_DIR": util.Interpolate("%(prop:builddir)s/.."),
3399-
# TODO: Switch to specifying rva23u64 once support is
3400-
# available in a released QEMU.
3401-
"BB_QEMU_CPU": "rv64,zba=true,zbb=true,zbc=false,zbs=true,zfhmin=true,v=true,vext_spec=v1.0,zkt=true,zvfhmin=true,zvbb=true,zvkt=true,zihintntl=true,zicond=true,zimop=true,zcmop=true,zcb=true,zfa=true,zawrs=true,rvv_ta_all_1s=true,rvv_ma_all_1s=true,rvv_vl_half_avl=true",
3402-
"BB_QEMU_SMP": "32",
3403-
"BB_QEMU_MEM": "64G"}
3404-
)},
3365+
'factory' : AnnotatedBuilder.getAnnotatedBuildFactory(
3366+
script="rise-riscv-build.sh",
3367+
checkout_llvm_sources=False,
3368+
script_interpreter=None,
3369+
clean=True)},
34053370

34063371
# Builders similar to used in Buildkite premerge pipeline.
34073372
# Please keep in sync with llvm-project/.ci configurations.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/bash
2+
3+
# Enable Error tracing
4+
set -o errtrace
5+
6+
# Print trace for all commands ran before execution
7+
set -x
8+
9+
ANN_SCRIPT_DIR="$(dirname $0)"
10+
. ${ANN_SCRIPT_DIR}/buildbot-helper.sh
11+
12+
# Ensure all commands pass, and no dereferencing of unset variables.
13+
set -eu
14+
halt_on_failure
15+
16+
# We don't want to build within 'build' (where we start by default).
17+
cd ..
18+
rm -rf build
19+
20+
# Set up variables
21+
LLVM_REVISION="${BUILDBOT_REVISION:-origin/main}"
22+
23+
case "$BUILDBOT_BUILDERNAME" in
24+
"clang-riscv-rva23-evl-vec-2stage")
25+
TARGET_CFLAGS="-march=rva23u64 -mllvm -force-tail-folding-style=data-with-evl -mllvm -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue"
26+
export BB_IMG_DIR=$(pwd)/..
27+
# TODO: Switch to specifying rva23u64 once support is available in a
28+
# released QEMU.
29+
export BB_QEMU_CPU="rv64,zba=true,zbb=true,zbc=false,zbs=true,zfhmin=true,v=true,vext_spec=v1.0,zkt=true,zvfhmin=true,zvbb=true,zvkt=true,zihintntl=true,zicond=true,zimop=true,zcmop=true,zcb=true,zfa=true,zawrs=true,rvv_ta_all_1s=true,rvv_ma_all_1s=true,rvv_vl_half_avl=true"
30+
export BB_QEMU_SMP=32
31+
export BB_QEMU_MEM="64G"
32+
;;
33+
*)
34+
echo "Unrecognised builder name"
35+
exit 1
36+
esac
37+
38+
39+
# Main builder stages start here
40+
41+
if [ ! -d llvm ]; then
42+
build_step "Cloning llvm-project repo"
43+
git clone --progress https://github.com/llvm/llvm-project.git llvm
44+
fi
45+
46+
build_step "Updating llvm-project repo"
47+
git -C llvm fetch origin
48+
git -C llvm reset --hard "${LLVM_REVISION}"
49+
50+
# We unconditionally clean (i.e. don't check BUILDBOT_CLOBBER=1) as the script
51+
# hasn't been tested without cleaning after each build.
52+
build_step "Cleaning last build"
53+
rm -rf stage1 stage2
54+
55+
build_step "llvm-project cmake stage 1"
56+
cmake -G Ninja \
57+
-DCMAKE_BUILD_TYPE=Release \
58+
-DLLVM_ENABLE_ASSERTIONS=True \
59+
-DLLVM_LIT_ARGS="-v" \
60+
-DCMAKE_C_COMPILER=clang \
61+
-DCMAKE_CXX_COMPILER=clang++ \
62+
-DLLVM_ENABLE_LLD=True \
63+
-DLLVM_TARGETS_TO_BUILD="RISCV" \
64+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
65+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
66+
-DLLVM_ENABLE_PROJECTS="lld;clang;llvm" \
67+
-B stage1 \
68+
-S llvm/llvm
69+
70+
build_step "llvm-project build stage 1"
71+
cmake --build stage1
72+
73+
build_step "llvm-project cmake stage 2"
74+
cat - <<EOF > stage1-toolchain.cmake
75+
set(CMAKE_SYSTEM_NAME Linux)
76+
set(CMAKE_SYSROOT $(pwd)/../rvsysroot)
77+
set(CMAKE_C_COMPILER_TARGET riscv64-linux-gnu)
78+
set(CMAKE_CXX_COMPILER_TARGET riscv64-linux-gnu)
79+
set(CMAKE_C_FLAGS_INIT "$TARGET_CFLAGS")
80+
set(CMAKE_CXX_FLAGS_INIT "$TARGET_CFLAGS")
81+
set(CMAKE_LINKER_TYPE LLD)
82+
set(CMAKE_C_COMPILER $(pwd)/stage1/bin/clang)
83+
set(CMAKE_CXX_COMPILER $(pwd)/stage1/bin/clang++)
84+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
85+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
86+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
87+
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
88+
EOF
89+
cmake -G Ninja \
90+
-DCMAKE_BUILD_TYPE=Release \
91+
-DLLVM_ENABLE_ASSERTIONS=True \
92+
-DLLVM_LIT_ARGS="-v" \
93+
-DLLVM_NATIVE_TOOL_DIR=$(pwd)/stage1/bin \
94+
-DLLVM_BUILD_TESTS=True \
95+
-DPython3_EXECUTABLE=/usr/bin/python3 \
96+
-DLLVM_EXTERNAL_LIT="$(pwd)/llvm-zorg/buildbot/riscv-rise/lit-on-qemu" \
97+
-DLLVM_ENABLE_PROJECTS="lld;clang;clang-tools-extra;llvm" \
98+
-DCMAKE_TOOLCHAIN_FILE=$(pwd)/stage1-toolchain.cmake \
99+
-DLLVM_HOST_TRIPLE=riscv64-linux-gnu \
100+
-S llvm/llvm \
101+
-B stage2
102+
103+
build_step "llvm-project build stage 2"
104+
cmake --build stage2
105+
106+
build_step "llvm-project check-all"
107+
cmake --build stage2 --target check-all

0 commit comments

Comments
 (0)