Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/workflows/build_wamrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ permissions:
jobs:
build:
runs-on: ${{ inputs.runner }}
strategy:
matrix:
include:
- build_options: ""
suffix: ""
- build_options: "-DWAMR_BUILD_GC=1"
suffix: "-gc"

permissions:
contents: write # for uploading release artifacts

Expand All @@ -58,7 +66,7 @@ jobs:

- name: generate wamrc binary release
run: |
cmake -S . -B build
cmake -S . -B build ${{ matrix.build_options }}
cmake --build build --config Release --parallel 4
working-directory: wamr-compiler

Expand Down Expand Up @@ -89,17 +97,17 @@ jobs:
- name: Compress the binary on Windows
if: inputs.runner == 'windows-latest' && inputs.release
run: |
tar -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
Compress-Archive -Path wamrc.exe -DestinationPath wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
mv wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
tar -czf wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
Compress-Archive -Path wamrc.exe -DestinationPath wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
mv wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
working-directory: wamr-compiler/build/Release

- name: compress the binary on non-Windows
if: inputs.runner != 'windows-latest' && inputs.release
run: |
# Follow the symlink to the actual binary file
tar --dereference -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
tar --dereference -czf wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
zip wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
working-directory: wamr-compiler/build

- name: upload release tar.gz
Expand All @@ -109,8 +117,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
asset_path: wamr-compiler/build/wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
asset_name: wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
asset_content_type: application/x-gzip

- name: upload release zip
Expand All @@ -120,6 +128,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
asset_path: wamr-compiler/build/wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
asset_name: wamrc${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
asset_content_type: application/zip
9 changes: 0 additions & 9 deletions .github/workflows/compilation_on_android_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ jobs:
[
build_iwasm,
build_llvm_libraries_on_ubuntu_2204,
build_wamrc,
]
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -464,14 +463,6 @@ jobs:
with:
os: ${{ matrix.os }}

- name: Build wamrc
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
run: |
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
working-directory: wamr-compiler

- name: Build Sample [wasm-c-api]
run: |
VERBOSE=1
Expand Down
12 changes: 2 additions & 10 deletions core/iwasm/compilation/aot_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -3953,23 +3953,15 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
unsupport_ref_types:
aot_set_last_error("reference type instruction was found, "
"try removing --disable-ref-types option "
"or adding --enable-gc option");
return false;
#endif

#if WASM_ENABLE_GC != 0
unsupport_gc:
aot_set_last_error("GC instruction was found, "
"try adding --enable-gc option");
"try removing --disable-ref-types option ");
return false;
#endif

#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
unsupport_gc_and_ref_types:
aot_set_last_error(
"reference type or gc instruction was found, try removing "
"--disable-ref-types option or adding --enable-gc option");
"--disable-ref-types option");
return false;
#endif

Expand Down
50 changes: 17 additions & 33 deletions samples/multi-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ set(WAMR_BUILD_INTERP 1)
if (NOT DEFINED WAMR_BUILD_AOT)
set(WAMR_BUILD_AOT 0)
endif ()

if (NOT DEFINED WAMR_BUILD_JIT)
set(WAMR_BUILD_JIT 0)
endif ()
if (NOT DEFINED WAMR_BUILD_DUMP_CALL_STACK)
set(WAMR_BUILD_DUMP_CALL_STACK 0)
endif ()
if (NOT DEFINED WAMR_BUILD_GC)
set(WAMR_BUILD_GC 0)
endif ()
set(WAMR_BUILD_GC 0)
set(WAMR_BUILD_SIMD 1)
set(WAMR_BUILD_REF_TYPES 1)
set(WAMR_BUILD_LIBC_BUILTIN 1)
Expand Down Expand Up @@ -160,45 +159,30 @@ ExternalProject_Add(WASM_MODULE

################ WASM MODULES TO AOT
if (WAMR_BUILD_AOT EQUAL 1)
set(WAMR_COMPILER_DIR ${CMAKE_CURRENT_LIST_DIR}/../../wamr-compiler/build)
message(CHECK_START "Detecting WAMR_COMPILER at ${WAMR_COMPILER_DIR}")
find_file(WAMR_COMPILER
wamrc
PATHS "${CMAKE_CURRENT_LIST_DIR}/../../wamr-compiler/build"
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
set(WAMR_COMPILER_DIR ${CMAKE_CURRENT_LIST_DIR}/../../wamr-compiler)

ExternalProject_Add(wamrc_local
SOURCE_DIR ${WAMR_ROOT_DIR}/wamr-compiler
BUILD_ALWAYS TRUE
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${WAMR_ROOT_DIR}/wamr-compiler -B build --install-prefix ${CMAKE_CURRENT_BINARY_DIR}
BUILD_COMMAND ${CMAKE_COMMAND} --build build
INSTALL_COMMAND ${CMAKE_COMMAND} --install build
)
if(WAMR_COMPILER)
message(CHECK_PASS "found")
else()
message(CHECK_FAIL "not found")
endif()
if((NOT EXISTS ${WAMR_COMPILER}) )
message(FATAL_ERROR "Please build wamrc under the path=${WAMR_ROOT_DIR}/wamr-compiler/ ")
else()
message(STATUS "WAMR_COMPILER is ${WAMR_COMPILER}")
endif()

if (WAMR_BUILD_DUMP_CALL_STACK EQUAL 1)
list(APPEND WAMR_AOT_COMPILE_OPTIONS "--enable-dump-call-stack")
endif ()
if (WAMR_BUILD_GC EQUAL 1)
list(APPEND WAMR_AOT_COMPILE_OPTIONS "--enable-gc")
endif ()

add_custom_target(
wasm_to_aot
ALL
DEPENDS
WASM_MODULE ${WAMR_COMPILER}
COMMAND
${WAMR_COMPILER} ${WAMR_AOT_COMPILE_OPTIONS} -o mA.aot ./mA.wasm
COMMAND
${WAMR_COMPILER} ${WAMR_AOT_COMPILE_OPTIONS} -o mB.aot ./mB.wasm
COMMAND
${WAMR_COMPILER} ${WAMR_AOT_COMPILE_OPTIONS} -o mC.aot ./mC.wasm
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}
DEPENDS WASM_MODULE wamrc_local
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/wamrc ${WAMR_AOT_COMPILE_OPTIONS} -o mA.aot ./mA.wasm
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/wamrc ${WAMR_AOT_COMPILE_OPTIONS} -o mB.aot ./mB.wasm
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/wamrc ${WAMR_AOT_COMPILE_OPTIONS} -o mC.aot ./mC.wasm
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()

Expand Down
27 changes: 15 additions & 12 deletions samples/multi-module/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# WAMR MULTI-MODUEL SAMPLE
**WAMR supports *multi-module* in both *interpreter* mode and *aot* mode.**

**WAMR supports _multi-module_ in both _interpreter_ mode and _aot_ mode.**

Multi-modules will determine the running mode based on the type of the main module.

## Interpreter mode

``` shell
$ mkdir build
```bash
$ cmake -S . -B build
$ cmake --build
$ cd build
$ cmake ..
$ make
$ # It will build multi_module runtime and
$ # wasm file under the ./build .
$ # If you have built wamrc,
$ # aot file will also generate.
$ ./multi_module mC.wasm
$ ...
$ ./multi_module mC.aot
$ ...
```

## Aot mode

```bash
$ cmake -S . -B build -DWAMR_BUILD_AOT=1
$ cmake --build
$ cd build
$ ./multi_module mC.aot
```
39 changes: 16 additions & 23 deletions samples/wasm-c-api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ if(NOT DEFINED WAMR_BUILD_AOT)
set(WAMR_BUILD_AOT 0)
endif()

include(CMakePrintHelpers)
cmake_print_variables(WAMR_BUILD_INTERP WAMR_BUILD_AOT)

if(NOT DEFINED WAMR_BUILD_JIT)
set(WAMR_BUILD_JIT 0)
endif()
Expand All @@ -71,11 +74,7 @@ set(WAMR_BUILD_LIBC_WASI 0)
set(WAMR_BUILD_MULTI_MODULE 1)
set(WAMR_BUILD_DUMP_CALL_STACK 1)
set(WAMR_BUILD_REF_TYPES 1)

# If not defined WAMR_BUILD_GC, set it to 0
if(NOT DEFINED WAMRC_BUILD_WITH_GC)
set(WAMRC_BUILD_WITH_GC 0)
endif()
set(WAMR_BUILD_GC 0)

if(NOT DEFINED WAMR_BUILD_FAST_INTERP)
set(WAMR_BUILD_FAST_INTERP 1)
Expand Down Expand Up @@ -130,17 +129,16 @@ if (${WAT2WASM_VERSION} VERSION_LESS 1.0.26)
endif ()

if(${WAMR_BUILD_AOT} EQUAL 1 AND ${WAMR_BUILD_INTERP} EQUAL 0)
## locate wamrc
find_program(WAMRC
wamrc
PATHS ${WAMR_ROOT_DIR}/wamr-compiler/build/
include(ExternalProject)
ExternalProject_Add(wamrc_local
SOURCE_DIR ${WAMR_ROOT_DIR}/wamr-compiler
BUILD_ALWAYS TRUE
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ${CMAKE_COMMAND} -S ${WAMR_ROOT_DIR}/wamr-compiler -B build --install-prefix ${CMAKE_CURRENT_BINARY_DIR}
BUILD_COMMAND ${CMAKE_COMMAND} --build build
INSTALL_COMMAND ${CMAKE_COMMAND} --install build
)

if(NOT WAMRC)
message(SEND_ERROR "can not find wamrc. refer to \
https://github.com/bytecodealliance/wasm-micro-runtime#build-wamrc-aot-compiler"
)
endif()
endif()
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)

Expand Down Expand Up @@ -182,16 +180,11 @@ foreach(EX ${EXAMPLES})
add_dependencies(${EX} ${EX}_WASM)

# generate .aot file
if(${WAMR_BUILD_AOT} EQUAL 1)
if(${WAMRC_BUILD_WITH_GC} EQUAL 1)
set(WAMRC_GC_FLAGS "--enable-gc")
else()
set(WAMRC_GC_FLAGS "")
endif()
if(${WAMR_BUILD_AOT} EQUAL 1 AND ${WAMR_BUILD_INTERP} EQUAL 0)
add_custom_target(${EX}_AOT
COMMAND ${WAMRC} ${WAMRC_GC_FLAGS} -o ${PROJECT_BINARY_DIR}/${EX}.aot
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/wamrc -o ${PROJECT_BINARY_DIR}/${EX}.aot
${PROJECT_BINARY_DIR}/${EX}.wasm
DEPENDS ${EX}_WASM
DEPENDS ${EX}_WASM wamrc_local
BYPRODUCTS ${PROJECT_BINARY_DIR}/${EX}.aot
VERBATIM
COMMENT "generate a aot file ${PROJECT_BINARY_DIR}/${EX}.aot"
Expand Down
1 change: 0 additions & 1 deletion tests/requirement-engineering/gc-aot/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,6 @@ def compile_wasm_to_aot(wasm_tempfile, aot_tempfile, runner, opts, r, output='de
cmd.append("--enable-multi-thread")

if opts.gc:
cmd.append("--enable-gc")
cmd.append("--enable-tail-call")

if output == 'object':
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.14)

project(wasm-apps-aot-stack-frame)

set (WAMRC_OPTION --enable-dump-call-stack --bounds-checks=1 --enable-gc)
set (WAMRC_OPTION --enable-dump-call-stack --bounds-checks=1)

if (WAMR_BUILD_TARGET STREQUAL "X86_32")
set (WAMRC_OPTION ${WAMRC_OPTION} --target=i386)
Expand Down
1 change: 0 additions & 1 deletion tests/wamr-test-suites/spec-test-script/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,6 @@ def compile_wasm_to_aot(wasm_tempfile, aot_tempfile, runner, opts, r, output = '
cmd.append("--enable-multi-thread")

if opts.gc:
cmd.append("--enable-gc")
cmd.append("--enable-tail-call")

if opts.extended_const:
Expand Down
21 changes: 15 additions & 6 deletions tests/wamr-test-suites/test_wamr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ function build_iwasm_with_cfg()
fi
}

function build_wamrc()
function build_wamrc_with_cfg()
{
if [[ "${TARGET_LIST[*]}" =~ "${TARGET}" ]]; then
echo "suppose wamrc is already built"
Expand All @@ -852,10 +852,7 @@ function build_wamrc()
&& ./${BUILD_LLVM_SH} \
&& if [ -d build ]; then rm -r build/*; else mkdir build; fi \
&& cd build \
&& cmake .. \
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE} \
-DWAMR_BUILD_SHRUNK_MEMORY=0 \
-DWAMR_BUILD_EXTENDED_CONST_EXPR=${ENABLE_EXTENDED_CONST_EXPR} \
&& cmake $* .. \
&& make -j 4
}

Expand Down Expand Up @@ -1073,6 +1070,18 @@ function trigger()
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SANITIZER=$WAMR_BUILD_SANITIZER"
fi

local WAMRC_BUILD_FLAGS=""
WAMRC_BUILD_FLAGS+=" -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
WAMRC_BUILD_FLAGS+=" -DWAMR_BUILD_SHRUNK_MEMORY=0"

if [[ ${ENABLE_GC} == 1 ]]; then
WAMRC_BUILD_FLAGS+=" -DWAMR_BUILD_GC=1"
fi

if [[ ${ENABLE_EXTENDED_CONST_EXPR} == 1 ]]; then
WAMRC_BUILD_FLAGS+=" -DWAMR_BUILD_EXTENDED_CONST_EXPR=1"
fi

# Make sure we're using the builtin WASI libc implementation
# if we're running the wasi certification tests.
if [[ $TEST_CASE_ARR ]]; then
Expand Down Expand Up @@ -1148,7 +1157,7 @@ function trigger()
build_iwasm_with_cfg $BUILD_FLAGS
fi
if [ -z "${WAMRC_CMD}" ]; then
build_wamrc
build_wamrc_with_cfg $WAMRC_BUILD_FLAGS
WAMRC_CMD=${WAMRC_CMD_DEFAULT}
fi
for suite in "${TEST_CASE_ARR[@]}"; do
Expand Down
Loading
Loading