diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index aa366833..0266a73d 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -338,7 +338,9 @@ jobs: ] runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: + sanitizer: ["", "ubsan"] make_options: [ # Running mode $AOT_BUILD_OPTIONS, @@ -363,6 +365,7 @@ jobs: llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} + steps: - name: checkout uses: actions/checkout@v3 @@ -395,15 +398,16 @@ jobs: if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) run: | mkdir build && cd build - cmake .. + cmake -DSANITIZER="${{matrix.sanitizer}}" .. cmake --build . --config Release --parallel 4 working-directory: wamr-compiler - name: Build Sample [wasm-c-api] 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 - ctest --test-dir build + ctest --test-dir build --output-on-failure working-directory: samples/wasm-c-api build_samples_others: diff --git a/samples/wasm-c-api/CMakeLists.txt b/samples/wasm-c-api/CMakeLists.txt index e2be3b8f..c528fe16 100644 --- a/samples/wasm-c-api/CMakeLists.txt +++ b/samples/wasm-c-api/CMakeLists.txt @@ -24,7 +24,7 @@ if (APPLE) add_definitions(-DBH_PLATFORM_DARWIN) endif () -# Resetdefault linker flags +# Reset default linker flags set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") @@ -87,6 +87,15 @@ endif() set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) 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}) if (MSVC) target_compile_definitions(vmlib PRIVATE WASM_API_EXTERN=)