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

Add Linux RISC-V 64 build to CI #31398

Merged
merged 22 commits into from Jul 6, 2023
Merged

Add Linux RISC-V 64 build to CI #31398

merged 22 commits into from Jul 6, 2023

Conversation

alexey-milovidov
Copy link
Member

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add experimental ClickHouse builds for Linux RISC-V 64 to CI.

@robot-clickhouse robot-clickhouse added the pr-build Pull request with build/testing/packaging improvement label Nov 13, 2021
@alexey-milovidov
Copy link
Member Author

This task requires support from the linker.

@alexey-milovidov
Copy link
Member Author

See #40199

@alexey-milovidov alexey-milovidov marked this pull request as draft August 14, 2022 08:36
@alexey-milovidov
Copy link
Member Author

It is almost ready: #40141
But we need to build a fresh LLVM/Clang on Docker build.

@alexey-milovidov
Copy link
Member Author

Looks like the compiler-rt library is missing.

@robot-clickhouse robot-clickhouse added the submodule changed At least one submodule changed in this PR. label Aug 20, 2022
@alexey-milovidov
Copy link
Member Author

clang-16 is not required, actually clang-14 is enough.

@azat azat mentioned this pull request May 9, 2023
@alexey-milovidov alexey-milovidov marked this pull request as ready for review July 4, 2023 19:29
@robot-clickhouse robot-clickhouse removed the submodule changed At least one submodule changed in this PR. label Jul 4, 2023
@robot-clickhouse
Copy link
Member

robot-clickhouse commented Jul 4, 2023

This is an automated comment for commit 98da25f with description of existing statuses. It's updated for the latest CI running
The full report is available here
The overall status of the commit is 🟡 pending

Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help🟢 success
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR🟡 pending
ClickHouse build checkBuilds ClickHouse in various configurations for use in further steps. You have to fix the builds that fail. Build logs often has enough information to fix the error, but you might have to reproduce the failure locally. The cmake options can be found in the build log, grepping for cmake. Use these options and follow the general build process🟢 success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help🟢 success
Docker image for serversThe check to build and optionally push the mentioned image to docker hub🟢 success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here🟢 success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integrational tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc🟢 success
Install packagesChecks that the built packages are installable in a clear environment🟢 success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests🟢 success
Mergeable CheckChecks if all other necessary checks are successful🟢 success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests🟢 success
Push to DockerhubThe check for building and pushing the CI related docker images to docker hub🟢 success
SQLancerFuzzing tests that detect logical bugs with SQLancer tool🟢 success
SqllogicRun clickhouse on the sqllogic test set against sqlite and checks that all statements are passed🟢 success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc🟢 success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc🟢 success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors🟢 success
Style CheckRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report🟢 success
Unit testsRuns the unit tests for different release types🟢 success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts🟢 success

@alexey-milovidov
Copy link
Member Author

Wow, it works!

@alexey-milovidov alexey-milovidov self-assigned this Jul 6, 2023
@alexey-milovidov alexey-milovidov merged commit 6cfeef0 into master Jul 6, 2023
256 of 258 checks passed
@alexey-milovidov alexey-milovidov deleted the riscv-in-ci branch July 6, 2023 19:49
@azat
Copy link
Collaborator

azat commented Jul 8, 2023

Interesting, it does not work for me. Maybe you have real RISC-V machine?

I got SIGSEGV with qemu (this is docker image that runs qemu inside):

$ docker run -p 2222 --name riscv --rm -it davidburela/riscv-emulator
$ apt update
$ apt install curl
$ ./clickhouse local
[  361.073643] clickhouse[3167]: unhandled signal 11 code 0x1 at 0xffffffff80016180 in clickhouse[10000+137af000]
[  361.076816] CPU: 0 PID: 3167 Comm: clickhouse Not tainted 6.1.0-7-riscv64 #1  Debian 6.1.20-1
[  361.078220] Hardware name: riscv-virtio,qemu (DT)
[  361.079163] epc : 000000000d87f8b6 ra : 000000000d87f878 sp : 00ffffffce43e820
[  361.080891]  gp : 000000001399d888 tp : 00ffffffbea3c780 t0 : 00ffffff800161c0
[  361.082941]  t1 : 00000000057db19c t2 : 0000000000000000 s0 : 00000000000000f0
[  361.085026]  s1 : 00ffffff60000000 a0 : ffffffff80016180 a1 : 0000000000030000
[  361.086458]  a2 : 0000000000000000 a3 : 00ffffff60010000 a4 : 00ffffff60010000
[  361.088158]  a5 : 00ffffff60010000 a6 : 0000000000000000 a7 : 00ffffff60000000
[  361.089689]  s2 : 00ffffffbea3c980 s3 : 000000000e073080 s4 : 00ffffffce43ec68
[  361.091433]  s5 : 00ffffffbea3c790 s6 : 000000000000ffff s7 : 00ffffff00000000
[  361.092908]  s8 : 00fffffff6363820 s9 : 00fffffff6363838 s10: 00aaaaaac82bfa4c
[  361.094654]  s11: 00aaaaaac82bf9c0 t3 : 00ffffffbeb2d7be t4 : 0000000000079594
[  361.095809]  t5 : 00ffffffce43c650 t6 : 0000000002f75a7c
[  361.096791] status: 8000000200006020 badaddr: ffffffff80016180 cause: 000000000000000d
Segmentation fault

AFAIR the error is in jemalloc, but I haven't checked this time.

@alexey-milovidov
Copy link
Member Author

We've tested it on a real RISC-V machine, including ClickBench run.

I've also tested on QEMU, and found a couple of bugs (most likely in QEMU).

@alexey-milovidov
Copy link
Member Author

Check this image instead: docker run -it --rm riscv64/ubuntu

Or you can use chroot instead of docker - just place a few .so, mount /proc, /dev, and /tmp, and put qemu-riscv64-static there.

@alexey-milovidov
Copy link
Member Author

Just in case - let's try to link it with Musl, maybe you can help...

@azat
Copy link
Collaborator

azat commented Jul 9, 2023

Check this image instead: docker run -it --rm riscv64/ubuntu

This is different, it is for riscv64 machine, not for amd64

$ docker run -it --rm riscv64/ubuntu
WARNING: The requested image's platform (linux/riscv64) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
exec /usr/bin/bash: exec format error

@alexey-milovidov
Copy link
Member Author

@azat you need to register qemu-riscv64-static in the binfmt-misc kernel module.

@azat
Copy link
Collaborator

azat commented Jul 15, 2023

@azat you need to register qemu-riscv64-static in the binfmt-misc kernel module.

@alexey-milovidov I don't get how this will help?
binfmt is just a way to execute binaries with different interpreter.
And even if I will do this, I sitll need some files for risvv64 (like libc)

So I used docker container, that has everything inside it, and run qemu-riscv64-system

Can you share how did you run binaries for riscv64 architecture?

@alexey-milovidov
Copy link
Member Author

alexey-milovidov commented Jul 15, 2023

cd ~/work/ClickHouse/contrib/sysroot/linux-riscv64
sudo cp ~/work/ClickHouse/programs/server/clickhouse .
sudo cp /usr/bin/qemu-riscv64-static .
mkdir dev
head -c1000 /dev/urandom > dev/urandom
mkdir proc
sudo mount -t proc /proc proc
mkdir tmp
sudo mount -t tmpfs /tmp tmp
sudo chroot . /qemu-riscv64-static /clickhouse
sudo chroot . /qemu-riscv64-static /clickhouse local --query "SELECT 1"

@azat
Copy link
Collaborator

azat commented Jul 15, 2023

Nice, thank you! Forgot that all libraries are there already.

But one more thing is required actually (to use binaries from CI artifacts) - #52138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-build Pull request with build/testing/packaging improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants