mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
CI: Add ubsan checks to samples/wasm-c-api (#2147)
This PR adds ubsan checks with no alignment enabled to basic CI tests for samples/wasm-c-api. Co-authored-by: Maksim Litskevich <makslit@amazon.co.uk>
This commit is contained in:
parent
8abb153546
commit
15139d2bb8
|
@ -338,7 +338,9 @@ jobs:
|
||||||
]
|
]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
sanitizer: ["", "ubsan"]
|
||||||
make_options: [
|
make_options: [
|
||||||
# Running mode
|
# Running mode
|
||||||
$AOT_BUILD_OPTIONS,
|
$AOT_BUILD_OPTIONS,
|
||||||
|
@ -363,6 +365,7 @@ jobs:
|
||||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }}
|
||||||
- os: ubuntu-22.04
|
- os: ubuntu-22.04
|
||||||
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
@ -395,15 +398,16 @@ jobs:
|
||||||
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
|
||||||
run: |
|
run: |
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake ..
|
cmake -DSANITIZER="${{matrix.sanitizer}}" ..
|
||||||
cmake --build . --config Release --parallel 4
|
cmake --build . --config Release --parallel 4
|
||||||
working-directory: wamr-compiler
|
working-directory: wamr-compiler
|
||||||
|
|
||||||
- name: Build Sample [wasm-c-api]
|
- name: Build Sample [wasm-c-api]
|
||||||
run: |
|
run: |
|
||||||
cmake -S . -B build ${{ matrix.make_options }}
|
VERBOSE=1
|
||||||
|
cmake -S . -B build ${{ matrix.make_options }} -DSANITIZER="${{matrix.sanitizer}}"
|
||||||
cmake --build build --config Release --parallel 4
|
cmake --build build --config Release --parallel 4
|
||||||
ctest --test-dir build
|
ctest --test-dir build --output-on-failure
|
||||||
working-directory: samples/wasm-c-api
|
working-directory: samples/wasm-c-api
|
||||||
|
|
||||||
build_samples_others:
|
build_samples_others:
|
||||||
|
|
|
@ -24,7 +24,7 @@ if (APPLE)
|
||||||
add_definitions(-DBH_PLATFORM_DARWIN)
|
add_definitions(-DBH_PLATFORM_DARWIN)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Resetdefault linker flags
|
# Reset default linker flags
|
||||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
||||||
|
|
||||||
|
@ -87,6 +87,15 @@ endif()
|
||||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
|
||||||
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
|
||||||
|
|
||||||
|
if (NOT DEFINED SANITIZER)
|
||||||
|
set(SANITIZER "")
|
||||||
|
elseif (SANITIZER STREQUAL "ubsan")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=alignment" )
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
|
||||||
|
elseif (NOT (SANITIZER STREQUAL "") )
|
||||||
|
message(SEND_ERROR "Unsupported sanitizer: ${SANITIZER}")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(vmlib STATIC ${WAMR_RUNTIME_LIB_SOURCE})
|
add_library(vmlib STATIC ${WAMR_RUNTIME_LIB_SOURCE})
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
target_compile_definitions(vmlib PRIVATE WASM_API_EXTERN=)
|
target_compile_definitions(vmlib PRIVATE WASM_API_EXTERN=)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user