-
Notifications
You must be signed in to change notification settings - Fork 21
157 lines (135 loc) · 5.64 KB
/
macos.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
name: macOS CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
ubuntu:
name: "macOS (host: ${{ matrix.host }}${{ matrix.variant }})"
strategy:
fail-fast: false
matrix:
# FIXME: support gcc plugin on macOS
# FIXME: support gcc + llvm and clang + gcc combinations
host: [llvm] # [gcc, llvm]
include:
# FIXME: gcc plugin on macOS is broken at the moment
# - variant: ', variant: expensive tests'
# host: gcc-expensive
# - variant: ', variant: debug build'
# host: gcc-debug
# FIXME: expected results of expensive tests are not patched for LLVM
# - variant: ', variant: expensive tests'
# host: llvm-expensive
- variant: ', variant: debug build'
host: llvm-debug
runs-on: macos-13
env:
CFLAGS: -Werror
CXXFLAGS: -Werror
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: brew install boost boost-build gcc@10 gmp llvm@14
- name: Set compiler variables
run: |
GCC_PATH="$(brew --prefix gcc@10)"
GCC_HOST=("$GCC_PATH"/bin/gcc-1*)
echo "GCC_HOST=$GCC_HOST" >> "$GITHUB_ENV"
if [[ '${{ matrix.host }}' =~ gcc* ]]; then
GXX_HOST=("$GCC_PATH"/bin/g++-1*)
echo "CC=$GCC_HOST" >> "$GITHUB_ENV"
echo "CXX=$GXX_HOST" >> "$GITHUB_ENV"
else
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
fi
- name: 'Add sanitizers to CXXFLAGS'
run: |
# Use ASAN and UBSAN
# CFLAGS="$CFLAGS -fsanitize=address,undefined"
# CXXFLAGS="$CXXFLAGS -fsanitize=address,undefined"
CFLAGS="$CFLAGS -fsanitize=undefined"
# TODO: It looks like the C++standard library is built with
# -fvisibility=hidden and some base classes are not exported leading
# into false positives.
CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize=vptr"
# Recommended for better error traces
CFLAGS="$CFLAGS -fno-omit-frame-pointer"
CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer"
# Make UBSAN reports fatal
CFLAGS="$CFLAGS -fno-sanitize-recover=all"
CXXFLAGS="$CXXFLAGS -fno-sanitize-recover=all"
# Use shared libasan for sanitization of shared libraries loaded
# by non-instrumented binaries.
# For details see https://systemd.io/TESTING_WITH_SANITIZERS/#clang.
if [[ '${{ matrix.compiler }}' == 'clang' ]]; then
CFLAGS="$CFLAGS -shared-libasan"
CXXFLAGS="$CXXFLAGS -shared-libasan"
fi
# Due to LD_PRELOAD above, leak sanitizer was reporting leaks
# literally in everything that was executed, e.g. make, shell,
# python and other tools that are not under our control.
ASAN_OPTIONS="detect_leaks=0"
# Do not detect ODR violations as we can't easily fix this problem in
# CL's compile-self-02-var-killer test.
ASAN_OPTIONS="$ASAN_OPTIONS,detect_odr_violation=0"
# Work-around for macOS System Integory Protection that prohibits
# the usage of DYLD_INSERT_LIBRARIES.
ASAN_OPTIONS="$ASAN_OPTIONS,verify_asan_link_order=0"
# Make UBSAN print whole stack traces
UBSAN_OPTIONS="print_stacktrace=1"
# Store the env variables
echo "CFLAGS=$CFLAGS" >> "$GITHUB_ENV"
echo "CXXFLAGS=$CXXFLAGS" >> "$GITHUB_ENV"
echo "ASAN_OPTIONS=$ASAN_OPTIONS" >> "$GITHUB_ENV"
echo "UBSAN_OPTIONS=$UBSAN_OPTIONS" >> "$GITHUB_ENV"
- name: Build and check
run: |
NPROC="$(sysctl -n hw.logicalcpu)"
if [[ '${{ matrix.host }}' =~ llvm* ]]; then
LLVM_CMAKE_PATH="$("$(brew --prefix llvm@14)/bin/llvm-config" --cmakedir)"
LLVM_CMAKE_FLAGS="-D LLVM_DIR='$LLVM_CMAKE_PATH'"
LLVM_CMAKE_FLAGS="$LLVM_CMAKE_FLAGS -D ENABLE_LLVM=ON"
fi
case '${{ matrix.variant }}' in
*debug*)
if [[ '${{ matrix.host }}' =~ llvm* ]]; then
make build_passes -s -j$NPROC "CMAKE=cmake $LLVM_CMAKE_FLAGS"
# FIXME: LLVM CL tests are broken
# merge with make call below when fixed
make -C cl -s -j$NPROC \
"CMAKE=cmake -D CL_DEBUG=ON $LLVM_CMAKE_FLAGS"
patch -p1 < build-aux/llvm.patch
else
make -C cl -s -j$NPROC "CMAKE=cmake -D CL_DEBUG=ON" check
fi
make -C sl -s -j$NPROC \
"CMAKE=cmake -D SL_DEBUG=ON $LLVM_CMAKE_FLAGS" check
exit 0
;;
*expensive*)
if [[ '${{ matrix.host }}' =~ llvm* ]]; then
make build_passes -s -j$(nproc) "CMAKE=cmake $LLVM_CMAKE_FLAGS"
# FIXME: LLVM CL tests are broken
# merge with make call below when fixed
make -C cl -s -j$(nproc) "CMAKE=cmake $LLVM_CMAKE_FLAGS"
patch -p1 < build-aux/llvm.patch
else
make -C cl -s -j$(nproc) "CMAKE=cmake" check
fi
make -C sl -s -j$(nproc) \
"CMAKE=cmake -D TEST_ONLY_FAST=OFF $LLVM_CMAKE_FLAGS" check
exit 0
;;
*)
;;
esac
if [[ '${{ matrix.host }}' == gcc ]]; then
./switch-host-gcc.sh "$GCC_HOST"
else
./switch-host-llvm.sh "$LLVM_CMAKE_PATH"
fi