From 8bb317c4b7d8a4f5bdbde81be4d25872d8c72b30 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:13:14 +0200 Subject: [PATCH] CI: added Ubuntu RISC-V build, fixed Windows builds --- .github/workflows/c-cpp.yml | 106 ++++++++++++++++++++++++++++++++-- cmake/riscv64_toolchain.cmake | 8 +++ 2 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 cmake/riscv64_toolchain.cmake diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 3c7907b..25da2c1 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -260,7 +260,6 @@ jobs: matrix: config: - {os: ubuntu-22.04, flags: "-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"} - - {os: ubuntu-24.04, flags: "-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"} steps: - name: Install dependencies @@ -330,6 +329,102 @@ jobs: name: p2pool-${{ matrix.config.os }}-aarch64 path: build/p2pool + build-ubuntu-riscv64: + + timeout-minutes: 60 + runs-on: ${{ matrix.config.os }} + + strategy: + matrix: + config: + - {os: ubuntu-22.04, flags: "-fuse-linker-plugin -ffunction-sections"} + + steps: + - name: Setup Alpine Linux + uses: jirutka/setup-alpine@v1 + with: + arch: riscv64 + branch: latest-stable + + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y git build-essential cmake gcc-riscv64-linux-gnu g++-riscv64-linux-gnu binutils-riscv64-linux-gnu + sudo cp /usr/riscv64-linux-gnu/lib/* /home/runner/rootfs/alpine-latest-riscv64/lib + + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Build libcurl + run: | + cd external/src/curl + cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS="-Os -flto=auto ${{ matrix.config.flags }}" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/src/include + make -j$(nproc) + cd lib && mkdir .libs && cp libcurl.a .libs + + - name: Build libuv + run: | + cd external/src/libuv + mkdir build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF + make -j$(nproc) + + - name: Build libzmq + run: | + cd external/src/libzmq + mkdir build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF -DCMAKE_POLICY_VERSION_MINIMUM="3.5" + make -j$(nproc) + + - name: Build p2pool + run: | + mkdir build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DSTATIC_LIBS=ON -DARCH_ID=riscv64 -DCMAKE_POLICY_VERSION_MINIMUM="3.5" + make -j$(nproc) p2pool + + - name: Run self-test + shell: alpine.sh {0} + run: build/p2pool --test + + - name: Build RandomX tests + run: | + cd build + make -j$(nproc) randomx-tests + + - name: Run RandomX tests + shell: alpine.sh {0} + run: build/external/src/RandomX/randomx-tests + + - name: Build tests + run: | + cd tests + mkdir build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DSTATIC_LIBS=ON -DARCH_ID=riscv64 -DCMAKE_POLICY_VERSION_MINIMUM="3.5" + make -j$(nproc) p2pool_tests + + - name: Prepare test data + run: | + cd tests/build + gunzip *.gz + + - name: Run tests + shell: alpine.sh {0} + run: | + cd tests/build + ./p2pool_tests + + - name: Archive binary + uses: actions/upload-artifact@v4 + with: + name: p2pool-${{ matrix.config.os }}-riscv64 + path: build/p2pool + build-windows-msys2: timeout-minutes: 60 @@ -423,11 +518,10 @@ jobs: matrix: config: - {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", rx: "ON", upnp: "ON", grpc: "ON", tls: "ON"} - - {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "ON", upnp: "ON", grpc: "ON", tls: "ON"} - - {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "ON", upnp: "ON", grpc: "OFF", tls: "ON"} - - {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "ON", grpc: "OFF", tls: "ON"} - - {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "OFF", grpc: "OFF", tls: "ON"} - - {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "OFF", grpc: "OFF", tls: "OFF"} + - {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "ON", upnp: "ON", grpc: "OFF", tls: "ON"} + - {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "ON", grpc: "OFF", tls: "ON"} + - {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "OFF", grpc: "OFF", tls: "ON"} + - {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "OFF", grpc: "OFF", tls: "OFF"} steps: - name: Checkout repository diff --git a/cmake/riscv64_toolchain.cmake b/cmake/riscv64_toolchain.cmake new file mode 100644 index 0000000..c179c49 --- /dev/null +++ b/cmake/riscv64_toolchain.cmake @@ -0,0 +1,8 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_CROSSCOMPILING TRUE) + +set(CMAKE_SYSTEM_PROCESSOR riscv64) + +set(CMAKE_C_COMPILER /usr/bin/riscv64-linux-gnu-gcc) +set(CMAKE_CXX_COMPILER /usr/bin/riscv64-linux-gnu-g++) +set(CMAKE_STRIP /usr/bin/riscv64-linux-gnu-strip)