Skip to content

Commit

Permalink
Merge pull request #885 from Chilledheart/gh_actions_add_riscv32_arch
Browse files Browse the repository at this point in the history
  • Loading branch information
Keeyou authored Apr 7, 2024
2 parents 2fb44c6 + b0f17bc commit 04505a5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/releases-linux-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
qemu_suffix: loongarch64
- arch: riscv64
qemu_suffix: riscv64
- arch: riscv32
qemu_suffix: riscv32
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand All @@ -75,15 +77,15 @@ jobs:
cd third_party/libc++abi
patch -p1 < v8-6.7.17-fix-gcc-unwind-header.patch
- name: Set SDK_ROOT
if: ${{ matrix.arch != 'loongarch64' && matrix.arch != 'riscv64' }}
if: ${{ matrix.arch != 'loongarch64' && matrix.arch != 'riscv64' && matrix.arch != 'riscv32' }}
run: |
echo "SDK_ROOT=${{ github.workspace }}/debian_bullseye_${{ matrix.arch }}-sysroot" >> $GITHUB_ENV
- name: Set SDK_ROOT for loongarch64
if: ${{ matrix.arch == 'loongarch64' }}
run: |
echo "SDK_ROOT=${{ github.workspace }}/debian_bullseye_${{ matrix.arch }}-sysroot/target" >> $GITHUB_ENV
- name: Set SDK_ROOT for riscv64
if: ${{ matrix.arch == 'riscv64' }}
- name: Set SDK_ROOT for riscv64 and riscv32
if: ${{ matrix.arch == 'riscv64' || matrix.arch == 'riscv32' }}
run: |
echo "SDK_ROOT=${{ github.workspace }}/debian_bullseye_${{ matrix.arch }}-sysroot/sysroot" >> $GITHUB_ENV
- name: Cache clang
Expand Down Expand Up @@ -130,7 +132,7 @@ jobs:
run: |
wget http://ftp.us.debian.org/debian/pool/main/q/qemu/qemu-user-static_8.2.2+ds-2_amd64.deb
- name: "Install dependency: sysroot"
if: ${{ steps.sysroot-cache.outputs.cache-hit != 'true' && matrix.arch != 'loongarch64' && matrix.arch != 'riscv64' }}
if: ${{ steps.sysroot-cache.outputs.cache-hit != 'true' && matrix.arch != 'loongarch64' && matrix.arch != 'riscv64' && matrix.arch != 'riscv32' }}
run: |
./scripts/install-sysroot.py --arch ${{ matrix.arch }}
- name: "Install dependency: sysroot (loongarch64)"
Expand All @@ -143,13 +145,13 @@ jobs:
cp -fv ./loongarch64-unknown-linux-gnu/lib/libgcc_s.so.1 target/lib64/
rm -rf bin include libexec loongarch64-unknown-linux-gnu share
cd ..
- name: "Install dependency: sysroot (riscv64)"
if: ${{ steps.sysroot-cache.outputs.cache-hit != 'true' && matrix.arch == 'riscv64' }}
- name: "Install dependency: sysroot (riscv64 and riscv32)"
if: ${{ steps.sysroot-cache.outputs.cache-hit != 'true' && (matrix.arch == 'riscv64' || matrix.arch == 'riscv32') }}
run: |
mkdir -p debian_bullseye_riscv64-sysroot
cd debian_bullseye_riscv64-sysroot
curl -L https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2023.07.07/riscv64-glibc-ubuntu-20.04-gcc-nightly-2023.07.07-nightly.tar.gz | tar --strip-components=1 --gz -xf -
rm -rf bin include libexec riscv64-unknown-linux-gnu share
mkdir -p debian_bullseye_${{ matrix.arch }}-sysroot
cd debian_bullseye_${{ matrix.arch }}-sysroot
curl -L https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2023.07.07/${{ matrix.arch }}-glibc-ubuntu-20.04-gcc-nightly-2023.07.07-nightly.tar.gz | tar --strip-components=1 --gz -xf -
rm -rf bin include libexec ${{ matrix.arch }}-unknown-linux-gnu share
cd ..
- name: Change ubuntu mirror
run: |
Expand All @@ -170,7 +172,7 @@ jobs:
./tools/build --variant cli --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc
./tools/build --variant server --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc
- name: Build TGZ packages (GUI)
if: ${{ matrix.arch != 'loongarch64' && matrix.arch != 'riscv64' }}
if: ${{ matrix.arch != 'loongarch64' && matrix.arch != 'riscv64' && matrix.arch != 'riscv32' }}
run: |
./tools/build --variant gui --arch ${{ matrix.arch }} --system linux --sysroot ${{ env.SDK_ROOT }} -build-benchmark -build-test -nc
- name: Run tests (i386 and amd64)
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ else()
if (CMAKE_C_COMPILER_TARGET MATCHES "^riscv64-.*")
set(OS_RISCV64 TRUE)
endif()
if (CMAKE_C_COMPILER_TARGET MATCHES "^riscv32-.*")
set(OS_RISCV32 TRUE)
endif()
# Fix MINGW (native mingw)'s CMAKE_SYSTEM_PROCESSOR
if (MINGW)
if (OS_X86)
Expand Down Expand Up @@ -534,8 +537,8 @@ if (UNIX AND CMAKE_CROSSCOMPILING AND CMAKE_SYSROOT AND COMPILER_CLANG AND NOT C
file(GLOB _GCC_SYSROOT "${CMAKE_SYSROOT}/../lib/gcc/*/*.*.*")
endif()
endif()
# fix up for riscv64 sysroot
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
# fix up for riscv64 and riscv32 sysroot
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv32")
file(GLOB _GCC_SYSROOT "${CMAKE_SYSROOT}/../lib/gcc/*/*.*.*")
endif()
if (_GCC_SYSROOT)
Expand Down Expand Up @@ -2288,6 +2291,10 @@ if (USE_TCMALLOC)
message(WARNING "tcmalloc: loongarch64 is not supported, disabling...")
set(USE_TCMALLOC OFF)
endif()
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv32")
message(WARNING "tcmalloc: riscv32 is not supported, disabling...")
set(USE_TCMALLOC OFF)
endif()
endif()

# tunings:
Expand Down
3 changes: 2 additions & 1 deletion src/core/rand_util_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class URandomFd {
// (https://chromium-review.googlesource.com/c/chromium/src/+/1545096) and land
// it or some form of it.
void RandBytes(void* output, size_t output_length) {
#ifdef __linux__
// FIXME currently lss doesn't like riscv32
#if defined(__linux__) && !defined(ARCH_CPU_RISCV32)
// We have to call `getrandom` via Linux Syscall Support, rather than through
// the libc wrapper, because we might not have an up-to-date libc (e.g. on
// some bots).
Expand Down
2 changes: 1 addition & 1 deletion third_party/boringssl/src
5 changes: 5 additions & 0 deletions third_party/googleurl-override/build/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@
#define ARCH_CPU_RISCV64 1
#define ARCH_CPU_64_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1
#elif defined(__riscv) && (__riscv_xlen == 32)
#define ARCH_CPU_RISCV_FAMILY 1
#define ARCH_CPU_RISCV32 1
#define ARCH_CPU_32_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1
#else
#error Please add support for your architecture in build/build_config.h
#endif
Expand Down
1 change: 0 additions & 1 deletion third_party/quiche/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ target_include_directories(quiche PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/overrides
${CMAKE_CURRENT_BINARY_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../googleurl
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../../src
${CMAKE_CURRENT_SOURCE_DIR}/../../
Expand Down
2 changes: 2 additions & 0 deletions tools/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ func getGNUTargetTypeAndArch(arch string, subsystem string) (string, string) {
return "loongarch64-linux-gnu", "loongarch64"
} else if arch == "riscv64" {
return "riscv64-linux-gnu", "riscv64"
} else if arch == "riscv32" {
return "riscv32-linux-gnu", "riscv32"
}
glog.Fatalf("Invalid arch: %s", arch)
return "", ""
Expand Down

0 comments on commit 04505a5

Please sign in to comment.