Skip to content

Commit 30b4802

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 2b59269 commit 30b4802

File tree

1 file changed

+57
-17
lines changed

1 file changed

+57
-17
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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,6 +66,8 @@ 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+
use-libcxx: {{#if (and (or (ieq compiler 'clang') (ieq compiler 'apple-clang')) (or ubsan asan msan)) }}true{{else}}false{{/if}}
70+
libcxx-path: ../third-party/libcxx
6971
llvm-hash: a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b
7072
llvm-build-preset-prefix: {{#if optimized-debug}}debwithopt{{else}}{{{lowercase build-type}}}{{/if}}
7173
llvm-build-preset-os: {{#if (ieq os 'windows') }}win{{else}}unix{{/if}}
@@ -77,10 +79,13 @@ jobs:
7779
llvm-archive-extension: {{#if (ieq os 'windows') }}7z{{else}}tar.bz2{{/if}}
7880
llvm-archive-filename: {{{ llvm-archive-basename }}}.{{{ llvm-archive-extension }}}
7981
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}}
82+
common-flags: -gz=zstd {{#if msan }}-fsanitize-memory-track-origins {{/if}}
83+
common-ccflags: {{{ ccflags }}} {{{ common-flags }}}
84+
common-cxxflags: {{{ cxxflags }}} {{#if (ieq use-libcxx 'true') }}-nostdinc++ -isystem{{{ libcxx-path }}}/include/c++/v1{{/if}}
85+
common-ldflags: {{{ ldflags }}} {{#if (ieq use-libcxx 'true') }}-nostdlib++ -L{{{ libcxx-path }}}/lib -lc++abi -lc++ -Wl,-rpath,{{{ libcxx-path }}}/lib {{/if}}
86+
mrdocs-flags: {{#if (and (eq compiler 'gcc') (not asan)) }}-static{{/if}}
87+
mrdocs-ccflags: {{{ common-ccflags }}} {{{ mrdocs-flags }}}
88+
mrdocs-cxxflags: {{{ common-cxxflags }}} {{{ mrdocs-flags }}}
8489
mrdocs-package-generators: {{#if (ieq os 'windows') }}7Z ZIP WIX{{else}}TGZ TXZ{{/if}}
8590
mrdocs-release-package-artifact: release-packages-{{{ lowercase os }}}
8691
output-file: matrix.json
@@ -224,6 +229,35 @@ jobs:
224229
fi
225230
echo -E "third-party-dir=$third_party_dir" >> $GITHUB_OUTPUT
226231
232+
- name: Install libc++
233+
uses: alandefreitas/cpp-actions/[email protected]
234+
if: matrix.use-libcxx == 'true'
235+
with:
236+
cmake-version: '>=3.26'
237+
source-dir: ../third-party/llvm-project/runtimes
238+
git-repository: https://github.com/llvm/llvm-project.git
239+
git-tag: llvmorg-21.1.0
240+
download-dir: ../third-party/llvm-project
241+
build-dir: ${{ matrix.libcxx-path }}
242+
build-type: ${{ matrix.build-type }}
243+
extra-args: |
244+
-D LLVM_USE_SANITIZER=${{ matrix.llvm-sanitizer-config }}
245+
-D LLVM_OPTIMIZED_TABLEGEN=ON
246+
-D LLVM_ENABLE_LIBCXX=OFF
247+
-D LLVM_ENABLE_PROJECT=""
248+
-D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"
249+
-D LLVM_ENABLE_PIC=ON
250+
-D LIBCXXABI_USE_LLVM_UNWINDER=OFF
251+
252+
cc: ${{ steps.setup-cpp.outputs.cc }}
253+
cxx: ${{ steps.setup-cpp.outputs.cxx }}
254+
ccflags: -gz=zstd
255+
cxxflags: -gz=zstd
256+
generator: Ninja
257+
install: false
258+
run-tests: false
259+
trace-commands: true
260+
227261
- name: Cached LLVM Binaries
228262
id: llvm-cache
229263
uses: actions/cache@v4
@@ -279,11 +313,14 @@ jobs:
279313
build-type: ${{ matrix.build-type }}
280314
# The LLVM_USE_SANITIZER option doesn't support GCC.
281315
extra-args: |
282-
-DLLVM_USE_SANITIZER=${{ matrix.llvm-sanitizer-config }}
316+
-D LLVM_USE_SANITIZER="${{ matrix.llvm-sanitizer-config }}"
317+
-D LLVM_OPTIMIZED_TABLEGEN=ON
318+
-D CMAKE_SHARED_LINKER_FLAGS="${{ matrix.common-ldflags }}"
319+
-D CMAKE_ENABLE_LIBCXX=OFF
283320
cc: ${{ steps.setup-cpp.outputs.cc }}
284321
cxx: ${{ steps.setup-cpp.outputs.cxx }}
285-
ccflags: -gz=zstd
286-
cxxflags: -gz=zstd
322+
ccflags: ${{ matrix.common-ccflags }}
323+
cxxflags: ${{ matrix.common-cxxflags }}
287324
generator: Ninja
288325
install: true
289326
install-prefix: ${sourceDir}/../install
@@ -306,10 +343,12 @@ jobs:
306343
build-dir: ${sourceDir}/build
307344
cc: ${{ steps.setup-cpp.outputs.cc }}
308345
cxx: ${{ steps.setup-cpp.outputs.cxx }}
309-
ccflags: ${{ matrix.ccflags }}
310-
cxxflags: ${{ matrix.cxxflags }}
346+
ccflags: ${{ matrix.common-ccflags }}
347+
cxxflags: ${{ matrix.common-cxxflags }}
311348
build-type: ${{ matrix.build-type }}
312349
shared: false
350+
extra-args: |
351+
-D CMAKE_STATIC_LINKER_FLAGS="${{ matrix.common-ldflags }}"
313352
install: true
314353
install-prefix: ${sourceDir}/install
315354
run-tests: false
@@ -325,11 +364,12 @@ jobs:
325364
build-dir: ${sourceDir}/build
326365
cc: ${{ steps.setup-cpp.outputs.cc }}
327366
cxx: ${{ steps.setup-cpp.outputs.cxx }}
328-
ccflags: ${{ matrix.ccflags }}
329-
cxxflags: ${{ matrix.cxxflags }}
367+
ccflags: ${{ matrix.common-ccflags }}
368+
cxxflags: ${{ matrix.common-cxxflags }}
330369
build-type: Release
331370
shared: false
332371
extra-args: |
372+
-D CMAKE_SHARED_LINKER_FLAGS="${{ matrix.common-ldflags }}"
333373
-D LIBXML2_WITH_PROGRAMS=ON
334374
-D LIBXML2_WITH_FTP=OFF
335375
-D LIBXML2_WITH_HTTP=OFF
@@ -388,11 +428,11 @@ jobs:
388428
install-prefix: .local
389429
extra-args: |
390430
-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
431+
-D CMAKE_EXE_LINKER_FLAGS="${{ matrix.common-ldflags }}"
432+
-D LLVM_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/llvm-project/install"
433+
-D Clang_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/llvm-project/install"
434+
-D duktape_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install"
435+
-D Duktape_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install"
396436
${{ runner.os == 'Windows' && '-D libxml2_ROOT=../third-party/libxml2/install' || '' }}
397437
${{ runner.os == 'Windows' && '-D LibXml2_ROOT=../third-party/libxml2/install' || '' }}
398438
export-compile-commands: true

0 commit comments

Comments
 (0)