Compare commits

...

18 Commits

Author SHA1 Message Date
YAMAMOTO Takashi
9102e6a796 test 2025-05-07 12:52:54 +09:00
YAMAMOTO Takashi
a73e3366fc test 2025-05-07 11:25:11 +09:00
YAMAMOTO Takashi
d6f22dc062 Revert "test"
This reverts commit 1cafd95143.
2025-05-07 09:47:07 +09:00
YAMAMOTO Takashi
1cafd95143 test 2025-05-07 09:32:54 +09:00
YAMAMOTO Takashi
e114bcc9a6 test 2025-05-07 08:45:50 +09:00
YAMAMOTO Takashi
54a14af17b CI: make macos' build_samples_wasm_c_api similar to ubuntu 2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
d8bc4f4172 samples/wasm-c-api: remove unused valgrind detection
* 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 08:16:01 +09:00
YAMAMOTO Takashi
56acae558b Revert "aot_create_comp_context: disable small data section"
This reverts commit 6ae395a8ce.
2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
721117a804 spec_test_on_nuttx.yml: disable xtensa xip 2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
7fd923eb42 Revert "wamr-test-suites: disable xtensa text section literals for now"
This reverts commit 6b7ff691fe.
2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
cb0ec6cb36 aot_create_comp_context: disable small data section
I observed errors like the following when trying to upgrade our
LLVM from 15 to 19.

```
AOT module load failed: resolve symbol .srodata.cst8 failed
```

The concept itself has been available since LLVM 9.
I don't know what exactly happened to trigger the use of it.

cf. https://reviews.llvm.org/D57493
2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
cdd9485d4b riscv: avoid llvm.cttz.i32/i64 for xip
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 08:16:01 +09:00
YAMAMOTO Takashi
08b05d4796 wamr-test-suites: disable xtensa text section literals for now 2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
b0aeea6453 aot_resolve_object_relocation_group: adapt to LLVM 19
cf.
https://github.com/llvm/llvm-project/pull/95031
https://github.com/llvm/llvm-project/pull/89693
2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
7c4bd0c9a2 aot_resolve_object_relocation_group: adapt to LLVM 16
cf. https://reviews.llvm.org/D123264
2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
cc9838be8b wamr-compiler: size_level=0 for sgx mode
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035
2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
f56eeb3fa4 spec-test-script/runtest.py: --size-level=0 for x86-64
with the recent version of LLVM, wamrc --size-level=1 often
generates R_X86_64_32S relocations which fail on load with
the infamous error:

"relocation truncated to fit R_X86_64_32S failed"

it seems that these relocations are often for jump tables.

this commit workarounds it with --size-level=0.

an alternative is to disable jump tables. (although it seems that
jump tables are not the only source of these relocations.)

cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035

it might be better to do this in wamrc itself. however, currently
target info is not available there in case of native compilation.
related: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3356
2025-05-07 08:16:01 +09:00
YAMAMOTO Takashi
a329d2aa60 build-scripts/build_llvm.py: bump to llvm 19
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/4210

why 19, not 20?
because, as of writing this, 19 is the latest released version for
the xtensa fork of llvm: https://github.com/espressif/llvm-project
while we can use different versions for different targets,
it's nicer to use the same version everywhere when possible.
2025-05-07 08:15:56 +09:00
10 changed files with 90 additions and 30 deletions

View File

@ -424,7 +424,8 @@ jobs:
VERBOSE=1
cmake -S . -B build ${{ matrix.make_options }}
cmake --build build --config Debug --parallel 4
ctest --test-dir build --output-on-failure
./build/callback_chain
ctest -V --test-dir build --output-on-failure
working-directory: samples/wasm-c-api
build_samples_others:

View File

@ -46,11 +46,14 @@ concurrency:
cancel-in-progress: true
env:
AOT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
FAST_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
LLVM_LAZY_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
# For BUILD
AOT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
CLASSIC_INTERP_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
FAST_INTERP_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=0 -DWAMR_BUILD_FAST_INTERP=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
FAST_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=0"
LLVM_LAZY_JIT_BUILD_OPTIONS: " -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
LLVM_EAGER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0"
MULTI_TIER_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=1"
permissions:
contents: read
@ -214,33 +217,68 @@ jobs:
working-directory: product-mini/platforms/${{ matrix.platform }}
build_samples_wasm_c_api:
needs: [build_iwasm]
needs:
[
build_iwasm,
build_llvm_libraries_on_intel_macos,
build_wamrc,
]
runs-on: ${{ matrix.os }}
strategy:
matrix:
make_options: [
# Running modes supported
$AOT_BUILD_OPTIONS,
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
# Running modes unsupported
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
#$AOT_BUILD_OPTIONS,
$FAST_JIT_BUILD_OPTIONS,
$LLVM_LAZY_JIT_BUILD_OPTIONS,
$LLVM_EAGER_JIT_BUILD_OPTIONS,
$MULTI_TIER_JIT_BUILD_OPTIONS,
]
os: [macos-13]
include:
- os: macos-13
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Get LLVM libraries
id: retrieve_llvm_libs
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
uses: actions/cache@v4
with:
path: |
./core/deps/llvm/build/bin
./core/deps/llvm/build/include
./core/deps/llvm/build/lib
./core/deps/llvm/build/libexec
./core/deps/llvm/build/share
key: ${{ matrix.llvm_cache_key }}
- name: Quit if cache miss
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
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
cmake -S . -B build ${{ matrix.make_options }}
cmake --build build --config Release --parallel 4
cmake --build build --config Debug --parallel 4
ctest --test-dir build --output-on-failure
working-directory: samples/wasm-c-api

View File

@ -139,6 +139,11 @@ jobs:
- target_config: { target: "xtensa" }
wamr_feature_option: { mode: "-G" }
# disabled for now:
# https://github.com/espressif/llvm-project/issues/112
- target_config: { target: "xtensa" }
wamr_test_option: { mode: "-t aot -X" }
steps:
# Note: we use an unreleased version nuttx for xtensa because
# 12.4 doesn't contain necessary esp32s3 changes.

View File

@ -294,17 +294,17 @@ def main():
"arc": {
"repo": "https://github.com/llvm/llvm-project.git",
"repo_ssh": "git@github.com:llvm/llvm-project.git",
"branch": "release/15.x",
"branch": "release/19.x",
},
"xtensa": {
"repo": "https://github.com/espressif/llvm-project.git",
"repo_ssh": "git@github.com:espressif/llvm-project.git",
"branch": "xtensa_release_17.0.1",
"branch": "xtensa_release_19.1.2",
},
"default": {
"repo": "https://github.com/llvm/llvm-project.git",
"repo_ssh": "git@github.com:llvm/llvm-project.git",
"branch": "release/15.x",
"branch": "release/19.x",
},
}

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

@ -4007,8 +4007,21 @@ 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
#if LLVM_VERSION_MAJOR >= 19
/* cf.
* https://github.com/llvm/llvm-project/pull/95031
* https://github.com/llvm/llvm-project/pull/89693
*
* note: the trailing space in ".L0 " is intentional. */
|| !strcmp(relocation->symbol_name, "")
|| !strcmp(relocation->symbol_name, ".L0 ")
#endif
)) {
/* change relocation->relocation_addend and
relocation->symbol_name */
LLVMSectionIteratorRef contain_section;

View File

@ -5741,7 +5741,7 @@ compile_jit_functions(WASMModule *module, char *error_buf,
if (os_thread_create(&module->orcjit_threads[i], orcjit_thread_callback,
(void *)&module->orcjit_thread_args[i],
APP_THREAD_STACK_SIZE_DEFAULT)
APP_THREAD_STACK_SIZE_DEFAULT * 2)
!= 0) {
set_error_buf(error_buf, error_buf_size,
"create orcjit compile thread failed");

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()

View File

@ -46,7 +46,8 @@ temp_module_table = {}
aot_target_options_map = {
"i386": ["--target=i386"],
"x86_32": ["--target=i386"],
"x86_64": ["--target=x86_64", "--cpu=skylake"],
# cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035
"x86_64": ["--target=x86_64", "--cpu=skylake", "--size-level=0"],
"aarch64": ["--target=aarch64", "--target-abi=eabi", "--cpu=cortex-a53"],
"aarch64_vfp": ["--target=aarch64", "--target-abi=gnueabihf", "--cpu=cortex-a53"],
"armv7": ["--target=armv7", "--target-abi=eabi", "--cpu=cortex-a9", "--cpu-features=-neon"],

View File

@ -712,7 +712,7 @@ main(int argc, char *argv[])
}
if (sgx_mode) {
option.size_level = 1;
option.size_level = 0;
option.is_sgx_platform = true;
}