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 CI on Github Actions for x86_64, aarch64, arm, ppc64 and s390x #476

Merged
merged 12 commits into from
Nov 10, 2023
138 changes: 138 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@

name: "Build & Test"

on:
# allow direct trigger
workflow_dispatch:
push:
pull_request:

permissions:
contents: read

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
persist-credentials: false

- name: Install dependencies
run: sudo apt-get update -y -qq && sudo apt-get install -y -qq build-essential clang curl ninja-build libgmp-dev libmpfr-dev cpuinfo

- name: CPU Info
run: isa-info

- name: Build native
run: |
cmake -S . -B _build-native -GNinja \
-DCMAKE_INSTALL_PREFIX=$(pwd)/_install-native \
-DBUILD_STATIC_TEST_BINS=ON
cmake --build _build-native
cmake --install _build-native

- name: Test native
run: |
cd _build-native
ctest -j$(nproc)

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-native
path: |
_build-*
_install-*
if: always()

build-and-test-cross:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# AArch64
- arch: aarch64
qemu_cpu: "max,sve=off"
- arch: aarch64
qemu_cpu: "max,sve=on,sve128=on"
- arch: aarch64
qemu_cpu: "max,sve=on,sve256=on"
- arch: aarch64
qemu_cpu: "max,sve=on,sve512=on"
# Aarch32
- arch: armhf
binfmt: arm
package: -arm-linux-gnueabihf
qemu_cpu: "max"
# PPC64
- arch: ppc64el
binfmt: ppc64le
package: -powerpc64le-linux-gnu
qemu_cpu: "power10"
# IBM Z
- arch: s390x
#TODO: figure out qemu_cpu variable to make tests pass on QEMU

steps:
- uses: actions/[email protected]
with:
persist-credentials: false

- uses: docker/[email protected]
with:
platforms: ${{ matrix.binfmt || matrix.arch }}

- name: Install dependencies
run: sudo apt-get update -y -qq && sudo apt-get install -y -qq build-essential clang curl ninja-build libgmp-dev libmpfr-dev gcc${{ matrix.package || format('-{0}-linux-gnu', matrix.arch) }}

- name: Print host CPU info
run: |
cat /proc/cpuinfo

- name: Build native
run: |
cmake -S . -B _build-native -GNinja \
-DCMAKE_INSTALL_PREFIX=$(pwd)/_install-native \
-DBUILD_STATIC_TEST_BINS=ON \
-DENFORCE_TESTER=ON
cmake --build _build-native
cmake --install _build-native

- name: Build ${{ matrix.arch }}
env:
CTEST_OUTPUT_ON_FAILURE: "TRUE"
QEMU_CPU: ${{ matrix.qemu_cpu }}
run: |
cmake -S . -B _build-${{ matrix.arch }} -GNinja \
-DCMAKE_TOOLCHAIN_FILE=$(pwd)/travis/toolchain-${{ matrix.arch }}.cmake \
-DCMAKE_INSTALL_PREFIX="$(pwd)/_install-${{ matrix.arch }}" \
-DNATIVE_BUILD_DIR="$(pwd)/_build-native" \
-DSLEEF_SHOW_CONFIG=1 \
-DDISABLE_SSL=ON \
-DBUILD_DFT=OFF \
-DBUILD_GNUABI_LIBS=OFF \
-DBUILD_INLINE_HEADERS=OFF \
-DBUILD_QUAD=OFF \
luhenry marked this conversation as resolved.
Show resolved Hide resolved
-DBUILD_SCALAR_LIB=ON \
-DBUILD_STATIC_TEST_BINS=ON \
${EXTRA_CMAKE_FLAGS}
luhenry marked this conversation as resolved.
Show resolved Hide resolved
cmake --build _build-${{ matrix.arch }}
cmake --install _build-${{ matrix.arch }}

- name: Test ${{ matrix.arch }}
env:
QEMU_CPU: ${{ matrix.qemu_cpu }}
run: |
cd _build-${{ matrix.arch }}
ctest -j$(nproc)

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.arch }}-${{ strategy.job-index }}
path: |
_build-*
_install-*
if: always()
5 changes: 0 additions & 5 deletions Configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ set(CLANG_FLAGS_ENABLE_VXE2 "-march=z15;-mzvector")
set(CLANG_FLAGS_ENABLE_VXE2NOFMA "-march=z15;-mzvector")

set(FLAGS_OTHERS "")
set(FLAGS_ARCH_NATIVE "")

# All variables storing compiler flags should be prefixed with FLAGS_
if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)")
Expand All @@ -178,10 +177,6 @@ if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)")
string(CONCAT FLAGS_STRICTMATH ${FLAGS_STRICTMATH} " -msse2 -mfpmath=sse")
string(CONCAT FLAGS_FASTMATH ${FLAGS_FASTMATH} " -msse2 -mfpmath=sse")
endif()

if (SLEEF_ARCH_X86)
set(FLAGS_ARCH_NATIVE "-march=native")
endif()

# Without the options below, gcc generates calls to libm
string(CONCAT FLAGS_OTHERS "-fno-math-errno -fno-trapping-math")
Expand Down
1 change: 0 additions & 1 deletion src/libm-tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ if(ENABLE_GNUABI AND COMPILER_SUPPORTS_OMP_SIMD AND NOT SLEEF_TARGET_PROCESSOR M
add_executable(testervecabi testervecabi.c)
target_compile_definitions(testervecabi PRIVATE ${COMMON_TARGET_DEFINITIONS})
target_compile_options(testervecabi PRIVATE ${OpenMP_C_FLAGS})
target_compile_options(testervecabi PRIVATE ${FLAGS_ARCH_NATIVE})
target_link_libraries(testervecabi ${TARGET_LIBSLEEF} ${OpenMP_C_FLAGS})
set_target_properties(testervecabi PROPERTIES C_STANDARD 99)
add_test(NAME testervecabi COMMAND testervecabi
Expand Down
2 changes: 1 addition & 1 deletion travis/toolchain-ppc64el.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SET (CMAKE_SYSTEM_PROCESSOR "ppc64")

SET(CMAKE_FIND_ROOT_PATH /usr/powerpc64le-linux-gnu /usr/include/powerpc64le-linux-gnu /usr/lib/powerpc64le-linux-gnu)

find_program(CMAKE_C_COMPILER ppc64el-cc)
find_program(CMAKE_C_COMPILER powerpc64le-linux-gnu-gcc ppc64el-cc)

SET(CMAKE_AR /usr/powerpc64le-linux-gnu/bin/ar)

Expand Down