CI: Add RISC-V 64 cross-build & qemu-user tests
This commit is contained in:
committed by
Nathaniel Wesley Filardo
parent
97a8bd1758
commit
eb0698fc09
15
.github/workflows/main.yml
vendored
15
.github/workflows/main.yml
vendored
@@ -119,18 +119,28 @@ jobs:
|
||||
system-processor: arm
|
||||
triple: arm-linux-gnueabihf
|
||||
rtld: ld-linux-armhf.so.3
|
||||
ld-flavour: lld
|
||||
- name: arm64
|
||||
system-processor: aarch64
|
||||
triple: aarch64-linux-gnu
|
||||
rtld: ld-linux-aarch64.so.1
|
||||
ld-flavour: lld
|
||||
- name: ppc64el
|
||||
system-processor: powerpc64le
|
||||
triple: powerpc64le-linux-gnu
|
||||
rtld: ld64.so.2
|
||||
ld-flavour: lld
|
||||
- name: riscv64
|
||||
system-processor: riscv64
|
||||
triple: riscv64-linux-gnu
|
||||
rtld: ld-linux-riscv64-lp64d.so.1
|
||||
extra-packages: binutils-riscv64-linux-gnu
|
||||
ld-flavour: bfd
|
||||
ld: /usr/bin/riscv64-linux-gnu-ld.bfd
|
||||
# Don't abort runners if a single one fails
|
||||
fail-fast: false
|
||||
runs-on: ubuntu-latest
|
||||
name: Cross-build for ${{ matrix.arch.triple }}
|
||||
name: ${{matrix.build-type}} cross-build for ${{ matrix.arch.triple }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install cross-compile toolchain and QEMU
|
||||
@@ -141,6 +151,7 @@ jobs:
|
||||
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"
|
||||
sudo apt update
|
||||
sudo apt install libstdc++-9-dev-${{ matrix.arch.name }}-cross qemu-user ninja-build clang-13 lld-13
|
||||
sudo apt install ${{matrix.arch.extra-packages}}
|
||||
# The default PowerPC qemu configuration uses the wrong page size.
|
||||
# Wrap it in a script that fixes this.
|
||||
sudo update-binfmts --disable qemu-ppc64le
|
||||
@@ -161,6 +172,8 @@ jobs:
|
||||
-DSNMALLOC_QEMU_WORKAROUND=ON
|
||||
-DSNMALLOC_STATIC_LIBRARY=OFF
|
||||
-DCMAKE_TOOLCHAIN_FILE=ci/Toolchain.cmake
|
||||
-DSNMALLOC_LINKER=${{matrix.arch.ld}}
|
||||
-DSNMALLOC_LINKER_FLAVOUR=${{matrix.arch.ld-flavour}}
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja
|
||||
|
||||
@@ -245,10 +245,21 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
|
||||
set(${result} ${dirlist} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(CMAKE_REQUIRED_LINK_OPTIONS -fuse-ld=lld)
|
||||
check_cxx_source_compiles("int main() { return 1; }" LLD_WORKS)
|
||||
if (LLD_WORKS)
|
||||
message(STATUS "Using LLD to link snmalloc shims")
|
||||
if(NOT (DEFINED SNMALLOC_LINKER_FLAVOUR) OR ("${SNMALLOC_LINKER_FLAVOUR}" MATCHES "^$"))
|
||||
# Linker not specified externally; probe to see if we can make lld work
|
||||
set(CMAKE_REQUIRED_LINK_OPTIONS -fuse-ld=lld)
|
||||
check_cxx_source_compiles("int main() { return 1; }" LLD_WORKS)
|
||||
if (LLD_WORKS)
|
||||
message(STATUS "Using LLD to link snmalloc shims")
|
||||
endif()
|
||||
elseif(SNMALLOC_LINKER_FLAVOUR STREQUAL "lld")
|
||||
# Linker specified externally to be lld; assume it works and that the flags
|
||||
# have also been set for us
|
||||
set(LLD_WORKS TRUE)
|
||||
else()
|
||||
# Linker specified externally as something other than lld; presume it
|
||||
# doesn't work and don't add its flags, below
|
||||
set(LLD_WORKS FALSE)
|
||||
endif()
|
||||
|
||||
function(add_shim name type)
|
||||
|
||||
@@ -7,7 +7,11 @@ set(CMAKE_C_COMPILER clang-13)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER clang++-13)
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
set(CROSS_LINKER_FLAGS "-fuse-ld=lld -Wl,--dynamic-linker=/usr/${triple}/lib/$ENV{RTLD_NAME},-rpath,/usr/${triple}/lib")
|
||||
|
||||
set(CROSS_LINKER_FLAGS "-fuse-ld=${SNMALLOC_LINKER_FLAVOUR} -Wl,--dynamic-linker=/usr/${triple}/lib/$ENV{RTLD_NAME},-rpath,/usr/${triple}/lib")
|
||||
if((DEFINED SNMALLOC_LINKER) AND NOT ("${SNMALLOC_LINKER}" MATCHES "^$"))
|
||||
string(APPEND CROSS_LINKER_FLAGS " --ld-path=${SNMALLOC_LINKER}")
|
||||
endif()
|
||||
set(CMAKE_EXE_LINKER_FLAGS ${CROSS_LINKER_FLAGS})
|
||||
set(CMAKE_SHARED_LINKER_FLAGS ${CROSS_LINKER_FLAGS})
|
||||
set(CMAKE_MODULE_LINKER_FLAGS ${CROSS_LINKER_FLAGS})
|
||||
|
||||
Reference in New Issue
Block a user