Skip to content

Commit 7155f7f

Browse files
committed
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 C11 from C99 to get `static_assert`. Also made a network ERROR into a WARNING. It triggers on FreeBSD.
1 parent 6c35cef commit 7155f7f

File tree

24 files changed

+160
-63
lines changed

24 files changed

+160
-63
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/_build
2+
/_install

.github/scripts/cmake-alpine-s390x

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Copyright (C) 2018-2023 nurupo
3+
4+
# Toxcore building
5+
6+
set -eux
7+
8+
cd .. # /work
9+
. cmake-alpine-run.sh
10+
11+
# === Get VM ready to build the code ===
12+
13+
start_vm
14+
15+
RUN apk add cmake g++ ninja
16+
17+
mv c-toxcore /
18+
19+
# Copy over toxcore code from host to qemu
20+
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P "$SSH_PORT" -r /c-toxcore root@localhost:~
21+
22+
cd /c-toxcore
23+
. ".github/scripts/flags-gcc.sh"
24+
25+
# Make compilation error on a warning
26+
add_flag -Werror
27+
28+
# - disabling toxav because vpx doesn't work on s390x.
29+
# - disabling bootstrap daemons because we don't need them for testing (saving time).
30+
# - disabling shared libraries because it saves a lot of time on building PIC objects.
31+
# - enable unity build because it saves a lot of time as well (fewer objects to build).
32+
RUN "cmake -B_build -Hc-toxcore -GNinja \
33+
-DCMAKE_C_FLAGS='$C_FLAGS' \
34+
-DCMAKE_CXX_FLAGS='$CXX_FLAGS' \
35+
-DCMAKE_EXE_LINKER_FLAGS='$LD_FLAGS' \
36+
-DCMAKE_SHARED_LINKER_FLAGS='$LD_FLAGS' \
37+
-DCMAKE_INSTALL_PREFIX:PATH='_install' \
38+
-DCMAKE_UNITY_BUILD=ON \
39+
-DMIN_LOGGER_LEVEL=TRACE \
40+
-DNON_HERMETIC_TESTS=ON \
41+
-DENABLE_SHARED=OFF \
42+
-DBUILD_TOXAV=OFF \
43+
-DDHT_BOOTSTRAP=OFF \
44+
-DBOOTSTRAP_DAEMON=OFF \
45+
-DSTRICT_ABI=ON \
46+
-DTEST_TIMEOUT_SECONDS=90 \
47+
-DUSE_IPV6=OFF \
48+
-DAUTOTEST=ON"
49+
50+
RUN 'cmake --build _build --parallel 2 --target install -- -k 0'
51+
RUN 'cd _build && ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:1 --timeout 90 || true' &
52+
53+
# Give the tests 5 minutes to run. Sometimes, the per-test timeout doesn't
54+
# work, so we put a global timeout here for everything.
55+
sleep 300
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
#!/bin/bash
2-
# Copyright (C) 2018-2021 nurupo
2+
# Copyright (C) 2018-2023 nurupo
33

44
# Toxcore building
55

66
set -eux
77

8-
if [ "$PWD" != "/work" ]; then
9-
cd ..
10-
mv c-toxcore /
11-
mkdir c-toxcore
12-
cd /work
13-
fi
14-
8+
cd .. # /work
159
. cmake-freebsd-run.sh
1610

1711
# === Get VM ready to build the code ===
1812

1913
gunzip "$IMAGE_NAME.gz"
2014

15+
mv c-toxcore /
16+
2117
start_vm
2218

2319
# Copy over toxcore code from host to qemu
@@ -26,27 +22,34 @@ scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -P "$SSH_PORT" -
2622
RUN ls -lh
2723

2824
cd /c-toxcore
29-
. ".github/scripts/flags-clang.sh"
25+
. '.github/scripts/flags-clang.sh'
3026

3127
add_ld_flag -Wl,-z,defs
3228

33-
# Make compilation error on a warning
29+
# Make compilation error on a warning.
3430
add_flag -Werror
3531

36-
RUN 'cmake -B_build -Hc-toxcore \
37-
-DCMAKE_C_FLAGS="$C_FLAGS" \
38-
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
39-
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
40-
-DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \
41-
-DCMAKE_INSTALL_PREFIX:PATH="_install" \
32+
# This triggers on FreeBSD's clang.
33+
add_flag -Wno-format
34+
add_flag -Wno-unsafe-buffer-usage
35+
36+
RUN "cmake -B_build -Hc-toxcore \
37+
-DCMAKE_C_FLAGS='$C_FLAGS' \
38+
-DCMAKE_CXX_FLAGS='$CXX_FLAGS' \
39+
-DCMAKE_EXE_LINKER_FLAGS='$LD_FLAGS' \
40+
-DCMAKE_SHARED_LINKER_FLAGS='$LD_FLAGS' \
41+
-DCMAKE_INSTALL_PREFIX:PATH='_install' \
4242
-DMIN_LOGGER_LEVEL=TRACE \
4343
-DMUST_BUILD_TOXAV=ON \
4444
-DNON_HERMETIC_TESTS=ON \
4545
-DSTRICT_ABI=ON \
4646
-DTEST_TIMEOUT_SECONDS=90 \
4747
-DUSE_IPV6=OFF \
48-
-DAUTOTEST=ON'
48+
-DAUTOTEST=ON"
4949

50-
# We created the VM with the same number of cores as the host, so the host-ran `nproc` here is fine
50+
# We created the VM with the same number of cores as the host, so the host-ran `nproc` here is fine.
5151
RUN 'gmake "-j$NPROC" -k install -C_build'
5252
RUN 'gmake "-j$NPROC" test ARGS="-j50" -C_build || true'
53+
54+
# Gracefully shut down the VM.
55+
stop_vm

.github/scripts/flags.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ add_flag -O3 -march=native
2828

2929
# Warn on non-ISO C.
3030
add_c_flag -pedantic
31-
add_c_flag -std=c99
32-
add_cxx_flag -std=c++11
3331

3432
add_flag -g3
3533
add_flag -ftrapv

.github/workflows/ci.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ jobs:
9090
with:
9191
file: other/docker/compcert/Dockerfile
9292

93+
build-alpine-s390x:
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: Set up Docker Buildx
97+
uses: docker/setup-buildx-action@v1
98+
- name: Docker Build
99+
uses: docker/build-push-action@v2
100+
with:
101+
file: other/docker/alpine-s390x/Dockerfile
102+
103+
build-freebsd:
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: Set up Docker Buildx
107+
uses: docker/setup-buildx-action@v1
108+
- name: Docker Build
109+
uses: docker/build-push-action@v2
110+
with:
111+
file: other/docker/freebsd/Dockerfile
112+
93113
cimplefmt:
94114
runs-on: ubuntu-latest
95115
steps:
@@ -117,16 +137,6 @@ jobs:
117137
- name: Cross compilation
118138
run: .github/scripts/cmake-win64 script
119139

120-
build-freebsd:
121-
runs-on: ubuntu-latest
122-
container: toxchat/freebsd
123-
steps:
124-
- uses: actions/checkout@v2
125-
with:
126-
submodules: recursive
127-
- name: Build on FreeBSD
128-
run: .github/scripts/cmake-freebsd-stage2
129-
130140
build-macos:
131141
runs-on: macos-latest
132142
steps:

CMakeLists.txt

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#
1515
################################################################################
1616

17-
cmake_minimum_required(VERSION 2.8.12)
18-
cmake_policy(VERSION 2.8.12)
17+
cmake_minimum_required(VERSION 3.5)
18+
cmake_policy(VERSION 3.5)
1919
project(toxcore)
2020

2121
list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
@@ -79,21 +79,14 @@ enable_testing()
7979

8080
set(CMAKE_MACOSX_RPATH ON)
8181

82-
if(${CMAKE_VERSION} VERSION_LESS "3.1.0")
83-
if(NOT MSVC)
84-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
85-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
86-
endif()
87-
else()
88-
# Set standard version for compiler.
89-
set(CMAKE_C_STANDARD 99)
90-
set(CMAKE_CXX_STANDARD 17)
91-
set(CMAKE_C_EXTENSIONS OFF)
92-
set(CMAKE_CXX_EXTENSIONS OFF)
93-
94-
message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
95-
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
96-
endif()
82+
# Set standard version for compiler.
83+
set(CMAKE_C_STANDARD 11)
84+
set(CMAKE_CXX_STANDARD 17)
85+
set(CMAKE_C_EXTENSIONS OFF)
86+
set(CMAKE_CXX_EXTENSIONS OFF)
87+
88+
message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
89+
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
9790

9891
set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)")
9992
if(MIN_LOGGER_LEVEL)

cmake/StrictAbi.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function(_make_version_script target)
2929
list(GET sublib 1 ns)
3030

3131
execute_process(
32-
COMMAND ${SHELL} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '\\w+' | sort -u"
32+
COMMAND ${SHELL} -c "egrep '^\\w' ${header} | grep '${ns}_[a-z0-9_]*(' | grep -v '^typedef' | grep -o '${ns}_[a-z0-9_]*(' | egrep -o '[a-z0-9_]+' | sort -u"
3333
OUTPUT_VARIABLE sublib_SYMS
3434
OUTPUT_STRIP_TRAILING_WHITESPACE)
3535
string(REPLACE "\n" ";" sublib_SYMS ${sublib_SYMS})

other/analysis/run-clang-tidy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
CHECKS="*"
44

5+
# We don't use memcpy_s.
6+
CHECKS="$CHECKS,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
7+
58
# __attribute__((nonnull)) causes this warning on defensive null checks.
69
CHECKS="$CHECKS,-clang-diagnostic-pointer-bool-conversion"
710
CHECKS="$CHECKS,-clang-diagnostic-tautological-pointer-compare"
@@ -57,6 +60,11 @@ CHECKS="$CHECKS,-readability-redundant-control-flow"
5760
CHECKS="$CHECKS,-bugprone-narrowing-conversions"
5861
CHECKS="$CHECKS,-cppcoreguidelines-narrowing-conversions"
5962

63+
# TODO(iphydf): Probably fix this in tox-bootstrapd.c.
64+
CHECKS="$CHECKS,-cert-dcl03-c"
65+
CHECKS="$CHECKS,-hicpp-static-assert"
66+
CHECKS="$CHECKS,-misc-static-assert"
67+
6068
# TODO(iphydf): We might want some of these. For the ones we don't want, add a
6169
# comment explaining why not.
6270
CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b18557c5c89ac6a06137a692418270ab08adc0544ed631545b862fca21502743 /usr/local/bin/tox-bootstrapd
1+
05c389460de83d58533a658d0df625600bc3e6940bbcc738db9dddee249fac59 /usr/local/bin/tox-bootstrapd
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM toxchat/alpine-s390x:latest
2+
3+
WORKDIR /work/c-toxcore
4+
COPY . /work/c-toxcore/
5+
6+
RUN .github/scripts/cmake-alpine-s390x

0 commit comments

Comments
 (0)