Skip to content

Commit c5414fd

Browse files
Merge branch 'bytecodealliance:main' into feature/support_wasm_load_by_name
2 parents 1df9b7c + 3cce6fd commit c5414fd

38 files changed

Lines changed: 353 additions & 111 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353

5454
# Initializes the CodeQL tools for scanning.
5555
- name: Initialize CodeQL
56-
uses: github/codeql-action/init@v3.28.15
56+
uses: github/codeql-action/init@v3.28.17
5757
with:
5858
languages: ${{ matrix.language }}
5959

@@ -70,7 +70,7 @@ jobs:
7070
- run: |
7171
./.github/scripts/codeql_buildscript.sh
7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@v3.28.15
73+
uses: github/codeql-action/analyze@v3.28.17
7474
with:
7575
category: "/language:${{matrix.language}}"
7676
upload: false
@@ -99,7 +99,7 @@ jobs:
9999
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
100100

101101
- name: Upload CodeQL results to code scanning
102-
uses: github/codeql-action/upload-sarif@v3.28.15
102+
uses: github/codeql-action/upload-sarif@v3.28.17
103103
with:
104104
sarif_file: ${{ steps.step1.outputs.sarif-output }}
105105
category: "/language:${{matrix.language}}"

.github/workflows/compilation_on_macos.yml

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ concurrency:
4646
cancel-in-progress: true
4747

4848
env:
49-
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"
50-
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"
51-
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"
52-
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"
53-
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"
49+
# For BUILD
50+
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"
51+
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"
52+
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"
53+
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"
54+
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"
55+
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"
56+
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"
5457

5558
permissions:
5659
contents: read
@@ -214,33 +217,68 @@ jobs:
214217
working-directory: product-mini/platforms/${{ matrix.platform }}
215218

216219
build_samples_wasm_c_api:
217-
needs: [build_iwasm]
220+
needs:
221+
[
222+
build_iwasm,
223+
build_llvm_libraries_on_intel_macos,
224+
build_wamrc,
225+
]
218226
runs-on: ${{ matrix.os }}
219227
strategy:
220228
matrix:
221229
make_options: [
222-
# Running modes supported
230+
$AOT_BUILD_OPTIONS,
223231
$CLASSIC_INTERP_BUILD_OPTIONS,
224232
$FAST_INTERP_BUILD_OPTIONS,
225-
# Running modes unsupported
226-
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
227-
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
228-
#$AOT_BUILD_OPTIONS,
233+
$FAST_JIT_BUILD_OPTIONS,
234+
$LLVM_LAZY_JIT_BUILD_OPTIONS,
235+
$LLVM_EAGER_JIT_BUILD_OPTIONS,
236+
$MULTI_TIER_JIT_BUILD_OPTIONS,
229237
]
230238
os: [macos-13]
239+
include:
240+
- os: macos-13
241+
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
242+
231243
steps:
232244
- name: checkout
233245
uses: actions/checkout@v4
234246

247+
- name: Get LLVM libraries
248+
id: retrieve_llvm_libs
249+
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
250+
uses: actions/cache@v4
251+
with:
252+
path: |
253+
./core/deps/llvm/build/bin
254+
./core/deps/llvm/build/include
255+
./core/deps/llvm/build/lib
256+
./core/deps/llvm/build/libexec
257+
./core/deps/llvm/build/share
258+
key: ${{ matrix.llvm_cache_key }}
259+
260+
- name: Quit if cache miss
261+
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
262+
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
263+
235264
- name: install-wasi-sdk-wabt
236265
uses: ./.github/actions/install-wasi-sdk-wabt
237266
with:
238267
os: ${{ matrix.os }}
239268

269+
- name: Build wamrc
270+
if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS'))
271+
run: |
272+
mkdir build && cd build
273+
cmake ..
274+
cmake --build . --config Release --parallel 4
275+
working-directory: wamr-compiler
276+
240277
- name: Build Sample [wasm-c-api]
241278
run: |
279+
VERBOSE=1
242280
cmake -S . -B build ${{ matrix.make_options }}
243-
cmake --build build --config Release --parallel 4
281+
cmake --build build --config Debug --parallel 4
244282
ctest --test-dir build --output-on-failure
245283
working-directory: samples/wasm-c-api
246284

.github/workflows/supply_chain.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ jobs:
6060

6161
# Upload the results to GitHub's code scanning dashboard.
6262
- name: "Upload to code-scanning"
63-
uses: github/codeql-action/upload-sarif@4c3e5362829f0b0bb62ff5f6c938d7f95574c306
63+
uses: github/codeql-action/upload-sarif@5eb3ed6614230b1931d5c08df9e096e4ba524f21
6464
with:
6565
sarif_file: results.sarif

build-scripts/build_llvm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,17 @@ def main():
294294
"arc": {
295295
"repo": "https://github.com/llvm/llvm-project.git",
296296
"repo_ssh": "git@github.com:llvm/llvm-project.git",
297-
"branch": "release/15.x",
297+
"branch": "release/18.x",
298298
},
299299
"xtensa": {
300300
"repo": "https://github.com/espressif/llvm-project.git",
301301
"repo_ssh": "git@github.com:espressif/llvm-project.git",
302-
"branch": "xtensa_release_17.0.1",
302+
"branch": "xtensa_release_18.1.2",
303303
},
304304
"default": {
305305
"repo": "https://github.com/llvm/llvm-project.git",
306306
"repo_ssh": "git@github.com:llvm/llvm-project.git",
307-
"branch": "release/15.x",
307+
"branch": "release/18.x",
308308
},
309309
}
310310

build-scripts/config_common.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,6 @@ endif ()
677677
message (
678678
"-- About Wasm Proposals:\n"
679679
" Always-on:\n"
680-
" \"Extended Constant Expressions\"\n"
681680
" \"Multi-value\"\n"
682681
" \"Non-trapping float-to-int conversions\"\n"
683682
" \"Sign-extension operators\"\n"
@@ -698,6 +697,7 @@ message (
698697
" \"Branch Hinting\"\n"
699698
" \"Custom Annotation Syntax in the Text Format\"\n"
700699
" \"Exception handling\"\n"
700+
" \"Extended Constant Expressions\"\n"
701701
" \"Import/Export of Mutable Globals\"\n"
702702
" \"JS String Builtins\"\n"
703703
" \"Relaxed SIMD\"\n"

ci/coding_guidelines_check.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,19 @@ def run_clang_format_diff(root: Path, commits: str) -> bool:
9898
code before committing the PR, or it might fail to pass the CI check:
9999
100100
1. Install clang-format-14.0.0
101-
Normally we can install it by `sudo apt-get install clang-format-14`,
102-
or download the package from https://github.com/llvm/llvm-project/releases
103-
and install it
101+
102+
You can download the package from
103+
https://github.com/llvm/llvm-project/releases
104+
and install it.
105+
106+
For Debian/Ubuntu, we can probably use
107+
`sudo apt-get install clang-format-14`.
108+
109+
Homebrew has it as a part of llvm@14.
110+
```shell
111+
brew install llvm@14
112+
/usr/local/opt/llvm@14/bin/clang-format
113+
```
104114
105115
2. Format the C/C++ source file
106116
``` shell

core/iwasm/aot/aot_intrinsic.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ aot_intrinsic_clz_i32(uint32 type)
194194
return num;
195195
}
196196

197-
uint32
197+
uint64
198198
aot_intrinsic_clz_i64(uint64 type)
199199
{
200200
uint32 num = 0;
@@ -220,7 +220,7 @@ aot_intrinsic_ctz_i32(uint32 type)
220220
return num;
221221
}
222222

223-
uint32
223+
uint64
224224
aot_intrinsic_ctz_i64(uint64 type)
225225
{
226226
uint32 num = 0;
@@ -244,7 +244,7 @@ aot_intrinsic_popcnt_i32(uint32 u)
244244
return ret;
245245
}
246246

247-
uint32
247+
uint64
248248
aot_intrinsic_popcnt_i64(uint64 u)
249249
{
250250
uint32 ret = 0;
@@ -898,6 +898,17 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx)
898898
if (!strncmp(comp_ctx->target_arch, "riscv32", 7)) {
899899
add_i64_common_intrinsics(comp_ctx);
900900
}
901+
/*
902+
* LLVM 16 and later expands cttz intrinsic to a table lookup,
903+
* which involves some relocations. (unless ZBB is available,
904+
* in which case the native instructions are preferred over
905+
* the table-based lowering.)
906+
* https://reviews.llvm.org/D128911
907+
*/
908+
#if LLVM_VERSION_MAJOR >= 16
909+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CTZ);
910+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CTZ);
911+
#endif
901912
}
902913
else if (!strncmp(comp_ctx->target_arch, "xtensa", 6)) {
903914
/*

core/iwasm/aot/aot_intrinsic.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,19 @@ aot_intrinsic_fmax_f64(float64 a, float64 b);
186186
uint32
187187
aot_intrinsic_clz_i32(uint32 type);
188188

189-
uint32
189+
uint64
190190
aot_intrinsic_clz_i64(uint64 type);
191191

192192
uint32
193193
aot_intrinsic_ctz_i32(uint32 type);
194194

195-
uint32
195+
uint64
196196
aot_intrinsic_ctz_i64(uint64 type);
197197

198198
uint32
199199
aot_intrinsic_popcnt_i32(uint32 u);
200200

201-
uint32
201+
uint64
202202
aot_intrinsic_popcnt_i64(uint64 u);
203203

204204
float32

core/iwasm/aot/aot_loader.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,10 +3189,12 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
31893189
symbol_addr = module->code;
31903190
}
31913191
else if (!strcmp(symbol, ".data") || !strcmp(symbol, ".sdata")
3192-
|| !strcmp(symbol, ".rdata")
3193-
|| !strcmp(symbol, ".rodata")
3192+
|| !strcmp(symbol, ".rdata") || !strcmp(symbol, ".rodata")
3193+
|| !strcmp(symbol, ".srodata")
31943194
/* ".rodata.cst4/8/16/.." */
31953195
|| !strncmp(symbol, ".rodata.cst", strlen(".rodata.cst"))
3196+
/* ".srodata.cst4/8/16/.." */
3197+
|| !strncmp(symbol, ".srodata.cst", strlen(".srodata.cst"))
31963198
/* ".rodata.strn.m" */
31973199
|| !strncmp(symbol, ".rodata.str", strlen(".rodata.str"))
31983200
|| !strcmp(symbol, AOT_STACK_SIZES_SECTION_NAME)
@@ -4125,6 +4127,12 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
41254127
}
41264128
#endif
41274129

4130+
#if WASM_ENABLE_LIBC_WASI != 0
4131+
module->wasi_args.stdio[0] = os_invalid_raw_handle();
4132+
module->wasi_args.stdio[1] = os_invalid_raw_handle();
4133+
module->wasi_args.stdio[2] = os_invalid_raw_handle();
4134+
#endif
4135+
41284136
return module;
41294137
#if WASM_ENABLE_GC != 0
41304138
fail2:

core/iwasm/common/wasm_exec_env.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ wasm_exec_env_restore_module_inst(
276276
void
277277
wasm_exec_env_set_thread_info(WASMExecEnv *exec_env)
278278
{
279-
uint8 *stack_boundary = os_thread_get_stack_boundary();
280-
281279
#if WASM_ENABLE_THREAD_MGR != 0
282280
os_mutex_lock(&exec_env->wait_lock);
283281
#endif
@@ -286,9 +284,11 @@ wasm_exec_env_set_thread_info(WASMExecEnv *exec_env)
286284
/* WASM_STACK_GUARD_SIZE isn't added for flexibility to developer,
287285
he must ensure that enough guard bytes are kept. */
288286
exec_env->native_stack_boundary = exec_env->user_native_stack_boundary;
289-
else
287+
else {
288+
uint8 *stack_boundary = os_thread_get_stack_boundary();
290289
exec_env->native_stack_boundary =
291290
stack_boundary ? stack_boundary + WASM_STACK_GUARD_SIZE : NULL;
291+
}
292292
exec_env->native_stack_top_min = (void *)UINTPTR_MAX;
293293
#if WASM_ENABLE_THREAD_MGR != 0
294294
os_mutex_unlock(&exec_env->wait_lock);

0 commit comments

Comments
 (0)