Compare commits

...

8 Commits

Author SHA1 Message Date
liang.he
5aa93ed71d
Merge e82bd0b451 into 0e8b57d8a8 2025-05-07 17:52:47 +08:00
Chris Woods
0e8b57d8a8
More detail to python setup, and fixed small typo (#4247)
Some checks are pending
compilation on SGX / build_iwasm (-DWAMR_DISABLE_HW_BOUND_CHECK=1, $FAST_INTERP_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / build_iwasm (-DWAMR_DISABLE_HW_BOUND_CHECK=1, $FAST_JIT_BUILD_OPTIONS, ubuntu-22.04, linux-sgx) (push) Waiting to run
compilation on SGX / run_samples_file (-DWAMR_BUILD_SGX_IPFS=1, $AOT_BUILD_OPTIONS, ${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, linux-sgx) (push) Blocked by required conditions
compilation on SGX / run_samples_file (-DWAMR_BUILD_SGX_IPFS=1, $CLASSIC_INTERP_BUILD_OPTIONS, ${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, linux-sgx) (push) Blocked by required conditions
compilation on SGX / run_samples_file (-DWAMR_BUILD_SGX_IPFS=1, $FAST_INTERP_BUILD_OPTIONS, ${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, linux-sgx) (push) Blocked by required conditions
compilation on SGX / run_samples_file (-DWAMR_BUILD_SGX_IPFS=1, $FAST_JIT_BUILD_OPTIONS, ${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, linux-sgx) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, aot, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, aot, $SIMD_TEST_OPTIONS) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, aot, $XIP_TEST_OPTIONS) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, classic-interp, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on SGX / spec_test_default (${{ needs.build_llvm_libraries.outputs.cache_key }}, ubuntu-22.04, fast-jit, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / build (-DWAMR_BUILD_AOT=0) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_CUSTOM_NAME_SECTION=1) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_DEBUG_INTERP=1) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_LIB_PTHREAD=1) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_LIB_WASI_THREADS=1) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_REF_TYPES=1) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_SIMD=1) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_BUILD_TAIL_CALL=1) (push) Waiting to run
compilation on windows-latest / build (-DWAMR_DISABLE_HW_BOUND_CHECK=1) (push) Waiting to run
compilation on windows-latest / test (classic-interp, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (classic-interp, $MULTI_MODULES_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (classic-interp, $THREADS_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (classic-interp, $WASI_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (fast-interp, $DEFAULT_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (fast-interp, $MULTI_MODULES_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (fast-interp, $THREADS_TEST_OPTIONS) (push) Blocked by required conditions
compilation on windows-latest / test (fast-interp, $WASI_TEST_OPTIONS) (push) Blocked by required conditions
2025-05-07 11:32:43 +08:00
YAMAMOTO Takashi
88b5f6a535
samples/wasm-c-api: remove unused valgrind detection (#4249)
- it's unused
- valgrind is basically a linux-only software.
  it isn't a good idea to make it a hard requirement.
  if we want to use valgrind, it's better to introduce
  a separate option to control it.
2025-05-07 11:32:29 +08:00
YAMAMOTO Takashi
ac2fe552d5
aot_resolve_object_relocation_group: adapt to LLVM 16 (#4250)
cf. https://reviews.llvm.org/D123264
2025-05-07 11:32:14 +08:00
liang.he
ea417d7619
Add overflow check for preserved local offset in preserve_referenced_local (#4211) 2025-05-07 09:45:49 +08:00
YAMAMOTO Takashi
bb36a43fa4
riscv: avoid llvm.cttz.i32/i64 for xip (#4248)
LLVM 16 and later expands cttz intrinsic to a table lookup,
which involves some relocations. (unless ZBB is available,
in which case the native instructions are preferred over
the table-based lowering.)

cf. https://reviews.llvm.org/D128911
2025-05-07 09:42:51 +08:00
liang.he@intel.com
e82bd0b451 feat: implement os_invalid_raw_handle function for consistent invalid handle representation 2025-02-24 01:32:03 +00:00
liang.he@intel.com
cf8b932e34 initialize WASI stdio handles to invalid for better error handling 2025-02-18 07:34:28 +00:00
15 changed files with 108 additions and 16 deletions

View File

@ -898,6 +898,17 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx)
if (!strncmp(comp_ctx->target_arch, "riscv32", 7)) {
add_i64_common_intrinsics(comp_ctx);
}
/*
* LLVM 16 and later expands cttz intrinsic to a table lookup,
* which involves some relocations. (unless ZBB is available,
* in which case the native instructions are preferred over
* the table-based lowering.)
* https://reviews.llvm.org/D128911
*/
#if LLVM_VERSION_MAJOR >= 16
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CTZ);
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CTZ);
#endif
}
else if (!strncmp(comp_ctx->target_arch, "xtensa", 6)) {
/*

View File

@ -4127,6 +4127,12 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
}
#endif
#if WASM_ENABLE_LIBC_WASI != 0
module->wasi_args.stdio[0] = os_invalid_raw_handle();
module->wasi_args.stdio[1] = os_invalid_raw_handle();
module->wasi_args.stdio[2] = os_invalid_raw_handle();
#endif
return module;
#if WASM_ENABLE_GC != 0
fail2:

View File

@ -4007,8 +4007,12 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
&& (str_starts_with(relocation->symbol_name, ".LCPI")
|| str_starts_with(relocation->symbol_name, ".LJTI")
|| str_starts_with(relocation->symbol_name, ".LBB")
|| str_starts_with(relocation->symbol_name,
".Lswitch.table."))) {
|| str_starts_with(relocation->symbol_name, ".Lswitch.table.")
#if LLVM_VERSION_MAJOR >= 16
/* cf. https://reviews.llvm.org/D123264 */
|| str_starts_with(relocation->symbol_name, ".Lpcrel_hi")
#endif
)) {
/* change relocation->relocation_addend and
relocation->symbol_name */
LLVMSectionIteratorRef contain_section;

View File

@ -6376,6 +6376,12 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
}
#endif
#if WASM_ENABLE_LIBC_WASI != 0
module->wasi_args.stdio[0] = os_invalid_raw_handle();
module->wasi_args.stdio[1] = os_invalid_raw_handle();
module->wasi_args.stdio[2] = os_invalid_raw_handle();
#endif
(void)ret;
return module;
@ -9197,6 +9203,15 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode,
loader_ctx->preserved_local_offset += 2;
emit_label(EXT_OP_COPY_STACK_TOP_I64);
}
/* overflow */
if (preserved_offset > loader_ctx->preserved_local_offset) {
set_error_buf_v(error_buf, error_buf_size,
"too much local cells 0x%x",
loader_ctx->preserved_local_offset);
return false;
}
emit_operand(loader_ctx, local_index);
emit_operand(loader_ctx, preserved_offset);
emit_label(opcode);

View File

@ -3137,6 +3137,12 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
}
#endif
#if WASM_ENABLE_LIBC_WASI != 0
module->wasi_args.stdio[0] = os_invalid_raw_handle();
module->wasi_args.stdio[1] = os_invalid_raw_handle();
module->wasi_args.stdio[2] = os_invalid_raw_handle();
#endif
(void)ret;
return module;
}
@ -4778,6 +4784,11 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode,
loader_ctx->preserved_local_offset += 2;
emit_label(EXT_OP_COPY_STACK_TOP_I64);
}
/* overflow */
bh_assert(preserved_offset
<= loader_ctx->preserved_local_offset);
emit_operand(loader_ctx, local_index);
emit_operand(loader_ctx, preserved_offset);
emit_label(opcode);

View File

@ -79,3 +79,9 @@ os_dcache_flush()
void
os_icache_flush(void *start, size_t len)
{}
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}

View File

@ -1033,3 +1033,9 @@ os_realpath(const char *path, char *resolved_path)
{
return realpath(path, resolved_path);
}
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}

View File

@ -1033,3 +1033,9 @@ os_realpath(const char *path, char *resolved_path)
{
return realpath(path, resolved_path);
}
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}

View File

@ -1607,6 +1607,15 @@ os_is_dir_stream_valid(os_dir_stream *dir_stream);
os_file_handle
os_get_invalid_handle(void);
/**
* Returns an invalid raw file handle that is guaranteed to cause failure when
* called with any filesystem operation.
*
* @return the invalid raw file handle
*/
os_raw_file_handle
os_invalid_raw_handle(void);
/**
* Checks whether the given file handle is valid. An invalid handle is
* guaranteed to cause failure when called with any filesystem operation.

View File

@ -95,3 +95,9 @@ os_dcache_flush(void)
void
os_icache_flush(void *start, size_t len)
{}
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}

View File

@ -192,3 +192,9 @@ posix_fallocate(int __fd, off_t __offset, off_t __length)
errno = ENOSYS;
return -1;
}
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}

View File

@ -1810,3 +1810,9 @@ os_realpath(const char *path, char *resolved_path)
return resolved_path;
}
os_raw_file_handle
os_invalid_raw_handle(void)
{
return INVALID_HANDLE_VALUE;
}

View File

@ -255,3 +255,9 @@ set_exec_mem_alloc_func(exec_mem_alloc_func_t alloc_func,
exec_mem_alloc_func = alloc_func;
exec_mem_free_func = free_func;
}
os_raw_file_handle
os_invalid_raw_handle(void)
{
return -1;
}

View File

@ -1,14 +1,17 @@
# WARM API
# WAMR API
* **Notice**: The python package `wamr.wamrapi.wamr` need python >= `3.10`.
* **Notice**: The python package `wamr.wamrapi.wamr` requires a python version >= `3.10`.
## Setup
### Pre-requisites
#### Install requirements
Before proceeding it is necessary to make sure your Python environment is correctly configured. To do ths open a terminal session in this directory and perfom the following:
Install requirements,
```shell
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```

View File

@ -205,12 +205,3 @@ foreach(EX ${EXAMPLES})
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
find_program(VALGRIND
valgrind
REQUIRED
)
# run `ctest -T memcheck -V --test-dir build`
endif()