Skip to content

Commit 3f4745c

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 3f4745c

File tree

2 files changed

+90
-52
lines changed

2 files changed

+90
-52
lines changed

.github/workflows/ci.yml

Lines changed: 88 additions & 50 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,30 @@ 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
69+
use-libcxx: {{#if (ieq compiler 'clang') }}true{{else}}false{{/if}}
70+
llvm-path: /usr/local/llvm
71+
libcxx-runtimes: libcxx{{#if (ne compiler 'msvc')}};libcxxabi{{/if}}
72+
llvm-hash: 3f797a8342c3dbe4a260b26f948d8776ff490431
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 }}}
76-
llvm-root: ../third-party/llvm-project/install
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+
llvm-enable-assertions: {{#if (ieq use-libcxx 'true')}}ON{{else}}OFF{{/if}}
83+
llvm-enable-modules: {{#if (or (ieq compiler 'clang') (ieq compiler 'apple-clang'))}}ON{{else}}OFF{{/if}}
84+
common-flags-base: {{#if (ieq compiler 'clang')}}-gz=zstd {{/if}}
85+
common-flags: {{{ common-flags-base }}}{{#if msan }}-fsanitize-memory-track-origins {{/if}}
86+
common-cxxflags-base: {{#if (ieq use-libcxx 'true') }}-nostdinc++ -isystem{{{ llvm-path }}}/include/c++/v1{{/if}}
87+
common-ccflags: {{{ ccflags }}} {{{ common-flags }}}
88+
common-cxxflags: {{{ cxxflags }}} {{{ common-flags }}} {{{ common-cxxflags-base }}}
89+
common-ldflags: {{{ ldflags }}} {{#if (ieq use-libcxx 'true') }}-nostdlib++ -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}}
90+
mrdocs-flags: {{#if (and (eq compiler 'gcc') (not asan)) }}-static{{/if}}
91+
mrdocs-ccflags: {{{ common-ccflags }}} {{{ mrdocs-flags }}}
92+
mrdocs-cxxflags: {{{ common-cxxflags }}} {{{ mrdocs-flags }}}
8493
mrdocs-package-generators: {{#if (ieq os 'windows') }}7Z ZIP WIX{{else}}TGZ TXZ{{/if}}
8594
mrdocs-release-package-artifact: release-packages-{{{ lowercase os }}}
8695
output-file: matrix.json
@@ -198,18 +207,15 @@ jobs:
198207
with:
199208
apt-get: ${{ matrix.install }}
200209

201-
- name: Resolve LLVM Root
202-
id: resolve-llvm-root
210+
- name: Install LLVM packages
211+
if: matrix.compiler == 'clang'
212+
env:
213+
DEBIAN_FRONTEND: 'noninteractive'
214+
TZ: 'Etc/UTC'
203215
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
216+
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" >> /etc/apt/sources.list
217+
apt-get update
218+
apt-get install -y libclang-18-dev libclang-19-dev libclang-20-dev libclang-21-dev
213219
214220
- name: Resolve Third-Party Directory
215221
id: resolve-third-party-dir
@@ -228,7 +234,7 @@ jobs:
228234
id: llvm-cache
229235
uses: actions/cache@v4
230236
with:
231-
path: ${{ steps.resolve-llvm-root.outputs.llvm-root }}
237+
path: ${{ matrix.llvm-path }}
232238
key: ${{ matrix.llvm-archive-basename }}
233239

234240
- name: Download LLVM Binaries
@@ -261,6 +267,42 @@ jobs:
261267
echo "found=$found" >> $GITHUB_OUTPUT
262268
fi
263269
270+
- name: Install libc++
271+
id: install_libcxx
272+
uses: alandefreitas/cpp-actions/[email protected]
273+
if: steps.llvm-cache.outputs.cache-hit != 'true' && steps.llvm-download.outputs.found != 'true'
274+
with:
275+
cmake-version: '>=3.26'
276+
source-dir: ../third-party/llvm-project/runtimes
277+
git-repository: https://github.com/llvm/llvm-project.git
278+
git-tag: ${{ matrix.llvm-hash }}
279+
download-dir: ../third-party/llvm-project
280+
build-dir: ${sourceDir}/build
281+
build-type: ${{ matrix.build-type }}
282+
extra-args: |
283+
-D LLVM_USE_SANITIZER=${{ matrix.llvm-sanitizer-config }}
284+
-D LLVM_OPTIMIZED_TABLEGEN=ON
285+
-D LLVM_ENABLE_LIBCXX=OFF
286+
-D LLVM_ENABLE_PROJECT=""
287+
-D LLVM_ENABLE_RUNTIMES="${{ matrix.libcxx-runtimes }}"
288+
-D LLVM_ENABLE_MODULES="${{ matrix.llvm-enable-modules }}"
289+
-D LIBCXXABI_USE_LLVM_UNWINDER=OFF
290+
-D CMAKE_C_FLAGS="${{ matrix.common-flags-base }}"
291+
-D CMAKE_CXX_FLAGS="${{ matrix.common-flags-base }}"
292+
293+
cc: ${{ steps.setup-cpp.outputs.cc }}
294+
cxx: ${{ steps.setup-cpp.outputs.cxx }}
295+
generator: Ninja
296+
install: true
297+
install-prefix: ${{ matrix.llvm-path }}
298+
run-tests: false
299+
trace-commands: true
300+
301+
- name: Remove libcxx build-dir
302+
if: steps.install_libcxx.outcome == 'success'
303+
run: |
304+
rm -r ../third-party/llvm-project/runtimes/build
305+
264306
- name: Install LLVM
265307
id: install_llvm
266308
uses: alandefreitas/cpp-actions/[email protected]
@@ -274,26 +316,35 @@ jobs:
274316
patches: |
275317
./third-party/llvm/CMakePresets.json
276318
./third-party/llvm/CMakeUserPresets.json
277-
build-dir: ${sourceDir}/llvm/build
319+
build-dir: ${sourceDir}/build
278320
preset: ${{ matrix.llvm-build-preset }}
279321
build-type: ${{ matrix.build-type }}
280-
# The LLVM_USE_SANITIZER option doesn't support GCC.
281322
extra-args: |
282-
-DLLVM_USE_SANITIZER=${{ matrix.llvm-sanitizer-config }}
323+
-D LLVM_ENABLE_ASSERTIONS=${{ matrix.llvm-enable-assertions }}
324+
-D LLVM_USE_SANITIZER="${{ matrix.llvm-sanitizer-config }}"
325+
-D LLVM_OPTIMIZED_TABLEGEN=ON
326+
-D LLVM_COMPILER_CHECKED=ON
327+
-D LLVM_BUILD_TOOLS=OFF
328+
-D LLVM_INCLUDE_TOOLS=ON
329+
-D LLVM_ENABLE_RUNTIMES=""
330+
-D LLVM_ENABLE_MODULES="${{ matrix.llvm-enable-modules }}"
331+
-D CMAKE_C_FLAGS="${{ matrix.common-flags-base }}"
332+
-D CMAKE_CXX_FLAGS="${{ matrix.common-flags-base }} ${{ matrix.common-cxxflags-base }}"
333+
-D CMAKE_SHARED_LINKER_FLAGS="${{ matrix.common-ldflags }}"
334+
-D CMAKE_EXE_LINKER_FLAGS="${{ matrix.common-ldflags }}"
283335
cc: ${{ steps.setup-cpp.outputs.cc }}
284336
cxx: ${{ steps.setup-cpp.outputs.cxx }}
285-
ccflags: -gz=zstd
286-
cxxflags: -gz=zstd
287337
generator: Ninja
288338
install: true
289-
install-prefix: ${sourceDir}/../install
339+
install-prefix: ${{ matrix.llvm-path }}
290340
run-tests: false
291341
trace-commands: true
292342

293343
- name: Remove LLVM build-dir
294344
if: steps.install_llvm.outcome == 'success'
295345
run: |
296-
rm -r ../third-party/llvm-project/llvm/llvm/build
346+
ls -laR "${{ matrix.llvm-path }}"
347+
rm -r ../third-party/llvm-project
297348
298349
- name: Install Duktape
299350
uses: alandefreitas/cpp-actions/[email protected]
@@ -306,8 +357,8 @@ jobs:
306357
build-dir: ${sourceDir}/build
307358
cc: ${{ steps.setup-cpp.outputs.cc }}
308359
cxx: ${{ steps.setup-cpp.outputs.cxx }}
309-
ccflags: ${{ matrix.ccflags }}
310-
cxxflags: ${{ matrix.cxxflags }}
360+
ccflags: ${{ matrix.common-ccflags }}
361+
cxxflags: ${{ matrix.common-cxxflags }}
311362
build-type: ${{ matrix.build-type }}
312363
shared: false
313364
install: true
@@ -325,11 +376,12 @@ jobs:
325376
build-dir: ${sourceDir}/build
326377
cc: ${{ steps.setup-cpp.outputs.cc }}
327378
cxx: ${{ steps.setup-cpp.outputs.cxx }}
328-
ccflags: ${{ matrix.ccflags }}
329-
cxxflags: ${{ matrix.cxxflags }}
379+
ccflags: ${{ matrix.common-ccflags }}
380+
cxxflags: ${{ matrix.common-cxxflags }}
330381
build-type: Release
331382
shared: false
332383
extra-args: |
384+
-D CMAKE_SHARED_LINKER_FLAGS="${{ matrix.common-ldflags }}"
333385
-D LIBXML2_WITH_PROGRAMS=ON
334386
-D LIBXML2_WITH_FTP=OFF
335387
-D LIBXML2_WITH_HTTP=OFF
@@ -388,11 +440,10 @@ jobs:
388440
install-prefix: .local
389441
extra-args: |
390442
-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
443+
-D CMAKE_EXE_LINKER_FLAGS="${{ matrix.common-ldflags }}"
444+
-D LLVM_ROOT="${{ matrix.llvm-path }}"
445+
-D duktape_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install"
446+
-D Duktape_ROOT="${{ steps.resolve-third-party-dir.outputs.third-party-dir }}/duktape/install"
396447
${{ runner.os == 'Windows' && '-D libxml2_ROOT=../third-party/libxml2/install' || '' }}
397448
${{ runner.os == 'Windows' && '-D LibXml2_ROOT=../third-party/libxml2/install' || '' }}
398449
export-compile-commands: true
@@ -882,25 +933,12 @@ jobs:
882933
fi
883934
echo "exists=$exists" >> $GITHUB_OUTPUT
884935
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-
898936
- name: LLVM Binaries
899937
id: llvm-cache
900938
if: steps.website-releases.outputs.exists != 'true'
901939
uses: actions/cache@v4
902940
with:
903-
path: ${{ steps.resolve-llvm-root.outputs.llvm-root }}
941+
path: ${{ matrix.llvm-path }}
904942
key: ${{ matrix.llvm-archive-basename }}
905943

906944
- name: Compress LLVM

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ elseif (LLVM_ROOT)
8686
# Clang_ROOT matches LLVM_ROOT by default
8787
set(Clang_ROOT "${LLVM_ROOT}" CACHE PATH "Root of Clang install." FORCE)
8888
endif()
89-
find_package(LLVM REQUIRED CONFIG)
90-
find_package(Clang REQUIRED CONFIG)
89+
find_package(LLVM REQUIRED CONFIG NO_DEFAULT_PATH)
90+
find_package(Clang REQUIRED CONFIG NO_DEFAULT_PATH)
9191

9292
set(LIBCXX_DIR "${LLVM_INCLUDE_DIR}/c++/v1" CACHE PATH
9393
"Path to libc++ include directory")

0 commit comments

Comments
 (0)