Skip to content

Commit 87ac7ae

Browse files
committed
ci: add msan Linux job
MSan is viral, so it is added to Clang only. Do not add MSan to MacOS job, since it is not supported in that platform.
1 parent 9508933 commit 87ac7ae

File tree

2 files changed

+105
-74
lines changed

2 files changed

+105
-74
lines changed

.github/workflows/ci.yml

Lines changed: 102 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: actions/checkout@v4
3131

3232
- name: Generate Test Matrix
33-
uses: alandefreitas/cpp-actions/[email protected].10
33+
uses: alandefreitas/cpp-actions/[email protected].11
3434
id: cpp-matrix
3535
with:
3636
compilers: |
@@ -42,7 +42,7 @@ jobs:
4242
latest-factors: |
4343
msvc Optimized-Debug
4444
gcc UBSan Coverage
45-
clang UBSan ASan
45+
clang UBSan ASan MSan
4646
apple-clang UBSan ASan
4747
factors: ''
4848
runs-on: |
@@ -66,21 +66,29 @@ jobs:
6666
clang: git build-essential pkg-config python3 curl openjdk-11-jdk pkg-config libncurses-dev libxml2-utils libxml2-dev g++-14=14.2.0-4ubuntu2~24.04
6767
msvc: ''
6868
extra-values: |
69-
llvm-hash: a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b
70-
llvm-build-preset-prefix: {{#if optimized-debug}}debwithopt{{else}}{{{lowercase build-type}}}{{/if}}
69+
use-libcxx: {{#if (and (ieq compiler 'clang') (or (eq major 19) (eq major 20) (eq major 21))) }}true{{else}}false{{/if}}
70+
libcxx-runtimes: libcxx{{#if (ne compiler 'msvc')}};libcxxabi{{/if}}
71+
llvm-runtimes: {{#if (ine use-libcxx 'true') }}{{{ libcxx-runtimes }}}{{/if}}
72+
llvm-path: {{#if (ieq compiler 'msvc') }}D:/a{{else if (ieq compiler 'apple-clang')}}/Users/runner/work{{else}}/__w{{/if}}/llvm
73+
llvm-hash: 3f797a8342c3dbe4a260b26f948d8776ff490431
74+
llvm-build-preset-prefix: {{#if optimized-debug}}optimizeddebug{{else}}{{{lowercase build-type}}}{{/if}}
7175
llvm-build-preset-os: {{#if (ieq os 'windows') }}win{{else}}unix{{/if}}
7276
llvm-sanitizer: {{#if (eq compiler 'gcc')}}{{else if ubsan}}-UBSan{{else if asan}}-ASan{{else if msan}}-MSan{{/if}}
7377
llvm-build-preset: {{{ llvm-build-preset-prefix }}}-{{{ llvm-build-preset-os }}}
7478
llvm-compiler-version: {{#if (or (contains version '*') (contains version '^'))}}{{else}}-{{{ version }}}{{/if}}
7579
llvm-archive-basename: llvm-{{{ lowercase os }}}-{{{ compiler }}}{{{ llvm-compiler-version }}}-{{{ llvm-build-preset-prefix }}}{{{ llvm-sanitizer }}}-{{{ substr llvm-hash 0 7 }}}
76-
llvm-root: ../third-party/llvm-project/install
7780
llvm-archive-extension: {{#if (ieq os 'windows') }}7z{{else}}tar.bz2{{/if}}
7881
llvm-archive-filename: {{{ llvm-archive-basename }}}.{{{ llvm-archive-extension }}}
7982
llvm-sanitizer-config: {{#if (and (ne compiler 'clang') (ne compiler 'apple-clang'))}}{{else if ubsan}}Undefined{{else if asan}}Address{{else if msan}}MemoryWithOrigins{{/if}}
80-
mrdocs-flags: {{#if (and (eq compiler 'gcc') (not asan)) }}-static{{/if}}{{#if (and (eq compiler 'clang') msan) }}-fsanitize-memory-track-origins{{/if}}
81-
mrdocs-ccflags: {{{ ccflags }}} {{{ mrdocs-flags }}}
82-
mrdocs-cxxflags: {{{ cxxflags }}} {{{ mrdocs-flags }}}
83-
mrdocs-linkflags: {{#if asan }}-fsanitize=address{{/if}}
83+
common-flags-base: {{#if (ieq compiler 'clang')}}-gz=zstd {{/if}}
84+
common-flags: {{{ common-flags-base }}}{{#if msan }}-fsanitize-memory-track-origins {{/if}}
85+
common-cxxflags-base: {{#if (ieq use-libcxx 'true') }}-nostdinc++ -nostdlib++ -isystem{{{ llvm-path }}}/include/c++/v1{{/if}}
86+
common-ccflags: {{{ ccflags }}} {{{ common-flags }}}
87+
common-cxxflags: {{{ cxxflags }}} {{{ common-flags }}} {{{ common-cxxflags-base }}}
88+
common-ldflags: {{{ ldflags }}} {{#if (ieq use-libcxx 'true') }}-L{{{ llvm-path }}}/lib -lc++abi -lc++ -Wl,-rpath,{{{ llvm-path }}}/lib {{/if}}{{#if ubsan }}-fsanitize=undefined {{/if}}{{#if asan }}-fsanitize=address {{/if}}{{#if msan }}-fsanitize=memory {{/if}}
89+
mrdocs-flags: {{#if (and (eq compiler 'gcc') (not asan)) }}-static{{/if}}
90+
mrdocs-ccflags: {{{ common-ccflags }}} {{{ mrdocs-flags }}}
91+
mrdocs-cxxflags: {{{ common-cxxflags }}} {{{ mrdocs-flags }}}
8492
mrdocs-package-generators: {{#if (ieq os 'windows') }}7Z ZIP WIX{{else}}TGZ TXZ{{/if}}
8593
mrdocs-release-package-artifact: release-packages-{{{ lowercase os }}}
8694
output-file: matrix.json
@@ -135,7 +143,7 @@ jobs:
135143
# We need git to ensure actions/checkout@v4 will use git and
136144
# for the next steps that need to clone repositories
137145
- name: Install Git
138-
uses: alandefreitas/cpp-actions/[email protected].10
146+
uses: alandefreitas/cpp-actions/[email protected].11
139147
if: matrix.container != ''
140148
env:
141149
DEBIAN_FRONTEND: 'noninteractive'
@@ -164,7 +172,7 @@ jobs:
164172
uses: seanmiddleditch/gha-setup-ninja@v5
165173

166174
- name: Setup C++
167-
uses: alandefreitas/cpp-actions/[email protected].10
175+
uses: alandefreitas/cpp-actions/[email protected].11
168176
id: setup-cpp
169177
with:
170178
compiler: ${{ matrix.compiler }}
@@ -189,7 +197,7 @@ jobs:
189197
${{ steps.setup-cpp.outputs.cxx }} --print-target-triple
190198
191199
- name: Install System Packages
192-
uses: alandefreitas/cpp-actions/[email protected].10
200+
uses: alandefreitas/cpp-actions/[email protected].11
193201
if: matrix.compiler != 'msvc'
194202
id: package-install
195203
env:
@@ -198,18 +206,15 @@ jobs:
198206
with:
199207
apt-get: ${{ matrix.install }}
200208

201-
- name: Resolve LLVM Root
202-
id: resolve-llvm-root
209+
- name: Install LLVM packages
210+
if: matrix.compiler == 'clang'
211+
env:
212+
DEBIAN_FRONTEND: 'noninteractive'
213+
TZ: 'Etc/UTC'
203214
run: |
204-
set -x
205-
cd ..
206-
llvm_root=$(pwd)/third-party/llvm-project/install
207-
if [[ ${{ runner.os }} == 'Windows' ]]; then
208-
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
209-
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|')
210-
echo "$llvm_root"
211-
fi
212-
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
215+
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" >> /etc/apt/sources.list
216+
apt-get update
217+
apt-get install -y libclang-18-dev libclang-19-dev libclang-20-dev libclang-21-dev
213218
214219
- name: Resolve Third-Party Directory
215220
id: resolve-third-party-dir
@@ -228,7 +233,7 @@ jobs:
228233
id: llvm-cache
229234
uses: actions/cache@v4
230235
with:
231-
path: ${{ steps.resolve-llvm-root.outputs.llvm-root }}
236+
path: ${{ matrix.llvm-path }}
232237
key: ${{ matrix.llvm-archive-basename }}
233238

234239
- name: Download LLVM Binaries
@@ -242,7 +247,7 @@ jobs:
242247
found="true"
243248
echo "found=$found" >> $GITHUB_OUTPUT
244249
curl -L -o ${{ matrix.llvm-archive-filename }} "$url"
245-
install_prefix=$(pwd)/../third-party/llvm-project/install
250+
install_prefix=${{ matrix.llvm-path }}
246251
mkdir -p $install_prefix
247252
if [[ ${{ matrix.llvm-archive-extension }} == '7z' ]]; then
248253
7z x ${{ matrix.llvm-archive-filename }} -o$install_prefix
@@ -261,9 +266,44 @@ jobs:
261266
echo "found=$found" >> $GITHUB_OUTPUT
262267
fi
263268
269+
- name: Install libc++
270+
id: install_libcxx
271+
uses: alandefreitas/cpp-actions/[email protected]
272+
if: matrix.use-libcxx == 'true' && steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true'
273+
with:
274+
cmake-version: '>=3.26'
275+
source-dir: ../third-party/llvm-project/runtimes
276+
git-repository: https://github.com/llvm/llvm-project.git
277+
git-tag: ${{ matrix.llvm-hash }}
278+
download-dir: ../third-party/llvm-project
279+
build-dir: ${sourceDir}/build
280+
build-type: ${{ matrix.build-type }}
281+
extra-args: |
282+
-D LLVM_USE_SANITIZER=${{ matrix.llvm-sanitizer-config }}
283+
-D LLVM_OPTIMIZED_TABLEGEN=ON
284+
-D LLVM_ENABLE_LIBCXX=OFF
285+
-D LLVM_ENABLE_PROJECT=""
286+
-D LLVM_ENABLE_RUNTIMES="${{ matrix.libcxx-runtimes }}"
287+
-D LIBCXXABI_USE_LLVM_UNWINDER=OFF
288+
-D CMAKE_C_FLAGS="${{ matrix.common-flags-base }}"
289+
-D CMAKE_CXX_FLAGS="${{ matrix.common-flags-base }}"
290+
291+
cc: ${{ steps.setup-cpp.outputs.cc }}
292+
cxx: ${{ steps.setup-cpp.outputs.cxx }}
293+
generator: Ninja
294+
install: true
295+
install-prefix: ${{ matrix.llvm-path }}
296+
run-tests: false
297+
trace-commands: true
298+
299+
- name: Remove libcxx build-dir
300+
if: steps.install_libcxx.outcome == 'success'
301+
run: |
302+
rm -r ../third-party/llvm-project/runtimes/build
303+
264304
- name: Install LLVM
265305
id: install_llvm
266-
uses: alandefreitas/cpp-actions/[email protected].10
306+
uses: alandefreitas/cpp-actions/[email protected].11
267307
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true'
268308
with:
269309
cmake-version: '>=3.26'
@@ -274,29 +314,37 @@ jobs:
274314
patches: |
275315
./third-party/llvm/CMakePresets.json
276316
./third-party/llvm/CMakeUserPresets.json
277-
build-dir: ${sourceDir}/llvm/build
317+
build-dir: ${sourceDir}/build
278318
preset: ${{ matrix.llvm-build-preset }}
279319
build-type: ${{ matrix.build-type }}
280-
# The LLVM_USE_SANITIZER option doesn't support GCC.
281320
extra-args: |
282-
-DLLVM_USE_SANITIZER=${{ matrix.llvm-sanitizer-config }}
321+
-D LLVM_ENABLE_ASSERTIONS=ON
322+
-D LLVM_USE_SANITIZER="${{ matrix.llvm-sanitizer-config }}"
323+
-D LLVM_OPTIMIZED_TABLEGEN=ON
324+
-D LLVM_COMPILER_CHECKED=ON
325+
-D LLVM_BUILD_TOOLS=OFF
326+
-D CLANG_BUILD_TOOLS=OFF
327+
-D LLVM_ENABLE_RUNTIMES="${{ matrix.llvm-runtimes }}"
328+
-D LIBCXXABI_USE_LLVM_UNWINDER=OFF
329+
-D CMAKE_C_FLAGS="${{ matrix.common-flags-base }}"
330+
-D CMAKE_CXX_FLAGS="${{ matrix.common-flags-base }} ${{ matrix.common-cxxflags-base }}"
331+
-D CMAKE_SHARED_LINKER_FLAGS="${{ matrix.common-ldflags }}"
332+
-D CMAKE_EXE_LINKER_FLAGS="${{ matrix.common-ldflags }}"
283333
cc: ${{ steps.setup-cpp.outputs.cc }}
284334
cxx: ${{ steps.setup-cpp.outputs.cxx }}
285-
ccflags: -gz=zstd
286-
cxxflags: -gz=zstd
287335
generator: Ninja
288336
install: true
289-
install-prefix: ${sourceDir}/../install
337+
install-prefix: ${{ matrix.llvm-path }}
290338
run-tests: false
291339
trace-commands: true
292340

293341
- name: Remove LLVM build-dir
294342
if: steps.install_llvm.outcome == 'success'
295343
run: |
296-
rm -r ../third-party/llvm-project/llvm/llvm/build
344+
rm -r ../third-party/llvm-project
297345
298346
- name: Install Duktape
299-
uses: alandefreitas/cpp-actions/[email protected].10
347+
uses: alandefreitas/cpp-actions/[email protected].11
300348
with:
301349
source-dir: ../third-party/duktape
302350
url: https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz
@@ -306,8 +354,8 @@ jobs:
306354
build-dir: ${sourceDir}/build
307355
cc: ${{ steps.setup-cpp.outputs.cc }}
308356
cxx: ${{ steps.setup-cpp.outputs.cxx }}
309-
ccflags: ${{ matrix.ccflags }}
310-
cxxflags: ${{ matrix.cxxflags }}
357+
ccflags: ${{ matrix.common-ccflags }}
358+
cxxflags: ${{ matrix.common-cxxflags }}
311359
build-type: ${{ matrix.build-type }}
312360
shared: false
313361
install: true
@@ -316,7 +364,7 @@ jobs:
316364
trace-commands: true
317365

318366
- name: Install Libxml2
319-
uses: alandefreitas/cpp-actions/[email protected].10
367+
uses: alandefreitas/cpp-actions/[email protected].11
320368
if: matrix.compiler == 'msvc'
321369
with:
322370
source-dir: ../third-party/libxml2
@@ -325,11 +373,12 @@ jobs:
325373
build-dir: ${sourceDir}/build
326374
cc: ${{ steps.setup-cpp.outputs.cc }}
327375
cxx: ${{ steps.setup-cpp.outputs.cxx }}
328-
ccflags: ${{ matrix.ccflags }}
329-
cxxflags: ${{ matrix.cxxflags }}
376+
ccflags: ${{ matrix.common-ccflags }}
377+
cxxflags: ${{ matrix.common-cxxflags }}
330378
build-type: Release
331379
shared: false
332380
extra-args: |
381+
-D CMAKE_SHARED_LINKER_FLAGS="${{ matrix.common-ldflags }}"
333382
-D LIBXML2_WITH_PROGRAMS=ON
334383
-D LIBXML2_WITH_FTP=OFF
335384
-D LIBXML2_WITH_HTTP=OFF
@@ -374,7 +423,7 @@ jobs:
374423
node-version: '20'
375424

376425
- name: CMake Workflow
377-
uses: alandefreitas/cpp-actions/[email protected].10
426+
uses: alandefreitas/cpp-actions/[email protected].11
378427
with:
379428
cmake-version: '>=3.26'
380429
cxxstd: ${{ matrix.cxxstd }}
@@ -388,11 +437,10 @@ jobs:
388437
install-prefix: .local
389438
extra-args: |
390439
-D MRDOCS_BUILD_DOCS=OFF
391-
-D CMAKE_EXE_LINKER_FLAGS=${{ matrix.mrdocs-linkflags }}
392-
-D LLVM_ROOT=${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/llvm-project/install
393-
-D Clang_ROOT=${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/llvm-project/install
394-
-D duktape_ROOT=${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install
395-
-D Duktape_ROOT=${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install
440+
-D CMAKE_EXE_LINKER_FLAGS="${{ matrix.common-ldflags }}"
441+
-D LLVM_ROOT="${{ matrix.llvm-path }}"
442+
-D duktape_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install"
443+
-D Duktape_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install"
396444
${{ runner.os == 'Windows' && '-D libxml2_ROOT=../third-party/libxml2/install' || '' }}
397445
${{ runner.os == 'Windows' && '-D LibXml2_ROOT=../third-party/libxml2/install' || '' }}
398446
export-compile-commands: true
@@ -423,7 +471,7 @@ jobs:
423471
retention-days: 1
424472

425473
- name: FlameGraph
426-
uses: alandefreitas/cpp-actions/[email protected].10
474+
uses: alandefreitas/cpp-actions/[email protected].11
427475
if: matrix.time-trace
428476
with:
429477
build-dir: build
@@ -493,7 +541,7 @@ jobs:
493541

494542
steps:
495543
- name: Install packages
496-
uses: alandefreitas/cpp-actions/[email protected].10
544+
uses: alandefreitas/cpp-actions/[email protected].11
497545
id: package-install
498546
with:
499547
apt-get: build-essential asciidoctor cmake bzip2 git
@@ -555,7 +603,7 @@ jobs:
555603
$MRDOCS_ROOT/bin/mrdocs --version
556604
557605
- name: Clone Boost.URL
558-
uses: alandefreitas/cpp-actions/[email protected].10
606+
uses: alandefreitas/cpp-actions/[email protected].11
559607
id: boost-url-clone
560608
with:
561609
branch: develop
@@ -822,7 +870,7 @@ jobs:
822870
scp -o StrictHostKeyChecking=no -r $(pwd)/demos/* [email protected]:$demo_dir/
823871
824872
- name: Create changelog
825-
uses: alandefreitas/cpp-actions/[email protected].10
873+
uses: alandefreitas/cpp-actions/[email protected].11
826874
with:
827875
output-path: CHANGELOG.md
828876
thank-non-regular: ${{ startsWith(github.ref, 'refs/tags/') }}
@@ -864,7 +912,7 @@ jobs:
864912

865913
steps:
866914
- name: Install packages
867-
uses: alandefreitas/cpp-actions/[email protected].10
915+
uses: alandefreitas/cpp-actions/[email protected].11
868916
id: package-install
869917
with:
870918
apt-get: ${{ matrix.install }}
@@ -882,25 +930,12 @@ jobs:
882930
fi
883931
echo "exists=$exists" >> $GITHUB_OUTPUT
884932
885-
- name: Resolve LLVM Root
886-
id: resolve-llvm-root
887-
run: |
888-
set -x
889-
cd ..
890-
llvm_root=$(pwd)/third-party/llvm-project/install
891-
if [[ ${{ runner.os }} == 'Windows' ]]; then
892-
llvm_root=$(echo "$llvm_root" | sed 's/\\/\//g')
893-
llvm_root=$(echo $llvm_root | sed 's|^/d/|D:/|')
894-
echo "$llvm_root"
895-
fi
896-
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
897-
898933
- name: LLVM Binaries
899934
id: llvm-cache
900935
if: steps.website-releases.outputs.exists != 'true'
901936
uses: actions/cache@v4
902937
with:
903-
path: ${{ steps.resolve-llvm-root.outputs.llvm-root }}
938+
path: ${{ matrix.llvm-path }}
904939
key: ${{ matrix.llvm-archive-basename }}
905940

906941
- name: Compress LLVM
@@ -910,20 +945,16 @@ jobs:
910945
run: |
911946
# LLVM is be installed with the default compiler
912947
set -x
913-
914-
# Compress the LLVM installation
915-
cd ../third-party/llvm-project
916-
948+
917949
# Use 7z on windows
918950
if [[ ${{ runner.os }} == 'Windows' ]]; then
919-
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on ${{ matrix.llvm-archive-filename }} install
951+
7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on "${{ matrix.llvm-archive-filename }}" "${{ matrix.llvm-path }}"
920952
else
921-
tar -cjf ${{ matrix.llvm-archive-filename }} -C install .
953+
tar -cjf "${{ matrix.llvm-archive-filename }}" -C "${{ matrix.llvm-path }}/.." llvm
922954
fi
923955
924956
- name: Website LLVM Releases
925957
if: steps.llvm-cache.outputs.cache-hit == 'true' && github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/'))
926-
working-directory: ../third-party/llvm-project
927958
run: |
928959
set -x
929960

0 commit comments

Comments
 (0)