Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch main into dev/dynamic_linking #3782

Merged
merged 23 commits into from
Sep 10, 2024
Merged

Merge branch main into dev/dynamic_linking #3782

merged 23 commits into from
Sep 10, 2024

Conversation

wenyongh
Copy link
Contributor

No description provided.

bianchui and others added 23 commits August 14, 2024 08:42
And enable merged os_mmap for aot data and text sections except on
platform nuttx and esp-idf.

Fix issue that aarch64 AOT module fails to load on android:
#2274
Merge branch main into dev/merge_aot_data_text
Make wamrc normalize "arm64" to "aarch64v8". Previously the only way to
make the "arm64" target was to not specify a target on 64 bit arm-based
mac builds. Now arm64 and aarch64v8 are treated as the same.

Make aot_loader accept "aarch64v8" on arm-based apple (as well as
accepting legacy "arm64" based aot targets).

This also removes __APPLE__ and __MACH__ from the block that defaults
size_level to 1 since it doesn't seem to be supported for aarch64:
`LLVM ERROR: Only small, tiny and large code models are allowed on AArch64`
Fix the compilation error of this CI:
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/10575515238

```
/__w/wasm-micro-runtime/wasm-micro-runtime/bloaty/third_party/abseil-cpp/absl/debugging/failure_signal_handler.cc:139:32: error: no matching function for call to 'max(long int, int)'
  139 |   size_t stack_size = (std::max(SIGSTKSZ, 65536) + page_mask) & ~page_mask;
      |                        ~~~~~~~~^~~~~~~~~~~~~~~~~
```
Merge branch dev/merge_aot_data_text into main to keep the commit history.
…ck is enabled (#3754)

In the AOT compiler, allow the user to control stack boundary check when the boundary
check is enabled (e.g. `wamrc --bounds-checks=1`). Now the code logic is:

1. When `--stack-bounds-checks` is not set, it will be the same value as `--bounds-checks`.
2. When `--stack-bounds-checks` is set, it will be the option value no matter what the
    status of `--bounds-checks` is.
…64 or riscv64 (#3755)

Mac on aarch64 uses posix_memmap.c os_mmap which doesn't do anything with
the flag MMAP_MAP_32BIT for that build so this condition ends up asserting unless
the mapping ends up in the first 4 gigs worth of addressable space.

Thsi PR changes to call os_mmap with MMAP_MAP_32BIT flag only when the target
is x86-64 or riscv64, and the macro __APPLE__ isn't enabled. The behavior is similar
to what the posix os_mmap does.
The specific commit has been deleted, I am pointing to the same commit in the main branch though.
- Only retry on EAGAIN, ENOMEM or EINTR.
- On EINTR, don't count it against the retry budget, just keep retrying.
  EINTR can happen in bursts.
- Log the errno on failure, and don't conditionalize that logging on
  BH_ENABLE_TRACE_MMAP. In other parts of the code, error logging is not
  conditional on that define, while turning on that tracing define makes
  things overly verbose.
Those parameters can be used to reduce the size of the AOT code.

There's going to be more changes related to AOT code size reduction,
this is just the initial step.

p.s. #3758
Fixes to enable building iwasm_shared and iwasm_static libraries on win32.
Minimum support:
- [x] accept (WasmEdge) customized model parameters. metadata.
- [x] Target [wasmedge-ggml examples](https://github.com/second-state/WasmEdge-WASINN-examples/tree/master/wasmedge-ggml)
  - [x] basic
  - [x] chatml
  - [x] gemma
  - [x] llama
  - [x] qwen

---

In the future, to support if required:
- [ ] Target [wasmedge-ggml examples](https://github.com/second-state/WasmEdge-WASINN-examples/tree/master/wasmedge-ggml)
  - [ ] command-r. (>70G memory requirement)
  - [ ] embedding. (embedding mode)
  - [ ] grammar. (use the grammar option to constrain the model to generate the JSON output)
  - [ ] llama-stream. (new APIS `compute_single`, `get_output_single`, `fini_single`)
  - [ ] llava. (image representation)
  - [ ] llava-base64-stream. (image representation)
  - [ ] multimodel. (image representation)
- [ ] Target [llamaedge](https://github.com/LlamaEdge/LlamaEdge)
- Implement TINY / STANDARD frame modes - tiny mode is only able to keep track on the IP
  and func idx, STANDARD mode provides more capabilities (parameters, stack pointer etc.).
- Implement FRAME_PER_FUNCTION / FRAME_PER_CALL modes - frame per function adds
  code at the beginning and at the end of each function for allocating / deallocating stack frame,
  whereas in per-call mode the frame is allocated before each call. The exception is call to
  the imported function, where frame-per-function mode also allocates the stack before the
  `call` instruction (as it can't instrument the imported function).

At the moment TINY + FRAME_PER_FUNCTION is automatically enabled in case GC and perf
profiling are disabled and `values` call stack feature is not requested. In all the other cases
STANDARD + FRAME_PER_CALL is used.

STANDARD + FRAME_PER_FUNCTION and TINY + FRAME_PER_CALL are currently not
implemented but possible, and might be enabled in the future.

ps. #3758
@wenyongh wenyongh merged commit 4f96a76 into dev/dynamic_linking Sep 10, 2024
384 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.