-
Notifications
You must be signed in to change notification settings - Fork 96
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,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, | ||
|
@@ -180,6 +184,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, | ||
|
@@ -219,6 +224,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, | ||
|
@@ -427,9 +436,31 @@ def _getClangCMakeBuildFactory( | |
# 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}") | ||
f"%(prop:builddir)s/{stage1_install}/bin/{cc}") | ||
stage1_cxx = InterpolateToPosixPath( | ||
f"-DCMAKE_CXX_COMPILER=%(prop:builddir)s/{stage1_install}/bin/{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 = [ | ||
f"-DCMAKE_C_COMPILER={stage1_cc}", | ||
f"-DCMAKE_CXX_COMPILER={stage1_cxx}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought maybe we should use a toolchain file for all 2 stage builds but:
So I agree with the decision to not change how the existing builds work. If transparency were our only goal here, I'd say to pass all the toolchain file contents as
Which answers that (and I have had similar experiences with CMake). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Crazy idea though, could the toolchain file's contents be pulled from a file here in the llvm-zorg repo? It could be like:
Then when someone wants to reproduce, there is a starting point that's already in the right form to use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In not actual Python terms:
|
||
] | ||
else: | ||
toolchain_file = InterpolateToPosixPath( | ||
f"%(prop:builddir)s/{stage2_build}/stage1-toolchain.cmake") | ||
with open(toolchain_file, 'w') as file: | ||
file.write(f"set(CMAKE_C_COMPILER {stage1_cc})\n") | ||
file.write(f"set(CMAKE_CXX_COMPILER {stage1_cxx})\n") | ||
for option in stage2_toolchain_options: | ||
file.write(f"{option}\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure whether this runs on the build master or the worker. If its the former, it might need to be a step "write toolchain file" that echos the contents into a file on the worker. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, I think it's likely this isn't writing to a worker-local file as I hope. |
||
|
||
compiler_args = [ | ||
"-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. | ||
|
@@ -445,13 +476,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, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a temporary path but where can this script be placed?
I think given that it's in stage 2 you could have it in llvm-project somewhere, as long as you hardcode the
../<whatever buildbot calls the repo folder because sometimes it uses non-default names...>
. I'm pretty sure the workers don't get a copy of llvm-zorg, otherwise that would be the perfect place for it.(this is a not an important detail though, as long as the script is available somewhere for debugging purposes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick review and for picking this out. I'd actually meant to call out this hardcoding in the PR as something I'd appreciate input on. Happy to put the script wherever is helpful, and I can document the setup I use for the VM - though in reality a bit of work will be needed to precisely replicate the setup (as is the case for most builders). I'd probably be better restructuring so there's a common lit-on-qemu-system.py helper that takes/selects any additional arguments via environment variables (in this case, just different args for
-cpu
for qemu).