-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
RFC: Riscv bare metal CI job #31425
base: master
Are you sure you want to change the base?
RFC: Riscv bare metal CI job #31425
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31425. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
e75c002
to
ece9dcd
Compare
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
Interesting. Do you think this is possible at all, given that the kernel library links leveldb, which I'd presume is not bare-metal ready? So I guess this mostly serves as a check that users can ship their own-brewed libbitcoinconsensus (or so, or subset of it)? |
ece9dcd
to
bc5adc3
Compare
Yes, definitely not ready. I think the main hurdle is the background compaction, which I am not sure how to tackle. Maybe we'll find a solution for it eventually though, either by patching it, or allowing the user to bring their own utxos.
Yes, that is the goal for now. |
A bare metal build is now supported by setting CMAKE_SYSTEM_NAME=Generic Skip the platform-dependent feature checks, such as threads and atomics, which are typically not available on bare metal. Also only make the boost headers mandatory if they exist for the target.
bc5adc3
to
4910ae5
Compare
ci/test/03_test_script.sh
Outdated
src/secp256k1/lib/libsecp256k1.a \ | ||
/opt/riscv-ilp32/riscv32-unknown-elf/lib/libstdc++.a \ | ||
/riscv/newlib/build/riscv32-unknown-elf/newlib/libc.a \ | ||
/riscv/newlib/build/riscv32-unknown-elf/newlib/libm.a \ |
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.
Any specific reason to use the intermediate build and not the installed libraries from /opt/newlib
, here?
ci/test/01_base_install.sh
Outdated
cd /riscv/newlib | ||
mkdir build && cd build | ||
../configure \ | ||
--target=riscv32-unknown-elf --disable-newlib-io-float --enable-newlib-io-long-long --enable-newlib-io-long-double --with-arch=rv32gc --with-abi=ilp32 --disable-shared --disable-multilib\ |
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.
Are you sure enabling i/o for long-double is needed? i don't believe we use this type anywhere.
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.
Sorry, all these flags were a mess. I was experimenting with linking in a range of other functionality, as well as running it on linux directly, and didn't prune stuff out nicely. Removed most of them again.
Mentioning this because i had to look it up to be sure: newlib-cygwin has nothing to do with Windows whatsoever. It's simply a minimalist libc.
Could be a periodic foreground task, if threads aren't available? But yes, this would imply patching leveldb, there is no such API right now. |
ci/test/01_base_install.sh
Outdated
@@ -84,6 +84,29 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then | |||
rm -rf /msan/llvm-project | |||
fi | |||
|
|||
if [[ ${BARE_METAL_RISCV} == "true" ]]; then | |||
${CI_RETRY_EXE} git clone --depth=1 https://github.com/riscv-collab/riscv-gnu-toolchain -b 2024.11.22 /riscv/gcc | |||
cd /riscv/gcc |
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.
style-wise, it would be good to not use cd
in the CI scripts, because it affects the global state for all remaining lines.
It is better to wrap it into ()
, for example ( cd a ; foo(); )
(or similar).
ci/test/01_base_install.sh
Outdated
CFLAGS_FOR_TARGET="-march=rv32gc -mabi=ilp32 -mcmodel=medlow "\ | ||
CXXFLAGS_FOR_TARGET="-std=c++20 -march=rv32gc -mabi=ilp32 -mcmodel=medlow" | ||
make -j "$MAKEJOBS" | ||
make install |
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.
It would be good to rm -rf everything duplicate. Otherwise, you are using up space twice:
$ podman image ls | grep riscv
localhost/ci_native_riscv_bare latest dfa9b8223b62 5 minutes ago 13.9 GB
See the llvm build on how to do this.
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.
Should be better now:
docker image ls | grep riscv
ci_native_riscv_bare latest 55627eefe6d7 3 minutes ago 2.8GB
4910ae5
to
f277600
Compare
Updated 4910ae5 -> f277600 (bare_metal_support_0 -> bare_metal_support_1, compare)
|
|
||
call main | ||
|
||
# Put Exit2 system call number into the a7 register |
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.
concept ACK on making it actually runnable somewhat
i was confused for a moment here, as to what syscall numbers mean for bare-metal
maybe add "Linux" to the comment
Concept ACK, this looks like the minimum required to sanity check that libconsensus.a can be compiled for, and linked for bare-metal RISC-V. |
This adds a CI job for building the static consensus library and linking it to an executable. It uses newlib-cygwin as a C library for the final linking step. This ensure compatibility with this target going forward and can serve as a starting point for enabling bare metal builds for the entire kernel library. This would have also caught the error fixed in #31365.