Add ASAN/MSAN/UBSAN support to CMake
This commit is contained in:
parent
94b85a0784
commit
1ccb36eee8
2 changed files with 145 additions and 53 deletions
153
.github/workflows/ci.yml
vendored
153
.github/workflows/ci.yml
vendored
|
@ -16,39 +16,6 @@ on:
|
|||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: build
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y all run-test262
|
||||
- name: test
|
||||
run: |
|
||||
make test test2
|
||||
linux-asan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_ASAN=y ASAN_OPTIONS="halt_on_error=1" test
|
||||
linux-msan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_MSAN=y CONFIG_CLANG=y MSAN_OPTIONS="halt_on_error=1" test
|
||||
linux-ubsan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_UBSAN=y UBSAN_OPTIONS="halt_on_error=1" test
|
||||
linux-cmake:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
@ -81,36 +48,76 @@ jobs:
|
|||
if: ${{ matrix.buildType == 'Release' }}
|
||||
run: |
|
||||
time ./build/run-test262 -m -c test262.conf -a
|
||||
|
||||
macos:
|
||||
runs-on: macos-latest
|
||||
linux-asan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: build
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y
|
||||
- name: stats
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y qjs
|
||||
./qjs -qd
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCONFIG_ASAN=ON ..
|
||||
cd ..
|
||||
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||
- name: test
|
||||
env:
|
||||
ASAN_OPTIONS: halt_on_error=1
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y test
|
||||
macos-asan:
|
||||
runs-on: macos-latest
|
||||
./build/qjs tests/test_bigint.js
|
||||
./build/qjs tests/test_closure.js
|
||||
./build/qjs tests/test_language.js
|
||||
./build/qjs tests/test_builtin.js
|
||||
./build/qjs tests/test_loop.js
|
||||
./build/qjs tests/test_std.js
|
||||
./build/qjs tests/test_worker.js
|
||||
linux-msan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
- name: build
|
||||
env:
|
||||
CC: clang
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_ASAN=y ASAN_OPTIONS="halt_on_error=1" test
|
||||
macos-ubsan:
|
||||
runs-on: macos-latest
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCONFIG_MSAN=ON ..
|
||||
cd ..
|
||||
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||
- name: test
|
||||
env:
|
||||
MSAN_OPTIONS: halt_on_error=1
|
||||
run: |
|
||||
./build/qjs tests/test_bigint.js
|
||||
./build/qjs tests/test_closure.js
|
||||
./build/qjs tests/test_language.js
|
||||
./build/qjs tests/test_builtin.js
|
||||
./build/qjs tests/test_loop.js
|
||||
./build/qjs tests/test_std.js
|
||||
./build/qjs tests/test_worker.js
|
||||
linux-ubsan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: test
|
||||
- name: build
|
||||
run: |
|
||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_UBSAN=y UBSAN_OPTIONS="halt_on_error=1" test
|
||||
macos-cmake:
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCONFIG_UBSAN=ON ..
|
||||
cd ..
|
||||
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||
- name: test
|
||||
env:
|
||||
UBSAN_OPTIONS: halt_on_error=1
|
||||
run: |
|
||||
./build/qjs tests/test_bigint.js
|
||||
./build/qjs tests/test_closure.js
|
||||
./build/qjs tests/test_language.js
|
||||
./build/qjs tests/test_builtin.js
|
||||
./build/qjs tests/test_loop.js
|
||||
./build/qjs tests/test_std.js
|
||||
./build/qjs tests/test_worker.js
|
||||
|
||||
macos:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
@ -137,6 +144,50 @@ jobs:
|
|||
./build/qjs tests/test_loop.js
|
||||
./build/qjs tests/test_std.js
|
||||
./build/qjs tests/test_worker.js
|
||||
macos-asan:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCONFIG_ASAN=ON ..
|
||||
cd ..
|
||||
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||
- name: test
|
||||
env:
|
||||
ASAN_OPTIONS: halt_on_error=1
|
||||
run: |
|
||||
./build/qjs tests/test_bigint.js
|
||||
./build/qjs tests/test_closure.js
|
||||
./build/qjs tests/test_language.js
|
||||
./build/qjs tests/test_builtin.js
|
||||
./build/qjs tests/test_loop.js
|
||||
./build/qjs tests/test_std.js
|
||||
./build/qjs tests/test_worker.js
|
||||
macos-ubsan:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCONFIG_UBSAN=ON ..
|
||||
cd ..
|
||||
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||
- name: test
|
||||
env:
|
||||
UBSAN_OPTIONS: halt_on_error=1
|
||||
run: |
|
||||
./build/qjs tests/test_bigint.js
|
||||
./build/qjs tests/test_closure.js
|
||||
./build/qjs tests/test_language.js
|
||||
./build/qjs tests/test_builtin.js
|
||||
./build/qjs tests/test_loop.js
|
||||
./build/qjs tests/test_std.js
|
||||
./build/qjs tests/test_worker.js
|
||||
|
||||
windows-mingw:
|
||||
runs-on: windows-latest
|
||||
|
|
|
@ -5,7 +5,6 @@ project(quickjs LANGUAGES C)
|
|||
# TODO:
|
||||
# - LTO
|
||||
# - Support cross-compilation
|
||||
# - ASAN / MSAN / UBSAN
|
||||
# - Install targets
|
||||
# - Shared library target
|
||||
|
||||
|
@ -51,7 +50,49 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
|||
)
|
||||
endif()
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE TRUE)
|
||||
option(CONFIG_ASAN "Enable AddressSanitizer (ASan)" OFF)
|
||||
option(CONFIG_MSAN "Enable MemorySanitizer (MSan)" OFF)
|
||||
option(CONFIG_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)
|
||||
|
||||
if(CONFIG_ASAN)
|
||||
message(STATUS "Building with ASan")
|
||||
add_compile_options(
|
||||
-fsanitize=address
|
||||
-fno-sanitize-recover=all
|
||||
-fno-omit-frame-pointer
|
||||
)
|
||||
add_link_options(
|
||||
-fsanitize=address
|
||||
-fno-sanitize-recover=all
|
||||
-fno-omit-frame-pointer
|
||||
)
|
||||
elseif(CONFIG_MSAN)
|
||||
message(STATUS "Building with MSan")
|
||||
add_compile_options(
|
||||
-fsanitize=memory
|
||||
-fno-sanitize-recover=all
|
||||
-fno-omit-frame-pointer
|
||||
)
|
||||
add_link_options(
|
||||
-fsanitize=memory
|
||||
-fno-sanitize-recover=all
|
||||
-fno-omit-frame-pointer
|
||||
)
|
||||
elseif(CONFIG_UBSAN)
|
||||
message(STATUS "Building with UBSan")
|
||||
add_compile_options(
|
||||
-fsanitize=undefined
|
||||
-fno-sanitize-recover=all
|
||||
-fno-omit-frame-pointer
|
||||
)
|
||||
add_link_options(
|
||||
-fsanitize=undefined
|
||||
-fno-sanitize-recover=all
|
||||
-fno-omit-frame-pointer
|
||||
)
|
||||
endif()
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON")
|
||||
|
||||
|
||||
# QuickJS library
|
||||
|
|
Loading…
Reference in a new issue