Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move first RISC-V builder over to cross-compiler + execute tests under qemu-system setup #279

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
25 changes: 21 additions & 4 deletions buildbot/osuosl/master/config/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,9 @@
'CXX': 'clang++',
})},

## RISC-V RVA20 profile check-all 2-stage
## RISC-V RVA20 profile check-all 2-stage. The second stage is
# cross-compiled on the x86 host and then lit runs under a qemu-system image
# using the just-built artifacts.
{'name' : "clang-riscv-rva20-2stage",
'tags' : ["clang"],
'workernames' : ["rise-clang-riscv-rva20-2stage"],
Expand All @@ -3161,6 +3163,7 @@
useTwoStage=True,
runTestSuite=False,
testStage1=False,
checkout_compiler_rt=False,
extra_cmake_args=[
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++",
Expand All @@ -3169,9 +3172,23 @@
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache"],
extra_stage2_cmake_args=[
"-DLLVM_ENABLE_LLD=True",
"-DCMAKE_C_FLAGS='-march=rva20u64'",
"-DCMAKE_CXX_FLAGS='-march=rva20u64'"]
util.Interpolate(f"-DLLVM_NATIVE_TOOL_DIR=%(prop:builddir)s/stage1.install/bin"),
"-DLLVM_BUILD_TESTS=True",
"-DLLVM_EXTERNAL_LIT=/home/buildbot-worker/lit-on-qemu-system-rva20.py",
DavidSpickett marked this conversation as resolved.
Show resolved Hide resolved
DavidSpickett marked this conversation as resolved.
Show resolved Hide resolved
],
stage2_toolchain_options=[
"set(CMAKE_SYSTEM_NAME Linux)",
"set(CMAKE_SYSROOT /home/buildbot-worker/rvsysroot)",
"set(CMAKE_C_COMPILER_TARGET riscv64-linux-gnu)",
"set(CMAKE_CXX_COMPILER_TARGET riscv64-linux-gnu)",
"set(CMAKE_C_FLAGS_INIT '-march=rva20u64')",
"set(CMAKE_CXX_FLAGS_INIT '-march=rva20u64')",
"set(CMAKE_LINKER_TYPE LLD)",
"set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)",
"set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)",
"set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)",
"set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)",
]
)},

## RISC-V RVA23 profile check-all 2-stage
Expand Down
41 changes: 34 additions & 7 deletions zorg/buildbot/builders/ClangBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from buildbot.plugins import util
from buildbot.steps.shell import ShellCommand, SetProperty
from buildbot.steps.shell import WarningCountingShellCommand
from buildbot.steps.transfer import StringDownload

import zorg.buildbot.builders.Util as builders_util

Expand Down Expand Up @@ -162,6 +163,10 @@ def getClangCMakeBuildFactory(
# CMake arguments to use for stage2 instead of extra_cmake_args.
extra_stage2_cmake_args=None,

# If set, use a toolchains file for the stage 2 build and add
# these options to it.
stage2_toolchain_options=None,

# Extra repositories
checkout_clang_tools_extra=True,
checkout_compiler_rt=True,
Expand All @@ -180,6 +185,7 @@ def getClangCMakeBuildFactory(
submitURL=submitURL, testerName=testerName,
env=env, extra_cmake_args=extra_cmake_args,
extra_stage2_cmake_args=extra_stage2_cmake_args,
stage2_toolchain_options=stage2_toolchain_options,
checkout_clang_tools_extra=checkout_clang_tools_extra,
checkout_lld=checkout_lld,
checkout_compiler_rt=checkout_compiler_rt,
Expand Down Expand Up @@ -219,6 +225,10 @@ def _getClangCMakeBuildFactory(
# CMake arguments to use for stage2 instead of extra_cmake_args.
extra_stage2_cmake_args=None,

# If set, use a toolchains file for the stage 2 build and add
# these options to it.
stage2_toolchain_options=None,

# Extra repositories
checkout_clang_tools_extra=True,
checkout_compiler_rt=True,
Expand Down Expand Up @@ -426,10 +436,28 @@ def _getClangCMakeBuildFactory(
# Absolute paths to just built compilers.
# Note: Backslash path separators do not work well with cmake and ninja.
# Forward slash path separator works on Windows as well.
stage1_cc = InterpolateToPosixPath(
f"-DCMAKE_C_COMPILER=%(prop:builddir)s/{stage1_install}/bin/{cc}")
stage1_cxx = InterpolateToPosixPath(
f"-DCMAKE_CXX_COMPILER=%(prop:builddir)s/{stage1_install}/bin/{cxx}")
stage1_cc = f"%(prop:builddir)s/{stage1_install}/bin/{cc}"
stage1_cxx = f"%(prop:builddir)s/{stage1_install}/bin/{cxx}"

# If stage2_toolchain_options is set when we'll use a toolchain file
# to specify the compiler being used (the just-built stage1) and add
# any stage2_toolchain_options to it. Otherwise, just set
# -DCMAKE_{C,CXX}_COMPILER.
if stage2_toolchain_options is None:
compiler_args = [
InterpolateToPosixPath(f"-DCMAKE_C_COMPILER={stage1_cc}"),
InterpolateToPosixPath(f"-DCMAKE_CXX_COMPILER={stage1_cxx}"),
]
else:
toolchain_file = f"%(prop:builddir)s/{stage2_build}/stage1-toolchain.cmake"
toolchain_file_contents = "\n".join([
f"set(CMAKE_C_COMPILER {stage1_cc})",
f"set(CMAKE_CXX_COMPILER {stage1_cxx})",
] + stage2_toolchain_options)
f.addStep(StringDownload(util.Interpolate(toolchain_file_contents),
workerdest=InterpolateToPosixPath(toolchain_file)))
compiler_args = [InterpolateToPosixPath(f"-DCMAKE_TOOLCHAIN_FILE={toolchain_file}")]


# If we have a separate stage2 cmake arg list, then ensure we re-apply
# enable_projects and enable_runtimes if necessary.
Expand All @@ -445,13 +473,12 @@ def _getClangCMakeBuildFactory(

rel_src_dir = LLVMBuildFactory.pathRelativeTo(f.llvm_srcdir, stage2_build)
cmake_cmd2 = [cmake, "-G", "Ninja", rel_src_dir,
stage1_cc,
stage1_cxx,
f"-DCMAKE_BUILD_TYPE={stage2_config}",
"-DLLVM_ENABLE_ASSERTIONS=True",
f"-DLLVM_LIT_ARGS={lit_args}",
f"-DCMAKE_INSTALL_PREFIX=../{stage2_install}"
] + (extra_stage2_cmake_args or extra_cmake_args)
] + (extra_stage2_cmake_args or extra_cmake_args) \
+ compiler_args

f.addStep(ShellCommand(name='cmake stage 2',
command=cmake_cmd2,
Expand Down