diff --git a/.github/workflows/compilation_on_nuttx.yml b/.github/workflows/compilation_on_nuttx.yml index 7a3c3067f6..2f8014face 100644 --- a/.github/workflows/compilation_on_nuttx.yml +++ b/.github/workflows/compilation_on_nuttx.yml @@ -68,18 +68,17 @@ jobs: # arm64 "boards/arm64/qemu/qemu-armv8a/configs/nsh", ] - wamr_config_option: [ - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_FAST=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_FAST=y\\nCONFIG_INTERPRETERS_WAMR_LIBC_WASI=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_FAST=y\\nCONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_CLASSIC=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_CLASSIC=y\\nCONFIG_INTERPRETERS_WAMR_LIBC_WASI=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_CLASSIC=y\\nCONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_FAST=y\\n", - "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_CLASSIC=y\\n", - ] + + wamr_config_option: + - "CONFIG_INTERPRETERS_WAMR_AOT" + - "CONFIG_INTERPRETERS_WAMR_FAST" + - "CONFIG_INTERPRETERS_WAMR_CLASSIC" + - "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST" + - "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_WASI" + - "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_FAST CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN" + - "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC" + - "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI" + - "CONFIG_INTERPRETERS_WAMR_AOT CONFIG_INTERPRETERS_WAMR_CLASSIC CONFIG_INTERPRETERS_WAMR_LIBC_WASI" steps: - name: Checkout NuttX @@ -102,16 +101,22 @@ jobs: repository: ${{ github.repository }} path: apps/interpreters/wamr/wamr - - name: Enable WAMR for NuttX + - name: Configure WAMR + working-directory: nuttx run: | - find nuttx/boards -name defconfig | xargs sed -i '$a\CONFIG_EOL_IS_LF=y\n${{ matrix.wamr_config_option }}' - find nuttx/boards/sim -name defconfig | xargs sed -i '$a\CONFIG_LIBM=y\n' + tools/configure.sh ${{ matrix.nuttx_board_config }} + kconfig-tweak --enable CONFIG_PSEUDOFS_SOFTLINKS + kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR + kconfig-tweak --enable CONFIG_INTERPRETERS_IWASM_TASK + kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_PRIORITY 100 + kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 8192 + for x in ${{ matrix.wamr_config_option }}; do + kconfig-tweak --enable $x + done - name: Build - run: | - cd nuttx - tools/configure.sh ${{ matrix.nuttx_board_config }} - make -j$(nproc) EXTRAFLAGS=-Werror + working-directory: nuttx + run: make -j$(nproc) EXTRAFLAGS=-Werror - name: Checkout Bloaty uses: actions/checkout@v3 diff --git a/.github/workflows/spec_test_on_nuttx.yml b/.github/workflows/spec_test_on_nuttx.yml index 059e5fbef9..f2e59ba68b 100644 --- a/.github/workflows/spec_test_on_nuttx.yml +++ b/.github/workflows/spec_test_on_nuttx.yml @@ -125,10 +125,6 @@ jobs: - target_config: { config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh64" } wamr_test_option: { mode: "-t aot -X" } - # XIP is not fully supported yet on RISCV32 ILP32F, some relocations can not be resolved - - target_config: { config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh", fpu_type: "fp" } - wamr_test_option: { mode: "-t aot -X" } - # Our xtensa environment doesn't have enough memory - target_config: { target: "xtensa" } wamr_feature_option: { mode: "-G" } diff --git a/core/iwasm/compilation/aot_llvm.c b/core/iwasm/compilation/aot_llvm.c index 8c989ed6e9..2e1e82e564 100644 --- a/core/iwasm/compilation/aot_llvm.c +++ b/core/iwasm/compilation/aot_llvm.c @@ -3108,6 +3108,16 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) goto fail; } + /* Return error if ref-types and GC are disabled by command line but + ref-types instructions are used */ + if (!option->enable_ref_types && !option->enable_gc + && wasm_module->is_ref_types_used) { + aot_set_last_error("ref-types instruction was found, " + "try removing --disable-ref-types option " + "or adding --enable-gc option."); + goto fail; + } + /* Disable features when they are not actually used */ if (!wasm_module->is_simd_used) { option->enable_simd = comp_ctx->enable_simd = false; diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index f2d6b7e7bd..766d2f52f0 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -2281,8 +2281,15 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, bh_assert(tidx < module->module->type_count); cur_type = wasm_types[tidx]; + /* clang-format off */ +#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 read_leb_uint32(frame_ip, frame_ip_end, tbl_idx); +#else + frame_ip++; + tbl_idx = 0; +#endif bh_assert(tbl_idx < module->table_count); + /* clang-format on */ tbl_inst = wasm_get_table_inst(module, tbl_idx); diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index d2bcf71763..0891598d14 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -7149,10 +7149,10 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, case WASM_OP_RETURN_CALL_INDIRECT: #endif skip_leb_uint32(p, p_end); /* typeidx */ -#if WASM_ENABLE_REF_TYPES == 0 && WASM_ENABLE_GC == 0 - u8 = read_uint8(p); /* 0x00 */ -#else +#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 skip_leb_uint32(p, p_end); /* tableidx */ +#else + u8 = read_uint8(p); /* 0x00 */ #endif break; @@ -12005,10 +12005,12 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, read_leb_uint32(p, p_end, type_idx); #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 #if WASM_ENABLE_WAMR_COMPILER != 0 - if (*p != 0x00) { - // Any non-0x00 byte requires the ref types proposal. - // This is different from checking the table_idx value - // since `0x80 0x00` etc. are all valid encodings of zero. + if (p + 1 < p_end && *p != 0x00) { + /* + * Any non-0x00 byte requires the ref types proposal. + * This is different from checking the table_idx value + * since `0x80 0x00` etc. are all valid encodings of zero. + */ module->is_ref_types_used = true; } #endif diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index 6e70203fa5..0bb2f34ebc 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -3501,8 +3501,11 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, case WASM_OP_RETURN_CALL_INDIRECT: #endif skip_leb_uint32(p, p_end); /* typeidx */ - CHECK_BUF(p, p_end, 1); +#if WASM_ENABLE_REF_TYPES != 0 + skip_leb_uint32(p, p_end); /* tableidx */ +#else u8 = read_uint8(p); /* 0x00 */ +#endif break; #if WASM_ENABLE_EXCE_HANDLING != 0 diff --git a/tests/wamr-test-suites/spec-test-script/runtest.py b/tests/wamr-test-suites/spec-test-script/runtest.py index 011578fce1..291718b6ee 100755 --- a/tests/wamr-test-suites/spec-test-script/runtest.py +++ b/tests/wamr-test-suites/spec-test-script/runtest.py @@ -65,7 +65,8 @@ # AOT compilation options mapping for XIP mode aot_target_options_map_xip = { # avoid l32r relocations for xtensa - "xtensa": ["--mllvm=-mtext-section-literals"] + "xtensa": ["--mllvm=-mtext-section-literals"], + "riscv32_ilp32f": ["--enable-builtin-intrinsics=i64.common,f64.common,f32.const,f64.const,f64xi32,f64xi64,f64_promote_f32,f32_demote_f64"], } def debug(data):