diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index dd6c096f1..521c2e08f 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -315,6 +315,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04] + build_target: [ + "X86_64", + "X86_32", + ] include: - os: ubuntu-22.04 llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} @@ -351,10 +355,16 @@ jobs: cmake --build . --config Release --parallel 4 working-directory: wamr-compiler + - name: Install dependencies for X86_32 + if: matrix.build_target == 'X86_32' + run: | + sudo apt-get update + sudo apt-get install -y g++-multilib + - name: Build and run unit tests run: | mkdir build && cd build - cmake .. + cmake .. -DWAMR_BUILD_TARGET=${{ matrix.build_target }} cmake --build . --config Release --parallel 4 ctest working-directory: tests/unit diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index fa9b400fa..8c963cadd 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -32,6 +32,7 @@ include (FetchContent) FetchContent_Declare ( googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) FetchContent_MakeAvailable (googletest) @@ -42,19 +43,27 @@ enable_testing() add_subdirectory(wasm-vm) add_subdirectory(interpreter) -add_subdirectory(aot) add_subdirectory(wasm-c-api) add_subdirectory(libc-builtin) add_subdirectory(shared-utils) -add_subdirectory(running-modes) -add_subdirectory(runtime-common) -add_subdirectory(custom-section) -add_subdirectory(compilation) add_subdirectory(linear-memory-wasm) add_subdirectory(linear-memory-aot) add_subdirectory(aot-stack-frame) add_subdirectory(linux-perf) add_subdirectory(gc) -add_subdirectory(memory64) add_subdirectory(tid-allocator) -add_subdirectory(shared-heap) \ No newline at end of file + +if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32") + # should enable 32-bit llvm when X86_32 + add_subdirectory (aot) + add_subdirectory (custom-section) + add_subdirectory (compilation) + + # Fast-JIT or mem64 is not supported on X86_32 + add_subdirectory (running-modes) + add_subdirectory (memory64) + add_subdirectory (shared-heap) + + # HW_BOUND_CHECK is not supported on X86_32 + add_subdirectory (runtime-common) +endif () diff --git a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt index 6c43a4184..7d80bbfbf 100644 --- a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt +++ b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt @@ -5,23 +5,37 @@ cmake_minimum_required(VERSION 3.14) project(wasm-apps-aot-stack-frame) -add_custom_target(aot-stack-frame-test-wasm ALL - COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc - -S ${WAMR_ROOT_DIR}/wamr-compiler - && cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc - && /opt/wabt/bin/wat2wasm - -o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm - ${CMAKE_CURRENT_LIST_DIR}/test.wast - && ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc - --enable-dump-call-stack --bounds-checks=1 --enable-gc - -o ${CMAKE_CURRENT_BINARY_DIR}/test.aot - ${CMAKE_CURRENT_BINARY_DIR}/test.wasm - && cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump - -S ${WAMR_ROOT_DIR}/test-tools/binarydump-tool - && cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump - && ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump/binarydump - -o ${CMAKE_CURRENT_LIST_DIR}/test_aot.h -n test_aot - ${CMAKE_CURRENT_BINARY_DIR}/test.aot +set (WAMRC_OPTION --enable-dump-call-stack --bounds-checks=1 --enable-gc) +if (WAMR_BUILD_TARGET STREQUAL "X86_32") + set (WAMRC_OPTION ${WAMRC_OPTION} --target=i386) +endif () + +add_custom_target( + aot-stack-frame-test-wasm ALL + + # Step 1: Build wamrc + COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc + -S ${WAMR_ROOT_DIR}/wamr-compiler + COMMAND cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc + + # Step 2: Compile .wast to .wasm + COMMAND /opt/wabt/bin/wat2wasm + -o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm ${CMAKE_CURRENT_LIST_DIR}/test.wast + + # Step 3: Compile .wasm to .aot using wamrc + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc ${WAMRC_OPTION} + -o ${CMAKE_CURRENT_BINARY_DIR}/test.aot ${CMAKE_CURRENT_BINARY_DIR}/test.wasm + + # Step 4: Build binarydump tool + COMMAND cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump + -S ${WAMR_ROOT_DIR}/test-tools/binarydump-tool + COMMAND cmake --build ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump + + # Step 5: Generate .h file from .aot + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump/binarydump + -o ${CMAKE_CURRENT_LIST_DIR}/test_aot.h + -n test_aot + ${CMAKE_CURRENT_BINARY_DIR}/test.aot ) diff --git a/tests/unit/wasm-c-api/CMakeLists.txt b/tests/unit/wasm-c-api/CMakeLists.txt index 9448cd8c3..9556c600e 100644 --- a/tests/unit/wasm-c-api/CMakeLists.txt +++ b/tests/unit/wasm-c-api/CMakeLists.txt @@ -13,7 +13,9 @@ set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") # WAMR features switch -set(WAMR_BUILD_TARGET "X86_64") +if (NOT DEFINED WAMR_BUILD_TARGET) + set(WAMR_BUILD_TARGET "X86_64") +endif() set(WAMR_BUILD_INTERP 1) set(WAMR_BUILD_AOT 0) set(WAMR_BUILD_JIT 0)