From 80ca0186376ac483b4807b864cd3f2163d5f16cd Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 22 Nov 2023 11:41:53 +0000 Subject: [PATCH] test: Add an s390x build (on alpine) for CI. It doesn't work at all, because we're missing something in the net code to do with endian conversions. I haven't investigated, yet, but at least now we have a failing test that can be investigated. Also moved to cmake 3.5 at minimum. CMake will stop supporting lower versions than that, soon. Also moved to C17 from C99 to get `static_assert`. --- .github/scripts/cmake-alpine-s390x | 46 +++++++++++++++++++ .../{cmake-freebsd-stage2 => cmake-freebsd} | 0 .github/scripts/flags.sh | 2 - .github/workflows/ci.yml | 30 ++++++++---- CMakeLists.txt | 27 ++++------- other/docker/alpine-s390x/Dockerfile | 6 +++ other/docker/alpine-s390x/run | 5 ++ other/docker/autotools/run | 4 +- other/docker/cimplefmt/run | 2 +- other/docker/circleci/run | 2 +- other/docker/compcert/run | 4 +- other/docker/coverage/run | 2 +- other/docker/doxygen/run | 2 +- other/docker/freebsd/Dockerfile | 6 +++ other/docker/freebsd/run | 5 ++ other/docker/misra/run | 4 +- other/docker/perf/run | 2 +- other/docker/tcc/run | 4 +- other/docker/tokstyle/run | 4 +- 19 files changed, 116 insertions(+), 41 deletions(-) create mode 100755 .github/scripts/cmake-alpine-s390x rename .github/scripts/{cmake-freebsd-stage2 => cmake-freebsd} (100%) create mode 100644 other/docker/alpine-s390x/Dockerfile create mode 100755 other/docker/alpine-s390x/run create mode 100644 other/docker/freebsd/Dockerfile create mode 100755 other/docker/freebsd/run diff --git a/.github/scripts/cmake-alpine-s390x b/.github/scripts/cmake-alpine-s390x new file mode 100755 index 00000000000..ac79eeed3b6 --- /dev/null +++ b/.github/scripts/cmake-alpine-s390x @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright (C) 2018-2021 nurupo + +# Toxcore building + +set -eux + +cd /work + +. cmake-alpine-run.sh + +# === Get VM ready to build the code === + +start_vm + +RUN apk add cmake g++ ninja + +mv c-toxcore / + +# Copy over toxcore code from host to qemu +scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P "$SSH_PORT" -r /c-toxcore root@localhost:~ + +cd /c-toxcore +. ".github/scripts/flags-gcc.sh" + +# Make compilation error on a warning +add_flag -Werror + +RUN "cmake -B_build -Hc-toxcore -GNinja \ + -DCMAKE_C_FLAGS='$C_FLAGS' \ + -DCMAKE_CXX_FLAGS='$CXX_FLAGS' \ + -DCMAKE_EXE_LINKER_FLAGS='$LD_FLAGS' \ + -DCMAKE_SHARED_LINKER_FLAGS='$LD_FLAGS' \ + -DCMAKE_INSTALL_PREFIX:PATH='_install' \ + -DCMAKE_UNITY_BUILD=ON \ + -DMIN_LOGGER_LEVEL=TRACE \ + -DNON_HERMETIC_TESTS=ON \ + -DBUILD_TOXAV=OFF \ + -DBOOTSTRAP_DAEMON=OFF \ + -DSTRICT_ABI=ON \ + -DTEST_TIMEOUT_SECONDS=90 \ + -DUSE_IPV6=OFF \ + -DAUTOTEST=ON" + +RUN 'cmake --build _build --parallel 2 --target install -- -k 0' +RUN 'cd _build && ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:1 || true' diff --git a/.github/scripts/cmake-freebsd-stage2 b/.github/scripts/cmake-freebsd similarity index 100% rename from .github/scripts/cmake-freebsd-stage2 rename to .github/scripts/cmake-freebsd diff --git a/.github/scripts/flags.sh b/.github/scripts/flags.sh index 80a56c017df..dd7ca18b8f7 100644 --- a/.github/scripts/flags.sh +++ b/.github/scripts/flags.sh @@ -28,8 +28,6 @@ add_flag -O3 -march=native # Warn on non-ISO C. add_c_flag -pedantic -add_c_flag -std=c99 -add_cxx_flag -std=c++11 add_flag -g3 add_flag -ftrapv diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eacf919ca5a..f0c169a0130 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,6 +90,26 @@ jobs: with: file: other/docker/compcert/Dockerfile + build-alpine-s390x: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Docker Build + uses: docker/build-push-action@v2 + with: + file: other/docker/alpine-s390x/Dockerfile + + build-freebsd: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Docker Build + uses: docker/build-push-action@v2 + with: + file: other/docker/freebsd/Dockerfile + cimplefmt: runs-on: ubuntu-latest steps: @@ -117,16 +137,6 @@ jobs: - name: Cross compilation run: .github/scripts/cmake-win64 script - build-freebsd: - runs-on: ubuntu-latest - container: toxchat/freebsd - steps: - - uses: actions/checkout@v2 - with: - submodules: recursive - - name: Build on FreeBSD - run: .github/scripts/cmake-freebsd-stage2 - build-macos: runs-on: macos-latest steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index 028112d42e5..5afa721c7d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,8 @@ # ################################################################################ -cmake_minimum_required(VERSION 2.8.12) -cmake_policy(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.5) +cmake_policy(VERSION 3.5) project(toxcore) list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake) @@ -79,21 +79,14 @@ enable_testing() set(CMAKE_MACOSX_RPATH ON) -if(${CMAKE_VERSION} VERSION_LESS "3.1.0") - if(NOT MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") - endif() -else() - # Set standard version for compiler. - set(CMAKE_C_STANDARD 99) - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_C_EXTENSIONS OFF) - set(CMAKE_CXX_EXTENSIONS OFF) - - message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}") - message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}") -endif() +# Set standard version for compiler. +set(CMAKE_C_STANDARD 17) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_CXX_EXTENSIONS OFF) + +message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}") +message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}") set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)") if(MIN_LOGGER_LEVEL) diff --git a/other/docker/alpine-s390x/Dockerfile b/other/docker/alpine-s390x/Dockerfile new file mode 100644 index 00000000000..86b1f1fd651 --- /dev/null +++ b/other/docker/alpine-s390x/Dockerfile @@ -0,0 +1,6 @@ +FROM toxchat/alpine-s390x:latest + +WORKDIR /work/c-toxcore +COPY . /work/c-toxcore/ + +RUN .github/scripts/cmake-alpine-s390x diff --git a/other/docker/alpine-s390x/run b/other/docker/alpine-s390x/run new file mode 100755 index 00000000000..f77eede2378 --- /dev/null +++ b/other/docker/alpine-s390x/run @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eux +BUILD=alpine-s390x +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" . diff --git a/other/docker/autotools/run b/other/docker/autotools/run index 895ff3caa3c..aadb1440ed8 100755 --- a/other/docker/autotools/run +++ b/other/docker/autotools/run @@ -1,3 +1,5 @@ #!/bin/sh -docker build -t toxchat/c-toxcore:autotools -f other/docker/autotools/Dockerfile . +set -eux +BUILD=autotools +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" . diff --git a/other/docker/cimplefmt/run b/other/docker/cimplefmt/run index 5016a063c5b..1211bb89209 100755 --- a/other/docker/cimplefmt/run +++ b/other/docker/cimplefmt/run @@ -5,4 +5,4 @@ if [ "$1" = "-u" ]; then docker pull toxchat/haskell:hs-cimple docker build -t toxchat/cimplefmt -f other/docker/cimplefmt/Dockerfile . fi -docker run --rm -v "$PWD:/work" toxchat/cimplefmt "$@" +docker run --name toxcore-cimplefmt --rm -v "$PWD:/work" toxchat/cimplefmt "$@" diff --git a/other/docker/circleci/run b/other/docker/circleci/run index 22aedf9fac2..668e0fc8654 100755 --- a/other/docker/circleci/run +++ b/other/docker/circleci/run @@ -3,4 +3,4 @@ SANITIZER="${1:-asan}" docker build -t toxchat/c-toxcore:circleci other/docker/circleci -docker run --rm -it -v "$PWD:/c-toxcore" toxchat/c-toxcore:circleci "$SANITIZER" +docker run --name toxcore-circleci --rm -it -v "$PWD:/c-toxcore" toxchat/c-toxcore:circleci "$SANITIZER" diff --git a/other/docker/compcert/run b/other/docker/compcert/run index a0613428161..8b03c84ca42 100755 --- a/other/docker/compcert/run +++ b/other/docker/compcert/run @@ -1,5 +1,5 @@ #!/bin/sh set -eux - -docker build -t toxchat/c-toxcore:compcert -f other/docker/compcert/Dockerfile . +BUILD=compcert +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" . diff --git a/other/docker/coverage/run b/other/docker/coverage/run index cfb57691664..a170812b12a 100755 --- a/other/docker/coverage/run +++ b/other/docker/coverage/run @@ -4,4 +4,4 @@ set -eux docker build -t toxchat/c-toxcore:sources -f other/docker/sources/Dockerfile . docker build -t toxchat/c-toxcore:coverage other/docker/coverage -docker run --rm -it -p "28192:80" toxchat/c-toxcore:coverage +docker run --name toxcore-coverage --rm -it -p "28192:80" toxchat/c-toxcore:coverage diff --git a/other/docker/doxygen/run b/other/docker/doxygen/run index 85b24cb78c9..c702ba5fff9 100755 --- a/other/docker/doxygen/run +++ b/other/docker/doxygen/run @@ -3,4 +3,4 @@ set -eux docker build -t toxchat/c-toxcore:docs -f other/docker/doxygen/Dockerfile . -docker run --rm -it -p "28192:80" toxchat/c-toxcore:docs +docker run --name toxcore-docs --rm -it -p "28192:80" toxchat/c-toxcore:docs diff --git a/other/docker/freebsd/Dockerfile b/other/docker/freebsd/Dockerfile new file mode 100644 index 00000000000..6e933d0fbcf --- /dev/null +++ b/other/docker/freebsd/Dockerfile @@ -0,0 +1,6 @@ +FROM toxchat/freebsd:latest + +WORKDIR /work/c-toxcore +COPY . /work/c-toxcore/ + +RUN .github/scripts/cmake-freebsd diff --git a/other/docker/freebsd/run b/other/docker/freebsd/run new file mode 100755 index 00000000000..f4448a46713 --- /dev/null +++ b/other/docker/freebsd/run @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eux +BUILD=freebsd +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" . diff --git a/other/docker/misra/run b/other/docker/misra/run index ab228f7af2d..2f96bb4b08a 100755 --- a/other/docker/misra/run +++ b/other/docker/misra/run @@ -1,3 +1,5 @@ #!/bin/sh -docker build -f other/docker/misra/Dockerfile . +set -eux +BUILD=misra +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" . diff --git a/other/docker/perf/run b/other/docker/perf/run index 44f336ca37b..4834614e20d 100755 --- a/other/docker/perf/run +++ b/other/docker/perf/run @@ -3,7 +3,7 @@ set -eux docker build -t toxchat/c-toxcore:perf -f other/docker/perf/Dockerfile . -docker run --privileged --rm -it \ +docker run --name toxcore-perf --privileged --rm -it \ -v "$PWD:/work/c-toxcore" \ toxchat/c-toxcore:perf \ "$@" diff --git a/other/docker/tcc/run b/other/docker/tcc/run index be28a71c99e..870852ba988 100755 --- a/other/docker/tcc/run +++ b/other/docker/tcc/run @@ -1,5 +1,5 @@ #!/bin/sh set -eux - -docker build -t toxchat/c-toxcore:tcc -f other/docker/tcc/Dockerfile . +BUILD=tcc +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" . diff --git a/other/docker/tokstyle/run b/other/docker/tokstyle/run index 30c2a738320..c743defdb2e 100755 --- a/other/docker/tokstyle/run +++ b/other/docker/tokstyle/run @@ -1,3 +1,5 @@ #!/bin/sh -docker build -f other/docker/tokstyle/Dockerfile . +set -eux +BUILD=tokstyle +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .