-
Notifications
You must be signed in to change notification settings - Fork 124
539 lines (519 loc) · 20.8 KB
/
main.yml
File metadata and controls
539 lines (519 loc) · 20.8 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
name: snmalloc CI
# The following should ensure that the workflow only runs a single set of actions
# for each PR. But it will not apply this to pushes to the main branch.
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
pull_request:
branches: [ main, snmalloc1 ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
ubuntu:
name: ${{matrix.os}} ${{matrix.build-type}} ${{matrix.variant}}
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-24.04", "ubuntu-22.04", "ubuntu-24.04-arm" ]
build-type: [ "Release", "Debug" ]
cmake-config: [ "-G Ninja" ]
# Extra cmake flags. GitHub Actions matrix overloads `include` to mean
# 'add extra things to a job' and 'add jobs'. You can add extra things
# to a job by specifying things that exist in a job created from the
# matrix definition and adding things. You can specify extra jobs by
# specifying properties that don't match existing jobs. We use
# `cmake-flags` to add cmake flags to all jobs matching a pattern and
# `extra-cmake-flags` to specify a new job with custom CMake flags.
#
# Note that adding new jobs does not *refine* existing matrix entries,
# but rather adds new tuples wholesale. That is, specifying "os" alone
# will result in a tuple without set "build-type" rather than one for
# each existing "build-type" value!
extra-cmake-flags: [ "" ]
self-host: [ false ]
build-only: [ false ]
variant: [ "" ]
include:
- os: "ubuntu-22.04"
variant: "C++17"
build-type: "Debug"
extra-cmake-flags: "-DSNMALLOC_USE_CXX17=ON"
# Add the self-host build, using the bounds-checked memcpy in
# maximally paranoid mode (checking loads and stores)
- os: "ubuntu-24.04"
build-type: Debug
self-host: true
extra-cmake-flags: "-DSNMALLOC_MEMCPY_BOUNDS=ON -DSNMALLOC_CHECK_LOADS=ON"
# Extra build to check using pthread library for destructing local state.
- os: "ubuntu-24.04"
variant: "with pthread destructors"
build-type: Debug
self-host: true
extra-cmake-flags: "-DSNMALLOC_USE_PTHREAD_DESTRUCTORS=On"
# Extra build to check using individual mitigations works.
- os: "ubuntu-24.04"
variant: "individual mitigations"
build-type: Release
self-host: true
extra-cmake-flags: >-
-DSNMALLOC_BENCHMARK_INDIVIDUAL_MITIGATIONS=On
-DSNMALLOC_BUILD_TESTING=Off
# Check that we can build specifically with libstdc++
- os: "ubuntu-24.04"
variant: "libstdc++ (Build only)"
extra-cmake-flags: >-
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_CXX_FLAGS=-stdlib=libstdc++
build-type: Release
build-only: true
- os: "ubuntu-22.04"
variant: "Traced Build"
build-type: Release
extra-cmake-flags: "-DSNMALLOC_TRACING=On"
build-only: true
- os: "ubuntu-22.04"
variant: "clang libstdc++ (Build only)"
build-type: Release
extra-cmake-flags: >-
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_CXX_FLAGS=-stdlib=libstdc++
build-only: true
# Self-vendored STL with clang
- os: "ubuntu-24.04"
variant: "Self-vendored clang"
build-type: RelWithDebInfo
extra-cmake-flags: >-
-DSNMALLOC_USE_SELF_VENDORED_STL=ON
-DCMAKE_CXX_COMPILER=clang++-18
# Self-vendored STL with gcc
- os: "ubuntu-24.04"
variant: "Self-vendored gcc"
build-type: RelWithDebInfo
extra-cmake-flags: >-
-DSNMALLOC_USE_SELF_VENDORED_STL=ON
-DCMAKE_CXX_COMPILER=g++-14
# Sanitizer builds (TSan + UBSan)
- os: "ubuntu-24.04"
variant: "TSan + UBSan"
build-type: "Release"
extra-cmake-flags: >-
-DSNMALLOC_SANITIZER=undefined,thread
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_CXX_FLAGS=-stdlib="libc++ -g"
dependencies: "sudo apt install -y ninja-build libc++-dev"
test-exclude-pattern: "memcpy|external_pointer"
test-extra-args: "--repeat-until-fail 2"
- os: "ubuntu-22.04"
variant: "TSan + UBSan"
build-type: "Release"
extra-cmake-flags: >-
-DSNMALLOC_SANITIZER=undefined,thread
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_CXX_FLAGS=-stdlib="libc++ -g"
dependencies: "sudo apt install -y ninja-build libc++-dev"
test-exclude-pattern: "memcpy|external_pointer"
test-extra-args: "--repeat-until-fail 2"
uses: ./.github/workflows/reusable-cmake-build.yml
with:
os: ${{matrix.os}}
build-type: ${{matrix.build-type}}
dependencies: ${{matrix.dependencies || 'sudo apt install -y ninja-build'}}
cmake-config: ${{matrix.cmake-config || '-G Ninja'}}
extra-cmake-flags: ${{matrix.extra-cmake-flags}}
self-host: ${{matrix.self-host || false}}
build-only: ${{matrix.build-only || false}}
test-exclude-pattern: ${{matrix.test-exclude-pattern || ''}}
test-extra-args: ${{matrix.test-extra-args || ''}}
# ============================================================================
# Bazel builds
# ============================================================================
bazel:
strategy:
matrix:
# Build each combination of OS and release/debug variants
os: [ "ubuntu-24.04", "ubuntu-22.04", "macos-14", "macos-15" ]
build-type: [ "Release", "Debug" ]
# Don't abort runners if a single one fails
fail-fast: false
runs-on: ${{ matrix.os }}
name: Bazel - ${{ matrix.os }} ${{ matrix.build-type }}
steps:
- uses: actions/checkout@v4
- uses: bazelbuild/setup-bazelisk@v3
- name: Mount bazel cache # Optional
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazel-${{ matrix.os }}-${{ matrix.build-type }}
- run: bazel build -c opt //:snmalloc
- run: bazel build -c opt //:snmalloc-rs
- run: bazel test -c opt --config=asan //fuzzing:snmalloc_fuzzer
if: ${{ matrix.os != 'macos-14' && matrix.os != 'macos-15' }}
# ============================================================================
# macOS builds
# ============================================================================
macos:
name: ${{matrix.os}} ${{matrix.build-type}} ${{matrix.cxx17 && 'C++17' || matrix.variant}}
strategy:
fail-fast: false
matrix:
os: [ "macos-14", "macos-15" ]
build-type: [ "Release", "Debug" ]
cxx17: [ false, true ]
cmake-config: [ "-G Ninja" ]
extra-cmake-flags: [ "" ]
variant: [ "" ]
include:
# Self-vendored STL
- os: "macos-latest"
build-type: RelWithDebInfo
extra-cmake-flags: >-
-DSNMALLOC_USE_SELF_VENDORED_STL=ON
-DCMAKE_CXX_COMPILER=clang++
variant: "Self-vendored"
uses: ./.github/workflows/reusable-cmake-build.yml
with:
os: ${{matrix.os}}
build-type: ${{matrix.build-type}}
# The homebrew packages are broken at the moment and error out
# after trying to install Python as a dependency of ninja because
# 2to3 exists. As a quick hack, delete it first. This should be
# removed once the homebrew install is fixed.
dependencies: "rm -f /usr/local/bin/2to3 || true; brew update && brew install ninja"
cmake-config: ${{matrix.cmake-config || '-G Ninja'}}
extra-cmake-flags: ${{matrix.cxx17 && '-DSNMALLOC_USE_CXX17=ON' || matrix.extra-cmake-flags || ''}}
# ============================================================================
# BSD builds
# ============================================================================
freebsd:
strategy:
matrix:
build-type: [ Release, Debug ]
fail-fast: false
uses: ./.github/workflows/reusable-vm-build.yml
with:
vm-type: freebsd
vm-version: '13.2'
build-type: ${{matrix.build-type}}
dependencies: "pkg ins -y cmake ninja"
netbsd:
uses: ./.github/workflows/reusable-vm-build.yml
with:
vm-type: netbsd
vm-version: '9.2'
build-type: Release
dependencies: "/usr/sbin/pkg_add cmake ninja-build gcc10"
cmake-flags: -DCMAKE_CXX_COMPILER=/usr/pkg/gcc10/bin/g++
# ============================================================================
# QEMU cross-compilation builds
# ============================================================================
qemu-crossbuild:
strategy:
fail-fast: false
matrix:
build-type: [ Release, Debug ]
arch:
- name: armhf
system-processor: arm
triple: arm-linux-gnueabihf
rtld: ld-linux-armhf.so.3
ld-flavour: lld
host-os: ubuntu-24.04
- name: arm64
system-processor: aarch64
triple: aarch64-linux-gnu
rtld: ld-linux-aarch64.so.1
ld-flavour: lld
host-os: ubuntu-24.04
- 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
host-os: ubuntu-24.04
runs-on: ${{matrix.arch.host-os}}
name: Crossbuild - ${{matrix.build-type}} ${{matrix.arch.triple}}
steps:
- uses: actions/checkout@v4
- name: Install cross-compile toolchain and QEMU
run: >
sudo apt update &&
sudo apt install
libstdc++-12-dev-${{ matrix.arch.name }}-cross
qemu-user ninja-build
binfmt-support
${{matrix.arch.extra-packages}}
- name: Configure
env:
SNMALLOC_CI_CLANG_VERSION: 16
RTLD_NAME: ${{ matrix.arch.rtld }}
ARCH: ${{ matrix.arch.system-processor }}
TRIPLE: ${{ matrix.arch.triple }}
run: >
cmake
-B ${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=${{matrix.build-type}}
-G Ninja
-DSNMALLOC_CI_BUILD=ON
-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
- name: Verify cross-compilation
working-directory: ${{github.workspace}}/build
run: file func*
- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -j 2 --output-on-failure -E '(perf-.*)|(.*-malloc$)' --timeout 400
timeout-minutes: 30
# ============================================================================
# Windows builds
# ============================================================================
windows:
name: ${{matrix.os}} ${{matrix.build-type}} ${{matrix.cmake-config}} ${{matrix.variant}}
strategy:
fail-fast: false
matrix:
os: [ windows-2022, windows-2025 ]
build-type: [ Release, Debug ]
cmake-config: [ "-A Win32", "-A x64", "-A Win32 -T ClangCL", "-A x64 -T ClangCL" ]
extra-cmake-flags: [ "-DSNMALLOC_RUST_SUPPORT=On" ]
build-only: [ false ]
dependencies: [ "" ]
variant: [ "" ]
use-msbuild: [ true ]
include:
# Windows 8 compatible build
- os: windows-2022
build-type: Release
cmake-config: "-A x64"
extra-cmake-flags: "-DWIN8COMPAT=TRUE -DSNMALLOC_RUST_SUPPORT=On"
variant: "Win8 compat"
use-msbuild: true
# ARM64 builds (build-only, no tests)
- os: windows-2022
build-type: Release
cmake-config: "-A ARM64"
extra-cmake-flags: "-DSNMALLOC_RUST_SUPPORT=On"
build-only: true
use-msbuild: true
- os: windows-2022
build-type: Debug
cmake-config: "-A ARM64"
extra-cmake-flags: "-DSNMALLOC_RUST_SUPPORT=On"
build-only: true
use-msbuild: true
# ARM64EC builds (build-only, no tests)
- os: windows-2022
build-type: Release
cmake-config: "-A ARM64EC"
extra-cmake-flags: "-DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DSNMALLOC_RUST_SUPPORT=On"
build-only: true
use-msbuild: true
- os: windows-2022
build-type: Debug
cmake-config: "-A ARM64EC"
extra-cmake-flags: "-DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DSNMALLOC_RUST_SUPPORT=On"
build-only: true
use-msbuild: true
# Self-vendored STL (uses Ninja)
- os: windows-2022
build-type: RelWithDebInfo
cmake-config: "-G Ninja -DCMAKE_CXX_COMPILER=clang-cl"
extra-cmake-flags: "-DSNMALLOC_USE_SELF_VENDORED_STL=ON"
dependencies: "choco upgrade llvm && choco install ninja"
variant: "Self-vendored"
use-msbuild: false
uses: ./.github/workflows/reusable-cmake-build.yml
with:
os: ${{matrix.os}}
build-type: ${{matrix.build-type}}
cmake-config: ${{matrix.cmake-config}}
extra-cmake-flags: ${{matrix.extra-cmake-flags}}
build-only: ${{matrix.build-only || false}}
dependencies: ${{matrix.dependencies || ''}}
use-msbuild: ${{matrix.use-msbuild}}
# ============================================================================
# Format and lint checks
# ============================================================================
format:
runs-on: ubuntu-22.04
name: Format check
# We don't need to do the build for this job, but we need to configure it to get the clang-format target
steps:
- uses: actions/checkout@v4
- name: Install clang-tidy and clang-format
run: |
sudo apt update
sudo apt install clang-tidy-15 clang-format-15
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DSNMALLOC_USE_CXX17=ON
# Run the clang-format check and error if it generates a diff
- name: Run clang-format
working-directory: ${{github.workspace}}/build
run: |
set -eo pipefail
make clangformat
git diff --exit-code
- name: Run clang-tidy
run: |
clang-tidy-15 src/snmalloc/override/malloc.cc -header-filter="`pwd`/*" -warnings-as-errors='*' -export-fixes=tidy.fail -- -std=c++17 -mcx16 -DSNMALLOC_USE_WAIT_ON_ADDRESS=1 -DSNMALLOC_PLATFORM_HAS_GETENTROPY=0 -Isrc
if [ -f tidy.fail ] ; then
cat tidy.fail
exit 1
fi
# ============================================================================
# Fuzzing
# ============================================================================
fuzzing:
name: Fuzzing
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DSNMALLOC_ENABLE_FUZZING=ON -DFUZZTEST_FUZZING_MODE=ON -DCMAKE_CXX_COMPILER=clang++
- name: Build
run: cmake --build ${{github.workspace}}/build --target snmalloc-fuzzer
- name: Test
run: ${{github.workspace}}/build/fuzzing/snmalloc-fuzzer
# ============================================================================
# GWP-ASan integration
# ============================================================================
gwp-asan:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
profile: [RelWithDebInfo, Debug]
runs-on: ${{matrix.os}}
name: GWP-ASan - ${{matrix.os}} ${{matrix.profile}}
steps:
- uses: actions/checkout@v4
- name: Install Ninja
run: sudo apt-get install -y ninja-build
- name: Install Compiler-RT
run: |
cd ..
git clone https://github.com/llvm/llvm-project --depth=1 -b llvmorg-19.1.7
mkdir compiler-rt
cmake -G Ninja \
-S llvm-project/runtimes \
-B llvm-project/build \
-DCMAKE_BUILD_TYPE=${{ matrix.profile }}\
-DLLVM_ENABLE_RUNTIMES=compiler-rt \
-DCMAKE_CXX_COMPILER=clang++-18 \
-DCMAKE_C_COMPILER=clang-18 \
-DCMAKE_INSTALL_PREFIX=$(realpath compiler-rt)
cmake --build llvm-project/build --parallel
cmake --build llvm-project/build --target=install
- name: Configure SnMalloc
run: >
cmake -GNinja
-B${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=${{ matrix.profile }}
-DCMAKE_CXX_COMPILER=clang++-18
-DSNMALLOC_ENABLE_GWP_ASAN_INTEGRATION=On
-DSNMALLOC_GWP_ASAN_INCLUDE_PATH=${{github.workspace}}/../llvm-project/compiler-rt/lib
-DSNMALLOC_GWP_ASAN_LIBRARY_PATH=${{github.workspace}}/../compiler-rt/lib/linux
- name: Build
run: cmake --build ${{github.workspace}}/build --parallel
- name: Test
run: |
cd ${{github.workspace}}/build
ctest --parallel --output-on-failure
# ============================================================================
# vcpkg integration
# ============================================================================
vcpkg-integration:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
feature: [ "default", "static-shim" ]
runs-on: ${{ matrix.os }}
name: vcpkg - ${{ matrix.os }} ${{ matrix.feature }}
steps:
- uses: actions/checkout@v4
- name: Bootstrap vcpkg
shell: bash
run: |
git clone https://github.com/microsoft/vcpkg.git "${{ runner.temp }}/vcpkg" --depth 1
if [ "$RUNNER_OS" = "Windows" ]; then
"${{ runner.temp }}/vcpkg/bootstrap-vcpkg.bat" -disableMetrics
else
"${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
fi
- name: Create overlay port pointing at local source
shell: bash
run: |
overlay="${{ runner.temp }}/overlay/snmalloc"
mkdir -p "$overlay"
# Copy the real port files
cp ports/snmalloc/vcpkg.json "$overlay/"
cp ports/snmalloc/usage "$overlay/"
# Normalize workspace path to forward slashes for CMake (Windows compat)
ws_path=$(echo "${{ github.workspace }}" | sed 's|\\|/|g')
# Rewrite portfile to use local source instead of vcpkg_from_github
{
echo 'if(NOT "static-shim" IN_LIST FEATURES)'
echo ' set(VCPKG_BUILD_TYPE release)'
echo 'endif()'
echo ''
echo "set(SOURCE_PATH \"${ws_path}\")"
echo ''
# Keep everything from vcpkg_check_features onwards (see comment in
# ports/snmalloc/portfile.cmake documenting this coupling)
sed -n '/^vcpkg_check_features/,$ p' ports/snmalloc/portfile.cmake
} > "$overlay/portfile.cmake"
- name: Install snmalloc via vcpkg
shell: bash
# Run from runner.temp to avoid the workspace vcpkg.json triggering
# manifest mode (which forbids positional package arguments).
working-directory: ${{ runner.temp }}
run: |
features=""
if [ "${{ matrix.feature }}" = "static-shim" ]; then
features="[static-shim]"
fi
"${{ runner.temp }}/vcpkg/vcpkg" install "snmalloc${features}" \
--overlay-ports="${{ runner.temp }}/overlay"
- name: Build consumer project
shell: bash
run: |
cmake -B "${{ runner.temp }}/consumer-build" \
-S test/vcpkg-consumer \
-DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake"
cmake --build "${{ runner.temp }}/consumer-build" --config Release
- name: Run tests
shell: bash
run: |
ctest --test-dir "${{ runner.temp }}/consumer-build" \
--build-config Release --output-on-failure
# ============================================================================
# Final gate check
# ============================================================================
all-checks:
needs: [
ubuntu,
macos,
freebsd, netbsd,
qemu-crossbuild,
windows,
format,
vcpkg-integration
]
runs-on: ubuntu-24.04
steps:
- name: All checks passed
run: echo "All required checks passed!"