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:
|
jobs:
|
||||||
linux:
|
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
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -81,36 +48,76 @@ jobs:
|
||||||
if: ${{ matrix.buildType == 'Release' }}
|
if: ${{ matrix.buildType == 'Release' }}
|
||||||
run: |
|
run: |
|
||||||
time ./build/run-test262 -m -c test262.conf -a
|
time ./build/run-test262 -m -c test262.conf -a
|
||||||
|
linux-asan:
|
||||||
macos:
|
runs-on: ubuntu-latest
|
||||||
runs-on: macos-latest
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y
|
mkdir build
|
||||||
- name: stats
|
cd build
|
||||||
run: |
|
cmake -DCONFIG_ASAN=ON ..
|
||||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y qjs
|
cd ..
|
||||||
./qjs -qd
|
cmake --build build -j$(getconf _NPROCESSORS_ONLN)
|
||||||
- name: test
|
- name: test
|
||||||
|
env:
|
||||||
|
ASAN_OPTIONS: halt_on_error=1
|
||||||
run: |
|
run: |
|
||||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y test
|
./build/qjs tests/test_bigint.js
|
||||||
macos-asan:
|
./build/qjs tests/test_closure.js
|
||||||
runs-on: macos-latest
|
./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:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: test
|
- name: build
|
||||||
|
env:
|
||||||
|
CC: clang
|
||||||
run: |
|
run: |
|
||||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_ASAN=y ASAN_OPTIONS="halt_on_error=1" test
|
mkdir build
|
||||||
macos-ubsan:
|
cd build
|
||||||
runs-on: macos-latest
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: test
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
make -j$(getconf _NPROCESSORS_ONLN) CONFIG_WERROR=y CONFIG_UBSAN=y UBSAN_OPTIONS="halt_on_error=1" test
|
mkdir build
|
||||||
macos-cmake:
|
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
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -137,6 +144,50 @@ jobs:
|
||||||
./build/qjs tests/test_loop.js
|
./build/qjs tests/test_loop.js
|
||||||
./build/qjs tests/test_std.js
|
./build/qjs tests/test_std.js
|
||||||
./build/qjs tests/test_worker.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:
|
windows-mingw:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
|
@ -5,7 +5,6 @@ project(quickjs LANGUAGES C)
|
||||||
# TODO:
|
# TODO:
|
||||||
# - LTO
|
# - LTO
|
||||||
# - Support cross-compilation
|
# - Support cross-compilation
|
||||||
# - ASAN / MSAN / UBSAN
|
|
||||||
# - Install targets
|
# - Install targets
|
||||||
# - Shared library target
|
# - Shared library target
|
||||||
|
|
||||||
|
@ -51,7 +50,49 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
)
|
)
|
||||||
endif()
|
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
|
# QuickJS library
|
||||||
|
|
Loading…
Reference in a new issue