Skip to content

Commit 580fdc9

Browse files
committed
build,ci: add ASAN build to CI
1 parent ae63e78 commit 580fdc9

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.github/workflows/ci.yml

+17
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,20 @@ jobs:
151151
run: make VERBOSE=1
152152
- name: Test it
153153
run: make test
154+
linux-asan:
155+
name: ASAN
156+
runs-on: ubuntu-latest
157+
steps:
158+
- uses: actions/checkout@v4
159+
with:
160+
submodules: true
161+
- name: Dependencies
162+
run: |
163+
sudo apt update
164+
sudo apt install -y libcurl4-openssl-dev
165+
- name: Build it
166+
run: make BUILD_WITH_ASAN=ON
167+
- name: Test it
168+
env:
169+
ASAN_OPTIONS: halt_on_error=1
170+
run: make test

CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ macro(cpr_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT)
4545
endmacro()
4646

4747
cpr_option(BUILD_WITH_ASAN "If ON, build with the address sanitizer enabled" OFF)
48+
cpr_option(BUILD_WITH_MSAN "If ON, build with the memory sanitizer enabled" OFF)
49+
cpr_option(BUILD_WITH_UBSAN "If ON, build with the undefined behavior sanitizer enabled" OFF)
4850
cpr_option(USE_EXTERNAL_FFI "Specify to use external ffi dependency" OFF)
4951

5052
add_subdirectory(deps/quickjs EXCLUDE_FROM_ALL)
@@ -144,8 +146,14 @@ target_include_directories(tjs PRIVATE ${CURL_INCLUDE_DIRS})
144146
target_link_libraries(tjs qjs uv_a m3 sqlite3 m pthread ${CURL_LIBRARIES})
145147

146148
if (BUILD_WITH_ASAN)
147-
target_compile_options(tjs PRIVATE -fsanitize=address)
148-
target_link_options(tjs PRIVATE -fsanitize=address)
149+
target_compile_options(tjs PRIVATE -fsanitize=address -fno-sanitize-recover=all -fno-omit-frame-pointer)
150+
target_link_options(tjs PRIVATE -fsanitize=address -fno-sanitize-recover=all -fno-omit-frame-pointer)
151+
elseif(BUILD_WITH_MSAN)
152+
target_compile_options(tjs PRIVATE -fsanitize=memory -fno-sanitize-recover=all -fno-omit-frame-pointer)
153+
target_link_options(tjs PRIVATE -fsanitize=memory -fno-sanitize-recover=all -fno-omit-frame-pointer)
154+
elseif(BUILD_WITH_UBSAN)
155+
target_compile_options(tjs PRIVATE -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer)
156+
target_link_options(tjs PRIVATE -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer)
149157
endif()
150158

151159
add_executable(tjsc EXCLUDE_FROM_ALL

0 commit comments

Comments
 (0)