Skip to content

Commit 5e08138

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 a0f694d commit 5e08138

File tree

1 file changed

+78
-20
lines changed

1 file changed

+78
-20
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 20 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,21 +66,28 @@ 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 (ieq compiler 'clang') (or ubsan asan msan)) }}true{{else}}false{{/if}}
70+
libcxx-path: /usr/local/libcxx
71+
libcxx-runtimes: libcxx;libcxxabi{{#if (ieq compiler 'apple-clang')}};compiler-rt{{/if}}
6972
llvm-hash: a1b6e7ff393533a5c4f3bdfd4efe5da106e2de2b
7073
llvm-build-preset-prefix: {{#if optimized-debug}}debwithopt{{else}}{{{lowercase build-type}}}{{/if}}
7174
llvm-build-preset-os: {{#if (ieq os 'windows') }}win{{else}}unix{{/if}}
72-
llvm-sanitizer: {{#if (eq compiler 'gcc')}}{{else if ubsan}}-UBSan{{else if asan}}-ASan{{else if msan}}-MSan{{/if}}
75+
llvm-sanitizer: {{#if (eq compiler 'gcc')}}{{else if ubsan}}-UBSan2{{else if asan}}-ASan2{{else if msan}}-MSan{{/if}}
7376
llvm-build-preset: {{{ llvm-build-preset-prefix }}}-{{{ llvm-build-preset-os }}}
7477
llvm-compiler-version: {{#if (or (contains version '*') (contains version '^'))}}{{else}}-{{{ version }}}{{/if}}
7578
llvm-archive-basename: llvm-{{{ lowercase os }}}-{{{ compiler }}}{{{ llvm-compiler-version }}}-{{{ llvm-build-preset-prefix }}}{{{ llvm-sanitizer }}}-{{{ substr llvm-hash 0 7 }}}
7679
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+
llvm-enable-assertions: {{#if (ieq use-libcxx 'true')}}ON{{else}}OFF{{/if}}
84+
common-flags: -gz=zstd {{#if msan }}-fsanitize-memory-track-origins {{/if}}
85+
common-ccflags: {{{ ccflags }}} {{{ common-flags }}}
86+
common-cxxflags: {{{ cxxflags }}} {{#if (ieq use-libcxx 'true') }}-nostdinc++ -isystem{{{ libcxx-path }}}/include/c++/v1{{/if}}
87+
common-ldflags: {{{ ldflags }}} {{#if (ieq use-libcxx 'true') }}-nostdlib++ -L{{{ libcxx-path }}}/lib -lc++abi -lc++ -Wl,-rpath,{{{ libcxx-path }}}/lib {{/if}}{{#if ubsan }}-fsanitize=undefined {{/if}}{{#if asan }}-fsanitize=address {{/if}}{{#if msan }}-fsanitize=memory {{/if}}
88+
mrdocs-flags: {{#if (and (eq compiler 'gcc') (not asan)) }}-static{{/if}}
89+
mrdocs-ccflags: {{{ common-ccflags }}} {{{ mrdocs-flags }}}
90+
mrdocs-cxxflags: {{{ common-cxxflags }}} {{{ mrdocs-flags }}}
8491
mrdocs-package-generators: {{#if (ieq os 'windows') }}7Z ZIP WIX{{else}}TGZ TXZ{{/if}}
8592
mrdocs-release-package-artifact: release-packages-{{{ lowercase os }}}
8693
output-file: matrix.json
@@ -198,6 +205,16 @@ jobs:
198205
with:
199206
apt-get: ${{ matrix.install }}
200207

208+
- name: Install LLVM packages
209+
if: matrix.use-libcxx == 'true' && matrix.compiler == 'clang'
210+
env:
211+
DEBIAN_FRONTEND: 'noninteractive'
212+
TZ: 'Etc/UTC'
213+
run: |
214+
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" >> /etc/apt/sources.list
215+
apt-get update
216+
apt-get install -y libclang-21-dev
217+
201218
- name: Resolve LLVM Root
202219
id: resolve-llvm-root
203220
run: |
@@ -224,6 +241,42 @@ jobs:
224241
fi
225242
echo -E "third-party-dir=$third_party_dir" >> $GITHUB_OUTPUT
226243
244+
- name: Install libc++
245+
id: install_libcxx
246+
uses: alandefreitas/cpp-actions/[email protected]
247+
if: matrix.use-libcxx == 'true'
248+
with:
249+
cmake-version: '>=3.26'
250+
source-dir: ../third-party/llvm-project/runtimes
251+
git-repository: https://github.com/llvm/llvm-project.git
252+
git-tag: llvmorg-21.1.0
253+
download-dir: ../third-party/llvm-project
254+
build-dir: ${sourceDir}/runtimes/build
255+
build-type: ${{ matrix.build-type }}
256+
extra-args: |
257+
-D LLVM_USE_SANITIZER=${{ matrix.llvm-sanitizer-config }}
258+
-D LLVM_OPTIMIZED_TABLEGEN=ON
259+
-D LLVM_ENABLE_LIBCXX=OFF
260+
-D LLVM_ENABLE_PROJECT=""
261+
-D LLVM_ENABLE_RUNTIMES="${{ matrix.libcxx-runtimes }}"
262+
-D LLVM_ENABLE_PIC=ON
263+
-D LIBCXXABI_USE_LLVM_UNWINDER=OFF
264+
265+
cc: ${{ steps.setup-cpp.outputs.cc }}
266+
cxx: ${{ steps.setup-cpp.outputs.cxx }}
267+
ccflags: -gz=zstd
268+
cxxflags: -gz=zstd
269+
generator: Ninja
270+
install: true
271+
install-prefix: ${{ matrix.libcxx-path }}
272+
run-tests: false
273+
trace-commands: true
274+
275+
- name: Remove libcxx build-dir
276+
if: steps.install_libcxx.outcome == 'success'
277+
run: |
278+
rm -r ../third-party/llvm-project/runtimes
279+
227280
- name: Cached LLVM Binaries
228281
id: llvm-cache
229282
uses: actions/cache@v4
@@ -277,13 +330,17 @@ jobs:
277330
build-dir: ${sourceDir}/llvm/build
278331
preset: ${{ matrix.llvm-build-preset }}
279332
build-type: ${{ matrix.build-type }}
280-
# The LLVM_USE_SANITIZER option doesn't support GCC.
281333
extra-args: |
282-
-DLLVM_USE_SANITIZER=${{ matrix.llvm-sanitizer-config }}
334+
-D LLVM_ENABLE_ASSERTIONS=${{ matrix.llvm-enable-assertions }}
335+
-D LLVM_USE_SANITIZER="${{ matrix.llvm-sanitizer-config }}"
336+
-D LLVM_OPTIMIZED_TABLEGEN=ON
337+
-D LLVM_COMPILER_CHECKED=ON
338+
-D CMAKE_C_FLAGS="${{ matrix.common-ccflags }}"
339+
-D CMAKE_CXX_FLAGS="${{ matrix.common-cxxflags }}"
340+
-D CMAKE_SHARED_LINKER_FLAGS="${{ matrix.common-ldflags }}"
341+
-D CMAKE_EXE_LINKER_FLAGS="${{ matrix.common-ldflags }}"
283342
cc: ${{ steps.setup-cpp.outputs.cc }}
284343
cxx: ${{ steps.setup-cpp.outputs.cxx }}
285-
ccflags: -gz=zstd
286-
cxxflags: -gz=zstd
287344
generator: Ninja
288345
install: true
289346
install-prefix: ${sourceDir}/../install
@@ -293,7 +350,7 @@ jobs:
293350
- name: Remove LLVM build-dir
294351
if: steps.install_llvm.outcome == 'success'
295352
run: |
296-
rm -r ../third-party/llvm-project/llvm/llvm/build
353+
rm -r ../third-party/llvm-project/llvm
297354
298355
- name: Install Duktape
299356
uses: alandefreitas/cpp-actions/[email protected]
@@ -306,8 +363,8 @@ jobs:
306363
build-dir: ${sourceDir}/build
307364
cc: ${{ steps.setup-cpp.outputs.cc }}
308365
cxx: ${{ steps.setup-cpp.outputs.cxx }}
309-
ccflags: ${{ matrix.ccflags }}
310-
cxxflags: ${{ matrix.cxxflags }}
366+
ccflags: ${{ matrix.common-ccflags }}
367+
cxxflags: ${{ matrix.common-cxxflags }}
311368
build-type: ${{ matrix.build-type }}
312369
shared: false
313370
install: true
@@ -325,11 +382,12 @@ jobs:
325382
build-dir: ${sourceDir}/build
326383
cc: ${{ steps.setup-cpp.outputs.cc }}
327384
cxx: ${{ steps.setup-cpp.outputs.cxx }}
328-
ccflags: ${{ matrix.ccflags }}
329-
cxxflags: ${{ matrix.cxxflags }}
385+
ccflags: ${{ matrix.common-ccflags }}
386+
cxxflags: ${{ matrix.common-cxxflags }}
330387
build-type: Release
331388
shared: false
332389
extra-args: |
390+
-D CMAKE_SHARED_LINKER_FLAGS="${{ matrix.common-ldflags }}"
333391
-D LIBXML2_WITH_PROGRAMS=ON
334392
-D LIBXML2_WITH_FTP=OFF
335393
-D LIBXML2_WITH_HTTP=OFF
@@ -388,11 +446,11 @@ jobs:
388446
install-prefix: .local
389447
extra-args: |
390448
-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
449+
-D CMAKE_EXE_LINKER_FLAGS="${{ matrix.common-ldflags }}"
450+
-D LLVM_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/llvm-project/install"
451+
-D Clang_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/llvm-project/install"
452+
-D duktape_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install"
453+
-D Duktape_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install"
396454
${{ runner.os == 'Windows' && '-D libxml2_ROOT=../third-party/libxml2/install' || '' }}
397455
${{ runner.os == 'Windows' && '-D LibXml2_ROOT=../third-party/libxml2/install' || '' }}
398456
export-compile-commands: true

0 commit comments

Comments
 (0)