Compare commits

..

No commits in common. "main" and "WAMR-1.0.0" have entirely different histories.

1905 changed files with 66350 additions and 203298 deletions

View File

@ -1,150 +1,98 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp/.devcontainer/base.Dockerfile
# [Choice] Debian / Ubuntu version (use Debian 12/11/9, Ubuntu 18.04/21.04 on local arm64/Apple Silicon): debian-12, debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT=debian-12
FROM mcr.microsoft.com/vscode/devcontainers/cpp:${VARIANT}
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/cpp/.devcontainer/base.Dockerfile
# [Choice] Debian / Ubuntu version (use Debian 11/9, Ubuntu 18.04/21.04 on local arm64/Apple Silicon): debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT=ubuntu-20.04
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asian/Shanghai
# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y apt-transport-https apt-utils build-essential \
ca-certificates ccache cmake curl g++-multilib git gnupg \
libgcc-12-dev lib32gcc-12-dev lsb-release \
ninja-build ocaml ocamlbuild \
RUN apt update \
&& apt install -y apt-transport-https apt-utils build-essential \
ca-certificates curl g++-multilib git gnupg \
libgcc-9-dev lib32gcc-9-dev lsb-release \
ninja-build ocaml ocamlbuild python2.7 \
software-properties-common tree tzdata \
unzip valgrind vim wget zip --no-install-recommends \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
#
# binaryen
ARG BINARYEN_VER=114
WORKDIR /opt
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VER}/binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz \
&& tar xf binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz \
&& ln -sf /opt/binaryen-version_${BINARYEN_VER} /opt/binaryen \
&& rm binaryen-version_${BINARYEN_VER}-x86_64-linux.tar.gz
unzip valgrind vim wget zip
#
# CMAKE (https://apt.kitware.com/)
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=DL3008
ARG CMAKE_VER=3.27.0
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-Linux-x86_64.sh \
-q -O /tmp/cmake-install.sh \
&& chmod u+x /tmp/cmake-install.sh \
&& mkdir /opt/cmake-${CMAKE_VER} \
&& /tmp/cmake-install.sh --skip-license --prefix=/opt/cmake-${CMAKE_VER} \
&& rm /tmp/cmake-install.sh \
&& ln -s /opt/cmake-${CMAKE_VER}/bin/* /usr/local/bin
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null \
&& echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ bionic main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null \
&& apt update \
&& rm /usr/share/keyrings/kitware-archive-keyring.gpg \
&& apt install -y kitware-archive-keyring \
&& apt install -y cmake
#
# install emsdk
WORKDIR /opt
RUN git clone https://github.com/emscripten-core/emsdk.git
ARG EMSDK_VER=3.1.43
WORKDIR /opt/emsdk
RUN git pull \
&& ./emsdk install ${EMSDK_VER} \
&& ./emsdk activate ${EMSDK_VER} \
RUN cd /opt \
&& git clone https://github.com/emscripten-core/emsdk.git
RUN cd /opt/emsdk \
&& git pull \
&& ./emsdk install 2.0.26 \
&& ./emsdk activate 2.0.26 \
&& echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc
#
# install wasi-sdk
ARG WASI_SDK_VER=20
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER}/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -P /opt \
&& tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \
&& ln -sf /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk \
&& rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz
ARG WASI_SDK_VER=16
RUN wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER}/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -P /opt
RUN tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \
&& ln -fs /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk
RUN rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz
#
#install wabt
ARG WABT_VER=1.0.33
RUN wget -c --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu.tar.gz -P /opt \
&& tar xf /opt/wabt-${WABT_VER}-ubuntu.tar.gz -C /opt \
&& ln -sf /opt/wabt-${WABT_VER} /opt/wabt \
&& rm /opt/wabt-${WABT_VER}-ubuntu.tar.gz
ARG WABT_VER=1.0.29
RUN wget -c https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu.tar.gz -P /opt
RUN tar xf /opt/wabt-${WABT_VER}-ubuntu.tar.gz -C /opt \
&& ln -fs /opt/wabt-${WABT_VER} /opt/wabt
RUN rm /opt/wabt-${WABT_VER}-ubuntu.tar.gz
#
# install bazelisk
ARG BAZELISK_VER=1.17.0
RUN mkdir /opt/bazelisk \
&& wget -c --progress=dot:giga https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64 -P /opt/bazelisk \
&& chmod a+x /opt/bazelisk/bazelisk-linux-amd64 \
ARG BAZELISK_VER=1.12.0
RUN mkdir /opt/bazelisk
RUN wget -c https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64 -P /opt/bazelisk
RUN chmod a+x /opt/bazelisk/bazelisk-linux-amd64 \
&& ln -fs /opt/bazelisk/bazelisk-linux-amd64 /opt/bazelisk/bazel
#
# install clang+llvm
ARG LLVM_VER=16
RUN apt-get purge -y clang-14 llvm-14 && apt-get autoremove -y
WORKDIR /etc/apt/apt.conf.d
RUN touch 99verfiy-peer.conf \
RUN cd /etc/apt/apt.conf.d \
&& touch 99verfiy-peer.conf \
&& echo "Acquire { https::Verify-Peer false }" > 99verfiy-peer.conf
WORKDIR /tmp
#RUN wget --progress=dot:giga https://apt.llvm.org/llvm.sh \
# && chmod a+x ./llvm.sh \
# && ./llvm.sh ${LLVM_VER} all
# Workaround due to https://github.com/llvm/llvm-project/issues/62475
# hadolint ignore=DL3008
RUN set -ex \
&& echo "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-${LLVM_VER} main" > /etc/apt/sources.list.d/apt.llvm.org.list \
&& wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc \
&& apt-get update \
&& apt-get install -y \
clang-${LLVM_VER} lldb-${LLVM_VER} lld-${LLVM_VER} clangd-${LLVM_VER} clang-tidy-${LLVM_VER} clang-format-${LLVM_VER} clang-tools-${LLVM_VER} \
llvm-${LLVM_VER}-dev lld-${LLVM_VER} lldb-${LLVM_VER} llvm-${LLVM_VER}-tools libomp-${LLVM_VER}-dev libc++-${LLVM_VER}-dev libc++abi-${LLVM_VER}-dev \
libclang-common-${LLVM_VER}-dev libclang-${LLVM_VER}-dev libclang-cpp${LLVM_VER}-dev libunwind-${LLVM_VER}-dev \
libclang-rt-${LLVM_VER}-dev libpolly-${LLVM_VER}-dev --no-install-recommends \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN cd /tmp \
&& wget https://apt.llvm.org/llvm.sh \
&& chmod a+x ./llvm.sh
RUN /tmp/llvm.sh 12 all
RUN ln -sf /usr/bin/clang-format-12 /usr/bin/clang-format
#
# [Optional]
#
# Install pip
# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get install -y --reinstall python3-venv python3-pip --no-install-recommends \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN apt update && apt install -y --reinstall python3-venv python3-pip
RUN python3 -m pip install --upgrade pip
#
# Install required python packages
# hadolint ignore=DL3013
RUN python3 -m pip install --no-cache-dir --break-system-packages --upgrade pip \
&& pip3 install --no-cache-dir --break-system-packages black nose pycparser pylint
#
# Install github-cli. It doens't work as a feature of devcontainer.json
ARG GH_CLI_VER=2.32.0
WORKDIR /tmp
RUN wget -q https://github.com/cli/cli/releases/download/v${GH_CLI_VER}/gh_${GH_CLI_VER}_linux_amd64.deb \
&& dpkg -i gh_${GH_CLI_VER}_linux_amd64.deb
#
# Install NodeJS
RUN wget -qO- https://deb.nodesource.com/setup_20.x | bash -
# hadolint ignore=DL3008
RUN apt-get install -y nodejs --no-install-recommends
RUN pip3 install --user black nose pycparser pylint
# set path
ENV PATH="/opt/bazelisk:/usr/lib/llvm-${LLVM_VER}/bin:${PATH}"
ENV CC=/usr/lib/llvm-${LLVM_VER}/bin/clang CXX=/usr/lib/llvm-${LLVM_VER}/bin/clang++
RUN printf "%s\n" "PS1='\n[ \u@wamr-dev-docker \W ]\n$ '" >> /root/.bashrc \
&& apt-get autoremove -y \
ENV PATH "/opt/bazelisk:/opt/clang-llvm/bin:${PATH}"
RUN echo "export PATH=/opt/bazelisk:/opt/clang-llvm/bin:${PATH}" >> /root/.bashrc
#
# PS
RUN echo "PS1='\n[ \u@wamr-dev-docker \W ]\n$ '" >> /root/.bashrc
# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*
# set workdir when container run
VOLUME /workspaces
WORKDIR /workspaces

View File

@ -1,23 +1,16 @@
// Copyright (C) 2019 Intel Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/cpp
// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/cpp
{
"name": "WAMR-Dev",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-12, debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
// Use Debian 12, Debian 11, Debian 9, Ubuntu 18.04 or Ubuntu 21.04 on local arm64/Apple Silicon
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
// Use Debian 11, Debian 9, Ubuntu 18.04 or Ubuntu 21.04 on local arm64/Apple Silicon
"args": {
"BINARYEN_VER": "114",
"BAZELISK_VER": "1.17.0",
"CMAKE_VER": "3.27.0",
"EMSDK_VER": "3.1.43",
"GH_CLI_VER": "2.32.0",
"LLVM_VER": "16",
"VARIANT": "debian-12",
"WASI_SDK_VER": "20",
"WABT_VER": "1.0.33"
"VARIANT": "ubuntu-20.04"
}
},
"runArgs": [
@ -34,10 +27,12 @@
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dtsvet.vscode-wasm",
"llvm-vs-code-extensions.vscode-clangd",
"esbenp.prettier-vscode",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vscode.cmake-tools"
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"twxs.cmake"
]
}
},

View File

@ -1,12 +0,0 @@
# for now, it is used to speed up wasi-nn tests only.
# you shall adapt below rules to incoming requirements
**/build
**/tmp.*
.*
**/*.gguf
/core/deps/
!/core/deps/tensorflow-src
/samples
/tests

View File

@ -1,5 +0,0 @@
---
name: Blank Issue
about: Create a blank issue.
title: ''
---

View File

@ -1,28 +0,0 @@
---
name: Improvement
about: A feature request or code improvement.
title: ''
labels: ''
assignees: ''
---
Thanks for filing a feature request! Please fill out the TODOs below.
#### Feature
TODO: Brief description of the feature/improvement you'd like to see in WAMR
#### Benefit
TODO: What is the value of adding this in WAMR? What problems does it solve?
#### Implementation
TODO: Do you have an implementation plan, and/or ideas for data structures or
algorithms to use?
#### Alternatives
TODO: What are the alternative implementation approaches or alternative ways to
solve the problem that this feature would solve? How do these alternatives
compare to this proposal?

View File

@ -1,36 +0,0 @@
---
name: WAMR bug or defect report
about: Report a bug or defect in WAMR
title: ''
---
Thanks for filing a bug or defect report! Please fill out the TODOs below.
### Subject of the issue
Describe the bug or defect here.
### Test case
Upload the related wasm file, wast file or the source files if you can.
### Your environment
* Host OS
* WAMR version, platform, cpu architecture, running mode, etc.
### Steps to reproduce
Tell us how to reproduce this bug or defect.
### Expected behavior
Tell us what should happen
### Actual behavior
Tell us what happens instead
### Extra Info
Anything else you'd like to add?

View File

@ -1,47 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Always follow https://download.01.org/intel-sgx/latest/linux-latest/docs/
name: "Install Intel SGX SDK"
description: "Installs the Intel SGX SDK and necessary libraries for Ubuntu."
author: "Intel Corporation"
inputs:
os:
description: "Operating system to install on (ubuntu-22.04)"
required: true
runs:
using: "composite"
steps:
- name: Check Runner OS
if: ${{ inputs.os != 'ubuntu-22.04' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Only support ubuntu-22.04 for now"
exit 1
- name: Create installation directory
shell: bash
run: sudo mkdir -p /opt/intel
- name: Download and install SGX SDK on ubuntu-22.04
if: ${{ inputs.os == 'ubuntu-22.04' }}
shell: bash
run: |
sudo wget -O sgx_linux_x64_sdk.bin https://download.01.org/intel-sgx/sgx-linux/2.25/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.25.100.3.bin
sudo chmod +x sgx_linux_x64_sdk.bin
echo 'yes' | sudo ./sgx_linux_x64_sdk.bin
working-directory: /opt/intel
- name: Add SGX repository and install libraries
shell: bash
run: |
echo "deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
sudo apt update
sudo apt install -y libsgx-launch libsgx-urts
- name: Source SGX SDK environment
shell: bash
run: source /opt/intel/sgxsdk/environment

View File

@ -1,80 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Get URLs from:
# - https://github.com/WebAssembly/wasi-sdk/releases
# - https://github.com/WebAssembly/wabt/releases
# Install WASI-SDK and WABT at /opt
# /opt is the assumed location widely used in the project
name: Install WASI-SDK and WABT
description: A composite action to download and install wasi-sdk and wabt on Ubuntu, macOS.
inputs:
os:
description: "Operating system to install on (ubuntu, macos)"
required: true
runs:
using: "composite"
steps:
- name: Check Runner OS
if: ${{ !startsWith(inputs.os, 'ubuntu') && !startsWith(inputs.os, 'windows') && !startsWith(inputs.os, 'macos') }}
shell: bash
run: |
echo "::error title=⛔ error hint::Support Ubuntu, Windows, and macOS Only"
exit 1
- name: Set up wasi-sdk and wabt on Ubuntu
if: ${{ startsWith(inputs.os, 'ubuntu') }}
shell: bash
run: |
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz
sudo tar -xf wasi-sdk.tar.gz
sudo ln -sf wasi-sdk-25.0-x86_64-linux/ wasi-sdk
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-ubuntu-20.04.tar.gz
sudo tar -xf wabt.tar.gz
sudo ln -sf wabt-1.0.37 wabt
/opt/wasi-sdk/bin/clang --version
/opt/wabt/bin/wasm-interp --version
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on ubuntu"
working-directory: /opt
- name: Set up wasi-sdk and wabt on macOS-13 (intel)
if: ${{ inputs.os == 'macos-13' }}
shell: bash
run: |
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-macos.tar.gz
sudo tar -xf wasi-sdk.tar.gz
sudo ln -sf wasi-sdk-25.0-x86_64-macos wasi-sdk
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.36/wabt-1.0.36-macos-12.tar.gz
sudo tar -xf wabt.tar.gz
sudo ln -sf wabt-1.0.36 wabt
/opt/wasi-sdk/bin/clang --version
/opt/wabt/bin/wasm-interp --version
echo "::notice::wasi-sdk-25 and wabt-1.0.36 installed on macos-13"
working-directory: /opt
- name: Set up wasi-sdk and wabt on macOS-14 (arm64)
if: ${{ inputs.os == 'macos-14' }}
shell: bash
run: |
sudo wget -O wasi-sdk.tar.gz --progress=dot:giga https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-arm64-macos.tar.gz
sudo tar -xf wasi-sdk.tar.gz
sudo ln -sf wasi-sdk-25.0-arm64-macos wasi-sdk
sudo wget -O wabt.tar.gz --progress=dot:giga https://github.com/WebAssembly/wabt/releases/download/1.0.37/wabt-1.0.37-macos-14.tar.gz
sudo tar -xf wabt.tar.gz
sudo ln -sf wabt-1.0.37 wabt
/opt/wasi-sdk/bin/clang --version
/opt/wabt/bin/wasm-interp --version
echo "::notice::wasi-sdk-25 and wabt-1.0.37 installed on macos-14"
working-directory: /opt
#TODO: Add support for Windows
- name: Set up wasi-sdk and wabt on Windows
if: ${{ startsWith(inputs.os, 'windows') }}
shell: powershell
run: |
echo "::notice::Support for Windows is not implemented yet"
exit 1

View File

@ -1,35 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/.devcontainer"
schedule:
interval: "weekly"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/build-scripts"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/language-bindings/python/wasm-c-api"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/language-bindings/python/wamr-api"
schedule:
interval: "weekly"

View File

@ -1,312 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
sudo apt update
sudo apt install -y build-essential cmake g++-multilib libgcc-12-dev lib32gcc-12-dev ccache ninja-build
WAMR_DIR=${PWD}
# TODO: use pre-built llvm binary to build wamrc to
# avoid static code analysing for llvm
: '
# build wamrc
cd ${WAMR_DIR}/wamr-compiler
./build_llvm.sh
rm -fr build && mkdir build && cd build
cmake ..
make -j
if [[ $? != 0 ]]; then
echo "Failed to build wamrc!"
exit 1;
fi
'
# build iwasm with default features enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -fr build && mkdir build && cd build
cmake ..
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with default features enabled!"
exit 1;
fi
# build iwasm with default features enabled on x86_32
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -fr build && mkdir build && cd build
cmake .. -DWAMR_BUILD_TARGET=X86_32
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with default features enabled on x86_32!"
exit 1;
fi
# build iwasm with classic interpreter enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_INTERP=0
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with classic interpreter enabled!"
exit 1;
fi
# build iwasm with extra features enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -fr build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DWAMR_BUILD_LIB_PTHREAD=1 -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_MULTI_MODULE=1 -DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_TAIL_CALL=1 -DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_CUSTOM_NAME_SECTION=1 -DWAMR_BUILD_MEMORY_PROFILING=1 \
-DWAMR_BUILD_PERF_PROFILING=1 -DWAMR_BUILD_DUMP_CALL_STACK=1 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build wamrc iwasm with extra features enabled!"
exit 1;
fi
# build iwasm with global heap pool enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -fr build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DWAMR_BUILD_ALLOC_WITH_USER_DATA=1 \
-DWAMR_DISABLE_STACK_HW_BOUND_CHECK=1 \
-DWAMR_BUILD_GLOBAL_HEAP_POOL=1 \
-DWAMR_BUILD_GLOBAL_HEAP_SIZE=131072
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with global heap pool enabled!"
exit 1;
fi
# build iwasm with wasi-threads enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -fr build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LIB_WASI_THREADS=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with wasi-threads enabled!"
exit 1;
fi
# build iwasm with GC enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_GC=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with GC enabled!"
exit 1;
fi
# build iwasm with exception handling enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_EXCE_HANDLING=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with exception handling enabled!"
exit 1;
fi
# build iwasm with memory64 enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MEMORY64=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with memory64 enabled!"
exit 1;
fi
# build iwasm with multi-memory enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MULTI_MEMORY=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with multi-memory enabled!"
exit 1;
fi
# build iwasm with hardware boundary check disabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_DISABLE_HW_BOUND_CHECK=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with hardware boundary check disabled!"
exit 1;
fi
# build iwasm with quick AOT entry disabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_QUICK_AOT_ENTRY=0
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with quick AOT entry disabled!"
exit 1;
fi
# build iwasm with wakeup of blocking operations disabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_DISABLE_WAKEUP_BLOCKING_OP=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with wakeup of blocking operations disabled!"
exit 1;
fi
# build iwasm with module instance context disabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MODULE_INST_CONTEXT=0 \
-DWAMR_BUILD_LIBC_BUILTIN=0 -DWAMR_BUILD_LIBC_WASI=0
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with module instance context disabled!"
exit 1;
fi
# build iwasm with libc-uvwasi enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -fr build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LIBC_UVWASI=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with libc-uvwasi enabled!"
exit 1;
fi
# build iwasm with fast jit lazy mode enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_FAST_JIT_DUMP=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with fast jit lazy mode enabled!"
exit 1;
fi
# build iwasm with fast jit eager mode enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_FAST_JIT_DUMP=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with fast jit eager mode enabled!"
exit 1;
fi
# TODO: use pre-built llvm binary to build llvm-jit and multi-tier-jit
: '
# build iwasm with llvm jit lazy mode enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_JIT=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build llvm jit lazy mode enabled!"
exit 1;
fi
# build iwasm with llvm jit eager mode enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LAZY_JIT=0
make -j
if [[ $? != 0 ]]; then
echo "Failed to build llvm jit eager mode enabled!"
exit 1;
fi
# build iwasm with multi-tier jit enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
-DWAMR_BUILD_FAST_JIT_DUMP=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with multi-tier jit enabled!"
exit 1;
fi
'
# build iwasm with wasm mini-loader enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_MINI_LOADER=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build with wasm mini-loader enabled!"
exit 1;
fi
# build iwasm with source debugging enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_DEBUG_INTERP=1 -DWAMR_BUILD_DEBUG_AOT=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with source debugging enabled!"
exit 1;
fi
# build iwasm with AOT static PGO enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_STATIC_PGO=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with AOT static PGO enabled!"
exit 1;
fi
# build iwasm with configurable bounds checks enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_CONFIGURABLE_BOUNDS_CHECKS=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with configurable bounds checks enabled!"
exit 1;
fi
# build iwasm with linux perf support enabled
cd ${WAMR_DIR}/product-mini/platforms/linux/
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_LINUX_PERF=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with linux perf support enabled!"
exit 1;
fi
# build iwasm with shared heap enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_SHARED_HEAP=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm with shared heap enabled!"
exit 1;
fi
# build iwasm with dynamic aot debug enabled
cd ${WAMR_DIR}/product-mini/platforms/linux
rm -rf build && mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BUILD_DYNAMIC_AOT_DEBUG=1
make -j
if [[ $? != 0 ]]; then
echo "Failed to build iwasm dynamic aot debug enabled!"
exit 1;
fi

View File

@ -1,124 +0,0 @@
#!/usr/bin/env python3
#
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
import json
import sys
import os
import requests
def fetch_dismissed_alerts(repo_name, github_token):
headers = {
"Authorization": f"token {github_token}",
"Accept": "application/vnd.github.v3+json",
}
url = (
f"https://api.github.com/repos/{repo_name}/code-scanning/alerts?state=dismissed"
)
response = requests.get(url, headers=headers)
return response.json() # This assumes a successful API call
def parse_location(location):
path = location.get("physicalLocation", {}).get("artifactLocation", {}).get("uri")
start_line = location.get("physicalLocation", {}).get("region", {}).get("startLine")
column_range = (
location.get("physicalLocation", {}).get("region", {}).get("startColumn"),
location.get("physicalLocation", {}).get("region", {}).get("endColumn"),
)
return (path, start_line, column_range)
def is_dismissed(rule_id, path, start_line, column_range, dismissed_alerts):
for alert in dismissed_alerts:
alert_rule_id = alert.get("rule", {}).get("id")
alert_path = alert.get("location", {}).get("path")
alert_start_line = alert.get("location", {}).get("start_line")
alert_column_range = (
alert.get("location", {}).get("start_column"),
alert.get("location", {}).get("end_column"),
)
if (
rule_id == alert_rule_id
and path == alert_path
and start_line == alert_start_line
and column_range == alert_column_range
):
return True
return False
# Return whether SARIF file contains error-level results
def codeql_sarif_contain_error(filename, dismissed_alerts):
has_error = False
with open(filename, "r") as f:
s = json.load(f)
for run in s.get("runs", []):
rules_metadata = run["tool"]["driver"]["rules"]
if not rules_metadata:
rules_metadata = run["tool"]["extensions"][0]["rules"]
for res in run.get("results", []):
if "ruleIndex" in res:
rule_index = res["ruleIndex"]
elif "rule" in res and "index" in res["rule"]:
rule_index = res["rule"]["index"]
else:
continue
# check whether it's dismissed before
rule_id = res["ruleId"]
path, start_line, column_range = parse_location(res["locations"][0])
# the source code is from dependencies
if "_deps" in path:
continue
if is_dismissed(rule_id, path, start_line, column_range, dismissed_alerts):
print(
f"====== Finding a dismissed entry: {rule_id} at {path}:{start_line} is dismissed.======"
)
print(res)
continue
try:
rule_level = rules_metadata[rule_index]["defaultConfiguration"]["level"]
except IndexError as e:
print(e, rule_index, len(rules_metadata))
else:
if rule_level == "error":
# very likely to be an actual error
if rules_metadata[rule_index]["properties"].get("precision") in [
"high",
"very-high",
]:
# the security severity is above medium(Common Vulnerability Scoring System (CVSS) >= 4.0)
if "security-severity" in rules_metadata[rule_index][
"properties"
] and (
float(
rules_metadata[rule_index]["properties"][
"security-severity"
]
)
> 4.0
):
print("====== Finding a likely error. ======")
print(res)
has_error = True
return has_error
if __name__ == "__main__":
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
GITHUB_REPOSITORY = os.getenv("GITHUB_REPOSITORY")
dismissed_alerts = fetch_dismissed_alerts(GITHUB_REPOSITORY, GITHUB_TOKEN)
if codeql_sarif_contain_error(sys.argv[1], dismissed_alerts):
sys.exit(1)

View File

@ -1,60 +0,0 @@
#!/usr/bin/env python3
#
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
"""
Extract the latest release notes content from RELEASE_NOTES.md
"""
import argparse
import os
import sys
import traceback
def latest_content(release_notes_path):
"""
can't change the format of the original content
"""
content = ""
start_extract = False
with open(release_notes_path, encoding="utf-8") as f:
for line in f:
if line.startswith("## "):
if start_extract:
break
start_extract = True
continue
# hit a separated line
if line.startswith("---"):
break
content += line
content += os.linesep
return content
def main():
"""
GO!GO!!GO!!!
"""
parser = argparse.ArgumentParser(description="run the sample and examine outputs")
parser.add_argument("release_notes_path", type=str)
args = parser.parse_args()
ret = 1
try:
print(latest_content(args.release_notes_path))
ret = 0
except AssertionError:
traceback.print_exc()
return ret
if __name__ == "__main__":
sys.exit(main())

View File

@ -1,126 +0,0 @@
#!/usr/bin/env python3
#
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
import re
import shlex
import subprocess
import sys
def fetch_version_from_code():
"""
search the semantic version definition in core/version.h
"""
major, minor, patch = "", "", ""
with open("core/version.h", encoding="utf-8") as f:
for line in f:
if "WAMR_VERSION" not in line:
continue
major_match = re.search(r"WAMR_VERSION_MAJOR (\d+)", line)
if major_match is not None:
major = major_match.groups()[0]
continue
minor_match = re.search(r"WAMR_VERSION_MINOR (\d+)", line)
if minor_match is not None:
minor = minor_match.groups()[0]
continue
patch_match = re.search(r"WAMR_VERSION_PATCH (\d+)", line)
if patch_match is not None:
patch = patch_match.groups()[0]
if len(major) == 0 or len(minor) == 0 or len(patch) == 0:
raise Exception(
"can't find the semantic version definition likes WAMR_VERSION_*"
)
return f"WAMR-{major}.{minor}.{patch}"
def fetch_latest_git_tag():
"""
Get the most recent tag from the HEAD,
if it's main branch, it should be the latest release tag.
if it's release/x.x.x branch, it should be the latest release tag of the branch.
"""
list_tag_cmd = "git describe --tags --abbrev=0 HEAD"
p = subprocess.run(shlex.split(list_tag_cmd), capture_output=True, check=True)
all_tags = p.stdout.decode().strip()
latest_tag = all_tags.split("\n")[-1]
return latest_tag
def match_version_pattern(v):
pattern = r"WAMR-\d+\.\d+\.\d+"
m = re.match(pattern, v)
return m is not None
def split_version_string(v):
"""
return the semantic version as an integer list
"""
pattern = r"WAMR-(\d+)\.(\d+)\.(\d+)"
m = re.match(pattern, v)
return [int(x) for x in m.groups()]
def compare_version_string(v1, v2):
"""
return value:
- 1. if v1 > v2
- -1. if v1 < v2
- 0. if v1 == v2
"""
if not match_version_pattern(v1):
raise Exception(f"{v1} doesn't match the version pattern")
if not match_version_pattern(v2):
raise Exception(f"{v2} doesn't match the version pattern")
v1_sem_ver = split_version_string(v1)
v2_sem_ver = split_version_string(v2)
return 0 if v1_sem_ver == v2_sem_ver else (1 if v1_sem_ver > v2_sem_ver else -1)
def is_major_or_minor_changed(v1, v2):
"""
return true if change either major of v2 or minor of v2
return false or else
"""
if not match_version_pattern(v1):
raise Exception(f"{v1} doesn't match the version pattern")
if not match_version_pattern(v2):
raise Exception(f"{v2} doesn't match the version pattern")
v1_major, v1_minor, _ = split_version_string(v1)
v2_major, v2_minor, _ = split_version_string(v2)
return v2_major != v1_major or v2_minor != v1_minor
def next_version():
definition = fetch_version_from_code()
tag = fetch_latest_git_tag()
new_version = ""
minor_changed = False
if compare_version_string(definition, tag) == 1:
new_version = definition.split("-")[-1]
if is_major_or_minor_changed(tag, definition):
minor_changed = True
return new_version, "major_minor_change" if minor_changed else "patch_change"
if __name__ == "__main__":
print(f"{next_version()[0]},{next_version()[1]}")
sys.exit(0)

View File

@ -1,10 +0,0 @@
#! /bin/sh
set -e
URL=https://github.com/espressif/qemu/releases/download/esp-develop-9.0.0-20240606/qemu-xtensa-softmmu-esp_develop_9.0.0_20240606-x86_64-linux-gnu.tar.xz
DIR=$(mktemp -d)
cd ${DIR}
curl -fLsS "${URL}" | xzcat | tar -x
ln -s ${DIR}/qemu/bin/qemu-system-xtensa /usr/local/bin/qemu-system-xtensa

View File

@ -1,102 +0,0 @@
#!/usr/bin/env python3
#
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
import argparse
import json
import os
import shlex
import subprocess
import sys
from urllib.error import HTTPError, URLError
import urllib.request
def get_last_commit(target_path, cwd):
last_commit_cmd = f"git log -n 1 --pretty=format:%H -- {target_path}"
p = subprocess.run(
shlex.split(last_commit_cmd), capture_output=True, check=True, cwd=cwd
)
return p.stdout.decode().strip()
def fetch_git_tags():
list_tag_cmd = (
'git tag --list WAMR-*.*.* --sort=committerdate --format="%(refname:short)"'
)
p = subprocess.run(shlex.split(list_tag_cmd), capture_output=True, check=True)
all_tags = p.stdout.decode().strip()
return all_tags.split("\n")
def download_binaries(binary_name_stem, cwd):
"""
1. find the latest release name
2. form assets download url:
"""
try:
all_tags = fetch_git_tags()
# *release_process.yml* will create a tag and release at first
second_last_tag = all_tags[-2]
latest_tag = all_tags[-1]
latest_url = "https://api.github.com/repos/bytecodealliance/wasm-micro-runtime/releases/latest"
print(f"::notice::query the latest release with {latest_url}...")
with urllib.request.urlopen(latest_url) as response:
body = response.read()
release_name = json.loads(body)["name"]
# WAMR-X.Y.Z -> X.Y.Z
second_last_sem_ver = second_last_tag[5:]
latest_sem_ver = latest_tag[5:]
assert latest_sem_ver in binary_name_stem
name_stem_in_release = binary_name_stem.replace(
latest_sem_ver, second_last_sem_ver
)
# download and rename
for file_ext in (".zip", ".tar.gz"):
assets_url = f"https://github.com/bytecodealliance/wasm-micro-runtime/releases/download/{release_name}/{name_stem_in_release}{file_ext}"
local_path = f"{binary_name_stem}{file_ext}"
print(f"::notice::download from {assets_url} and save as {local_path}...")
urllib.request.urlretrieve(assets_url, local_path)
return True
except HTTPError as error:
print(error.status, error.reason)
except URLError as error:
print(error.reason)
except TimeoutError:
print("Request timeout")
return False
def main():
parser = argparse.ArgumentParser(
description="Reuse binaries of the latest release if no more modification on the_path since last_commit"
)
parser.add_argument("working_directory", type=str)
parser.add_argument("--binary_name_stem", type=str)
parser.add_argument("--last_commit", type=str)
parser.add_argument("--the_path", type=str)
args = parser.parse_args()
last_commit = get_last_commit(args.the_path, args.working_directory)
if last_commit == args.last_commit:
return download_binaries(args.binary_name_stem, args.working_directory)
else:
return False
if __name__ == "__main__":
# use output to indicate results
# echo "result=${result}" >> "$GITHUB_OUTPUT"
with open(os.environ.get("GITHUB_OUTPUT"), 'a') as output_file:
output_file.write("result=hit\n" if main() else "result=not-hit\n")
# always return 0
sys.exit(0)

View File

@ -1,94 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Create and publish Docker images
on:
workflow_call:
inputs:
upload_url:
description: upload binary assets to the URL of release
type: string
required: true
ver_num:
description: a semantic version number.
type: string
required: true
permissions:
contents: read
jobs:
build-and-push-images:
runs-on: ubuntu-22.04
permissions:
contents: write # for uploading release artifacts
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build and save Docker image(wasm-debug-server:${{ inputs.ver_num }}) to tar file
run: |
docker build -t wasm-debug-server:${{ inputs.ver_num }} .
docker save -o wasm-debug-server.tar wasm-debug-server:${{ inputs.ver_num }}
working-directory: test-tools/wamr-ide/WASM-Debug-Server/Docker
- name: compress the tar file
run: |
tar czf wasm-debug-server-${{ inputs.ver_num }}.tar.gz wasm-debug-server.tar
zip wasm-debug-server-${{ inputs.ver_num }}.zip wasm-debug-server.tar
working-directory: test-tools/wamr-ide/WASM-Debug-Server/Docker
- name: upload release tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: test-tools/wamr-ide/WASM-Debug-Server/Docker/wasm-debug-server-${{ inputs.ver_num }}.tar.gz
asset_name: wasm-debug-server-${{ inputs.ver_num }}.tar.gz
asset_content_type: application/x-gzip
- name: upload release zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: test-tools/wamr-ide/WASM-Debug-Server/Docker/wasm-debug-server-${{ inputs.ver_num }}.zip
asset_name: wasm-debug-server-${{ inputs.ver_num }}.zip
asset_content_type: application/zip
- name: Build and save Docker image(wasm-toolchain:${{ inputs.ver_num }}) to tar file
run: |
docker build -t wasm-toolchain:${{ inputs.ver_num }} .
docker save -o wasm-toolchain.tar wasm-toolchain:${{ inputs.ver_num }}
working-directory: test-tools/wamr-ide/WASM-Toolchain/Docker
- name: compress the tar file
run: |
tar czf wasm-toolchain-${{ inputs.ver_num }}.tar.gz wasm-toolchain.tar
zip wasm-toolchain-${{ inputs.ver_num }}.zip wasm-toolchain.tar
working-directory: test-tools/wamr-ide/WASM-Toolchain/Docker
- name: upload release tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: test-tools/wamr-ide/WASM-Toolchain/Docker/wasm-toolchain-${{ inputs.ver_num }}.tar.gz
asset_name: wasm-toolchain-${{ inputs.ver_num }}.tar.gz
asset_content_type: application/x-gzip
- name: upload release zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: test-tools/wamr-ide/WASM-Toolchain/Docker/wasm-toolchain-${{ inputs.ver_num }}.zip
asset_name: wasm-toolchain-${{ inputs.ver_num }}.zip
asset_content_type: application/zip

View File

@ -1,162 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: build iwasm release
on:
workflow_call:
inputs:
arch:
description: arch of the release
type: string
required: false
default: x86_64
cwd:
description: working directory
type: string
required: true
llvm_cache_key:
description: the cache key of llvm libraries
type: string
required: true
runner:
description: OS of compilation
type: string
required: true
upload_url:
description: a semantic version number. it is required when `release` is true.
type: string
required: false
ver_num:
description: a semantic version number. it is required when `release` is true.
type: string
required: false
env:
DEFAULT_BUILD_OPTIONS:
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-DWAMR_BUILD_DEBUG_INTERP=0 \
-DWAMR_BUILD_DEBUG_AOT=0 \
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
-DWAMR_BUILD_LIBC_UVWASI=0 \
-DWAMR_BUILD_LIBC_EMCC=0 \
-DWAMR_BUILD_LIB_RATS=0 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-DWAMR_BUILD_MEMORY_PROFILING=0 \
-DWAMR_BUILD_MINI_LOADER=0 \
-DWAMR_BUILD_MULTI_MODULE=0 \
-DWAMR_BUILD_PERF_PROFILING=0 \
-DWAMR_BUILD_SPEC_TEST=0 \
-DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_BUILD_LIB_PTHREAD=1 \
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_SHARED_MEMORY=1 \
-DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_THREAD_MGR=1"
GC_EH_BUILD_OPTIONS:
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 \
-DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
-DWAMR_BUILD_DEBUG_INTERP=0 \
-DWAMR_BUILD_DEBUG_AOT=0 \
-DWAMR_BUILD_DUMP_CALL_STACK=0 \
-DWAMR_BUILD_LIBC_UVWASI=0 \
-DWAMR_BUILD_LIBC_EMCC=0 \
-DWAMR_BUILD_LIB_RATS=0 \
-DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
-DWAMR_BUILD_MEMORY_PROFILING=0 \
-DWAMR_BUILD_MINI_LOADER=0 \
-DWAMR_BUILD_MULTI_MODULE=0 \
-DWAMR_BUILD_PERF_PROFILING=0 \
-DWAMR_BUILD_SPEC_TEST=0 \
-DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_BUILD_LIB_PTHREAD=1 \
-DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
-DWAMR_BUILD_LIB_WASI_THREADS=1 \
-DWAMR_BUILD_LIBC_BUILTIN=1 \
-DWAMR_BUILD_LIBC_WASI=1 \
-DWAMR_BUILD_REF_TYPES=1 \
-DWAMR_BUILD_SIMD=1 \
-DWAMR_BUILD_SHARED_MEMORY=1 \
-DWAMR_BUILD_TAIL_CALL=1 \
-DWAMR_BUILD_THREAD_MGR=1 \
-DWAMR_BUILD_EXCE_HANDLING=1 \
-DWAMR_BUILD_GC=1"
permissions:
contents: read
jobs:
build:
runs-on: ${{ inputs.runner }}
strategy:
matrix:
include:
- build_options: $DEFAULT_BUILD_OPTIONS
suffix: ''
- build_options: $GC_EH_BUILD_OPTIONS
suffix: '-gc-eh'
permissions:
contents: write # for uploading release artifacts
steps:
- uses: actions/checkout@v4
- name: get cached LLVM libraries
id: retrieve_llvm_libs
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: ${{ inputs.llvm_cache_key }}
fail-on-cache-miss: true
- name: generate iwasm binary release
shell: bash
run: |
cmake -S . -B build ${{ matrix.build_options }}
cmake --build build --config Release --parallel 4
working-directory: ${{ inputs.cwd }}
- name: Compress the binary on Windows
if: inputs.runner == 'windows-latest'
run: |
tar -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm.exe
Compress-Archive -Path iwasm.exe -DestinationPath iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
mv iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
working-directory: ${{ inputs.cwd }}/build/Release
- name: compress the binary on non-Windows
if: inputs.runner != 'windows-latest'
run: |
tar czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
zip iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm
working-directory: ${{ inputs.cwd }}/build
- name: upload release tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ${{ inputs.cwd }}/build/iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
asset_name: iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
asset_content_type: application/x-gzip
- name: upload release zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ${{ inputs.cwd }}/build/iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
asset_name: iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
asset_content_type: application/zip

View File

@ -1,131 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Reusable workflow-build_llvm_libraries
on:
workflow_call:
inputs:
os:
required: true
type: string
arch:
required: true
type: string
container_image:
required: false
type: string
extra_build_llvm_options:
required: false
type: string
default: ""
cache_key_suffix:
required: false
type: string
default: ""
outputs:
cache_key:
description: "A cached key of LLVM libraries"
value: ${{ jobs.build_llvm_libraries.outputs.key}}
permissions:
contents: read
jobs:
build_llvm_libraries:
runs-on: ${{ inputs.os }}
# Using given container image if it is specified.
# Otherwise, it will be ignored by the runner.
container:
image: ${{ inputs.container_image }}
outputs:
key: ${{ steps.create_lib_cache_key.outputs.key}}
permissions:
contents: read
actions: write # for uploading cached artifact
steps:
- name: checkout
uses: actions/checkout@v4
- name: install dependencies for non macos-14
if: inputs.os != 'macos-14'
shell: bash
run: /usr/bin/env python3 -m pip install -r requirements.txt
working-directory: build-scripts
- name: install dependencies for macos-14
if: inputs.os == 'macos-14'
run: /usr/bin/env python3 -m pip install -r requirements.txt --break-system-packages
working-directory: build-scripts
- name: Retrieve the last commit ID
id: get_last_commit
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --llvm-ver)" >> $GITHUB_OUTPUT
working-directory: build-scripts
# Bump the prefix number to evict all previous caches and
# enforce a clean build, in the unlikely case that some
# weird build error occur and llvm/build becomes a potential
# suspect.
- name: form the cache key of libraries
id: create_lib_cache_key
shell: bash
run: |
echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}${{ inputs.cache_key_suffix }}" >> $GITHUB_OUTPUT
- name: Cache LLVM libraries
id: retrieve_llvm_libs
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: ${{ steps.create_lib_cache_key.outputs.key}}
- uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
restore-keys: |
0-ccache-${{ inputs.os }}
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-22.04'
# Don't install dependencies if the cache is hit or running in docker container
- run: sudo apt install -y ccache ninja-build
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'ubuntu') && inputs.container_image == ''
- uses: actions/cache@v4
with:
path: ~/Library/Caches/ccache
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
restore-keys: |
0-ccache-${{ inputs.os }}
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
- run: brew install ccache ninja
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')
- uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
restore-keys: |
0-ccache-${{ inputs.os }}
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'
# Install tools on Windows
- run: choco install -y ccache ninja
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'
- name: Build LLVM libraries
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
shell: bash
run: /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --arch ${{ inputs.arch }}
working-directory: build-scripts

View File

@ -1,269 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: build wamr lldb
on:
workflow_call:
inputs:
arch:
description: arch of the release
type: string
required: false
default: x86_64
runner:
description: OS of compilation
type: string
required: true
upload_url:
description: upload binary assets to the URL of release
type: string
required: true
ver_num:
description: a semantic version number
type: string
required: true
wasi_sdk_url:
description: download WASI_SDK from this URL
type: string
required: false
default: "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz"
permissions:
contents: read
jobs:
try_reuse:
permissions:
contents: write # for uploading release artifacts
uses: ./.github/workflows/reuse_latest_release_binaries.yml
with:
binary_name_stem: "wamr-lldb-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}"
last_commit: "ea63ba4bd010c2285623ad4acc0262a4d63bcfea"
the_path: "./build-scripts/lldb_wasm.patch"
upload_url: ${{ inputs.upload_url }}
build:
needs: try_reuse
if: needs.try_reuse.outputs.result != 'hit'
runs-on: ${{ inputs.runner }}
env:
PYTHON_VERSION: '3.10'
PYTHON_UBUNTU_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz
PYTHON_MACOS_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-apple-darwin-install_only.tar.gz
permissions:
contents: write # for uploading release artifacts
steps:
- uses: actions/checkout@v4
- name: download and install wasi-sdk
run: |
cd /opt
basename=$(basename ${{ inputs.wasi_sdk_url }})
sudo wget --progress=dot:giga ${{ inputs.wasi_sdk_url }}
sudo tar -xzf ${basename}
sudo rm ${basename}
sudo mv wasi-sdk-* wasi-sdk
- name: Cache build
id: lldb_build_cache
uses: actions/cache@v4
with:
path: |
./core/deps/llvm-project/build/bin
./core/deps/llvm-project/build/include
./core/deps/llvm-project/build/lib
./core/deps/llvm-project/build/libexec
./core/deps/llvm-project/build/share
./core/deps/llvm-project/lldb/tools/
./core/deps/llvm-project/wamr-lldb/
key: ${{inputs.arch}}-${{ inputs.runner }}-lldb_build
- name: setup xcode macos
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
# Remove xCode command line tools, to prevent duplicate symbol compilation failures
- name: install utils macos
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
run: |
brew install swig cmake ninja libedit
sudo rm -rf /Library/Developer/CommandLineTools
- name: install utils ubuntu
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
run: sudo apt update && sudo apt-get install -y lld ninja-build
# `git clone` takes ~7m
- name: download llvm
if: steps.lldb_build_cache.outputs.cache-hit != 'true'
run: |
wget https://github.com/llvm/llvm-project/archive/1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
unzip -q 1f27fe6128769f00197925c3b8f6abb9d0e5cd2e.zip
mv llvm-project-1f27fe6128769f00197925c3b8f6abb9d0e5cd2e llvm-project
working-directory: core/deps/
- name: apply wamr patch
if: steps.lldb_build_cache.outputs.cache-hit != 'true'
run: |
git init
git config user.email "action@github.com"
git config user.name "github action"
git apply ../../../build-scripts/lldb_wasm.patch
working-directory: core/deps/llvm-project
- name: get stand-alone python ubuntu
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
run: |
wget ${{ env.PYTHON_UBUNTU_STANDALONE_BUILD }} -O python.tar.gz
tar -xvf python.tar.gz
working-directory: core/deps
- name: get stand-alone python macos
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
run: |
wget ${{ env.PYTHON_MACOS_STANDALONE_BUILD }} -O python.tar.gz
tar -xvf python.tar.gz
working-directory: core/deps
- name: build lldb ubuntu
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
run: |
echo "start to build lldb..."
mkdir -p wamr-lldb
cmake -S ./llvm -B build \
-G Ninja \
-DCMAKE_INSTALL_PREFIX=../wamr-lldb \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLLVM_ENABLE_PROJECTS="clang;lldb" \
-DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \
-DLLVM_BUILD_BENCHMARKS:BOOL=OFF \
-DLLVM_BUILD_DOCS:BOOL=OFF \
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
-DLLVM_BUILD_TESTS:BOOL=OFF \
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
-DLLVM_INCLUDE_DOCS:BOOL=OFF \
-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
-DLLVM_ENABLE_BINDINGS:BOOL=OFF \
-DLLVM_ENABLE_LIBXML2:BOOL=ON \
-DLLVM_ENABLE_LLD:BOOL=ON \
-DLLDB_ENABLE_PYTHON:BOOL=ON \
-DLLDB_EMBED_PYTHON_HOME=ON \
-DLLDB_PYTHON_HOME=.. \
-DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \
-DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}"
cmake --build build --target lldb install --parallel $(nproc)
working-directory: core/deps/llvm-project
- name: validate lldb ubuntu
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
run: |
echo "start to validate lldb..."
mkdir -p wamr-debug
cmake -S product-mini/platforms/linux -B wamr-debug -DWAMR_BUILD_DEBUG_INTERP=1
cmake --build wamr-debug --parallel $(nproc)
export LD_LIBRARY_PATH=$(pwd)/core/deps/python/lib:${LD_LIBRARY_PATH}
python3 ci/validate_lldb.py --port 1239 --lldb core/deps/wamr-lldb/bin/lldb --wamr wamr-debug/iwasm --verbose
working-directory: .
# Define CMAKE_OSX_SYSROOT to avoid the error:
# no such file or directory: 'llvm-project/build/tools/lldb/tools/debugserver/source/mach_excServer.c'
# no such file or directory: 'llvm-project/build/tools/lldb/tools/debugserver/source/mach_excUser.c'
#
# This workaround should be removed when the issue is fixed in llvm-project:
# - https://github.com/llvm/llvm-project/pull/138020/
- name: build lldb macos
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
run: |
echo "start to build lldb..."
mkdir -p wamr-lldb
cmake -S ./llvm -B build \
-G Ninja \
-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path) \
-DCMAKE_INSTALL_PREFIX=../wamr-lldb \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLLVM_ENABLE_PROJECTS="clang;lldb" \
-DLLVM_TARGETS_TO_BUILD:STRING="X86;WebAssembly" \
-DLLVM_BUILD_BENCHMARKS:BOOL=OFF \
-DLLVM_BUILD_DOCS:BOOL=OFF \
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
-DLLVM_BUILD_TESTS:BOOL=OFF \
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
-DLLVM_INCLUDE_DOCS:BOOL=OFF \
-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF \
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
-DLLVM_ENABLE_BINDINGS:BOOL=OFF \
-DLLVM_ENABLE_LIBXML2:BOOL=ON \
-DLLDB_BUILD_FRAMEWORK:BOOL=OFF \
-DLLDB_ENABLE_PYTHON:BOOL=ON \
-DLLDB_EMBED_PYTHON_HOME=ON \
-DLLDB_PYTHON_HOME=.. \
-DLLDB_PYTHON_RELATIVE_PATH=lib/lldb-python \
-DPython3_EXECUTABLE="$(pwd)/../python/bin/python${{ env.PYTHON_VERSION }}"
cmake --build build --target lldb install --parallel $(nproc)
working-directory: core/deps/llvm-project
- name: pack a distribution
if: steps.lldb_build_cache.outputs.cache-hit != 'true'
run: |
mkdir -p wamr-lldb/bin
mkdir -p wamr-lldb/lib
cp build/bin/lldb* wamr-lldb/bin
cp lldb/tools/lldb-vscode/package.json wamr-lldb
cp -r lldb/tools/lldb-vscode/syntaxes/ wamr-lldb
working-directory: core/deps/llvm-project
- name: pack ubuntu specific libraries
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'ubuntu')
run: |
cp build/lib/liblldb*.so wamr-lldb/lib
cp build/lib/liblldb*.so.* wamr-lldb/lib
cp -R build/lib/lldb-python wamr-lldb/lib
cp -R ../python/lib/python* wamr-lldb/lib
cp ../python/lib/libpython${{ env.PYTHON_VERSION }}.so.1.0 wamr-lldb/lib
working-directory: core/deps/llvm-project
- name: pack macos specific libraries
if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos')
run: |
cp build/lib/liblldb*.dylib wamr-lldb/lib
cp -R build/lib/lldb-python wamr-lldb/lib
cp -R ../python/lib/python* wamr-lldb/lib
cp ../python/lib/libpython*.dylib wamr-lldb/lib
install_name_tool -change /install/lib/libpython${{ env.PYTHON_VERSION }}.dylib @rpath/libpython${{ env.PYTHON_VERSION }}.dylib wamr-lldb/lib/liblldb.*.dylib
# Patch path of python library -> https://github.com/indygreg/python-build-standalone/blob/85923ca3911784e6978b85d56e06e9ae75cb2dc4/docs/quirks.rst?plain=1#L412-L446
working-directory: core/deps/llvm-project
- name: compress the binary
run: |
tar czf wamr-lldb-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamr-lldb
zip -r wamr-lldb-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamr-lldb
working-directory: core/deps/llvm-project
- name: upload release tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: core/deps/llvm-project/wamr-lldb-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
asset_name: wamr-lldb-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
asset_content_type: application/x-gzip
- name: upload release zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: core/deps/llvm-project/wamr-lldb-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
asset_name: wamr-lldb-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
asset_content_type: application/zip

View File

@ -1,109 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: build wamr-sdk
on:
workflow_call:
inputs:
arch:
description: arch of the release
type: string
required: false
default: x86_64
config_file:
description: warm-sdk config file path
type: string
required: true
runner:
description: OS of compilation
type: string
required: true
upload_url:
description: upload binary assets to the URL of release
type: string
required: true
ver_num:
description: a semantic version number
type: string
required: true
wasi_sdk_url:
description: download WASI_SDK from this URL
type: string
required: true
wamr_app_framework_url:
description: download WAMR app framework to get wamr_sdk
type: string
required: true
permissions:
contents: read
jobs:
build:
runs-on: ${{ inputs.runner }}
permissions:
contents: write # for uploading release artifacts
steps:
- uses: actions/checkout@v4
- name: download wamr-app-framework
run: |
git clone ${{ inputs.wamr_app_framework_url }}
cd wamr-app-framework
git submodule init
git submodule update
working-directory: wamr-sdk
- name: download and install wasi-sdk
run: |
cd /opt
basename=$(basename ${{ inputs.wasi_sdk_url }})
sudo wget --progress=dot:giga ${{ inputs.wasi_sdk_url }}
sudo tar -xzf ${basename}
sudo rm ${basename}
sudo mv wasi-sdk-* wasi-sdk
- name: download dependencies
run: |
cd ./wamr-app-framework/deps
./download.sh
working-directory: wamr-sdk
- name: generate wamr-sdk release
run: |
cd ./wamr-app-framework/wamr-sdk
./build_sdk.sh -n wamr-sdk -x $(pwd)/${{ inputs.config_file }}
working-directory: wamr-sdk
- name: compress the binary
run: |
cd wamr-app-framework/wamr-sdk/out
tar czf wamr-sdk-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamr-sdk
zip -r wamr-sdk-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamr-sdk
working-directory: wamr-sdk
- name: upload release tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-sdk/wamr-app-framework/wamr-sdk/out/wamr-sdk-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
asset_name: wamr-sdk-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
asset_content_type: application/x-gzip
- name: upload release zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-sdk/wamr-app-framework/wamr-sdk/out/wamr-sdk-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
asset_name: wamr-sdk-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
asset_content_type: application/zip
- name: delete wamr-app-framework
run: |
rm -rf wamr-app-framework
working-directory: wamr-sdk

View File

@ -1,79 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: build wamr-ide vscode extension
on:
workflow_call:
inputs:
upload_url:
description: upload binary assets to the URL of release
type: string
required: true
ver_num:
description: a semantic version number.
type: string
required: true
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: write # for uploading release artifacts
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: set vscode extension to correct version
run: |
npm install -g json
json -I -f package.json -e "this.version=\"${{ inputs.ver_num }}\""
working-directory: test-tools/wamr-ide/VSCode-Extension
- name: generate wamr ide vscode extension
run: |
npm install -g @vscode/vsce
rm -rf node_modules
npm install
vsce package
working-directory: test-tools/wamr-ide/VSCode-Extension
- name: publish wamr ide vscode extension to the vsce marketplace
if: ${{ github.repository == 'bytecodealliance/wasm-micro-runtime' }}
run: |
vsce publish -p ${{ secrets.TOKEN }}
working-directory: test-tools/wamr-ide/VSCode-Extension
- name: compress the vscode extension
run: |
mv wamride-*.vsix wamr-ide.vsix
tar czf wamr-ide-${{ inputs.ver_num }}.tar.gz wamr-ide.vsix
zip wamr-ide-${{ inputs.ver_num }}.zip wamr-ide.vsix
working-directory: test-tools/wamr-ide/VSCode-Extension
- name: upload release tar.gz
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: test-tools/wamr-ide/VSCode-Extension/wamr-ide-${{ inputs.ver_num }}.tar.gz
asset_name: wamr-ide-${{ inputs.ver_num }}.tar.gz
asset_content_type: application/x-gzip
- name: upload release zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: test-tools/wamr-ide/VSCode-Extension/wamr-ide-${{ inputs.ver_num }}.zip
asset_name: wamr-ide-${{ inputs.ver_num }}.zip
asset_content_type: application/zip

View File

@ -1,100 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: build wamrc
on:
workflow_call:
inputs:
arch:
description: arch of the release
type: string
required: false
default: x86_64
llvm_cache_key:
description: the cache key of llvm libraries
type: string
required: true
release:
description: it is a part of the release process
type: boolean
required: true
runner:
description: OS of compilation
type: string
required: true
upload_url:
description: a semantic version number. it is required when `release` is true.
type: string
required: false
ver_num:
description: a semantic version number. it is required when `release` is true.
type: string
required: false
permissions:
contents: read
jobs:
build:
runs-on: ${{ inputs.runner }}
permissions:
contents: write # for uploading release artifacts
steps:
- uses: actions/checkout@v4
- name: get cached LLVM libraries
id: retrieve_llvm_libs
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: ${{ inputs.llvm_cache_key }}
fail-on-cache-miss: true
- name: generate wamrc binary release
run: |
cmake -S . -B build
cmake --build build --config Release --parallel 4
working-directory: wamr-compiler
- name: Compress the binary on Windows
if: inputs.runner == 'windows-latest' && inputs.release
run: |
tar -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
Compress-Archive -Path wamrc.exe -DestinationPath wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
mv wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
working-directory: wamr-compiler/build/Release
- name: compress the binary on non-Windows
if: inputs.runner != 'windows-latest' && inputs.release
run: |
tar czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
working-directory: wamr-compiler/build
- name: upload release tar.gz
if: inputs.release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
asset_content_type: application/x-gzip
- name: upload release zip
if: inputs.release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
asset_content_type: application/zip

View File

@ -1,29 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: confirm version.h stay in sync
on:
workflow_call:
permissions:
contents: read
jobs:
confirm_version:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: cmake execute to generate version.h
run: cmake -B build_version -S .
- name: confirm version.h
run: |
if [ -z "$(git status --porcelain | grep version.h)" ]; then
echo "version.h is in sync"
else
echo "version.h is not in sync"
exit 1
fi

View File

@ -14,15 +14,23 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
compliance_job:
runs-on: ubuntu-22.04
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
cancel_previous:
runs-on: ubuntu-latest
steps:
- name: Cancel Workflow Action
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
complinace_job:
needs: cancel_previous
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 0

View File

@ -1,121 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
name: "CodeQL"
on:
#pull_request:
# types:
# - opened
# branches: '*'
#push:
# branches: [ "main" ]
# midnight UTC
schedule:
- cron: '0 0 * * *'
# allow to be triggered manually
workflow_dispatch:
permissions:
contents: read
jobs:
analyze:
if: github.repository == 'bytecodealliance/wasm-micro-runtime'
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-13') || 'ubuntu-22.04' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
permissions:
contents: read
actions: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3.28.17
with:
languages: ${{ matrix.language }}
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
queries: security-and-quality
# Command-line programs to run using the OS shell.
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
- run: |
./.github/scripts/codeql_buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.28.17
with:
category: "/language:${{matrix.language}}"
upload: false
id: step1
# Filter out rules with low severity or high false positve rate
# Also filter out warnings in third-party code
- name: Filter out unwanted errors and warnings
uses: advanced-security/filter-sarif@v1
with:
patterns: |
-**:cpp/path-injection
-**:cpp/world-writable-file-creation
-**:cpp/poorly-documented-function
-**:cpp/potentially-dangerous-function
-**:cpp/use-of-goto
-**:cpp/integer-multiplication-cast-to-long
-**:cpp/comparison-with-wider-type
-**:cpp/leap-year/*
-**:cpp/ambiguously-signed-bit-field
-**:cpp/suspicious-pointer-scaling
-**:cpp/suspicious-pointer-scaling-void
-**:cpp/unsigned-comparison-zero
-**/cmake*/Modules/**
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
- name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v3.28.17
with:
sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:${{matrix.language}}"
- name: Upload CodeQL results as an artifact
if: success() || failure()
uses: actions/upload-artifact@v4.6.2
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}
retention-days: 10
- name: Fail if an error is found
run: |
./.github/scripts/codeql_fail_on_error.py \
${{ steps.step1.outputs.sarif-output }}/cpp.sarif
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}

File diff suppressed because it is too large Load Diff

View File

@ -1,41 +1,25 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: compilation on macos
name: compilation on macos-latest
on:
# will be triggered on PR events
pull_request:
types:
- opened
- synchronize
paths:
- ".github/workflows/build_llvm_libraries.yml"
paths-ignore:
- "assembly-script/**"
- "ci/**"
- "doc/**"
- "test-tools/**"
- ".github/workflows/compilation_on_macos.yml"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# will be triggered on push events
push:
branches:
- main
- "dev/**"
paths:
- ".github/workflows/build_llvm_libraries.yml"
paths-ignore:
- "assembly-script/**"
- "ci/**"
- "doc/**"
- "test-tools/**"
- ".github/workflows/compilation_on_macos.yml"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# allow to be triggered manually
workflow_dispatch:
@ -46,51 +30,69 @@ concurrency:
cancel-in-progress: true
env:
# 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
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"
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"
MC_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"
LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
jobs:
build_llvm_libraries_on_intel_macos:
permissions:
contents: read
actions: write
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "macos-13"
arch: "X86"
build_llvm_libraries_on_arm_macos:
permissions:
contents: read
actions: write
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "macos-14"
arch: "AArch64 ARM"
build_wamrc:
needs: [build_llvm_libraries_on_intel_macos]
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
cancel_previous:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-13
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
os: [macos-latest]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Cancel Workflow Action
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
- name: Get LLVM libraries
id: retrieve_llvm_libs
uses: actions/cache@v4
# set different traffic lights based on the current repo and the running OS.
# according to light colors, the workflow will run different jobs
check_repo:
needs: cancel_previous
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
outputs:
traffic_light: ${{ steps.do_check.outputs.light }}
steps:
- name: do_check
id: do_check
if: ${{ matrix.os == 'macos-latest' }}
run: |
if [[ ${{ github.repository }} == */wasm-micro-runtime ]]; then
echo "::set-output name=light::green"
else
echo "::set-output name=light::red"
fi
build_llvm_libraries:
needs: check_repo
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
include:
- os: macos-latest
light: ${{ needs.check_repo.outputs.traffic_light }}
steps:
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: checkout
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: Cache LLVM libraries
id: cache_llvm
if: ${{ matrix.light == 'green' }}
uses: actions/cache@v3
with:
path: |
./core/deps/llvm/build/bin
@ -98,13 +100,50 @@ jobs:
./core/deps/llvm/build/lib
./core/deps/llvm/build/libexec
./core/deps/llvm/build/share
key: ${{ matrix.llvm_cache_key }}
key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
- name: Build llvm and clang from source
id: build_llvm
if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
run: /usr/bin/env python3 ./build_llvm.py --arch X86 WebAssembly
working-directory: build-scripts
build_wamrc:
needs: [build_llvm_libraries, check_repo]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
include:
- os: macos-latest
light: ${{ needs.check_repo.outputs.traffic_light }}
steps:
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: checkout
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: Get LLVM libraries
id: cache_llvm
if: ${{ matrix.light == 'green' }}
uses: actions/cache@v3
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.os }}-${{ env.LLVM_CACHE_SUFFIX }}
- name: Quit if cache miss
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: Build wamrc
if: ${{ matrix.light == 'green' }}
run: |
mkdir build && cd build
cmake ..
@ -112,7 +151,7 @@ jobs:
working-directory: wamr-compiler
build_iwasm:
needs: [build_llvm_libraries_on_intel_macos]
needs: [build_llvm_libraries, check_repo]
runs-on: ${{ matrix.os }}
strategy:
matrix:
@ -121,8 +160,8 @@ jobs:
$AOT_BUILD_OPTIONS,
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
$LLVM_LAZY_JIT_BUILD_OPTIONS,
$LLVM_EAGER_JIT_BUILD_OPTIONS,
$LAZY_JIT_BUILD_OPTIONS,
$MC_JIT_BUILD_OPTIONS,
]
make_options_feature: [
# Features
@ -132,7 +171,6 @@ jobs:
"-DWAMR_BUILD_DEBUG_INTERP=1",
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
"-DWAMR_BUILD_LIB_PTHREAD=1",
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
"-DWAMR_BUILD_MINI_LOADER=1",
"-DWAMR_BUILD_MEMORY_PROFILING=1",
@ -143,15 +181,17 @@ jobs:
"-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
]
os: [macos-13]
os: [macos-latest]
platform: [darwin]
exclude:
# incompatible feature and platform
# incompatible mode and feature
# MULTI_MODULE only on INTERP mode and AOT mode
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
# uncompatiable feature and platform
# uncompatiable mode and feature
# MULTI_MODULE only on INTERP mode
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
# SIMD only on JIT/AOT mode
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
@ -161,9 +201,9 @@ jobs:
# DEBUG_INTERP only on CLASSIC INTERP mode
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
@ -173,29 +213,33 @@ jobs:
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
# TODO: DEBUG_AOT on JIT
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
# MINI_LOADER only on INTERP mode
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
- make_options_run_mode: $LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
- make_options_run_mode: $MC_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
include:
- os: macos-13
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
- os: macos-latest
light: ${{ needs.check_repo.outputs.traffic_light }}
steps:
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: checkout
uses: actions/checkout@v4
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
# only download llvm cache when needed
- name: Get LLVM libraries
id: retrieve_llvm_libs
if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')
uses: actions/cache@v4
id: cache_llvm
if: (matrix.light == 'green') && (endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS'))
uses: actions/cache@v3
with:
path: |
./core/deps/llvm/build/bin
@ -203,13 +247,14 @@ jobs:
./core/deps/llvm/build/lib
./core/deps/llvm/build/libexec
./core/deps/llvm/build/share
key: ${{ matrix.llvm_cache_key }}
key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
- name: Quit if cache miss
if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
if: (matrix.light == 'green') && (endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS')) && (steps.cache_llvm.outputs.cache-hit != 'true')
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: Build iwasm
if: ${{ matrix.light == 'green' }}
run: |
mkdir build && cd build
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
@ -217,202 +262,132 @@ jobs:
working-directory: product-mini/platforms/${{ matrix.platform }}
build_samples_wasm_c_api:
needs:
[
build_iwasm,
build_llvm_libraries_on_intel_macos,
build_wamrc,
]
needs: [build_iwasm, check_repo]
runs-on: ${{ matrix.os }}
strategy:
matrix:
make_options: [
$AOT_BUILD_OPTIONS,
# Running mode
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
$FAST_JIT_BUILD_OPTIONS,
$LLVM_LAZY_JIT_BUILD_OPTIONS,
$LLVM_EAGER_JIT_BUILD_OPTIONS,
$MULTI_TIER_JIT_BUILD_OPTIONS,
# doesn't support
#$LAZY_JIT_BUILD_OPTIONS,
#$MC_JIT_BUILD_OPTIONS,
#$AOT_BUILD_OPTIONS,
]
os: [macos-13]
os: [macos-latest]
include:
- os: macos-13
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
- os: macos-latest
light: ${{ needs.check_repo.outputs.traffic_light }}
wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz
wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-macos.tar.gz
steps:
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: checkout
uses: actions/checkout@v4
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- 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'))
- name: download and install wabt
if: ${{ matrix.light == 'green' }}
run: |
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
working-directory: wamr-compiler
cd /opt
sudo wget ${{ matrix.wabt_release }}
sudo tar -xzf wabt-1.0.24-*.tar.gz
sudo mv wabt-1.0.24 wabt
- name: Build Sample [wasm-c-api]
if: ${{ matrix.light == 'green' }}
run: |
VERBOSE=1
cmake -S . -B build ${{ matrix.make_options }}
cmake --build build --config Debug --parallel 4
ctest --test-dir build --output-on-failure
mkdir build && cd build
cmake .. ${{ matrix.make_options }}
cmake --build . --config Release --parallel 4
./callback
./callback_chain
./empty_imports
./global
./hello
./hostref
./memory
./reflect
./table
./trap
working-directory: samples/wasm-c-api
build_samples_others:
needs: [build_iwasm, build_wamrc, build_llvm_libraries_on_intel_macos, build_llvm_libraries_on_arm_macos]
needs: [build_iwasm, check_repo]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, macos-14]
include:
- os: macos-13
llvm_cache_key: ${{ needs.build_llvm_libraries_on_intel_macos.outputs.cache_key }}
- os: macos-14
llvm_cache_key: ${{ needs.build_llvm_libraries_on_arm_macos.outputs.cache_key }}
- os: macos-latest
light: ${{ needs.check_repo.outputs.traffic_light }}
wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz
wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-macos.tar.gz
steps:
- name: checkout
uses: actions/checkout@v4
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- name: checkout
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: download and install wasi-sdk
if: ${{ matrix.light == 'green' }}
run: |
cd /opt
sudo wget ${{ matrix.wasi_sdk_release }}
sudo tar -xzf wasi-sdk-12.0-*.tar.gz
sudo mv wasi-sdk-12.0 wasi-sdk
- name: download and install wabt
if: ${{ matrix.light == 'green' }}
run: |
cd /opt
sudo wget ${{ matrix.wabt_release }}
sudo tar -xzf wabt-1.0.24-*.tar.gz
sudo mv wabt-1.0.24 wabt
- name: Build Sample [basic]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/basic
./build.sh
./run.sh
- name: Build Sample [file]
run: |
cd samples/file
mkdir build && cd build
cmake ..
cmake --build . --config Debug --parallel 4
./src/iwasm -f wasm-app/file.wasm -d .
- name: Build Sample [multi-thread]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/multi-thread
mkdir build && cd build
cmake ..
cmake --build . --config Debug --parallel 4
cmake --build . --config Release --parallel 4
./iwasm wasm-apps/test.wasm
- name: Build Sample [multi-module]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/multi-module
mkdir build && cd build
cmake ..
cmake --build . --config Debug --parallel 4
./multi_module mC.wasm
cmake --build . --config Release --parallel 4
./multi_module
- name: Build Sample [spawn-thread]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/spawn-thread
mkdir build && cd build
cmake ..
cmake --build . --config Debug --parallel 4
cmake --build . --config Release --parallel 4
./spawn_thread
- name: Build Sample [ref-types]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/ref-types
mkdir build && cd build
cmake ..
cmake --build . --config Debug --parallel 4
./hello
- name: Get LLVM libraries
id: retrieve_llvm_libs
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: Build wamrc
run: |
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
working-directory: wamr-compiler
# cmake --build . --config Debug --parallel 4
- name: Build Sample [wasi-threads]
run: |
cd samples/wasi-threads
mkdir build && cd build
cmake ..
cmake --build . --config Debug --verbose
./iwasm wasm-apps/no_pthread.wasm
../../../wamr-compiler/build/wamrc --size-level=0 --enable-multi-thread -o wasm-apps/no_pthread.aot wasm-apps/no_pthread.wasm
./iwasm wasm-apps/no_pthread.aot
- name: Build Sample [shared-module]
run: |
cd samples/shared-module
./build.sh
./run.sh
- name: Build Sample [terminate]
run: |
cd samples/terminate
./build.sh
./run.sh
- name: Build Sample [debug-tools]
run: |
cd samples/debug-tools
mkdir build && cd build
cmake ..
cmake --build . --config Debug --parallel 4
./iwasm wasm-apps/trap.wasm | grep "#" > call_stack.txt
./iwasm wasm-apps/trap.aot | grep "#" > call_stack_aot.txt
bash -x ../symbolicate.sh
- name: Build Sample [native-stack-overflow]
run: |
cd samples/native-stack-overflow
./build.sh
./run.sh test1
./run.sh test2
- name: Build Sample [shared-heap]
run: |
cd samples/shared-heap
mkdir build && cd build
cmake ..
cmake --build . --config Debug --parallel 4
./shared_heap_test
./shared_heap_test --aot
./hello

View File

@ -6,34 +6,18 @@ name: compilation on nuttx
on:
# will be triggered on PR events
pull_request:
types:
- opened
- synchronize
paths:
- ".github/workflows/compilation_on_nuttx.yml"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
paths-ignore:
- "assembly-script/**"
- "ci/**"
- "doc/**"
- "test-tools/**"
# will be triggered on push events
push:
branches:
- main
- "dev/**"
paths:
- ".github/workflows/compilation_on_nuttx.yml"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
paths-ignore:
- "assembly-script/**"
- "ci/**"
- "doc/**"
- "test-tools/**"
# allow to be triggered manually
workflow_dispatch:
@ -43,104 +27,87 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
WASI_SDK_PATH: "/opt/wasi-sdk"
permissions:
contents: read
jobs:
build_iwasm_on_nuttx:
runs-on: ubuntu-latest
container:
image: ghcr.io/apache/nuttx/apache-nuttx-ci-linux@sha256:d9261eacf6c6ebe656c571757751c803e8f04c3ae9b820320a5ea5dd57b7205a
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
cancel_previous:
runs-on: ubuntu-22.04
steps:
- name: Cancel Workflow Action
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
build_iwasm_on_nuttx:
runs-on: ubuntu-22.04
strategy:
matrix:
nuttx_board_config: [
nuttx_board_config : [
# x64
"boards/sim/sim/sim/configs/nsh",
# cortex-m0
"boards/arm/rp2040/raspberrypi-pico/configs/nsh",
# cortex-m4
"boards/arm/stm32/stm32f4discovery/configs/nsh",
# cortex-m7
"boards/arm/stm32h7/nucleo-h743zi/configs/nsh",
# riscv32gc
# cortex-a9
"boards/arm/imx6/sabre-6quad/configs/nsh",
# riscv32imac
"boards/risc-v/qemu-rv/rv-virt/configs/nsh",
# riscv64gc
# riscv64imac
"boards/risc-v/qemu-rv/rv-virt/configs/nsh64",
# arm64
"boards/arm64/qemu/qemu-armv8a/configs/nsh",
# riscv64gc
"boards/risc-v/k210/maix-bit/configs/nsh",
]
wamr_config_option: [
"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_FAST=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_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: Install Utilities
run: sudo apt install -y kconfig-frontends-nox genromfs
- name: Install ARM Compilers
if: ${{ contains(matrix.nuttx_board_config, 'arm') }}
run: sudo apt install -y gcc-arm-none-eabi
- name: Install RISC-V Compilers
if: ${{ contains(matrix.nuttx_board_config, 'risc-v') }}
run: sudo apt install -y gcc-riscv64-unknown-elf
- name: Checkout NuttX
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: apache/nuttx
ref: releases/12.9
repository: apache/incubator-nuttx
path: nuttx
- name: Checkout NuttX Apps
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: apache/nuttx-apps
ref: releases/12.9
repository: apache/incubator-nuttx-apps
path: apps
- name: Checkout WAMR
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
repository: ${{ github.repository }}
path: apps/interpreters/wamr/wamr
- name: Configure WAMR
working-directory: nuttx
run: |
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: Enable WAMR for NuttX
run: |
find nuttx/boards -name defconfig | xargs sed -i '$a\CONFIG_EOL_IS_CR=y\n${{ matrix.wamr_config_option }}'
find nuttx/boards/sim -name defconfig | xargs sed -i '$a\CONFIG_LIBM=y\n'
find nuttx/boards/risc-v -name defconfig | xargs sed -i '$a\CONFIG_LIBM=y\n'
- name: Build
working-directory: nuttx
run: make -j$(nproc) EXTRAFLAGS=-Werror
- name: Checkout Bloaty
uses: actions/checkout@v4
with:
repository: google/bloaty
submodules: recursive
path: bloaty
ref: 34f4a66559ad4938c1e629e9b5f54630b2b4d7b0
- name: Build Bloaty
run: |
cmake -Bbuild -GNinja bloaty
cmake --build build
- name: Size Report
run: |
echo "Build target: ${{ matrix.nuttx_board_config }}"
echo "WAMR build config: ${{ matrix.wamr_config_option }}"
echo "WAMR size:"
build/bloaty -d compileunits --source-filter wamr nuttx/nuttx
echo "libc-builtin size (if enabled):"
build/bloaty -d compileunits --source-filter libc-builtin nuttx/nuttx
echo "libc-wasi size (if enabled):"
build/bloaty -d compileunits --source-filter libc-wasi nuttx/nuttx
cd nuttx
tools/configure.sh ${{ matrix.nuttx_board_config }}
make -j$(nproc)

View File

@ -6,36 +6,20 @@ name: compilation on SGX
on:
# will be triggered on PR events
pull_request:
types:
- opened
- synchronize
paths:
- ".github/workflows/build_llvm_libraries.yml"
paths-ignore:
- "assembly-script/**"
- "ci/**"
- "doc/**"
- "test-tools/**"
- ".github/workflows/compilation_on_sgx.yml"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# will be triggered on push events
push:
branches:
- main
- "dev/**"
paths:
- ".github/workflows/build_llvm_libraries.yml"
paths-ignore:
- "assembly-script/**"
- "ci/**"
- "doc/**"
- "test-tools/**"
- ".github/workflows/compilation_on_sgx.yml"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# allow to be triggered manually
workflow_dispatch:
@ -46,44 +30,97 @@ concurrency:
cancel-in-progress: true
env:
# ref types enabled in wamrc by default, so we need to enable it for iwasm in AOT mode
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 -DWAMR_BUILD_REF_TYPES=1"
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 -DWAMR_BUILD_SIMD=0"
FAST_JIT_BUILD_OPTIONS: "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_LAZY_JIT=1"
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 Spec Test
DEFAULT_TEST_OPTIONS: "-s spec -x -p -b"
SIMD_TEST_OPTIONS: "-s spec -x -p -b -S"
XIP_TEST_OPTIONS: "-s spec -x -p -b -X"
permissions:
contents: read
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"
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"
MC_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"
LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
jobs:
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
cancel_previous:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- name: Cancel Workflow Action
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
# set different traffic lights based on the current repo and the running OS.
# according to light colors, the workflow will run different jobs
check_repo:
needs: cancel_previous
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
outputs:
traffic_light_on_ubuntu_2004: ${{ steps.do_check_on_ubuntu_2004.outputs.light }}
steps:
- name: do_check_on_ubuntu_2004
id: do_check_on_ubuntu_2004
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
if [[ ${{ github.repository }} == */wasm-micro-runtime ]]; then
echo "::set-output name=light::green"
else
echo "::set-output name=light::green"
fi
build_llvm_libraries:
permissions:
contents: read
actions: write
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: ubuntu-22.04
arch: "X86"
needs: check_repo
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
include:
- os: ubuntu-20.04
light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
steps:
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: checkout
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: Cache LLVM libraries
id: cache_llvm
if: ${{ matrix.light == 'green' }}
uses: actions/cache@v3
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.os }}-${{ env.LLVM_CACHE_SUFFIX }}
- name: Build llvm and clang from source
id: build_llvm
if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
run: /usr/bin/env python3 ./build_llvm.py --arch X86 WebAssembly --project clang lldb
working-directory: build-scripts
build_iwasm:
needs: [check_repo]
runs-on: ${{ matrix.os }}
strategy:
matrix:
make_options_run_mode: [
# Running modes supported
# Running mode
$AOT_BUILD_OPTIONS,
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
$FAST_JIT_BUILD_OPTIONS,
# Running modes unsupported
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
# doesn't support
# $LAZY_JIT_BUILD_OPTIONS,
# $MC_JIT_BUILD_OPTIONS,
]
make_options_feature: [
# Features
@ -93,7 +130,6 @@ jobs:
# "-DWAMR_BUILD_DEBUG_INTERP=1",
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
"-DWAMR_BUILD_LIB_PTHREAD=1",
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
"-DWAMR_BUILD_MINI_LOADER=1",
"-DWAMR_BUILD_MEMORY_PROFILING=1",
@ -101,165 +137,88 @@ jobs:
"-DWAMR_BUILD_PERF_PROFILING=1",
"-DWAMR_BUILD_REF_TYPES=1",
# doesn't support
"-DWAMR_BUILD_SIMD=0",
# "-DWAMR_BUILD_SIMD=1",
"-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_SGX_IPFS=1",
]
os: [ubuntu-22.04]
os: [ubuntu-20.04]
platform: [linux-sgx]
exclude:
# incompatible mode and feature
# uncompatiable mode and feature
# MULTI_MODULE only on INTERP mode
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
# MINI_LOADER only on INTERP mode
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
include:
- os: ubuntu-20.04
light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: install SGX SDK and necessary libraries
uses: ./.github/actions/install-linux-sgx
with:
os: ${{ matrix.os }}
if: ${{ matrix.light == 'green' }}
run: |
mkdir -p /opt/intel
cd /opt/intel
wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
sudo apt update
sudo apt install -y libsgx-launch libsgx-urts
source /opt/intel/sgxsdk/environment
- name: checkout
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: Build iwasm
if: ${{ matrix.light == 'green' }}
run: |
mkdir build && cd build
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
cmake --build . --config Release --parallel 4
cd ../enclave-sample
make
working-directory: product-mini/platforms/${{ matrix.platform }}
run_samples_file:
needs: [build_iwasm, build_llvm_libraries]
build_wamrc:
needs: [build_llvm_libraries, check_repo]
runs-on: ${{ matrix.os }}
strategy:
matrix:
iwasm_make_options_run_mode: [
# Running modes supported
$AOT_BUILD_OPTIONS,
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
$FAST_JIT_BUILD_OPTIONS,
# Running modes unsupported
#$LLVM_LAZY_JIT_BUILD_OPTIONS,
#$LLVM_EAGER_JIT_BUILD_OPTIONS,
]
os: [ubuntu-22.04]
iwasm_make_options_feature: [
# Features to be tested: IPFS
"-DWAMR_BUILD_SGX_IPFS=1",
]
platform: [linux-sgx]
os: [ubuntu-20.04]
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
- os: ubuntu-20.04
light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: install SGX SDK and necessary libraries
uses: ./.github/actions/install-linux-sgx
with:
os: ${{ matrix.os }}
- name: Build iwasm for testing samples
run: |
mkdir build && cd build
cmake .. ${{ matrix.iwasm_make_options_run_mode }} ${{ matrix.iwasm_make_options_feature }}
cmake --build . --config Release --parallel 4
cd ../enclave-sample
make
working-directory: product-mini/platforms/${{ matrix.platform }}
- name: Get LLVM libraries
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
id: retrieve_llvm_libs
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 }}
fail-on-cache-miss: true
- name: Build wamrc only for testing samples in aot mode
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
run: |
cmake -S . -B build
cmake --build build --config Release --parallel 4
cp build/wamrc ../product-mini/platforms/${{ matrix.platform }}/enclave-sample
working-directory: wamr-compiler
- name: Build Sample [file]
run: |
cmake -S . -B build
cmake --build build --config Debug --parallel 4
cp build/wasm-app/file.wasm ../../product-mini/platforms/${{ matrix.platform }}/enclave-sample
working-directory: samples/file
- name: Test Sample [file] in non-aot mode
if: matrix.iwasm_make_options_run_mode != '$AOT_BUILD_OPTIONS'
if: ${{ matrix.light == 'green' }}
run: |
mkdir -p /opt/intel
cd /opt/intel
wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
sudo apt update
sudo apt install -y libsgx-launch libsgx-urts
source /opt/intel/sgxsdk/environment
./iwasm --dir=. ./file.wasm
working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
- name: Test Sample [file] in aot mode
if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS'
run: |
source /opt/intel/sgxsdk/environment
./wamrc -sgx -o ./file.aot ./file.wasm
./iwasm --dir=. ./file.aot
working-directory: product-mini/platforms/${{ matrix.platform }}/enclave-sample
spec_test_default:
needs: [build_iwasm, build_llvm_libraries]
runs-on: ${{ matrix.os }}
strategy:
matrix:
#(workaround) disable "fast-interp" because of SIMDE
running_mode: ["classic-interp", "aot", "fast-jit"]
test_option:
[$DEFAULT_TEST_OPTIONS, $SIMD_TEST_OPTIONS, $XIP_TEST_OPTIONS]
os: [ubuntu-22.04]
exclude:
# classic-interp, fast-interp and fast-jit don't support simd
- running_mode: "classic-interp"
test_option: $SIMD_TEST_OPTIONS
- running_mode: "fast-interp"
test_option: $SIMD_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $SIMD_TEST_OPTIONS
# classic-interp, fast-interp and fast jit don't support XIP
- running_mode: "classic-interp"
test_option: $XIP_TEST_OPTIONS
- running_mode: "fast-interp"
test_option: $XIP_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $XIP_TEST_OPTIONS
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: Get LLVM libraries
if: matrix.running_mode == 'aot'
id: retrieve_llvm_libs
uses: actions/cache@v4
id: cache_llvm
if: ${{ matrix.light == 'green' }}
uses: actions/cache@v3
with:
path: |
./core/deps/llvm/build/bin
@ -267,51 +226,231 @@ jobs:
./core/deps/llvm/build/lib
./core/deps/llvm/build/libexec
./core/deps/llvm/build/share
key: ${{ matrix.llvm_cache_key }}
key: ${{ matrix.os }}-${{ env.LLVM_CACHE_SUFFIX }}
- name: Quit if cache miss
if: matrix.running_mode == 'aot' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: install SGX SDK and necessary libraries
uses: ./.github/actions/install-linux-sgx
with:
os: ${{ matrix.os }}
#workaround about a https://github.com/actions/runner-images/issues/6680#issuecomment-2640923706
- name: Increase swapfile
- name: Build wamrc
if: ${{ matrix.light == 'green' }}
run: |
sudo swapoff -a
sudo fallocate -l 15G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
working-directory: wamr-compiler
build_samples_wasm_c_api:
needs: [build_iwasm, check_repo]
runs-on: ${{ matrix.os }}
strategy:
matrix:
make_options: [
# Running mode
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
# doesn't support
#$LAZY_JIT_BUILD_OPTIONS,
#$MC_JIT_BUILD_OPTIONS,
#$AOT_BUILD_OPTIONS,
]
os: [ubuntu-20.04]
include:
- os: ubuntu-20.04
light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-ubuntu.tar.gz
steps:
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: checkout
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: download and install wabt
if: ${{ matrix.light == 'green' }}
run: |
cd /opt
sudo wget ${{ matrix.wabt_release }}
sudo tar -xzf wabt-1.0.24-*.tar.gz
sudo mv wabt-1.0.24 wabt
- name: install SGX SDK and necessary libraries
if: ${{ matrix.light == 'green' }}
run: |
mkdir -p /opt/intel
cd /opt/intel
wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
sudo apt update
sudo apt install -y libsgx-launch libsgx-urts
source /opt/intel/sgxsdk/environment
- name: Build Sample [wasm-c-api]
if: ${{ matrix.light == 'green' }}
run: |
mkdir build && cd build
cmake .. ${{ matrix.make_options }}
cmake --build . --config Release --parallel 4
./callback
./callback_chain
./empty_imports
./global
./hello
./hostref
./memory
./reflect
./table
./trap
working-directory: samples/wasm-c-api
build_samples_others:
needs: [build_iwasm, check_repo]
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-20.04
light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
wasi_sdk_release: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
wabt_release: https://github.com/WebAssembly/wabt/releases/download/1.0.24/wabt-1.0.24-ubuntu.tar.gz
steps:
- name: light status
run: echo "matrix.os=${{ matrix.os }}, light=${{ matrix.light }}"
- name: checkout
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: download and install wasi-sdk
if: ${{ matrix.light == 'green' }}
run: |
cd /opt
sudo wget ${{ matrix.wasi_sdk_release }}
sudo tar -xzf wasi-sdk-12.0-*.tar.gz
sudo mv wasi-sdk-12.0 wasi-sdk
- name: download and install wabt
if: ${{ matrix.light == 'green' }}
run: |
cd /opt
sudo wget ${{ matrix.wabt_release }}
sudo tar -xzf wabt-1.0.24-*.tar.gz
sudo mv wabt-1.0.24 wabt
- name: install SGX SDK and necessary libraries
if: ${{ matrix.light == 'green' }}
run: |
mkdir -p /opt/intel
cd /opt/intel
wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
sudo apt update
sudo apt install -y libsgx-launch libsgx-urts
source /opt/intel/sgxsdk/environment
- name: Build Sample [basic]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/basic
./build.sh
./run.sh
- name: Build Sample [multi-thread]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/multi-thread
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./iwasm wasm-apps/test.wasm
- name: Build Sample [multi-module]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/multi-module
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./multi_module
- name: Build Sample [spawn-thread]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/spawn-thread
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./spawn_thread
- name: Build Sample [ref-types]
if: ${{ matrix.light == 'green' }}
run: |
cd samples/ref-types
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./hello
spec_test_default:
needs: [build_iwasm, build_llvm_libraries, build_wamrc, check_repo]
runs-on: ubuntu-20.04
strategy:
matrix:
running_mode: ["classic-interp", "fast-interp", "aot"]
test_option: ["-x -p -s spec -P", "-x -p -s spec -S -P"]
include:
- os: ubuntu-20.04
light: ${{ needs.check_repo.outputs.traffic_light_on_ubuntu_2004 }}
steps:
- name: checkout
if: ${{ matrix.light == 'green' }}
uses: actions/checkout@v3
- name: Get LLVM libraries
if: ${{ matrix.light == 'green' }}
id: cache_llvm
uses: actions/cache@v3
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: ubuntu-20.04-${{ env.LLVM_CACHE_SUFFIX }}
- name: Quit if cache miss
if: ${{ matrix.light == 'green' && steps.cache_llvm.outputs.cache-hit != 'true' }}
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: install Ninja
if: ${{ matrix.light == 'green' }}
run: sudo apt install -y ninja-build
- name: install SGX SDK and necessary libraries
if: ${{ matrix.light == 'green' }}
run: |
mkdir -p /opt/intel
cd /opt/intel
wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
chmod +x sgx_linux_x64_sdk_2.15.100.3.bin
echo 'yes' | ./sgx_linux_x64_sdk_2.15.100.3.bin
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
sudo apt update
sudo apt install -y libsgx-launch libsgx-urts
- name: run spec tests
if: ${{ matrix.light == 'green' }}
run: |
set +e
source /opt/intel/sgxsdk/environment
attempts=0
max_attempts=3
while [ $attempts -lt $max_attempts ]; do
./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
exitcode="$?"
if [ $exitcode -eq 0 ]; then
echo "Spec test passed"
exit 0
elif [ $exitcode -ne 143 ]; then
echo "Spec test failed with error code $exitcode"
exit 1
fi
echo "$exitcode is a known GitHub-hosted runner issue"
echo "::notice::Re-running the spec test due to error code 143"
attempts=$((attempts + 1))
done
echo "::notice::Report an error with code 143 in SGX CI after $max_attempts attempts"
exit 143
./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
working-directory: ./tests/wamr-test-suites

View File

@ -6,132 +6,110 @@ name: compilation on windows-latest
on:
# will be triggered on PR events
pull_request:
types:
- opened
- synchronize
paths:
paths-ignore:
- "assembly-script/**"
- "ci/**"
- "doc/**"
- "test-tools/**"
- ".github/workflows/compilation_on_windows.yml"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# will be triggered on push events
push:
branches:
- main
- "dev/**"
paths:
paths-ignore:
- "assembly-script/**"
- "ci/**"
- "doc/**"
- "test-tools/**"
- ".github/workflows/compilation_on_windows.yml"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# allow to be triggered manually
workflow_dispatch:
env:
# For Spec Test
DEFAULT_TEST_OPTIONS: "-s spec -b"
MULTI_MODULES_TEST_OPTIONS: "-s spec -b -M"
THREADS_TEST_OPTIONS: "-s spec -b -p"
WASI_TEST_OPTIONS: "-s wasi_certification -w"
WASI_TEST_FILTER: ${{ github.workspace }}/product-mini/platforms/windows/wasi_filtered_tests.json
# Used when building the WASI socket and thread tests
CC: ${{ github.workspace }}/wasi-sdk/bin/clang
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
cancel_previous:
runs-on: windows-latest
strategy:
matrix:
build_options: [
"-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0",
"-DWAMR_BUILD_AOT=0",
"-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_REF_TYPES=1",
"-DWAMR_BUILD_SIMD=1",
"-DWAMR_BUILD_DEBUG_INTERP=1",
"-DWAMR_BUILD_LIB_PTHREAD=1",
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
"-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1"
]
steps:
- uses: actions/checkout@v4
- name: Cancel Workflow Action
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}
build:
needs: cancel_previous
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: clone uvwasi library
if: ${{ !contains(matrix.build_options, '-DWAMR_BUILD_LIBC_UVWASI=0') }}
run: |
cd core/deps
git clone https://github.com/nodejs/uvwasi.git
- name: Build iwasm
- name: Build iwasm [default]
run: |
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. ${{ matrix.build_options }}
cmake ..
cmake --build . --config Release --parallel 4
test:
runs-on: windows-latest
needs: [build]
strategy:
fail-fast: false
matrix:
running_mode:
[
"classic-interp",
"fast-interp",
]
test_option:
[
$DEFAULT_TEST_OPTIONS,
$MULTI_MODULES_TEST_OPTIONS,
$THREADS_TEST_OPTIONS,
$WASI_TEST_OPTIONS,
]
steps:
- name: checkout
uses: actions/checkout@v4
- name: download and install wasi-sdk
if: matrix.test_option == '$WASI_TEST_OPTIONS'
cd .. && rm -force -r build
- name: Build iwasm [aot only]
run: |
curl "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0.m-mingw.tar.gz" -o wasi-sdk.tar.gz -L
mkdir wasi-sdk
tar -xzf wasi-sdk.tar.gz -C wasi-sdk --strip-components 1
- name: build socket api tests
shell: bash
if: matrix.test_option == '$WASI_TEST_OPTIONS'
run: ./build.sh
working-directory: ./core/iwasm/libraries/lib-socket/test/
- name: Build WASI thread tests
shell: bash
if: matrix.test_option == '$WASI_TEST_OPTIONS'
run: ./build.sh
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
- name: run tests
shell: bash
timeout-minutes: 20
run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
working-directory: ./tests/wamr-test-suites
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0
cmake --build . --config Release --parallel 4
cd .. && rm -force -r build
- name: Build iwasm [interp only]
run: |
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. -DWAMR_BUILD_AOT=0
cmake --build . --config Release --parallel 4
cd .. && rm -force -r build
- name: Build iwasm [tail call]
run: |
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. -DWAMR_BUILD_TAIL_CALL=1
cmake --build . --config Release --parallel 4
cd .. && rm -force -r build
- name: Build iwasm [custom name section]
run: |
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. -DWAMR_BUILD_CUSTOM_NAME_SECTION=1
cmake --build . --config Release --parallel 4
cd .. && rm -force -r build
- name: Build iwasm [disable hardware boundary check]
run: |
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. -DWAMR_DISABLE_HW_BOUND_CHECK=1
cmake --build . --config Release --parallel 4
cd .. && rm -force -r build
- name: Build iwasm [reference types]
run: |
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. -DWAMR_BUILD_REF_TYPES=1
cmake --build . --config Release --parallel 4
cd .. && rm -force -r build
- name: Build iwasm [128-bit SIMD]
run: |
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. -DWAMR_BUILD_SIMD=1
cmake --build . --config Release --parallel 4
cd .. && rm -force -r build
- name: Build iwasm [source debugger]
run: |
cd product-mini/platforms/windows
mkdir build && cd build
cmake .. -DWAMR_BUILD_DEBUG_INTERP=1
cmake --build . --config Release --parallel 4
cd .. && rm -force -r build

View File

@ -1,87 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: create a tag
on:
workflow_call:
outputs:
minor_version:
description: "the new version is a minor version or a major version"
value: ${{ jobs.create_tag.outputs.minor_version}}
new_ver:
description: "the new version"
value: ${{ jobs.create_tag.outputs.new_ver}}
new_tag:
description: "the new tag just created"
value: ${{ jobs.create_tag.outputs.new_tag}}
permissions:
contents: read
jobs:
create_tag:
runs-on: ubuntu-latest
outputs:
minor_version: ${{ steps.preparation.outputs.minor_version }}
new_ver: ${{ steps.preparation.outputs.new_ver }}
new_tag: ${{ steps.preparation.outputs.new_tag }}
permissions:
contents: write # create and push tags
steps:
- uses: actions/checkout@v4
# Full git history is needed to get a proper list of commits and tags
with:
fetch-depth: 0
- name: prepare
id: preparation
run: |
# show latest 3 versions on the branch that create release
# Set the initial commit to the head of the branch
commit="HEAD"
#
# Loop to get the three most recent tags
for i in {1..3}
do
# Get the most recent tag reachable from the current commit
tag=$(git describe --tags --abbrev=0 $commit)
# Print the tag
echo "$tag"
# Move to the commit before the found tag to find the next tag in the next iteration
commit=$(git rev-list -n 1 $tag^)
done
# compare latest git tag and semantic version definition
result=$(python3 ./.github/scripts/fetch_and_compare_version.py)
echo "script result is ${result}"
#
# return in a form like "WAMR-X.Y.Z,major_minor_change" or ",patch_change"
new_ver=$(echo "${result}" | awk -F',' '{print $1}')
diff_versioning=$(echo "${result}" | awk -F',' '{print $2}')
echo "next version is ${new_ver}, it ${diff_versioning}"
#
# set output
if [[ ${diff_versioning} == 'major_minor_change' ]];then
echo "minor_version=true" >> "$GITHUB_OUTPUT"
else
echo "minor_version=false" >> "$GITHUB_OUTPUT"
fi
#
#
if [[ -z ${new_ver} ]]; then
echo "::error::please indicate the right semantic version in core/version.h"
echo "new_ver=''" >> "$GITHUB_OUTPUT"
echo "new_tag=''" >> "$GITHUB_OUTPUT"
exit 1
else
echo "new_ver=${new_ver}" >> "$GITHUB_OUTPUT"
echo "new_tag=WAMR-${new_ver}" >> "$GITHUB_OUTPUT"
fi
- name: push tag
if: steps.preparation.outputs.new_tag != ''
run: |
git tag ${{ steps.preparation.outputs.new_tag }}
git push origin --force --tags

View File

@ -1,50 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: hadolint dockerfiles
on:
# will be triggered on PR events
pull_request:
types:
- opened
- synchronize
paths:
- "**/Dockerfile*"
- ".github/workflows/hadolint_dockerfiles.yml"
push:
branches:
- main
- "dev/**"
paths:
- "**/Dockerfile*"
- ".github/workflows/hadolint_dockerfiles.yml"
# allow to be triggered manually
workflow_dispatch:
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
run-hadolint-on-dockerfiles:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
# on default, hadolint will fail on warnings and errors
- name: Run hadolint on dockerfiles
run: |
docker pull hadolint/hadolint:latest-debian
find . -name "*Dockerfile*" | while read dockerfile; do
echo "run hadolint on $dockerfile:"
docker run --rm -i hadolint/hadolint:latest-debian hadolint - <"$dockerfile"
echo "successful"
done

View File

@ -1,733 +0,0 @@
# Copyright (C) 2023 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: nightly_run
on:
pull_request:
types:
- opened
- synchronize
# running nightly pipeline if you're changing it
# stress tests are run only in nightly at the moment, so running them in they are changed
paths:
- ".github/workflows/nightly_run.yml"
- "core/iwasm/libraries/lib-wasi-threads/stress-test/**"
# midnight UTC
schedule:
- cron: "0 0 * * *"
# allow to be triggered manually
workflow_dispatch:
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# 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"
# For Spec Test
# FIXME: use binary release(adding -b) instead of building from source after upgrading to 22.04
DEFAULT_TEST_OPTIONS: "-s spec -P"
MULTI_MODULES_TEST_OPTIONS: "-s spec -M -P"
SIMD_TEST_OPTIONS: "-s spec -S -P"
THREADS_TEST_OPTIONS: "-s spec -p -P"
X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
WASI_TEST_OPTIONS: "-s wasi_certification -w"
permissions:
contents: read
jobs:
build_llvm_libraries_on_ubuntu:
permissions:
contents: read
actions: write
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "ubuntu-22.04"
arch: "X86"
build_wamrc:
needs: build_llvm_libraries_on_ubuntu
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
# since jobs.id can't contain the dot character
# it is hard to use `format` to assemble the cache key
- name: Get LLVM libraries
id: retrieve_llvm_libs
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: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: Build wamrc
run: |
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
working-directory: wamr-compiler
build_iwasm:
needs: build_llvm_libraries_on_ubuntu
runs-on: ${{ matrix.os }}
strategy:
matrix:
make_options_run_mode: [
# Running mode
$AOT_BUILD_OPTIONS,
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
$FAST_JIT_BUILD_OPTIONS,
$LLVM_LAZY_JIT_BUILD_OPTIONS,
$LLVM_EAGER_JIT_BUILD_OPTIONS,
$MULTI_TIER_JIT_BUILD_OPTIONS,
]
make_options_feature: [
# Features
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
"-DWAMR_BUILD_DEBUG_AOT=1",
"-DWAMR_BUILD_DEBUG_INTERP=1",
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
"-DWAMR_BUILD_LIB_PTHREAD=1",
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
"-DWAMR_BUILD_MINI_LOADER=1",
"-DWAMR_BUILD_MEMORY_PROFILING=1",
"-DWAMR_BUILD_MULTI_MODULE=1",
"-DWAMR_BUILD_PERF_PROFILING=1",
"-DWAMR_BUILD_REF_TYPES=1",
"-DWAMR_BUILD_SIMD=1",
"-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_MEMORY64=1",
"-DWAMR_BUILD_MULTI_MEMORY=1",
"-DWAMR_BUILD_SHARED=1",
]
os: [ubuntu-22.04]
platform: [android, linux]
exclude:
# incompatible feature and platform
# incompatible mode and feature
# MULTI_MODULE only on INTERP mode and AOT mode
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
# SIMD only on JIT/AOT mode
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_SIMD=1"
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_SIMD=1"
# DEBUG_INTERP only on CLASSIC INTERP mode
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
# DEBUG_AOT only on JIT/AOT mode
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
# TODO: DEBUG_AOT on JIT
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
# MINI_LOADER only on INTERP mode
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
# Memory64 only on CLASSIC INTERP and AOT mode, and only on 64-bit platform
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
platform: android
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
# Multi memory only on CLASSIC INTERP mode, and only on 64-bit platform
- make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
platform: android
- make_options_run_mode: $AOT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
# Fast-JIT and Multi-Tier-JIT mode don't support android
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
platform: android
- make_options_run_mode: $MULTI_TIER_JIT_BUILD_OPTIONS
platform: android
# LLVM JIT pre-built binary wasn't compiled by Android NDK
# and isn't available for android
- make_options_run_mode: $LLVM_LAZY_JIT_BUILD_OPTIONS
platform: android
- make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS
platform: android
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
# only download llvm cache when needed
- name: Get LLVM libraries
id: retrieve_llvm_libs
if: endsWith(matrix.make_options_run_mode, '_JIT_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_run_mode, '_JIT_BUILD_OPTIONS') && (steps.retrieve_llvm_libs.outputs.cache-hit != 'true')
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: Build iwasm for linux
if: matrix.platform == 'linux'
run: |
mkdir build && cd build
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }}
cmake --build . --config Release --parallel 4
working-directory: product-mini/platforms/${{ matrix.platform }}
- name: Build iwasm for android
if: matrix.platform == 'android'
run: |
mkdir build && cd build
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} \
-DWAMR_BUILD_TARGET=X86_64
cmake --build . --config Release --parallel 4
working-directory: product-mini/platforms/${{ matrix.platform }}
build_iwasm_linux_gcc4_8:
runs-on: ubuntu-latest
container:
image: ubuntu:14.04
strategy:
matrix:
make_options_run_mode: [
# Running mode
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
$FAST_JIT_BUILD_OPTIONS,
]
make_options_feature: [
# Features
"-DWAMR_BUILD_CUSTOM_NAME_SECTION=1",
"-DWAMR_BUILD_DEBUG_AOT=1",
"-DWAMR_BUILD_DEBUG_INTERP=1",
"-DWAMR_BUILD_DUMP_CALL_STACK=1",
"-DWAMR_BUILD_LIB_PTHREAD=1",
"-DWAMR_BUILD_LIB_WASI_THREADS=1",
"-DWAMR_BUILD_LOAD_CUSTOM_SECTION=1",
"-DWAMR_BUILD_MINI_LOADER=1",
"-DWAMR_BUILD_MEMORY_PROFILING=1",
"-DWAMR_BUILD_MULTI_MODULE=1",
"-DWAMR_BUILD_PERF_PROFILING=1",
"-DWAMR_BUILD_REF_TYPES=1",
"-DWAMR_BUILD_SIMD=1",
"-DWAMR_BUILD_TAIL_CALL=1",
"-DWAMR_DISABLE_HW_BOUND_CHECK=1",
"-DWAMR_BUILD_MEMORY64=1",
"-DWAMR_BUILD_MULTI_MEMORY=1",
]
exclude:
# incompatible feature and platform
# incompatible mode and feature
# MULTI_MODULE only on INTERP mode and AOT mode
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MODULE=1"
# SIMD only on JIT/AOT mode
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_SIMD=1"
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_SIMD=1"
# DEBUG_INTERP only on CLASSIC INTERP mode
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_INTERP=1"
# DEBUG_AOT only on JIT/AOT mode
- make_options_run_mode: $CLASSIC_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
# TODO: DEBUG_AOT on JIT
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_DEBUG_AOT=1"
# MINI_LOADER only on INTERP mode
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1"
# Memory64 only on CLASSIC INTERP mode
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MEMORY64=1"
# Memory64 only on CLASSIC INTERP mode
- make_options_run_mode: $FAST_INTERP_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
- make_options_run_mode: $FAST_JIT_BUILD_OPTIONS
make_options_feature: "-DWAMR_BUILD_MULTI_MEMORY=1"
steps:
- name: Install dependencies
run: |
apt update && apt install -y make g++-4.8 gcc-4.8 wget git
- name: checkout
run: |
git clone https://github.com/${{ github.repository }} wamr
- name: Install cmake
run: |
wget https://github.com/Kitware/CMake/releases/download/v3.26.1/cmake-3.26.1-linux-x86_64.tar.gz -O cmake.tar.gz
tar xzf cmake.tar.gz
cp cmake-3.26.1-linux-x86_64/bin/cmake /usr/local/bin
cp -r cmake-3.26.1-linux-x86_64/share/cmake-3.26/ /usr/local/share/
- name: Build iwasm
run: |
mkdir build && cd build
cmake .. ${{ matrix.make_options_run_mode }} ${{ matrix.make_options_feature }} -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8
cmake --build . --config Release --parallel 4
working-directory: wamr/product-mini/platforms/linux
build_samples_wasm_c_api:
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
sanitizer: ["", "ubsan", "asan"]
make_options: [
# Running mode
$AOT_BUILD_OPTIONS,
$CLASSIC_INTERP_BUILD_OPTIONS,
$FAST_INTERP_BUILD_OPTIONS,
$FAST_JIT_BUILD_OPTIONS,
$LLVM_LAZY_JIT_BUILD_OPTIONS,
$LLVM_EAGER_JIT_BUILD_OPTIONS,
$MULTI_TIER_JIT_BUILD_OPTIONS,
]
os: [ubuntu-22.04]
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
exclude:
- make_options: $MULTI_TIER_JIT_BUILD_OPTIONS
sanitizer: asan
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 -D WAMR_BUILD_SANITIZER="${{matrix.sanitizer}}" ..
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 }} \
-D WAMR_BUILD_SANITIZER="${{matrix.sanitizer}}" \
-D WAMR_BUILD_QUICK_AOT_ENTRY=0
cmake --build build --config Release --parallel 4
ctest --test-dir build --output-on-failure
working-directory: samples/wasm-c-api
build_samples_others:
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
- name: Get LLVM libraries
id: retrieve_llvm_libs
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: Build wamrc
run: |
mkdir build && cd build
cmake -D WAMR_BUILD_SANITIZER="${{matrix.sanitizer}}" ..
cmake --build . --config Release --parallel 4
working-directory: wamr-compiler
- name: Build Sample [basic]
run: |
cd samples/basic
./build.sh
./run.sh
- name: Build Sample [file]
run: |
cd samples/file
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./src/iwasm -f wasm-app/file.wasm -d .
- name: Build Sample [multi-thread]
run: |
cd samples/multi-thread
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./iwasm wasm-apps/test.wasm
- name: Build Sample [multi-module]
run: |
cd samples/multi-module
mkdir build && cd build
cmake .. -DWAMR_BUILD_AOT=1
cmake --build . --config Release --parallel 4
./multi_module mC.wasm
./multi_module mC.aot
- name: Build Sample [spawn-thread]
run: |
cd samples/spawn-thread
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./spawn_thread
- name: Build Sample [ref-types]
run: |
cd samples/ref-types
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./hello
- name: Build Sample [wasi-threads]
run: |
cd samples/wasi-threads
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./iwasm wasm-apps/no_pthread.wasm
- name: Build Sample [shared-module]
run: |
cd samples/shared-module
./build.sh
./run.sh
- name: Build Sample [terminate]
run: |
cd samples/terminate
./build.sh
./run.sh
- name: Build Sample [native-stack-overflow]
run: |
cd samples/native-stack-overflow
./build.sh
./run.sh test1
./run.sh test2
- name: Build Sample [native-lib]
run: |
mkdir build && cd build
cmake ..
cmake --build . --config Release --parallel 4
./iwasm --native-lib=./libtest_add.so --native-lib=./libtest_sqrt.so --native-lib=./libtest_hello.so --native-lib=./libtest_hello2.so wasm-app/test.wasm
working-directory: ./samples/native-lib
# FIXME: un-comment me after fix cmake minimum issue
# https://github.com/bytecodealliance/wamr-app-framework/pull/11
# - name: checkout wamr-app-framework
# run: git clone https://github.com/bytecodealliance/wamr-app-framework.git
# - name: download wamr-app-framework dependencies
# run: LVGL=0 LV_DRIVERS=0 ./download.sh
# working-directory: ./wamr-app-framework/deps
# - name: Build Sample [simple]
# run: |
# ./build.sh -p host-interp
# python3 ./sample_test_run.py $(pwd)/out
# exit $?
# working-directory: ./wamr-app-framework/samples/simple
- name: Build Sample [shared-heap]
run: |
cd samples/shared-heap
mkdir build && cd build
cmake ..
cmake --build . --config Debug --parallel 4
./shared_heap_test
./shared_heap_test --aot
test:
needs: [build_iwasm, build_llvm_libraries_on_ubuntu, build_wamrc]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
sanitizer: ["", "ubsan", "asan", "tsan"]
running_mode:
[
"classic-interp",
"fast-interp",
"jit",
"aot",
"fast-jit",
"multi-tier-jit",
]
test_option:
[
$DEFAULT_TEST_OPTIONS,
$MULTI_MODULES_TEST_OPTIONS,
$SIMD_TEST_OPTIONS,
$THREADS_TEST_OPTIONS,
$WASI_TEST_OPTIONS,
]
include:
- os: ubuntu-22.04
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu.outputs.cache_key }}
ubuntu_version: "22.04"
exclude:
# asan works only for aot now
- running_mode: "classic-interp"
sanitizer: asan
- running_mode: "fast-interp"
sanitizer: asan
- running_mode: "jit"
sanitizer: asan
- running_mode: "fast-jit"
sanitizer: asan
- running_mode: "multi-tier-jit"
sanitizer: asan
- running_mode: "classic-interp"
sanitizer: tsan
- running_mode: "jit"
sanitizer: tsan
- running_mode: "fast-jit"
sanitizer: tsan
- running_mode: "multi-tier-jit"
sanitizer: tsan
# classic-interp and fast-interp don't support simd
- running_mode: "classic-interp"
test_option: $SIMD_TEST_OPTIONS
- running_mode: "fast-interp"
test_option: $SIMD_TEST_OPTIONS
# llvm jit doesn't support multi module
- running_mode: "jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
# fast-jit doesn't support multi module, simd
- running_mode: "fast-jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
- running_mode: "fast-jit"
test_option: $SIMD_TEST_OPTIONS
# multi-tier-jit doesn't support multi module, simd
- running_mode: "multi-tier-jit"
test_option: $MULTI_MODULES_TEST_OPTIONS
- running_mode: "multi-tier-jit"
test_option: $SIMD_TEST_OPTIONS
steps:
- name: checkout
uses: actions/checkout@v4
- name: install-wasi-sdk-wabt
uses: ./.github/actions/install-wasi-sdk-wabt
with:
os: ${{ matrix.os }}
# It is a temporary solution until new wasi-sdk that includes bug fixes is released
- name: build wasi-libc from source
if: matrix.test_option == '$WASI_TEST_OPTIONS'
run: |
git clone https://github.com/WebAssembly/wasi-libc
cd wasi-libc
make -j AR=/opt/wasi-sdk/bin/llvm-ar NM=/opt/wasi-sdk/bin/llvm-nm CC=/opt/wasi-sdk/bin/clang THREAD_MODEL=posix
echo "SYSROOT_PATH=$PWD/sysroot" >> $GITHUB_ENV
- name: set env variable(if llvm are used)
if: matrix.running_mode == 'aot' || matrix.running_mode == 'jit' || matrix.running_mode == 'multi-tier-jit'
run: echo "USE_LLVM=true" >> $GITHUB_ENV
- name: set env variable(if x86_32 test needed)
if: >
(matrix.test_option == '$DEFAULT_TEST_OPTIONS' || matrix.test_option == '$THREADS_TEST_OPTIONS'
|| matrix.test_option == '$WASI_TEST_OPTIONS')
&& matrix.running_mode != 'fast-jit' && matrix.running_mode != 'jit' && matrix.running_mode != 'multi-tier-jit'
run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
- name: set additional tsan options
run: |
echo "TSAN_OPTIONS=suppressions=$PWD/tsan_suppressions.txt" >> $GITHUB_ENV
sudo sysctl vm.mmap_rnd_bits=28
working-directory: tests/wamr-test-suites
#only download llvm libraries in jit and aot mode
- name: Get LLVM libraries
if: env.USE_LLVM == 'true'
id: retrieve_llvm_libs
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: env.USE_LLVM == 'true' && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: install jq JSON processor
if: matrix.running_mode == 'aot' && matrix.test_option == '$WASI_TEST_OPTIONS'
run: sudo apt-get update && sudo apt install -y jq
- name: install for wabt compilation
run: sudo apt update && sudo apt install -y ninja-build
- name: Build WASI thread tests
if: matrix.test_option == '$WASI_TEST_OPTIONS'
run: bash build.sh --sysroot "$SYSROOT_PATH"
working-directory: ./core/iwasm/libraries/lib-wasi-threads/test/
- name: Build WASI thread stress tests
if: matrix.test_option == '$WASI_TEST_OPTIONS'
run: bash build.sh --sysroot "$SYSROOT_PATH"
working-directory: ./core/iwasm/libraries/lib-wasi-threads/stress-test/
- name: build socket api tests
if: matrix.test_option == '$WASI_TEST_OPTIONS'
run: bash build.sh
working-directory: ./core/iwasm/libraries/lib-socket/test/
- name: run tests
timeout-minutes: 40
run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} -T "${{ matrix.sanitizer }}"
working-directory: ./tests/wamr-test-suites
#only install x32 support libraries when to run x86_32 cases
- name: install x32 support libraries
if: env.TEST_ON_X86_32 == 'true'
run:
# Add another apt repository as some packages cannot
# be downloaded with the github default repository
sudo curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc &&
sudo apt-add-repository https://packages.microsoft.com/ubuntu/${{ matrix.ubuntu_version }}/prod &&
sudo apt-get update &&
sudo apt install -y g++-multilib lib32gcc-9-dev
- name: run tests x86_32
timeout-minutes: 40
if: env.TEST_ON_X86_32 == 'true'
run: ./test_wamr.sh ${{ env.X86_32_TARGET_TEST_OPTIONS }} ${{ matrix.test_option }} -t ${{ matrix.running_mode }}
working-directory: ./tests/wamr-test-suites

View File

@ -1,241 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: the binary release processes
on:
workflow_dispatch:
inputs:
require_confirmation:
description: "If the process requires a confirmation"
type: boolean
required: false
default: false
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
create_tag:
permissions:
contents: write # create and push tags
uses: ./.github/workflows/create_tag.yml
create_release:
permissions:
contents: write # create release
needs: [create_tag]
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: prepare the release note
run: |
extract_result="$(python3 ./.github/scripts/extract_from_release_notes.py RELEASE_NOTES.md)"
echo "RELEASE_NOTE<<EOF" >> $GITHUB_ENV
echo "${extract_result}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: create a release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create_tag.outputs.new_tag }}
release_name: ${{ needs.create_tag.outputs.new_tag }}
prerelease: ${{ inputs.require_confirmation || needs.create_tag.outputs.minor_version }}
draft: false
body: ${{ env.RELEASE_NOTE }}
#
# LLVM_LIBRARIES
build_llvm_libraries_on_ubuntu_2204:
permissions:
contents: read
actions: write
needs: [create_tag, create_release]
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "ubuntu-22.04"
arch: "AArch64 ARM Mips RISCV X86"
build_llvm_libraries_on_macos:
permissions:
contents: read
actions: write
needs: [create_tag, create_release]
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "macos-13"
arch: "AArch64 ARM Mips RISCV X86"
build_llvm_libraries_on_windows:
permissions:
contents: read
actions: write
needs: [create_tag, create_release]
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "windows-latest"
arch: "AArch64 ARM Mips RISCV X86"
#
# WAMRC
release_wamrc_on_ubuntu_2204:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release, build_llvm_libraries_on_ubuntu_2204 ]
uses: ./.github/workflows/build_wamrc.yml
with:
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
release: true
runner: ubuntu-22.04
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver }}
release_wamrc_on_ubuntu_macos:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release, build_llvm_libraries_on_macos]
uses: ./.github/workflows/build_wamrc.yml
with:
llvm_cache_key: ${{ needs.build_llvm_libraries_on_macos.outputs.cache_key }}
release: true
runner: macos-13
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver }}
release_wamrc_on_windows:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release, build_llvm_libraries_on_windows]
uses: ./.github/workflows/build_wamrc.yml
with:
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
release: true
runner: windows-latest
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver }}
#
# IWASM
release_iwasm_on_ubuntu_2204:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release, build_llvm_libraries_on_ubuntu_2204]
uses: ./.github/workflows/build_iwasm_release.yml
with:
cwd: product-mini/platforms/linux
llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }}
runner: ubuntu-22.04
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}
release_iwasm_on_macos:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release, build_llvm_libraries_on_macos]
uses: ./.github/workflows/build_iwasm_release.yml
with:
cwd: product-mini/platforms/darwin
llvm_cache_key: ${{ needs.build_llvm_libraries_on_macos.outputs.cache_key }}
runner: macos-13
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}
release_iwasm_on_windows:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release, build_llvm_libraries_on_windows]
uses: ./.github/workflows/build_iwasm_release.yml
with:
cwd: product-mini/platforms/windows
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
runner: windows-latest
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}
#
# WAMR_SDK
release_wamr_sdk_on_ubuntu_2204:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release]
uses: ./.github/workflows/build_wamr_sdk.yml
with:
config_file: wamr_config_ubuntu_release.cmake
runner: ubuntu-22.04
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}
wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git
release_wamr_sdk_on_macos:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release]
uses: ./.github/workflows/build_wamr_sdk.yml
with:
config_file: wamr_config_macos_release.cmake
runner: macos-13
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}
wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-macos.tar.gz
wamr_app_framework_url: https://github.com/bytecodealliance/wamr-app-framework.git
# Let's disable it for now and reopen it when the actual requirement arises.
# Please ensure all dependencies have been updated before reopening.
#
# # vscode extension cross-platform
# release_wamr_ide_vscode_ext:
# permissions:
# contents: write # upload release artifact
# needs: [create_tag, create_release]
# uses: ./.github/workflows/build_wamr_vscode_ext.yml
# secrets: inherit
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# ver_num: ${{ needs.create_tag.outputs.new_ver }}
# #
# # vscode extension docker images package
# release_wamr_ide_docker_images_package:
# permissions:
# contents: write # upload release artifact
# needs: [create_tag, create_release]
# uses: ./.github/workflows/build_docker_images.yml
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# ver_num: ${{ needs.create_tag.outputs.new_ver }}
#
# WAMR_LLDB
release_wamr_lldb_on_ubuntu_2204:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release]
uses: ./.github/workflows/build_wamr_lldb.yml
with:
runner: ubuntu-22.04
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}
release_wamr_lldb_on_macos_universal:
permissions:
contents: write # upload release artifact
needs: [create_tag, create_release]
uses: ./.github/workflows/build_wamr_lldb.yml
with:
runner: macos-13
arch: universal
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}

View File

@ -1,74 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: reuse binaries of the latest release if no more modification on the_path since last_commit
on:
workflow_call:
inputs:
binary_name_stem:
type: string
required: true
last_commit:
type: string
required: true
the_path:
type: string
required: true
upload_url:
description: upload binary assets to the URL of release
type: string
required: true
outputs:
result:
value: ${{ jobs.build.outputs.result }}
permissions:
contents: read
jobs:
reuse:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.try_reuse.outputs.result }}
permissions:
contents: write # for creating realease and uploading release artifacts
steps:
- uses: actions/checkout@v4
# Full git history is needed to get a proper list of commits and tags
with:
fetch-depth: 0
- name: try to reuse binaries
id: try_reuse
run: |
echo '::echo::on'
python3 ./.github/scripts/reuse_latest_release_binaries.py \
--binary_name_stem ${{ inputs.binary_name_stem }} \
--last_commit ${{ inputs.last_commit }} \
--the_path ${{ inputs.the_path }} .
ls -lh .
- run: echo ${{ steps.try_reuse.outputs.result }}
- name: upload release tar.gz
if: steps.try_reuse.outputs.result == 'hit'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ${{ inputs.binary_name_stem }}.tar.gz
asset_name: ${{ inputs.binary_name_stem }}.tar.gz
asset_content_type: application/x-gzip
- name: upload release zip
if: steps.try_reuse.outputs.result == 'hit'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ${{ inputs.binary_name_stem }}.zip
asset_name: ${{ inputs.binary_name_stem }}.zip
asset_content_type: application/zip

View File

@ -1,335 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: spec test on nuttx
on:
pull_request:
types:
- opened
- synchronize
paths:
- ".github/workflows/spec_test_on_nuttx.yml"
- "core/**"
- "!core/deps/**"
- "product-mini/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
- "wamr-sdk/**"
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
# Note on INTERPRETERS_WAMR_STACK_GUARD_SIZE:
# https://github.com/apache/nuttx-apps/pull/2241 is not included in
# releases/12.4 branch as of writing this.
env:
LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex"
WASI_SDK_PATH: "/opt/wasi-sdk"
permissions:
contents: read
jobs:
build_llvm_libraries:
permissions:
contents: read
actions: write
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "ubuntu-22.04"
arch: "ARM RISCV AArch64"
container_image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
build_llvm_libraries_xtensa:
permissions:
contents: read
actions: write
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "ubuntu-22.04"
arch: "Xtensa"
extra_build_llvm_options: "--platform xtensa"
cache_key_suffix: "-xtensa"
container_image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
spec_test_on_qemu:
runs-on: ubuntu-latest
needs: [build_llvm_libraries, build_llvm_libraries_xtensa]
container:
image: ghcr.io/no1wudi/nuttx/apache-nuttx-ci-linux@sha256:8c4e00b607d4d6d66ba8f51c4544819a616eac69d3a2ac669e2af2150e2eb0f9
strategy:
matrix:
target_config: [
# {
# config: "boards/arm64/qemu/qemu-armv8a/configs/nsh",
# target: "aarch64_vfp",
# fpu_type: "fp"
# },
# {
# config: "boards/arm/imx6/sabre-6quad/configs/nsh",
# target: "thumbv7",
# fpu_type: "none"
# },
{
config: "boards/arm/imx6/sabre-6quad/configs/nsh",
target: "thumbv7_vfp",
fpu_type: "dp"
},
{
config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
target: "riscv32",
fpu_type: "none"
},
#{
# config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
# target: "riscv32_ilp32f",
# fpu_type: "fp"
#},
# {
# config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh",
# target: "riscv32_ilp32d",
# fpu_type: "dp"
# },
{
config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh64",
target: "riscv64",
fpu_type: "none"
},
{
config: "boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_debug",
target: "xtensa",
fpu_type: "none"
},
]
wamr_test_option: [
{
mode: "-t aot",
option: "CONFIG_INTERPRETERS_WAMR_AOT"
},
{
mode: "-t aot -X",
option: "CONFIG_INTERPRETERS_WAMR_AOT"
},
# {
# mode: "-t classic-interp",
# option: "CONFIG_INTERPRETERS_WAMR_CLASSIC"
# },
# {
# mode: "-t fast-interp",
# option: "CONFIG_INTERPRETERS_WAMR_FAST"
# },
]
wamr_feature_option:
# Empty option for default
- { option: "", mode: "" }
# need to install menhir
# - { option: "CONFIG_INTERPRETERS_WAMR_GC CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME", mode: "-G" }
exclude:
# XIP is not fully supported yet on RISCV64, some relocations can not be resolved
- target_config: { config: "boards/risc-v/qemu-rv/rv-virt/configs/nsh64" }
wamr_test_option: { mode: "-t aot -X" }
# Our xtensa environment doesn't have enough memory
- target_config: { target: "xtensa" }
wamr_feature_option: { mode: "-G" }
steps:
# Note: we use an unreleased version nuttx for xtensa because
# 12.4 doesn't contain necessary esp32s3 changes.
- name: Checkout NuttX
uses: actions/checkout@v4
with:
repository: apache/nuttx
ref: ${{ matrix.target_config.target == 'xtensa' && '985d395b025cf2012b22f6bb4461959fa6d87645' || 'releases/12.9' }}
path: nuttx
- name: Checkout NuttX Apps
uses: actions/checkout@v4
with:
repository: apache/nuttx-apps
ref: ${{ matrix.target_config.target == 'xtensa' && '2ef3eb25c0cec944b13792185f7e5d5a05990d5f' || 'releases/12.9' }}
path: apps
- name: Checkout WAMR
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
path: apps/interpreters/wamr/wamr
- name: Get LLVM libraries
if: contains(matrix.wamr_test_option.mode, 'aot')
id: retrieve_llvm_libs
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.target_config.target == 'xtensa' && needs.build_llvm_libraries_xtensa.outputs.cache_key || needs.build_llvm_libraries.outputs.cache_key }}
- name: Quit if cache miss
if: contains(matrix.wamr_test_option.mode, 'aot') && steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
run: echo "::error::can not get prebuilt llvm libraries" && exit 1
- name: Copy LLVM
if: contains(matrix.wamr_test_option.mode, 'aot')
run: cp -r core/deps/llvm apps/interpreters/wamr/wamr/core/deps/llvm
- name: Build wamrc
if: contains(matrix.wamr_test_option.mode, 'aot')
working-directory: apps/interpreters/wamr/wamr/wamr-compiler
run: |
cmake -B build -DWAMR_BUILD_SHRUNK_MEMORY=0 -S .
cmake --build build
# the nuttx version we use for xtensa requires esptool.py newer than
# what we have in our version of the apache-nuttx-ci-linux image.
- name: Install the latest esptool.py (xtensa)
if: matrix.target_config.target == 'xtensa'
run: |
pip3 install esptool==4.7.0
esptool.py version
- name: Configure NuttX
run: |
tools/configure.sh ${{ matrix.target_config.config }}
working-directory: nuttx
# depending on configurations, the iwasm command line generated
# by spec-test-script can be longer than the default NSH_LINELEN,
# which is 64 or 80.
- name: Enable WAMR for NuttX
run: |
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_LOG
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_REF_TYPES
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_ENABLE_SPEC_TEST
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_SHARED_MEMORY
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_BULK_MEMORY
kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE 1024
kconfig-tweak --enable CONFIG_FS_HOSTFS
kconfig-tweak --enable CONFIG_ARM_SEMIHOSTING_HOSTFS
kconfig-tweak --enable CONFIG_ARM_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
kconfig-tweak --enable CONFIG_RISCV_SEMIHOSTING_HOSTFS
kconfig-tweak --enable CONFIG_RISCV_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
kconfig-tweak --enable CONFIG_XTENSA_SEMIHOSTING_HOSTFS
kconfig-tweak --enable CONFIG_XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE
kconfig-tweak --enable CONFIG_LIBC_FLOATINGPOINT
kconfig-tweak --set-val CONFIG_NSH_LINELEN 255
working-directory: nuttx
- name: Set WAMR stack size for NuttX
if: matrix.target_config.target != 'xtensa'
run: |
kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 327680
working-directory: nuttx
# because qemu doesn't have a proper emulation of esp32s3 psram,
# we are limited to the internal ram, which is about 400KB.
- name: Set WAMR stack size for NuttX (xtensa)
if: matrix.target_config.target == 'xtensa'
run: |
kconfig-tweak --set-val CONFIG_INTERPRETERS_WAMR_STACKSIZE 25600
working-directory: nuttx
- name: Enable WAMR interpreter/aot runtime for NuttX
if: matrix.wamr_test_option.option != ''
run: |
for x in ${{ matrix.wamr_test_option.option }}; do
kconfig-tweak --enable $x
done
working-directory: nuttx
- name: Enable WAMR Features for NuttX
if: matrix.wamr_feature_option.option != ''
run: |
for x in ${{ matrix.wamr_feature_option.option }}; do
kconfig-tweak --enable $x
done
working-directory: nuttx
- name: Disable FPU for NuttX
if: matrix.target_config.fpu_type == 'none'
run: |
kconfig-tweak --disable CONFIG_ARCH_FPU
working-directory: nuttx
- name: Disable DPFPU for NuttX
if: matrix.target_config.fpu_type == 'fp'
run: |
kconfig-tweak --disable CONFIG_ARCH_DPFPU
working-directory: nuttx
# Note: while a real hardware would need
# INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=y,
# it doesn't work with xtensa qemu which we use on the CI because it
# doesn't have a proper emulation of I/D separate mappings.
# we work it around by using INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR=n.
# this configuration won't work on a real hardware.
- name: Tweak NuttX config (xtensa)
if: matrix.target_config.target == 'xtensa'
run: |
kconfig-tweak --enable CONFIG_INTERPRETERS_WAMR_AOT_WORD_ALIGN_READ
kconfig-tweak --disable CONFIG_INTERPRETERS_WAMR_MEM_DUAL_BUS_MIRROR
working-directory: nuttx
- name: Build NuttX
run: |
make olddefconfig
make -j$(nproc)
working-directory: nuttx
# for xtensa, build a 8MB firmware image.
# simple boot is assumed. (thus the nuttx.bin offset in the image is 0)
# qemu will infer the flash size from the file size.
- name: Post build processing (xtensa)
if: matrix.target_config.target == 'xtensa'
run: |
cd nuttx
dd if=/dev/zero of=flash.img bs=1024 count=8192
dd if=nuttx.bin of=flash.img conv=notrunc
mv flash.img nuttx
- name: Build firmware path
id: build_firmware_path
run: |
echo "firmware=$PWD/nuttx/nuttx" >> $GITHUB_OUTPUT
# for xtensa, use the espressif fork of qemu, which has esp32s3 support.
- name: Install QEMU (xtensa)
if: matrix.target_config.target == 'xtensa'
run: |
apt-get remove -y qemu-system-misc
apt-get update && apt-get install -y libsdl2-2.0-0
./.github/scripts/install_qemu_xtensa.sh
qemu-system-xtensa --version
working-directory: apps/interpreters/wamr/wamr
- name: Test
run: |
cd apps/interpreters/wamr/wamr/tests/wamr-test-suites
./test_wamr.sh -s spec ${{ matrix.wamr_test_option.mode }} -m ${{ matrix.target_config.target }} -b -Q -F ${{ steps.build_firmware_path.outputs.firmware }} ${{ matrix.wamr_feature_option.mode}}
- name: pack the log
if: always()
run: |
mkdir log
cp $PWD/nuttx/.config log/dot-config
cp ${{ steps.build_firmware_path.outputs.firmware }} log
tar -C apps/interpreters/wamr/wamr/tests/wamr-test-suites/workspace -cvzf log/report.tgz report
- name: upload the log
if: always()
uses: actions/upload-artifact@v4.6.2
with:
name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }}
path: log

View File

@ -1,65 +0,0 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
# Check current WASM Micro Runtime results here: https://securityscorecards.dev/viewer/?uri=github.com/bytecodealliance/wasm-micro-runtime
name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
# midnight UTC
schedule:
- cron: "0 0 * * *"
# allow to be triggered manually
workflow_dispatch:
# Declare default permissions as read only.
permissions:
contents: read
jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
if: github.repository == 'bytecodealliance/wasm-micro-runtime'
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
steps:
- name: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
with:
results_file: results.sarif
results_format: sarif
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5eb3ed6614230b1931d5c08df9e096e4ba524f21
with:
sarif_file: results.sarif

24
.gitignore vendored
View File

@ -1,25 +1,20 @@
.cache
.clangd
.vs
.vscode
.venv
/.idea
**/cmake-build-*/
**/*build*/
!/build-scripts
**/*build/
*.obj
*.a
*.so
.clangd
.DS_Store
*.o
.aider*
core/deps/**
core/shared/mem-alloc/tlsf
core/iwasm/libraries/lib-wasi-threads/test/*.wasm
core/iwasm/libraries/lib-socket/test/*.wasm
core/app-framework/wgl
wamr-sdk/out/
wamr-sdk/runtime/build_runtime_sdk/
test-tools/host-tool/bin/
product-mini/app-samples/hello-world/test.wasm
product-mini/platforms/linux-sgx/enclave-sample/App/
product-mini/platforms/linux-sgx/enclave-sample/Enclave/
@ -32,11 +27,4 @@ tests/wamr-test-suites/workspace
samples/socket-api/wasm-src/inc/pthread.h
**/__pycache__
tests/benchmarks/coremark/coremark*
samples/workload/include/**
!samples/workload/include/.gitkeep
# core/iwasm/libraries/wasi-threads
**/__pycache__

View File

@ -1,36 +0,0 @@
# WAMR adopters
_If you are using WAMR in production/pre-production at your organization, please add your company name to this list.
The list is in alphabetical order._
| Organization | Contact | Status | Description of Use |
| -------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| [Alibaba](https://www.alibaba.com) | [@johnlanni](https://github.com/johnlanni) | ![production](https://img.shields.io/badge/-production-blue?style=flat) | Higress is a next-generation cloud-native gateway built on the core of open-source Istio + Envoy based on Alibaba's internal Envoy Gateway practice. |
| [Amazon](https://www.amazon.com) | [@loganek](https://github.com/loganek) | ![production](https://img.shields.io/badge/-production-blue?style=flat) | Prime Video is a global streaming service by Amazon that provides on-demand access to a vast library of movies, TV shows, and original programming, as well as live content. |
| [Ant Group](https://www.antgroup.com) | [@wei-tang](https://github.com/wei-tang) | ![production](https://img.shields.io/badge/-production-blue?style=flat) | AntChain is a blockchain technology platform owned by Ant Group, a Chinese tech conglomerate that also runs Alipay, China's largest digital payment system. |
| [Bosch](https://www.bosch.com) | emily.ruppel@us.bosch.com | ![Undisclosed](https://img.shields.io/badge/-Undisclosed-orange?style=flat) | Silverline Cloud-Edge platform |
| [Disney](https://www.disney.com) | | ![production](https://img.shields.io/badge/-production-blue?style=flat) | Disney+ Streaming |
| [Intel](https://www.intel.com) | [@wenyongh](https://github.com/wenyongh) | ![Undisclosed](https://img.shields.io/badge/-Undisclosed-orange?style=flat) | Edge and the embedded environments |
| [Moonbit](https://www.moonbitlang.com) | [@peter-jerry-ye](https://github.com/peter-jerry-ye) | ![Undisclosed](https://img.shields.io/badge/-Undisclosed-orange?style=flat) | MoonBit is an end-to-end programming language toolchain for cloud and edge computing using WebAssembly. |
| [Microsoft](https://www.microsoft.com) | [@Mossaka](https://github.com/Mossaka) | ![production](https://img.shields.io/badge/-production-blue?style=flat) | Hyperlight runs Wasm workloads in VMs without OS and kernel, it is a solution for improving the management and security of Wasm workloads on Azure. |
| [Midokura](https://www.midokura.com) | [@yamt](https://github.com/yamt) | ![Undisclosed](https://img.shields.io/badge/-Undisclosed-orange?style=flat) | The next-generation Edge AI sensing platform |
| [Siemens](https://www.siemens.com) | [@ttrenner](https://github.com/ttrenner) | ![Undisclosed](https://img.shields.io/badge/-Undisclosed-orange?style=flat) | Industrial, IoT |
| [Sony Semiconductor Solutions](https://www.sony-semicon.com) | [@dongsheng28849455](https://github.com/dongsheng28849455) | ![production](https://img.shields.io/badge/-production-blue?style=flat) | AI digital camera |
| [Xiaomi](https://www.mi.com) | [@no1wudi](https://github.com/no1wudi) | ![production](https://img.shields.io/badge/-production-blue?style=flat) | Xiaomi Vela is Xiaomi's IoT embedded software platform based on the open-source, real-time operating system NuttX. |
| [Xiaomi](https://www.mi.com) | [@no1wudi](https://github.com/no1wudi) | ![production](https://img.shields.io/badge/-production-blue?style=flat) | TEE (trusted execution environment) app engine. |
# Adopted in open-source projects
_The list is in alphabetical order._
| Project | Reference |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [Apache Teaclave](https://github.com/apache/incubator-teaclave) | https://github.com/apache/incubator-teaclave/blob/master/docs/executing-wasm.md |
| [Envoy](https://github.com/envoyproxy/envoy) | https://github.com/envoyproxy/envoy/blob/main/docs/root/configuration/other_features/wasm.rst |
| [faasm](https://github.com/faasm/faasm) | https://github.com/faasm/faasm/blob/main/docs/source/wamr.md |
| [fluent-bit](https://github.com/fluent/fluent-bit) | https://github.com/fluent/fluent-bit/tree/master/lib/wasm-micro-runtime-WAMR-1.3.0 |
| [harfbuzz](https://github.com/harfbuzz/harfbuzz) | https://github.com/harfbuzz/harfbuzz/blob/main/docs/wasm-shaper.md#enabling-the-wasm-shaper-when-building-harfbuzz |
| [inclave-containers](https://github.com/inclavare-containers/inclavare-containers) | https://github.com/inclavare-containers/inclavare-containers |
| [private-data-objects](https://github.com/hyperledger-labs/private-data-objects) | https://github.com/hyperledger-labs/private-data-objects/blob/main/common/interpreter/wawaka_wasm/README.md |
| [runwasi](https://github.com/containerd/runwasi) | https://github.com/containerd/runwasi/pull/508 (WIP) |
| [Wasmnizer-ts](https://github.com/web-devkits/Wasmnizer-ts) | https://github.com/web-devkits/Wasmnizer-ts |

View File

@ -2,10 +2,10 @@ WebAssembly Micro Runtime Attributions
======================================
WAMR project reused some components from other open source project:
- **cJson**: in the repository [wamr-app-framework](https://github.com/bytecodealliance/wamr-app-framework/), used in the host_tool for remotely managing wasm applications
- **cJson**: used in the host_tool for remotely managing wasm applications
- **contiki-ng**: for the coap protocol implementation
- **freebsd libm**: used in core/shared/platform/alios/bh_math.c
- **LVGL**: in the repository [wamr-app-framework](https://github.com/bytecodealliance/wamr-app-framework/), for the gui samples and wrapped the wasm graphic layer
- **LVGL**: for the gui samples and wrapped the wasm graphic layer
- **llvm**: for the AOT/JIT compilation
- **wasm-c-api**: to implement the C-APIs of wasm. using headers and sameples
- **wasmtime**: for the wasi libc implementation
@ -15,14 +15,12 @@ WAMR project reused some components from other open source project:
- **uvwasi**: for the WASI Libc with uvwasi implementation
- **asmjit**: for the Fast JIT x86-64 codegen implementation
- **zydis**: for the Fast JIT x86-64 codegen implementation
- **NuttX ELF headers**: used in core/iwasm/aot/debug/elf_parser.c
- **Dhrystone**: for the test benchmark dhrystone
The WAMR fast interpreter is a clean room development. We would acknowledge the inspirations by [WASM3](https://github.com/wasm3/wasm3) open source project for the approach of pre-calculated operand stack location.
The WAMR fast interpreter is a clean room development. We would acknowledge the inspirations by [WASM3](https://github.com/wasm3/wasm3) open source project for the approach of pre-calculated oprand stack location.
| third party components | version number | latest release | vendor pages | CVE details |
| --- | --- | --- | --- | --- |
| cjson | 1.7.16 | 1.7.16 | https://github.com/DaveGamble/cJSON | https://www.cvedetails.com/vendor/19164/Cjson-Project.html |
| cjson | 1.7.10 | 1.7.14 | https://github.com/DaveGamble/cJSON | https://www.cvedetails.com/vendor/19164/Cjson-Project.html |
| contiki-ng (er-coap) | unspecified | 3.0 | https://github.com/contiki-os/contiki | https://www.cvedetails.com/vendor/16528/Contiki-os.html |
| freebsd libm | unspecified | 13.0 | https://www.freebsd.org/ | https://www.cvedetails.com/vendor/6/Freebsd.html |
| LVGL | 6.0.1 | 7.11.0 | https://lvgl.io/ | |
@ -31,18 +29,16 @@ The WAMR fast interpreter is a clean room development. We would acknowledge the
| wasmtime | unspecified | v0.26.0 | https://github.com/bytecodealliance/wasmtime | |
| zephyr | unspecified | v2.5.0 | https://www.zephyrproject.org/ | https://www.cvedetails.com/vendor/19255/Zephyrproject.html |
| WebAssembly debugging patch for LLDB | unspecified | unspecified | https://reviews.llvm.org/D78801 | |
| libuv | v1.46.0 | v1.46.0 | https://github.com/libuv/libuv | https://www.cvedetails.com/vendor/15402/Libuv-Project.html |
| libuv | v1.42.0 | v1.44.1 | https://github.com/libuv/libuv | https://www.cvedetails.com/vendor/15402/Libuv-Project.html |
| uvwasi | unspecified | v0.0.12 | https://github.com/nodejs/uvwasi | |
| asmjit | unspecified | unspecified | https://github.com/asmjit/asmjit | |
| zydis | unspecified | e14a07895136182a5b53e181eec3b1c6e0b434de | https://github.com/zyantific/zydis | |
| NuttX ELF headers | 72313301e23f9c2de969fb64b9a0f67bb4c284df | 10.3.0 | https://github.com/apache/nuttx | |
| Dhrystone | 2.1 | 2.1 | https://fossies.org/linux/privat/old/ | |
## Licenses
### cJson
[LICENSE](https://github.com/bytecodealliance/wamr-app-framework/blob/main/test-tools/host-tool/external/cJSON/LICENSE)
[LICENSE](./test-tools/host-tool/external/cJSON/LICENSE)
### contiki-ng
@ -54,13 +50,13 @@ The WAMR fast interpreter is a clean room development. We would acknowledge the
### LVGL
[LICENSE](https://github.com/bytecodealliance/wamr-app-framework/blob/main/samples/littlevgl/LICENCE.txt)
[LICENSE](./samples/littlevgl/LICENCE.txt)
[LICENSE](https://github.com/bytecodealliance/wamr-app-framework/blob/main/app-framework/wgl/app/wa-inc/lvgl/LICENCE.txt)
[LICENSE](./core/app-framework/wgl/app/wa-inc/lvgl/LICENCE.txt)
### llvm
[LICENSE](./LICENSE)
[LICENSE](./core/deps/llvm/llvm/LICENCE.txt)
### wasm-c-api
@ -76,30 +72,20 @@ The WAMR fast interpreter is a clean room development. We would acknowledge the
### zephyr
[LICENSE](https://github.com/bytecodealliance/wamr-app-framework/blob/main/samples/gui/wasm-runtime-wgl/src/platform/zephyr/LICENSE)
[LICENSE](./samples/gui/wasm-runtime-wgl/src/platform/zephyr/LICENSE)
### wac
[LICENSE](./tests/wamr-test-suites/spec-test-script/LICENSE)
### libuv
[LICENSE](./core/iwasm/libraries/libc-uvwasi/LICENSE_LIBUV)
### uvwasi
[LICENSE](./core/iwasm/libraries/libc-uvwasi/LICENSE_UVWASI)
### asmjit
[LICENSE](./core/iwasm/fast-jit/cg/LICENSE_ASMJIT)
### zydis
[LICENSE](./core/iwasm/fast-jit/cg/LICENSE_ZYDIS)
### NuttX ELF headers
[LICENSE](./core/iwasm/aot/debug/LICENSE_NUTTX)
[NOTICE](./core/iwasm/aot/debug/NOTICE_NUTTX)
### Dhrystone
[LICENSE](./tests/benchmarks/dhrystone/LICENSE)

View File

@ -1,24 +1,13 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required (VERSION 3.14)
cmake_minimum_required (VERSION 2.9)
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
if(ESP_PLATFORM)
include (${COMPONENT_DIR}/build-scripts/esp-idf/wamr/CMakeLists.txt)
return()
endif()
project (iwasm LANGUAGES C)
set(CMAKE_CXX_STANDARD 17)
project (iwasm)
set (CMAKE_VERBOSE_MAKEFILE OFF)
if (NOT DEFINED WAMR_BUILD_PLATFORM)
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
endif ()
string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
# Reset default linker flags
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
@ -94,16 +83,6 @@ if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD)
set (WAMR_BUILD_LIB_PTHREAD 0)
endif ()
if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS)
# Disable wasi threads library by default
set (WAMR_BUILD_LIB_WASI_THREADS 0)
endif ()
if (NOT DEFINED WAMR_ENABLE_COPY_CALLSTACK)
# Disable copy callstack by default
set (WAMR_ENABLE_COPY_CALLSTACK 0)
endif()
if (NOT DEFINED WAMR_BUILD_MINI_LOADER)
# Disable wasm mini loader by default
set (WAMR_BUILD_MINI_LOADER 0)
@ -115,23 +94,25 @@ if (NOT DEFINED WAMR_BUILD_SIMD)
endif ()
if (NOT DEFINED WAMR_BUILD_REF_TYPES)
# Enable reference types by default
set (WAMR_BUILD_REF_TYPES 1)
# Disable reference types by default
set (WAMR_BUILD_REF_TYPES 0)
endif ()
if (COLLECT_CODE_COVERAGE EQUAL 1)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif ()
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
if (NOT WIN32)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security \
-ffunction-sections -fdata-sections \
-Wno-unused-parameter -Wno-pedantic \
-fvisibility=hidden")
# Remove the extra spaces for better make log
string (REGEX REPLACE " *" " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
endif()
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow")
# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused")
if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
@ -149,47 +130,25 @@ endif ()
include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# STATIC LIBRARY
add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE})
set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib)
if (MSVC)
add_definitions(-DCOMPILING_WASM_RUNTIME_API=1)
endif ()
install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE})
set_target_properties (vmlib PROPERTIES OUTPUT_NAME iwasm)
target_include_directories(vmlib INTERFACE
$<BUILD_INTERFACE:${WAMR_ROOT_DIR}/core/iwasm/include>
$<INSTALL_INTERFACE:include/iwasm>
)
target_link_libraries (vmlib PUBLIC ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl ${CMAKE_THREAD_LIBS_INIT})
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
target_link_libraries(vmlib INTERFACE boringssl_crypto)
endif ()
# SHARED LIBRARY
add_library (iwasm_shared SHARED ${WAMR_RUNTIME_LIB_SOURCE})
set_target_properties (iwasm_shared PROPERTIES OUTPUT_NAME iwasm)
target_link_libraries (iwasm_shared ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread)
if (MINGW)
target_link_libraries(vmlib INTERFACE -lWs2_32 -lwsock32)
target_link_libraries(vmlib PRIVATE ws2_32)
target_link_libraries (iwasm_shared -lWs2_32)
endif ()
if (WIN32)
target_link_libraries(vmlib PRIVATE ntdll)
endif()
install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
set (WAMR_PUBLIC_HEADERS
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h
${WAMR_ROOT_DIR}/core/iwasm/include/lib_export.h
)
set_target_properties (vmlib PROPERTIES PUBLIC_HEADER "${WAMR_PUBLIC_HEADERS}")
set_version_info (vmlib)
install (TARGETS vmlib
EXPORT iwasmTargets
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/iwasm
)
install_iwasm_package ()
# HEADERS
install (FILES
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_c_api.h
${WAMR_ROOT_DIR}/core/iwasm/include/wasm_export.h
DESTINATION include)

View File

@ -1,29 +0,0 @@
# In this project, we use CODEOWNERS to identify people who are likely to know
# who should review a pull request.
#
# People listed in this file are committing to respond in a timely fashion to
# PRs in the selected areas. However, that response doesn't have to be a full
# code review; it could also take any of these forms:
#
# - "I intend to review this but I can't yet. Please leave me a message if I
# haven't responded by (a specific date in the near future)."
#
# - "I think (a specific other contributor) should review this." (Note that the
# best reviewer for a PR may not necessarily be listed in this file.)
#
# People must only be added to this file if they've agreed to provide one of
# the above responses in a reasonable amount of time for every PR to which
# they're assigned.
#
# We only ask for this commitment from people who are employed full-time to
# work on this project. We gratefully welcome reviews from other contributors,
# but we don't believe it's fair to ask volunteers to respond quickly.
# If none of the later patterns match, assign to anyone. This team is the
# parent of all the other teams and automatically includes everyone on those
# teams.
* @loganek @lum1n0us @no1wudi @TianlongLiang @wenyongh @xujuntwt95329 @yamt
# Some parts of the project require more specialized knowledge. In those areas
# we designate smaller groups who are more likely to be aware of who's working
# in specific areas.

View File

@ -19,7 +19,7 @@ Code changes
We Use Github Flow, So All Code Changes Happen Through Pull Requests. Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
- If you've added code that should be tested, add tests. Ensure the test suite passes.
- Avoid use macros for different platforms. Use separate folder of source files to host different platform logic.
- Avoid use macros for different platforms. Use seperate folder of source files to host diffeent platform logic.
- Put macro definitions inside share_lib/include/config.h if you have to use macro.
- Make sure your code lints and compliant to our coding style.
- Extend the application library is highly welcome.
@ -27,7 +27,7 @@ We Use Github Flow, So All Code Changes Happen Through Pull Requests. Pull reque
Coding Style
===============================
Please use [K&R](https://en.wikipedia.org/wiki/Indentation_style#K.26R) coding style, such as 4 spaces for indentation rather than tabs etc.
We suggest using VS Code like IDE or stable coding format tools, like clang-format, to make your code compliant to the customized format(in .clang-format).
We suggest use Eclipse like IDE or stable coding format tools to make your code compliant to K&R format.
Report bugs
===================

191
README.md
View File

@ -1,56 +1,64 @@
# WebAssembly Micro Runtime
WebAssembly Micro Runtime
=========================
[Build WAMR](./doc/build_wamr.md) | [Build AOT Compiler](./README.md#build-wamrc-aot-compiler) | [Embed WAMR](./doc/embed_wamr.md) | [Export Native API](./doc/export_native_api.md) | [Build WASM Apps](./doc/build_wasm_app.md) | [Samples](./README.md#samples)
**A [Bytecode Alliance][BA] project**
[BA]: https://bytecodealliance.org/
**[Guide](https://wamr.gitbook.io/)**&emsp;&emsp;**[Website](https://bytecodealliance.github.io/wamr.dev)**&emsp;&emsp;**[Chat](https://bytecodealliance.zulipchat.com/#narrow/stream/290350-wamr)**
WebAssembly Micro Runtime (WAMR) is a lightweight standalone WebAssembly (WASM) runtime with small footprint, high performance and highly configurable features for applications cross from embedded, IoT, edge to Trusted Execution Environment (TEE), smart contract, cloud native and so on. It includes a few parts as below:
- The [**"iwasm" VM core**](./README.md#iwasm-vm-core) to run WASM applications, supporting interpreter mode, AOT mode (Ahead-of-Time compilation) and JIT modes (Just-in-Time compilation, LLVM JIT and Fast JIT are supported)
[Build WAMR](./doc/build_wamr.md) | [Build AOT Compiler](./wamr-compiler/README.md) | [Embed WAMR](./doc/embed_wamr.md) | [Export Native API](./doc/export_native_api.md) | [Build Wasm Apps](./doc/build_wasm_app.md) | [Samples](./samples/README.md)
- The [**"wamrc" AOT compiler**](./README.md#build-wamrc-aot-compiler) to compile WASM file into AOT file for best performance and smaller runtime footprint, which is run by "iwasm" VM Core
WebAssembly Micro Runtime (WAMR) is a lightweight standalone WebAssembly (Wasm) runtime with small footprint, high performance and highly configurable features for applications cross from embedded, IoT, edge to Trusted Execution Environment (TEE), smart contract, cloud native and so on. It includes a few parts as below:
- [**VMcore**](./core/iwasm/): A set of runtime libraries for loading and running Wasm modules. It supports rich running modes including interpreter, Ahead-of-Time compilation(AoT) and Just-in-Time compilation (JIT). WAMR supports two JIT tiers - Fast JIT, LLVM JIT, and dynamic tier-up from Fast JIT to LLVM JIT.
- [**iwasm**](./product-mini/): The executable binary built with WAMR VMcore which supports WASI and command line interface.
- [**wamrc**](./wamr-compiler/): The AOT compiler to compile Wasm file into AOT file
- Useful components and tools for building real solutions with WAMR vmcore:
- [App-framework](https://github.com/bytecodealliance/wamr-app-framework/blob/main/app-framework/README.md): A framework for supporting APIs for the Wasm applications
- [App-manager](https://github.com/bytecodealliance/wamr-app-framework/blob/main/app-mgr/README.md): A framework for dynamical loading the Wasm module remotely
- [WAMR-IDE](./test-tools/wamr-ide): An experimental VSCode extension for developping WebAssembly applications with C/C++
- The [**application framework**](./README.md#application-framework) and the supporting APIs for the WASM applications
- The [**dynamic management**](./README.md#remote-application-management) of the WASM applications
Getting started
==================
- [Build iwasm VM core](./doc/build_wamr.md) on [Linux](./doc/build_wamr.md#linux), [SGX](./doc/linux_sgx.md), [MacOS](./doc/build_wamr.md#macos) and [Windows](./doc/build_wamr.md#windows), and [Build wamrc AOT compiler](./README.md#build-wamrc-aot-compiler)
- [Embed WAMR into host applications](./doc/embed_wamr.md)
- [Embed into C/C++](./doc/embed_wamr.md), [Embed into Python](./language-bindings/python), [Embed into Go](./language-bindings/go)
- [Register native APIs for WASM applications](./doc/export_native_api.md)
- [Build WASM applications](./doc/build_wasm_app.md)
- [Port WAMR to a new platform](./doc/port_wamr.md)
- [Benchmarks](./tests/benchmarks) and [Samples](./samples)
iwasm VM core
=========================
### Key features
- Full compliant to the W3C Wasm MVP
- Small runtime binary size (core vmlib on cortex-m4f with tail-call/bulk memroy/shared memroy support, text size from bloaty)
* ~58.9K for fast interpreter
* ~56.3K for classic interpreter
* ~29.4K for aot runtime
* ~21.4K for libc-wasi library
* ~3.7K for libc-builtin library
- Full compliant to the W3C WASM MVP
- Small runtime binary size (~85K for interpreter and ~50K for AOT) and low memory usage
- Near to native speed by AOT and JIT
- Self-implemented AOT module loader to enable AOT working on Linux, Windows, MacOS, Android, SGX and MCU systems
- Choices of Wasm application libc support: the built-in libc subset for the embedded environment or [WASI](https://github.com/WebAssembly/WASI) for the standard libc
- Choices of WASM application libc support: the built-in libc subset for the embedded environment or [WASI](https://github.com/WebAssembly/WASI) for the standard libc
- [The simple C APIs to embed WAMR into host environment](./doc/embed_wamr.md), see [how to integrate WAMR](./doc/embed_wamr.md) and the [API list](./core/iwasm/include/wasm_export.h)
- [The mechanism to export native APIs to Wasm applications](./doc/export_native_api.md), see [how to register native APIs](./doc/export_native_api.md)
- [The mechanism to export native APIs to WASM applications](./doc/export_native_api.md), see [how to register native APIs](./doc/export_native_api.md)
- [Multiple modules as dependencies](./doc/multi_module.md), ref to [document](./doc/multi_module.md) and [sample](samples/multi-module)
- [Multi-thread, pthread APIs and thread management](./doc/pthread_library.md), ref to [document](./doc/pthread_library.md) and [sample](samples/multi-thread)
- [wasi-threads](./doc/pthread_impls.md#wasi-threads-new), ref to [document](./doc/pthread_impls.md#wasi-threads-new) and [sample](samples/wasi-threads)
- [Linux SGX (Intel Software Guard Extension) support](./doc/linux_sgx.md), ref to [document](./doc/linux_sgx.md)
- [Source debugging support](./doc/source_debugging.md), ref to [document](./doc/source_debugging.md)
- [WAMR-IDE (Experimental)](./test-tools/wamr-ide) to develop WebAssembly applications with build, run and debug support, ref to [document](./test-tools/wamr-ide)
- [XIP (Execution In Place) support](./doc/xip.md), ref to [document](./doc/xip.md)
- [Berkeley/Posix Socket support](./doc/socket_api.md), ref to [document](./doc/socket_api.md) and [sample](./samples/socket-api)
- [Multi-tier JIT](./product-mini#linux) and [Running mode control](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/)
- Language bindings: [Go](./language-bindings/go/README.md), [Python](./language-bindings/python/README.md), [Rust](./language-bindings/rust/README.md)
- Language bindings: [Go](./language-bindings/go/README.md), [Python](./language-bindings/python/README.md)
### Wasm post-MVP features
### WASM post-MVP features
- [wasm-c-api](https://github.com/WebAssembly/wasm-c-api), ref to [document](doc/wasm_c_api.md) and [sample](samples/wasm-c-api)
- [128-bit SIMD](https://github.com/WebAssembly/simd), ref to [samples/workload](samples/workload)
- [Reference Types](https://github.com/WebAssembly/reference-types), ref to [document](doc/ref_types.md) and [sample](samples/ref-types)
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations), [Shared memory](https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md#shared-linear-memory), [Memory64](https://github.com/WebAssembly/memory64)
- [Tail-call](https://github.com/WebAssembly/tail-call), [Garbage Collection](https://github.com/WebAssembly/gc), [Exception Handling](https://github.com/WebAssembly/exception-handling)
- [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions)
- [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops), [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations)
- [Multi-value](https://github.com/WebAssembly/multi-value), [Tail-call](https://github.com/WebAssembly/tail-call), [Shared memory](https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md#shared-linear-memory)
### Supported architectures and platforms
The WAMR VMcore supports the following architectures:
The iwasm supports the following architectures:
- X86-64, X86-32
- ARM, THUMB (ARMV7 Cortex-M7 and Cortex-A15 are tested)
- AArch64 (Cortex-A57 and Cortex-A53 are tested)
@ -58,51 +66,113 @@ The WAMR VMcore supports the following architectures:
- XTENSA, MIPS, ARC
The following platforms are supported, click each link below for how to build iwasm on that platform. Refer to [WAMR porting guide](./doc/port_wamr.md) for how to port WAMR to a new platform.
- [Linux](./product-mini/README.md#linux), [Linux SGX (Intel Software Guard Extension)](./doc/linux_sgx.md), [MacOS](./product-mini/README.md#macos), [Android](./product-mini/README.md#android), [Windows](./product-mini/README.md#windows), [Windows (MinGW, MSVC)](./product-mini/README.md#mingw)
- [Zephyr](./product-mini/README.md#zephyr), [AliOS-Things](./product-mini/README.md#alios-things), [VxWorks](./product-mini/README.md#vxworks), [NuttX](./product-mini/README.md#nuttx), [RT-Thread](./product-mini/README.md#RT-Thread), [ESP-IDF(FreeRTOS)](./product-mini/README.md#esp-idf)
- [Linux](./doc/build_wamr.md#linux), [Linux SGX (Intel Software Guard Extension)](./doc/linux_sgx.md), [MacOS](./doc/build_wamr.md#macos), [Android](./doc/build_wamr.md#android), [Windows](./doc/build_wamr.md#windows), [Windows (MinGW)](./doc/build_wamr.md#mingw)
- [Zephyr](./doc/build_wamr.md#zephyr), [AliOS-Things](./doc/build_wamr.md#alios-things), [VxWorks](./doc/build_wamr.md#vxworks), [NuttX](./doc/build_wamr.md#nuttx), [RT-Thread](./doc/build_wamr.md#RT-Thread), [ESP-IDF](./doc/build_wamr.md#esp-idf)
## Getting started
- [Build VM core](./doc/build_wamr.md) and [Build wamrc AOT compiler](./wamr-compiler/README.md)
- [Build iwasm (mini product)](./product-mini/README.md): [Linux](./product-mini/README.md#linux), [SGX](./doc/linux_sgx.md), [MacOS](./product-mini/README.md#macos) and [Windows](./product-mini/README.md#windows)
- [Embed into C/C++](./doc/embed_wamr.md), [Embed into Python](./language-bindings/python), [Embed into Go](./language-bindings/go), [Embed in Rust](./language-bindings/rust)
- [Register native APIs for Wasm applications](./doc/export_native_api.md)
- [Build wamrc AOT compiler](./wamr-compiler/README.md)
- [Build Wasm applications](./doc/build_wasm_app.md)
- [Port WAMR to a new platform](./doc/port_wamr.md)
- [VS Code development container](./doc/devcontainer.md)
- [Samples](./samples) and [Benchmarks](./tests/benchmarks)
- [End-user APIs documentation](https://bytecodealliance.github.io/wamr.dev/apis/)
### Build iwasm VM core (mini product)
WAMR supports building the iwasm VM core only (no app framework) to the mini product. The WAMR mini product takes the WASM application file name or AOT file name as input and then executes it. For the detailed procedure, please see **[build WAMR VM core](./doc/build_wamr.md)** and **[build and run WASM application](./doc/build_wasm_app.md)**. Also we can click the link of each platform above to see how to build iwasm on it.
### Performance and memory
- [Blog: The WAMR memory model](https://bytecodealliance.github.io/wamr.dev/blog/the-wamr-memory-model/)
- [Blog: Understand WAMR heaps](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-heaps/) and [stacks](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-stacks/)
- [Blog: Introduction to WAMR running modes](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/)
- [Memory usage tuning](./doc/memory_tune.md): the memory model and how to tune the memory usage
- [Memory usage profiling](./doc/build_wamr.md#enable-memory-profiling-experiment): how to profile the memory usage
- [Performance tuning](./doc/perf_tune.md): how to tune the performance
### Build wamrc AOT compiler
Both wasm binary file and AOT file are supported by iwasm. The wamrc AOT compiler is to compile wasm binary file to AOT file which can also be run by iwasm. Execute following commands to build **wamrc** compiler for Linux:
```shell
cd wamr-compiler
./build_llvm.sh (or "./build_llvm_xtensa.sh" to support xtensa target)
mkdir build && cd build
cmake .. (or "cmake .. -DWAMR_BUILD_PLATFORM=darwin" for MacOS)
make
# wamrc is generated under current directory
```
For **Windows**
```shell
cd wamr-compiler
python build_llvm.py
mkdir build && cd build
cmake ..
cmake --build . --config Release
# wamrc.exe is generated under .\Release directory
```
### Performance and Footprint
- [Performance and footprint data](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Performance): checkout [here](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Performance) for the performance and footprint data
- [Memory usage tunning](./doc/memory_tune.md): checkout [here](./doc/memory_tune.md) for the memory model and how to tune the memory usage
- [Memory usage profiling](./doc/build_wamr.md#enable-memory-profiling-experiment): checkout [here](./doc/build_wamr.md#enable-memory-profiling-experiment) for how to profile the memory usage
- [Benchmarks](./tests/benchmarks): checkout these links for how to run the benchmarks: [PolyBench](./tests/benchmarks/polybench), [CoreMark](./tests/benchmarks/coremark), [Sightglass](./tests/benchmarks/sightglass), [JetStream2](./tests/benchmarks/jetstream)
- [Performance and footprint data](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Performance): the performance and footprint data
### User cases
WAMR is widely used in a lot areas, here are some cases:
- [Hyperledger Private Data Objects](https://github.com/hyperledger-labs/private-data-objects/blob/main/common/interpreter/wawaka_wasm/README.md)
- [Inclavare Containers](https://github.com/alibaba/inclavare-containers)
- [Fassm](https://github.com/faasm/faasm)
- [Waft](https://developer.aliyun.com/article/787582)
- [Envoy Proxy](https://github.com/envoyproxy/envoy)
- [Apache Teaclave](https://teaclave.apache.org/docs/executing-wasm)
Application framework
===================================
By using the iwasm VM core, we are flexible to build different application frameworks for the specific domains, although it would take quite some effort.
The WAMR has offered a comprehensive framework for programming WASM applications for device and IoT usages. The framework supports running multiple applications, that are based on the event driven programming model. Here are the supporting API sets by the [WAMR application framework library](./doc/wamr_api.md) :
- Timer, Inter-app communication (request/response and pub/sub), Sensor, Connectivity and data transmission, 2D graphic UI
Browse the folder [core/app-framework](./core/app-framework) for how to extend the application framework.
# Remote application management
The WAMR application manager supports [remote application management](./core/app-mgr) from the host environment or the cloud through any physical communications such as TCP, UPD, UART, BLE, etc. Its modular design makes it able to support application management for different managed runtimes.
The tool [host_tool](./test-tools/host-tool) communicates to the WAMR app manager for installing/uninstalling the WASM applications on companion chip from the host system. And the [IoT App Store Demo](./test-tools/IoT-APP-Store-Demo/) shows the conception of remotely managing the device applications from the cloud.
WAMR SDK
==========
Usually there are two tasks for integrating the WAMR into a particular project:
- Select what WAMR components (vmcore, libc, app-mgr, app-framework components) to be integrated, and get the associated source files added into the project building configuration
- Generate the APP SDK for developing the WASM apps on the selected libc and framework components
The **[WAMR SDK](./wamr-sdk)** tools is helpful to finish the two tasks quickly. It supports menu configuration for selecting WAMR components and builds the WAMR to a SDK package that includes **runtime SDK** and **APP SDK**. The runtime SDK is used for building the native application and the APP SDK should be shipped to WASM application developers.
Samples
=================
The WAMR [samples](./samples) integrate the iwasm VM core, application manager and selected application framework components.
- [**basic**](./samples/basic): Demonstrating how to use runtime exposed API's to call WASM functions, how to register native functions and call them, and how to call WASM function from native function.
- **[simple](./samples/simple/README.md)**: The runtime is integrated with most of the WAMR APP libraries, and a few WASM applications are provided for testing the WAMR APP API set. It uses **built-in libc** and executes apps in **interpreter** mode by default.
- **[littlevgl](./samples/littlevgl/README.md)**: Demonstrating the graphic user interface application usage on WAMR. The whole [LVGL](https://github.com/lvgl/lvgl) 2D user graphic library and the UI application are built into WASM application. It uses **WASI libc** and executes apps in **AOT mode** by default.
- **[gui](./samples/gui/README.md)**: Move the [LVGL](https://github.com/lvgl/lvgl) library into the runtime and define a WASM application interface by wrapping the littlevgl API. It uses **WASI libc** and executes apps in **interpreter** mode by default.
- **[multi-thread](./samples/multi-thread/)**: Demonstrating how to run wasm application which creates multiple threads to execute wasm functions concurrently, and uses mutex/cond by calling pthread related API's.
- **[spawn-thread](./samples/spawn-thread)**: Demonstrating how to execute wasm functions of the same wasm application concurrently, in threads created by host embedder or runtime, but not the wasm application itself.
- **[multi-module](./samples/multi-module)**: Demonstrating the [multiple modules as dependencies](./doc/multi_module.md) feature which implements the [load-time dynamic linking](https://webassembly.org/docs/dynamic-linking/).
- **[ref-types](./samples/ref-types)**: Demonstrating how to call wasm functions with argument of externref type introduced by [reference types proposal](https://github.com/WebAssembly/reference-types).
- **[wasm-c-api](./samples/wasm-c-api/README.md)**: Demonstrating how to run some samples from [wasm-c-api proposal](https://github.com/WebAssembly/wasm-c-api) and showing the supported API's.
- **[socket-api](./samples/socket-api/README.md)**: Demonstrating how to run wasm tcp server and tcp client applications, and how they communicate with each other.
- **[workload](./samples/workload/README.md)**: Demonstrating how to build and run some complex workloads, e.g. tensorflow-lite, XNNPACK, wasm-av1, meshoptimizer and bwa.
- **[sgx-ra](./samples/sgx-ra/README.md)**: Demonstrating how to execute Remote Attestation on SGX with [librats](https://github.com/inclavare-containers/librats), which enables mutual attestation with other runtimes or other entities that support librats to ensure that each is running within the TEE.
Project Technical Steering Committee
====================================
The [WAMR PTSC Charter](./TSC_Charter.md) governs the operations of the project TSC.
The current TSC members:
- [dongsheng28849455](https://github.com/dongsheng28849455) - **Dongsheng Yan**, <dongsheng.yan@sony.com>
- [loganek](https://github.com/loganek) - **Marcin Kolny**, <mkolny@amazon.co.uk>
- [lum1n0us](https://github.com/lum1n0us) - **Liang He** <liang.he@intel.com>
- [no1wudi](https://github.com/no1wudi) **Qi Huang**, <huangqi3@xiaomi.com>
- [qinxk-inter](https://github.com/qinxk-inter) - **Xiaokang Qin** <xiaokang.qxk@antgroup.com>
- [ttrenner ](https://github.com/ttrenner) - **Trenner, Thomas** <trenner.thomas@siemens.com>
- [wei-tang](https://github.com/wei-tang) - **Wei Tang** <tangwei.tang@antgroup.com>
- [wenyongh](https://github.com/wenyongh) - **Wenyong Huang** <wenyong.huang@intel.com>
- [woodsmc](https://github.com/woodsmc) - **Woods, Chris** <chris.woods@siemens.com>
- [xujuntwt95329](https://github.com/xujuntwt95329) - **Jun Xu** <Jun1.Xu@intel.com>
- [xwang98](https://github.com/xwang98) - **Xin Wang** <xin.wang@intel.com> (chair)
- [yamt](https://github.com/yamt) - **Takashi Yamamoto**, <yamamoto@midokura.com>
License
=======
@ -112,8 +182,11 @@ use, modify, distribute and sell your own products based on WAMR.
Any contributions you make will be under the same license.
# More resources
- [Who use WAMR?](https://github.com/bytecodealliance/wasm-micro-runtime/wiki)
- [WAMR Blogs](https://bytecodealliance.github.io/wamr.dev/blog/)
- [Community news and events](https://bytecodealliance.github.io/wamr.dev/events/)
- [WAMR TSC meetings](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/TSC-meeting-notes)
Check out the [Wiki documents ](https://github.com/bytecodealliance/wasm-micro-runtime/wiki) for more resources:
- [Community news and events](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Events)
- [Roadmap](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Roadmap)
- [WAMR TSC meetings](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/TSC-meeting)
- Technical documents

File diff suppressed because it is too large Load Diff

1
assembly-script/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/node_modules

124
assembly-script/README.md Normal file
View File

@ -0,0 +1,124 @@
# AssemblyScript_on_WAMR
This project is based on [Wasm Micro Runtime](https://github.com/bytecodealliance/wasm-micro-runtime) (WAMR) and [AssemblyScript](https://github.com/AssemblyScript/assemblyscript). It implements some of the `wamr app framework` in *assemblyscript*, which allows you to write some applications in *assemblyscript* and dynamically installed on *WAMR Runtime*
## Building
To build the samples in this repo, you need `npm` on your system
``` bash
sudo apt install npm
```
Then install all the dependencies under the repo's root dir
``` bash
cd $repo_root
npm install
```
Use the command to build all samples:
``` bash
npm run build:all
```
or you can build every sample individually:
``` bash
npm run build:timer
npm run build:publisher
npm run build:subscriber
# ...
```
You will get the compiled wasm file under `build` folder
Please refer to [package.json](./package.json) for more commands.
## Run
These applications require WAMR's application framework, you need to build WAMR first.
``` bash
cd ${WAMR_ROOT}/samples/simple
./build.sh
```
You will get two executable files under `out` folder:
`simple`: The wamr runtime with application framework
`host_tool`: The tool used to dynamically install/uninstall applications
1. Start the runtime:
``` bash
./simple -s
```
2. Install the compiled wasm file using `host_tool`:
``` bash
./host_tool -i app_name -f your_compiled_wasm_file.wasm
```
You can also use the WAMR's AoT compiler `wamrc` to compile the wasm bytecode into native code before you run them. Please refer to this [guide](../README.md#build-wamrc-aot-compiler) to build and install `WAMR AoT compiler`.
After installing `wamrc`, you can compile the wasm file using command:
``` bash
wamrc -o file_name.aot file_name.wasm
```
and you can install the AoT file to the runtime:
``` bash
./host_tool -i app_name -f your_compiled_aot_file.aot
```
## Development
You can develop your own application based on the `wamr_app_lib` APIs.
### Console APIs
``` typescript
function log(a: string): void;
function log_number(a: number): void;
```
### Timer APIs
``` typescript
function setTimeout(cb: () => void, timeout: i32): user_timer;
function setInterval(cb: () => void, timeout: i32): user_timer;
function timer_cancel(timer: user_timer): void;
function timer_restart(timer: user_timer, interval: number): void;
function now(): i32;
// export to runtime
function on_timer_callback(on_timer_id: i32): void;
```
### Request APIs
``` typescript
// register handler
function register_resource_handler(url: string,
request_handle: request_handler_f): void;
// request
function post(url: string, payload: ArrayBuffer, payload_len: number,
tag: string, cb: (resp: wamr_response) => void): void;
function get(url: string, tag: string,
cb: (resp: wamr_response) => void): void;
function put(url: string, payload: ArrayBuffer, payload_len: number, tag: string,
cb: (resp: wamr_response) => void): void;
function del(url: string, tag: string,
cb: (resp: wamr_response) => void): void;
// response
function make_response_for_request(req: wamr_request): wamr_response;
function api_response_send(resp: wamr_response): void;
// event
function publish_event(url: string, fmt: number,
payload: ArrayBuffer, payload_len: number): void;
function subscribe_event(url: string, cb: request_handler_f): void;
// export to runtime
function on_request(buffer_offset: i32, size: i32): void;
function on_response(buffer_offset : i32, size: i32): void;
```
You should export the `on_timer_callback`, `on_request` and `on_response` in your application entry file, refer to the samples for example.
To build your application, you can use `asc`:
``` bash
asc app.ts -b build/app.wasm -t build/app.wat --sourceMap --validate --optimize
```
or you can add a command into [package.json](./package.json):
``` json
"build:app": "asc app.ts -b build/app.wasm -t build/app.wat --sourceMap --validate --optimize",
```

30
assembly-script/package-lock.json generated Normal file
View File

@ -0,0 +1,30 @@
{
"name": "assembly_script",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"assemblyscript": {
"version": "0.17.4",
"resolved": "https://registry.npm.taobao.org/assemblyscript/download/assemblyscript-0.17.4.tgz",
"integrity": "sha1-1GEduJpClDNa1H7DxmYaJqRCh3E=",
"dev": true,
"requires": {
"binaryen": "98.0.0-nightly.20201109",
"long": "^4.0.0"
}
},
"binaryen": {
"version": "98.0.0-nightly.20201109",
"resolved": "https://registry.npm.taobao.org/binaryen/download/binaryen-98.0.0-nightly.20201109.tgz",
"integrity": "sha1-USv2yhXGe/dAIURzSkg25jmTqgU=",
"dev": true
},
"long": {
"version": "4.0.0",
"resolved": "https://registry.npm.taobao.org/long/download/long-4.0.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flong%2Fdownload%2Flong-4.0.0.tgz",
"integrity": "sha1-mntxz7fTYaGU6lVSQckvdGjVvyg=",
"dev": true
}
}
}

View File

@ -0,0 +1,20 @@
{
"name": "assembly_script",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:request_handler": "asc samples/request_handler.ts -b build/request_handler.wasm -t build/request_handler.wat --sourceMap --optimize --exportRuntime --use abort=",
"build:request_sender": "asc samples/request_sender.ts -b build/request_sender.wasm -t build/request_sender.wat --sourceMap --optimize --exportRuntime --use abort=",
"build:timer": "asc samples/timer.ts -b build/timer.wasm -t build/timer.wat --sourceMap --optimize --exportRuntime --use abort=",
"build:publisher": "asc samples/event_publisher.ts -b build/event_publisher.wasm -t build/event_publisher.wat --sourceMap --optimize --exportRuntime --use abort=",
"build:subscriber": "asc samples/event_subscriber.ts -b build/event_subscriber.wasm -t build/event_subscriber.wat --sourceMap --optimize --exportRuntime --use abort=",
"build:all": "npm run build:request_handler; npm run build:request_sender; npm run build:timer; npm run build:subscriber; npm run build:publisher"
},
"author": "",
"license": "ISC",
"devDependencies": {
"assemblyscript": "^0.18.15"
}
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
// The entry file of your WebAssembly module.
import * as console from "../wamr_app_lib/console"
import * as timer from "../wamr_app_lib/timer"
import * as request from "../wamr_app_lib/request"
function publish_overheat_event(): void {
var payload = String.UTF8.encode("warning: temperature is over high");
request.publish_event("alert/overheat", 0, payload, payload.byteLength);
}
export function on_init() : void {
timer.setInterval(publish_overheat_event, 2000);
}
export function on_destroy() : void {
}
/* Function below are requred by wamr runtime, don't remove or modify them */
export function _on_timer_callback(on_timer_id: i32): void {
timer.on_timer_callback(on_timer_id);
}
export function _on_request(buffer_offset: i32, size: i32): void {
request.on_request(buffer_offset, size);
}
export function _on_response(buffer_offset : i32, size: i32): void {
request.on_response(buffer_offset, size);
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
// The entry file of your WebAssembly module.
import * as console from "../wamr_app_lib/console"
import * as timer from "../wamr_app_lib/timer"
import * as request from "../wamr_app_lib/request"
export function on_init() : void {
request.subscribe_event("alert/overheat", (req) => {
console.log("### user over heat event handler called:");
console.log("");
console.log(" " + String.UTF8.decode(req.payload) + "\n");
})
}
export function on_destroy() : void {
}
/* Function below are requred by wamr runtime, don't remove or modify them */
export function _on_timer_callback(on_timer_id: i32): void {
timer.on_timer_callback(on_timer_id);
}
export function _on_request(buffer_offset: i32, size: i32): void {
request.on_request(buffer_offset, size);
}
export function _on_response(buffer_offset : i32, size: i32): void {
request.on_response(buffer_offset, size);
}

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
// The entry file of your WebAssembly module.
import * as console from "../wamr_app_lib/console"
import * as timer from "../wamr_app_lib/timer"
import * as request from "../wamr_app_lib/request"
export function on_init() : void {
request.register_resource_handler("/test", (req) => {
console.log("### Req: /test " + String.UTF8.decode(req.payload));
console.log(" request payload:");
console.log(" " + String.UTF8.decode(req.payload) + "\n");
var resp = request.make_response_for_request(req);
resp.set_payload(String.UTF8.encode("Ok"), 2);
request.api_response_send(resp);
});
}
export function on_destroy() : void {
}
/* Function below are requred by wamr runtime, don't remove or modify them */
export function _on_timer_callback(on_timer_id: i32): void {
timer.on_timer_callback(on_timer_id);
}
export function _on_request(buffer_offset: i32, size: i32): void {
request.on_request(buffer_offset, size);
}
export function _on_response(buffer_offset : i32, size: i32): void {
request.on_response(buffer_offset, size);
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
// The entry file of your WebAssembly module.
import * as console from "../wamr_app_lib/console"
import * as timer from "../wamr_app_lib/timer"
import * as request from "../wamr_app_lib/request"
export function on_init() : void {
var payload = String.UTF8.encode("test message");
request.post("/test", payload, payload.byteLength, "", (resp) => {
if (resp != null) {
console.log("Post Success");
if (resp.payload != null) {
console.log(" response payload:")
console.log(" " + String.UTF8.decode(resp.payload!) + "\n");
}
}
else
console.log("Post Timeout");
});
}
export function on_destroy() : void {
}
/* Function below are requred by wamr runtime, don't remove or modify them */
export function _on_timer_callback(on_timer_id: i32): void {
timer.on_timer_callback(on_timer_id);
}
export function _on_request(buffer_offset: i32, size: i32): void {
request.on_request(buffer_offset, size);
}
export function _on_response(buffer_offset : i32, size: i32): void {
request.on_response(buffer_offset, size);
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
// The entry file of your WebAssembly module.
import * as console from '../wamr_app_lib/console'
import * as timer from '../wamr_app_lib/timer'
/* clousure is not implemented yet, we need to declare global variables
so that they can be accessed inside a callback function */
var cnt = 0;
var my_timer: timer.user_timer;
export function on_init(): void {
/* The callback function will be called every 2 second,
and will stop after 10 calls */
my_timer = timer.setInterval(() => {
cnt ++;
console.log((cnt * 2).toString() + " seconds passed");
if (cnt >= 10) {
timer.timer_cancel(my_timer);
console.log("Stop Timer");
}
}, 2000);
}
export function on_destroy(): void {
}
/* Function below are requred by wamr runtime, don't remove or modify them */
export function _on_timer_callback(on_timer_id: i32): void {
timer.on_timer_callback(on_timer_id);
}

View File

@ -0,0 +1,6 @@
{
"extends": "../node_modules/assemblyscript/std/assembly.json",
"include": [
"./**/*.ts"
]
}

View File

@ -12,4 +12,4 @@ export function log(a: string): void {
export function log_number(a: number): void {
printf(String.UTF8.encode(a.toString()));
}
}

View File

@ -0,0 +1,495 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
import * as console from './console'
import * as timer from './timer'
@external("env", "wasm_response_send")
declare function wasm_response_send(buffer: ArrayBuffer, size: i32): void;
@external("env", "wasm_register_resource")
declare function wasm_register_resource(url: ArrayBuffer): void;
@external("env", "wasm_post_request")
declare function wasm_post_request(buffer: ArrayBuffer, size: i32): void;
@external("env", "wasm_sub_event")
declare function wasm_sub_event(url: ArrayBuffer): void;
var COAP_GET = 1;
var COAP_POST = 2;
var COAP_PUT = 3;
var COAP_DELETE = 4;
var COAP_EVENT = COAP_DELETE + 2;
/* CoAP response codes */
export enum CoAP_Status {
NO_ERROR = 0,
CREATED_2_01 = 65, /* CREATED */
DELETED_2_02 = 66, /* DELETED */
VALID_2_03 = 67, /* NOT_MODIFIED */
CHANGED_2_04 = 68, /* CHANGED */
CONTENT_2_05 = 69, /* OK */
CONTINUE_2_31 = 95, /* CONTINUE */
BAD_REQUEST_4_00 = 128, /* BAD_REQUEST */
UNAUTHORIZED_4_01 = 129, /* UNAUTHORIZED */
BAD_OPTION_4_02 = 130, /* BAD_OPTION */
FORBIDDEN_4_03 = 131, /* FORBIDDEN */
NOT_FOUND_4_04 = 132, /* NOT_FOUND */
METHOD_NOT_ALLOWED_4_05 = 133, /* METHOD_NOT_ALLOWED */
NOT_ACCEPTABLE_4_06 = 134, /* NOT_ACCEPTABLE */
PRECONDITION_FAILED_4_12 = 140, /* BAD_REQUEST */
REQUEST_ENTITY_TOO_LARGE_4_13 = 141, /* REQUEST_ENTITY_TOO_LARGE */
UNSUPPORTED_MEDIA_TYPE_4_15 = 143, /* UNSUPPORTED_MEDIA_TYPE */
INTERNAL_SERVER_ERROR_5_00 = 160, /* INTERNAL_SERVER_ERROR */
NOT_IMPLEMENTED_5_01 = 161, /* NOT_IMPLEMENTED */
BAD_GATEWAY_5_02 = 162, /* BAD_GATEWAY */
SERVICE_UNAVAILABLE_5_03 = 163, /* SERVICE_UNAVAILABLE */
GATEWAY_TIMEOUT_5_04 = 164, /* GATEWAY_TIMEOUT */
PROXYING_NOT_SUPPORTED_5_05 = 165, /* PROXYING_NOT_SUPPORTED */
/* Erbium errors */
MEMORY_ALLOCATION_ERROR = 192, PACKET_SERIALIZATION_ERROR,
/* Erbium hooks */
MANUAL_RESPONSE, PING_RESPONSE
};
var g_mid: i32 = 0;
class wamr_request {
mid: i32 = 0;
url: string = "";
action: i32 = 0;
fmt: i32 = 0;
payload: ArrayBuffer;
payload_len: i32 = 0;
sender: i32 = 0;
constructor(mid: i32, url: string, action: i32, fmt: i32,
payload: ArrayBuffer, payload_len: number) {
this.mid = mid;
this.url = url;
this.action = action;
this.fmt = fmt;
this.payload = payload;
this.payload_len = i32(payload_len);
}
}
class wamr_response {
mid: i32 = 0;
status: i32 = 0;
fmt: i32 = 0;
payload: ArrayBuffer | null;
payload_len: i32 = 0;
receiver: i32 = 0;
constructor(mid: i32, status: i32, fmt: i32,
payload: ArrayBuffer | null, payload_len: i32) {
this.mid = mid;
this.status = status;
this.fmt = fmt;
this.payload = payload;
this.payload_len = payload_len;
}
set_status(status: number): void {
this.status = i32(status);
}
set_payload(payload: ArrayBuffer, payload_len: number): void {
this.payload = payload;
this.payload_len = i32(payload_len);
}
}
class wamr_resource {
url: string;
type: number;
cb: request_handler_f;
constructor(url: string, type: number, cb: request_handler_f) {
this.url = url;
this.type = type;
this.cb = cb;
}
}
function is_expire(trans: wamr_transaction, index: i32, array: Array<wamr_transaction>): bool {
var now = timer.now();
var elapsed_ms = (now < trans.time) ?
(now + (0xFFFFFFFF - trans.time) + 1) : (now - trans.time);
return elapsed_ms >= TRANSACTION_TIMEOUT_MS;
}
function not_expire(trans: wamr_transaction, index: i32, array: Array<wamr_transaction>): bool {
var now = timer.now();
var elapsed_ms = (now < trans.time) ?
(now + (0xFFFFFFFF - trans.time) + 1) : (now - trans.time);
return elapsed_ms >= TRANSACTION_TIMEOUT_MS;
}
function transaction_timeout_handler(): void {
var now = timer.now();
var expired = transaction_list.filter(is_expire);
transaction_list = transaction_list.filter(not_expire);
expired.forEach(item => {
item.cb(null);
transaction_remove(item);
})
if (transaction_list.length > 0) {
var elpased_ms: number, ms_to_expiry: number;
now = timer.now();
if (now < transaction_list[0].time) {
elpased_ms = now + (0xFFFFFFFF - transaction_list[0].time) + 1;
} else {
elpased_ms = now - transaction_list[0].time;
}
ms_to_expiry = TRANSACTION_TIMEOUT_MS - elpased_ms;
timer.timer_restart(g_trans_timer, ms_to_expiry);
} else {
timer.timer_cancel(g_trans_timer);
}
}
function transaction_find(mid: number): wamr_transaction | null {
for (let i = 0; i < transaction_list.length; i++) {
if (transaction_list[i].mid == mid)
return transaction_list[i];
}
return null;
}
function transaction_add(trans: wamr_transaction): void {
transaction_list.push(trans);
if (transaction_list.length == 1) {
g_trans_timer = timer.setTimeout(
transaction_timeout_handler,
TRANSACTION_TIMEOUT_MS
);
}
}
function transaction_remove(trans: wamr_transaction): void {
var index = transaction_list.indexOf(trans);
transaction_list.splice(index, 1);
}
var transaction_list = new Array<wamr_transaction>();
class wamr_transaction {
mid: number;
time: number;
cb: (resp: wamr_response | null) => void;
constructor(mid: number, time: number, cb: (resp: wamr_response) => void) {
this.mid = mid;
this.time = time;
this.cb = cb;
}
}
var REQUEST_PACKET_FIX_PART_LEN = 18;
var RESPONSE_PACKET_FIX_PART_LEN = 16;
var TRANSACTION_TIMEOUT_MS = 5000;
var g_trans_timer: timer.user_timer;
var Reg_Event = 0;
var Reg_Request = 1;
function pack_request(req: wamr_request): DataView {
var url_len = req.url.length + 1;
var len = REQUEST_PACKET_FIX_PART_LEN + url_len + req.payload_len
var buf = new ArrayBuffer(len);
var dataview = new DataView(buf, 0, len);
dataview.setUint8(0, 1);
dataview.setUint8(1, u8(req.action));
dataview.setUint16(2, u16(req.fmt));
dataview.setUint32(4, req.mid);
dataview.setUint32(8, req.sender);
dataview.setUint16(12, u16(url_len))
dataview.setUint32(14, req.payload_len);
var i = 0;
for (i = 0; i < url_len - 1; i++) {
dataview.setUint8(i + 18, u8(req.url.codePointAt(i)));
}
dataview.setUint8(i + 18, 0);
var payload_view = new DataView(req.payload);
for (i = 0; i < req.payload_len; i++) {
dataview.setUint8(i + 18 + url_len, u8(payload_view.getUint8(i)));
}
return dataview;
}
function unpack_request(packet: ArrayBuffer, size: i32): wamr_request {
var dataview = new DataView(packet, 0, size);
if (dataview.getUint8(0) != 1)
throw new Error("packet version mismatch");
if (size < REQUEST_PACKET_FIX_PART_LEN)
throw new Error("packet size error");
var url_len = dataview.getUint16(12);
var payload_len = dataview.getUint32(14);
if (size != (REQUEST_PACKET_FIX_PART_LEN + url_len + payload_len))
throw new Error("packet size error");
var action = dataview.getUint8(1);
var fmt = dataview.getUint16(2);
var mid = dataview.getUint32(4);
var sender = dataview.getUint32(8);
var url = packet.slice(REQUEST_PACKET_FIX_PART_LEN, REQUEST_PACKET_FIX_PART_LEN + url_len - 1);
var payload = packet.slice(REQUEST_PACKET_FIX_PART_LEN + url_len, REQUEST_PACKET_FIX_PART_LEN + url_len + payload_len);
var req = new wamr_request(mid, String.UTF8.decode(url), action, fmt, payload, payload_len);
req.sender = sender;
return req;
}
function pack_response(resp: wamr_response): DataView {
var len = RESPONSE_PACKET_FIX_PART_LEN + resp.payload_len
var buf = new ArrayBuffer(len);
var dataview = new DataView(buf, 0, len);
dataview.setUint8(0, 1);
dataview.setUint8(1, u8(resp.status));
dataview.setUint16(2, u16(resp.fmt));
dataview.setUint32(4, resp.mid);
dataview.setUint32(8, resp.receiver);
dataview.setUint32(12, resp.payload_len)
if (resp.payload != null) {
var payload_view = new DataView(resp.payload!);
for (let i = 0; i < resp.payload_len; i++) {
dataview.setUint8(i + 16, payload_view.getUint8(i));
}
}
return dataview;
}
function unpack_response(packet: ArrayBuffer, size: i32): wamr_response {
var dataview = new DataView(packet, 0, size);
if (dataview.getUint8(0) != 1)
throw new Error("packet version mismatch");
if (size < RESPONSE_PACKET_FIX_PART_LEN)
throw new Error("packet size error");
var payload_len = dataview.getUint32(12);
if (size != RESPONSE_PACKET_FIX_PART_LEN + payload_len)
throw new Error("packet size error");
var status = dataview.getUint8(1);
var fmt = dataview.getUint16(2);
var mid = dataview.getUint32(4);
var receiver = dataview.getUint32(8);
var payload = packet.slice(RESPONSE_PACKET_FIX_PART_LEN);
var resp = new wamr_response(mid, status, fmt, payload, payload_len);
resp.receiver = receiver;
return resp;
}
function do_request(req: wamr_request, cb: (resp: wamr_response) => void): void {
var trans = new wamr_transaction(req.mid, timer.now(), cb);
var msg = pack_request(req);
transaction_add(trans);
wasm_post_request(msg.buffer, msg.byteLength);
}
function do_response(resp: wamr_response): void {
var msg = pack_response(resp);
wasm_response_send(msg.buffer, msg.byteLength);
}
var resource_list = new Array<wamr_resource>();
type request_handler_f = (req: wamr_request) => void;
function registe_url_handler(url: string, cb: request_handler_f, type: number): void {
for (let i = 0; i < resource_list.length; i++) {
if (resource_list[i].type == type && resource_list[i].url == url) {
resource_list[i].cb = cb;
return;
}
}
var res = new wamr_resource(url, type, cb);
resource_list.push(res);
if (type == Reg_Request)
wasm_register_resource(String.UTF8.encode(url));
else
wasm_sub_event(String.UTF8.encode(url));
}
function is_event_type(req: wamr_request): bool {
return req.action == COAP_EVENT;
}
function check_url_start(url: string, leading_str: string): bool {
return url.split('/')[0] == leading_str.split('/')[0];
}
/* User APIs below */
export function post(url: string, payload: ArrayBuffer, payload_len: number, tag: string,
cb: (resp: wamr_response) => void): void {
var req = new wamr_request(g_mid++, url, COAP_POST, 0, payload, payload_len);
do_request(req, cb);
}
export function get(url: string, tag: string,
cb: (resp: wamr_response) => void): void {
var req = new wamr_request(g_mid++, url, COAP_GET, 0, new ArrayBuffer(0), 0);
do_request(req, cb);
}
export function put(url: string, payload: ArrayBuffer, payload_len: number, tag: string,
cb: (resp: wamr_response) => void): void {
var req = new wamr_request(g_mid++, url, COAP_PUT, 0, payload, payload_len);
do_request(req, cb);
}
export function del(url: string, tag: string,
cb: (resp: wamr_response) => void): void {
var req = new wamr_request(g_mid++, url, COAP_PUT, 0, new ArrayBuffer(0), 0);
do_request(req, cb);
}
export function make_response_for_request(req: wamr_request): wamr_response {
var resp = new wamr_response(req.mid, CoAP_Status.CONTENT_2_05, 0, null, 0);
resp.receiver = req.sender;
return resp;
}
export function api_response_send(resp: wamr_response): void {
do_response(resp);
}
export function register_resource_handler(url: string,
request_handle: request_handler_f): void {
registe_url_handler(url, request_handle, Reg_Request);
}
export function publish_event(url: string, fmt: number,
payload: ArrayBuffer, payload_len: number): void {
var req = new wamr_request(g_mid++, url, COAP_EVENT, i32(fmt), payload, payload_len);
var msg = pack_request(req);
wasm_post_request(msg.buffer, msg.byteLength);
}
export function subscribe_event(url: string, cb: request_handler_f): void {
registe_url_handler(url, cb, Reg_Event);
}
/* These two APIs are required by wamr runtime,
use a wrapper to export them in the entry file
e.g:
import * as request from '.wamr_app_lib/request'
// Your code here ...
export function _on_request(buffer_offset: i32, size: i32): void {
on_request(buffer_offset, size);
}
export function _on_response(buffer_offset: i32, size: i32): void {
on_response(buffer_offset, size);
}
*/
export function on_request(buffer_offset: i32, size: i32): void {
var buffer = new ArrayBuffer(size);
var dataview = new DataView(buffer);
for (let i = 0; i < size; i++) {
dataview.setUint8(i, load<i8>(buffer_offset + i, 0, 1));
}
var req = unpack_request(buffer, size);
var is_event = is_event_type(req);
for (let i = 0; i < resource_list.length; i++) {
if ((is_event && resource_list[i].type == Reg_Event)
|| (!is_event && resource_list[i].type == Reg_Request)) {
if (check_url_start(req.url, resource_list[i].url)) {
resource_list[i].cb(req);
return;
}
}
}
console.log("on_request: exit. no service handler.");
}
export function on_response(buffer_offset: i32, size: i32): void {
var buffer = new ArrayBuffer(size);
var dataview = new DataView(buffer);
for (let i = 0; i < size; i++) {
dataview.setUint8(i, load<i8>(buffer_offset + i, 0, 1));
}
var resp = unpack_response(buffer, size);
var trans = transaction_find(resp.mid);
if (trans != null) {
if (transaction_list.indexOf(trans) == 0) {
if (transaction_list.length >= 2) {
var elpased_ms: number, ms_to_expiry: number;
var now = timer.now();
if (now < transaction_list[1].time) {
elpased_ms = now + (0xFFFFFFFF - transaction_list[1].time) + 1;
} else {
elpased_ms = now - transaction_list[1].time;
}
ms_to_expiry = TRANSACTION_TIMEOUT_MS - elpased_ms;
timer.timer_restart(g_trans_timer, ms_to_expiry);
} else {
timer.timer_cancel(g_trans_timer);
}
}
trans.cb(resp);
}
}

View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
@external("env", "wasm_create_timer")
declare function wasm_create_timer(a: i32, b: bool, c: bool): i32;
@external("env", "wasm_timer_cancel")
declare function wasm_timer_cancel(a: i32): void;
@external("env", "wasm_timer_restart")
declare function wasm_timer_restart(a: i32, b: i32): void;
@external("env", "wasm_get_sys_tick_ms")
declare function wasm_get_sys_tick_ms(): i32;
export var timer_list = new Array<user_timer>();
export class user_timer {
timer_id: i32 = 0;
timeout: i32;
period: bool = false;
cb: () => void;
constructor(cb: () => void, timeout: i32, period: bool) {
this.cb = cb;
this.timeout = timeout;
this.period = period
this.timer_id = timer_create(this.timeout, this.period, true);
}
}
export function timer_create(a: i32, b: bool, c: bool): i32 {
return wasm_create_timer(a, b, c);
}
export function setTimeout(cb: () => void, timeout: i32): user_timer {
var timer = new user_timer(cb, timeout, false);
timer_list.push(timer);
return timer;
}
export function setInterval(cb: () => void, timeout: i32): user_timer {
var timer = new user_timer(cb, timeout, true);
timer_list.push(timer);
return timer;
}
export function timer_cancel(timer: user_timer): void {
wasm_timer_cancel(timer.timer_id);
var i = 0;
for (i = 0; i < timer_list.length; i++) {
if (timer_list[i].timer_id == timer.timer_id)
break;
}
timer_list.splice(i, 1);
}
export function timer_restart(timer: user_timer, interval: number): void {
wasm_timer_restart(timer.timer_id, i32(interval));
}
export function now(): i32 {
return wasm_get_sys_tick_ms();
}
// This export function need to be copied to the top application file
//
export function on_timer_callback(on_timer_id: i32): void {
for (let i = 0; i < timer_list.length; i++) {
if (timer_list[i].timer_id == on_timer_id) {
timer_list[i].cb();
}
}
}

View File

@ -0,0 +1,6 @@
{
"extends": "../node_modules/assemblyscript/std/assembly.json",
"include": [
"./**/*.ts"
]
}

View File

@ -13,6 +13,8 @@ objs = []
WAMR_ROOT_DIR = os.path.join(cwd, "..")
SHARED_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'shared')
IWASM_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'iwasm')
APP_MGR_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-mgr')
APP_FRAMEWORK_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-framework')
DEPS_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'deps')
if GetDepend(['WAMR_BUILD_INTERP']):
@ -26,16 +28,20 @@ if GetDepend(['WAMR_BUILD_AOT']):
script_path = os.path.join(IWASM_DIR, 'compilation', 'SConscript')
objs += SConscript(script_path)
if GetDepend(['WAMR_BUILD_APP_FRAMEWORK']):
objs += SConscript(os.path.join(APP_FRAMEWORK_DIR, 'SConscript'))
objs += SConscript(os.path.join(SHARED_DIR, 'coap', 'SConscript'))
objs += SConscript(os.path.join(APP_MGR_DIR, 'app-manager', 'SConscript'))
objs += SConscript(os.path.join(APP_MGR_DIR, 'app-mgr-shared', 'SConscript'))
if GetDepend(['WAMR_BUILD_LIBC_BUILTIN']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-builtin', 'SConscript'))
if GetDepend(['WAMR_BUILD_LIBC_WASI']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-wasi', 'SConscript'))
objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'common', 'posix', 'SConscript'))
objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'common', 'libc-util', 'SConscript'))
if GetDepend(['WAMR_BUILD_LIB_PTHREAD']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'lib-pthread', 'SConscript'))
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-pthread', 'SConscript'))
if GetDepend(['WAMR_BUILD_THREAD_MGR']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'thread-mgr', 'SConscript'))
@ -43,9 +49,6 @@ if GetDepend(['WAMR_BUILD_THREAD_MGR']):
if GetDepend(['WAMR_BUILD_LIBC_EMCC']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-emmc', 'SConscript'))
if GetDepend(['WAMR_BUILD_LIB_WASI_THREADS']):
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'lib-wasi-threads', 'SConscript'))
objs += SConscript(os.path.join(cwd, 'SConscript_config'));
objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'rt-thread', 'SConscript'))

View File

@ -92,7 +92,6 @@ else:
if GetDepend(['WAMR_DISABLE_HW_BOUND_CHECK']):
CPPDEFINES += ['WASM_DISABLE_HW_BOUND_CHECK=1']
CPPDEFINES += ['WASM_DISABLE_STACK_HW_BOUND_CHECK=1']
print("[WAMR] Hardware boundary check disabled")
if GetDepend(['WAMR_BUILD_SIMD']):
@ -109,27 +108,7 @@ if GetDepend(['WAMR_BUILD_CUSTOM_NAME_SECTION']):
if GetDepend(['WAMR_BUILD_TAIL_CALL']):
CPPDEFINES += ['WASM_ENABLE_TAIL_CALL=1']
print('[WAMR] Tail call enabled')
if GetDepend(['WAMR_BUILD_THREAD_MGR']):
CPPDEFINES += ['WASM_ENABLE_THREAD_MGR=1']
print('[WAMR] Thread manager enabled')
if GetDepend(['WAMR_BUILD_LIBC_WASI']):
CPPDEFINES += ['WASM_ENABLE_LIBC_WASI=1']
CPPDEFINES += ['WASM_ENABLE_MODULE_INST_CONTEXT=1']
print('[WAMR] Libc wasi enabled')
if GetDepend(['WAMR_BUILD_LIB_WASI_THREADS']):
CPPDEFINES += ['WASM_ENABLE_LIB_WASI_THREADS=1']
print('[WAMR] Lib wasi threads enabled')
if GetDepend(['WAMR_BUILD_REF_TYPES']):
CPPDEFINES += ['WASM_ENABLE_REF_TYPES=1']
print('[WAMR] enable ref types')
CPPDEFINES += ['BH_MALLOC=wasm_runtime_malloc']
CPPDEFINES += ['BH_FREE=wasm_runtime_free']
print('[WAMR] Tail call enabledd')
LIBS = ['m']

View File

@ -7,7 +7,6 @@
import argparse
import os
import pathlib
import requests
import shlex
import shutil
import subprocess
@ -22,71 +21,39 @@ def clone_llvm(dst_dir, llvm_repo, llvm_branch):
llvm_dir = dst_dir.joinpath("llvm").resolve()
if not llvm_dir.exists():
print(f"Clone llvm to {llvm_dir} ...")
GIT_CLONE_CMD = f"git clone --depth 1 --branch {llvm_branch} {llvm_repo} llvm"
print(GIT_CLONE_CMD)
subprocess.check_output(shlex.split(GIT_CLONE_CMD), cwd=dst_dir)
else:
print(f"There is an LLVM local repo in {llvm_dir}, clean and keep using it")
return llvm_dir
def query_llvm_version(llvm_info):
github_token = os.environ['GH_TOKEN']
owner_project = llvm_info['repo'].replace("https://github.com/", "").replace(".git", "")
url = f"https://api.github.com/repos/{owner_project}/commits/{llvm_info['branch']}"
headers = {
'Authorization': f"Bearer {github_token}"
}
try:
response = requests.request("GET", url, headers=headers, data={})
response.raise_for_status()
except requests.exceptions.HTTPError as error:
print (error) # for debugging purpose
return None
response = response.json()
return response['sha']
def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_flags=''):
def build_llvm(llvm_dir, platform, backends, projects):
LLVM_COMPILE_OPTIONS = [
'-DCMAKE_BUILD_TYPE:STRING="Release"',
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DLLVM_APPEND_VC_REV:BOOL=ON",
"-DLLVM_BUILD_BENCHMARKS:BOOL=OFF",
"-DLLVM_BUILD_DOCS:BOOL=OFF",
"-DLLVM_BUILD_EXAMPLES:BOOL=OFF",
"-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF",
"-DLLVM_BUILD_TESTS:BOOL=OFF",
"-DLLVM_CCACHE_BUILD:BOOL=OFF",
"-DLLVM_ENABLE_BINDINGS:BOOL=OFF",
"-DLLVM_ENABLE_IDE:BOOL=OFF",
"-DLLVM_ENABLE_LIBEDIT=OFF",
"-DLLVM_ENABLE_TERMINFO:BOOL=OFF",
"-DLLVM_ENABLE_ZLIB:BOOL=ON",
"-DLLVM_ENABLE_ZLIB:BOOL=OFF",
"-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF",
"-DLLVM_INCLUDE_DOCS:BOOL=OFF",
"-DLLVM_INCLUDE_EXAMPLES:BOOL=OFF",
"-DLLVM_INCLUDE_UTILS:BOOL=OFF",
"-DLLVM_INCLUDE_TESTS:BOOL=OFF",
"-DLLVM_BUILD_TESTS:BOOL=OFF",
"-DLLVM_OPTIMIZED_TABLEGEN:BOOL=ON",
]
# ccache is not available on Windows
if not "windows" == platform:
LLVM_COMPILE_OPTIONS.append("-DLLVM_CCACHE_BUILD:BOOL=ON")
# perf support is available on Linux only
if "linux" == platform:
LLVM_COMPILE_OPTIONS.append("-DLLVM_USE_PERF:BOOL=ON")
# use clang/clang++/lld. but macos doesn't support lld
if not sys.platform.startswith("darwin") and use_clang:
if shutil.which("clang") and shutil.which("clang++") and shutil.which("lld"):
os.environ["CC"] = "clang"
os.environ["CXX"] = "clang++"
LLVM_COMPILE_OPTIONS.append('-DLLVM_USE_LINKER:STRING="lld"')
print("Use the clang toolchain")
else:
print("Can not find clang, clang++ and lld, keep using the gcc toolchain")
else:
print("Use the gcc toolchain")
LLVM_EXTRA_COMPILE_OPTIONS = {
"arc": [
'-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD:STRING="ARC"',
@ -102,21 +69,12 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
"default": [],
}
experimental_backends = ["ARC", "Xtensa"]
normal_backends = [s for s in backends if s not in experimental_backends]
LLVM_TARGETS_TO_BUILD = [
'-DLLVM_TARGETS_TO_BUILD:STRING="' + ";".join(normal_backends) + '"'
if normal_backends
'-DLLVM_TARGETS_TO_BUILD:STRING="' + ";".join(backends) + '"'
if backends
else '-DLLVM_TARGETS_TO_BUILD:STRING="AArch64;ARM;Mips;RISCV;X86"'
]
# if not on ARC platform, but want to add expeirmental backend ARC as target
if platform != "ARC" and "ARC" in backends:
LLVM_TARGETS_TO_BUILD.extend(
LLVM_EXTRA_COMPILE_OPTIONS["arc"]
)
LLVM_PROJECTS_TO_BUILD = [
'-DLLVM_ENABLE_PROJECTS:STRING="' + ";".join(projects) + '"' if projects else ""
]
@ -134,15 +92,15 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
if not llvm_dir.exists():
raise Exception(f"{llvm_dir} doesn't exist")
build_dir = llvm_dir.joinpath("build").resolve()
build_dir = llvm_dir.joinpath(
"win32build" if "windows" == platform else "build"
).resolve()
build_dir.mkdir(exist_ok=True)
lib_llvm_core_library = build_dir.joinpath("lib/libLLVMCore.a").resolve()
if lib_llvm_core_library.exists():
print(
f"It has already been fully compiled. If want to a re-build, please remove {build_dir} manually and try again"
)
return None
print(f"Please remove {build_dir} manually and try again")
return build_dir
compile_options = " ".join(
LLVM_COMPILE_OPTIONS
@ -155,23 +113,18 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
+ LLVM_INCLUDE_TOOLS_OPTION
)
CONFIG_CMD = f"cmake {compile_options} {extra_flags} ../llvm"
CONFIG_CMD = f"cmake {compile_options} ../llvm"
if "windows" == platform:
if "mingw" in sysconfig.get_platform().lower():
CONFIG_CMD += " -G'Unix Makefiles'"
else:
CONFIG_CMD += " -A x64"
else:
CONFIG_CMD += " -G'Ninja'"
print(f"Config command: {CONFIG_CMD}")
print(f"{CONFIG_CMD}")
subprocess.check_call(shlex.split(CONFIG_CMD), cwd=build_dir)
BUILD_CMD = "cmake --build . --target package" + (
BUILD_CMD = f"cmake --build . --target package --parallel {os.cpu_count()}" + (
" --config Release" if "windows" == platform else ""
)
if "windows" == platform:
BUILD_CMD += " --parallel " + str(os.cpu_count())
print(f"Build command: {BUILD_CMD}")
subprocess.check_call(shlex.split(BUILD_CMD), cwd=build_dir)
return build_dir
@ -180,52 +133,24 @@ def build_llvm(llvm_dir, platform, backends, projects, use_clang=False, extra_fl
def repackage_llvm(llvm_dir):
build_dir = llvm_dir.joinpath("./build").resolve()
packs = [f for f in build_dir.glob("LLVM-*.tar.gz")]
packs = [f for f in build_dir.glob("LLVM-13*.tar.gz")]
if len(packs) > 1:
raise Exception("Find more than one LLVM-*.tar.gz")
raise Exception("Find more than one LLVM-13*.tar.gz")
if not packs:
raise Exception("Didn't find any LLVM-* package")
return
llvm_package = packs[0].name
# mv build/LLVM-*.gz .
# mv build/LLVM-13.0.0*.gz .
shutil.move(str(build_dir.joinpath(llvm_package).resolve()), str(llvm_dir))
# rm -r build
shutil.rmtree(str(build_dir))
# mkdir build
build_dir.mkdir()
# tar xf ./LLVM-*.tar.gz --strip-components=1 --directory=build
# tar xf ./LLVM-13.0.0-*.tar.gz --strip-components=1 --directory=build
CMD = f"tar xf {llvm_dir.joinpath(llvm_package).resolve()} --strip-components=1 --directory={build_dir}"
subprocess.check_call(shlex.split(CMD), cwd=llvm_dir)
# rm ./LLVM-1*.gz
os.remove(llvm_dir.joinpath(llvm_package).resolve())
def repackage_llvm_windows(llvm_dir):
build_dir = llvm_dir.joinpath("./build").resolve()
packs_path = [f for f in build_dir.glob("./_CPack_Packages/win64/NSIS/LLVM-*-win64")]
if len(packs_path) > 1:
raise Exception("Find more than one LLVM-* package")
if not packs_path:
raise Exception("Didn't find any LLVM-* package")
return
llvm_package_path = f"_CPack_Packages/win64/NSIS/{packs_path[0].name}"
windows_package_dir = build_dir.joinpath(llvm_package_path).resolve()
# mv package dir outside of build
shutil.move(str(windows_package_dir), str(llvm_dir))
# rm -r build
shutil.rmtree(str(build_dir))
# mkdir build
build_dir.mkdir()
# move back all the subdiretories under cpack directory(bin/include/lib) to build dir
moved_package_dir = llvm_dir.joinpath(packs_path[0].name)
for sub_dir in moved_package_dir.iterdir():
shutil.move(str(sub_dir), str(build_dir))
moved_package_dir.rmdir()
def main():
parser = argparse.ArgumentParser(description="build necessary LLVM libraries")
@ -249,7 +174,6 @@ def main():
"X86",
"Xtensa",
],
default=[],
help="identify LLVM supported backends, separate by space, like '--arch ARM Mips X86'",
)
parser.add_argument(
@ -260,23 +184,8 @@ def main():
choices=["clang", "lldb"],
help="identify extra LLVM projects, separate by space, like '--project clang lldb'",
)
parser.add_argument(
"--llvm-ver",
action="store_true",
help="return the version info of generated llvm libraries",
)
parser.add_argument(
"--use-clang",
action="store_true",
help="use clang instead of gcc",
)
parser.add_argument(
"--extra-cmake-flags",
type=str,
default="",
help="custom extra cmake flags",
)
options = parser.parse_args()
print(f"options={options}")
# if the "platform" is not identified in the command line option,
# detect it
@ -290,21 +199,20 @@ def main():
else:
platform = options.platform
print(f"========== Build LLVM for {platform} ==========\n")
llvm_repo_and_branch = {
"arc": {
"repo": "https://github.com/llvm/llvm-project.git",
"repo_ssh": "git@github.com:llvm/llvm-project.git",
"branch": "release/18.x",
"branch": "release/13.x",
},
"xtensa": {
"repo": "https://github.com/espressif/llvm-project.git",
"repo_ssh": "git@github.com:espressif/llvm-project.git",
"branch": "xtensa_release_18.1.2",
"branch": "xtensa_release_13.0.0",
},
"default": {
"repo": "https://github.com/llvm/llvm-project.git",
"repo_ssh": "git@github.com:llvm/llvm-project.git",
"branch": "release/18.x",
"branch": "release/13.x",
},
}
@ -317,33 +225,19 @@ def main():
deps_dir = current_dir.joinpath("../core/deps").resolve()
try:
print(f"==================== CLONE LLVM ====================")
llvm_info = llvm_repo_and_branch.get(platform, llvm_repo_and_branch["default"])
llvm_dir = clone_llvm(deps_dir, llvm_info["repo"], llvm_info["branch"])
if options.llvm_ver:
commit_hash = query_llvm_version(llvm_info)
print(commit_hash)
return commit_hash is not None
print()
print(f"==================== BUILD LLVM ====================")
build_llvm(llvm_dir, platform, options.arch, options.project)
repo_addr = llvm_info["repo"]
if os.environ.get('USE_GIT_SSH') == "true":
repo_addr = llvm_info["repo_ssh"]
else:
print("To use ssh for git clone, run: export USE_GIT_SSH=true")
llvm_dir = clone_llvm(deps_dir, repo_addr, llvm_info["branch"])
if (
build_llvm(
llvm_dir, platform, options.arch, options.project, options.use_clang,
options.extra_cmake_flags
)
is not None
):
# TODO: repackage process may change in the future, this work for LLVM 15.x
if "windows" == platform:
repackage_llvm_windows(llvm_dir)
else:
repackage_llvm(llvm_dir)
print()
print(f"==================== PACKAGE LLVM ====================")
repackage_llvm(llvm_dir)
print()
return True
except subprocess.CalledProcessError:
return False

View File

@ -3,6 +3,7 @@
string(TOUPPER ${WAMR_BUILD_TARGET} WAMR_BUILD_TARGET)
# Add definitions for the build target
if (WAMR_BUILD_TARGET STREQUAL "X86_64")
add_definitions(-DBUILD_TARGET_X86_64)
@ -39,8 +40,6 @@ elseif (WAMR_BUILD_TARGET STREQUAL "RISCV64_LP64")
add_definitions(-DBUILD_TARGET_RISCV64_LP64)
elseif (WAMR_BUILD_TARGET STREQUAL "RISCV32" OR WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32D")
add_definitions(-DBUILD_TARGET_RISCV32_ILP32D)
elseif (WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32F")
add_definitions(-DBUILD_TARGET_RISCV32_ILP32F)
elseif (WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32")
add_definitions(-DBUILD_TARGET_RISCV32_ILP32)
elseif (WAMR_BUILD_TARGET STREQUAL "ARC")
@ -59,9 +58,7 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
# Add -fPIC flag if build as 64-bit
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -fPIC")
endif ()
else ()
include(CheckCCompilerFlag)
@ -87,145 +84,95 @@ if (NOT WAMR_BUILD_AOT EQUAL 1)
endif ()
endif ()
if (WAMR_BUILD_FAST_JIT EQUAL 1)
if (NOT WAMR_BUILD_LAZY_JIT EQUAL 0)
# Enable Lazy JIT by default
set (WAMR_BUILD_LAZY_JIT 1)
endif ()
endif ()
if (WAMR_BUILD_JIT EQUAL 1)
if (NOT WAMR_BUILD_LAZY_JIT EQUAL 0)
# Enable Lazy JIT by default
set (WAMR_BUILD_LAZY_JIT 1)
endif ()
if (NOT DEFINED LLVM_DIR)
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/build")
if (NOT EXISTS "${LLVM_BUILD_ROOT}")
if (WAMR_BUILD_AOT EQUAL 1)
add_definitions("-DWASM_ENABLE_JIT=1")
if (NOT WAMR_BUILD_LAZY_JIT EQUAL 0)
# Enable Lazy JIT by default
set (WAMR_BUILD_LAZY_JIT 1)
add_definitions("-DWASM_ENABLE_LAZY_JIT=1")
endif ()
if (NOT DEFINED LLVM_DIR)
set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/build")
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
set (LLVM_BUILD_ROOT "${LLVM_SRC_ROOT}/win32build")
endif ()
if (NOT EXISTS "${LLVM_BUILD_ROOT}")
message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_BUILD_ROOT}")
endif ()
set (CMAKE_PREFIX_PATH "${LLVM_BUILD_ROOT};${CMAKE_PREFIX_PATH}")
endif ()
set (CMAKE_PREFIX_PATH "${LLVM_BUILD_ROOT};${CMAKE_PREFIX_PATH}")
set (LLVM_DIR ${LLVM_BUILD_ROOT}/lib/cmake/llvm)
endif ()
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
# Disable -Wredundant-move when building LLVM JIT
include(CheckCXXCompilerFlag)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
check_cxx_compiler_flag("-Wredundant-move" CXX_SUPPORTS_REDUNDANT_MOVE_FLAG)
if (CXX_SUPPORTS_REDUNDANT_MOVE_FLAG)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-redundant-move")
endif ()
# Enable exporting symbols after llvm-17, or LLVM JIT may run failed
# with `llvm_orc_registerEHFrameSectionWrapper` symbol not found error
if (${LLVM_PACKAGE_VERSION} VERSION_GREATER_EQUAL "17.0.0")
set (CMAKE_ENABLE_EXPORTS 1)
endif ()
endif ()
find_package(LLVM REQUIRED CONFIG)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
else ()
set (WAMR_BUILD_JIT 0)
message ("-- WAMR JIT disabled due to WAMR AOT is disabled")
endif ()
else ()
unset (LLVM_AVAILABLE_LIBS)
endif ()
# Version
include (${WAMR_ROOT_DIR}/build-scripts/version.cmake)
# Package
include (${WAMR_ROOT_DIR}/build-scripts/package.cmake)
# Sanitizers
if (NOT DEFINED WAMR_BUILD_SANITIZER)
set(WAMR_BUILD_SANITIZER $ENV{WAMR_BUILD_SANITIZER})
endif ()
if (NOT DEFINED WAMR_BUILD_SANITIZER)
set(WAMR_BUILD_SANITIZER "")
elseif (WAMR_BUILD_SANITIZER STREQUAL "ubsan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=alignment" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
elseif (WAMR_BUILD_SANITIZER STREQUAL "asan")
if (NOT WAMR_BUILD_JIT EQUAL 1)
set (ASAN_OPTIONS "verbosity=2 debug=true ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=address -fno-sanitize-recover=all" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
endif()
elseif (WAMR_BUILD_SANITIZER STREQUAL "tsan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
elseif (WAMR_BUILD_SANITIZER STREQUAL "posan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=pointer-overflow -fno-sanitize-recover=all" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=pointer-overflow")
elseif (NOT (WAMR_BUILD_SANITIZER STREQUAL "") )
message(SEND_ERROR "Unsupported sanitizer: ${WAMR_BUILD_SANITIZER}")
endif()
if (WAMR_BUILD_LINUX_PERF EQUAL 1)
if (NOT WAMR_BUILD_JIT AND NOT WAMR_BUILD_AOT)
message(WARNING "only support perf in aot and llvm-jit")
set(WAMR_BUILD_LINUX_PERF 0)
endif ()
endif ()
if (NOT DEFINED WAMR_BUILD_SHRUNK_MEMORY)
# Enable shrunk memory by default
set (WAMR_BUILD_SHRUNK_MEMORY 1)
endif ()
########################################
# Default values
########################################
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
set (WAMR_BUILD_BULK_MEMORY 1)
## semantic version information
if (NOT DEFINED WAMR_VERSION_MAJOR)
set (WAMR_VERSION_MAJOR 1)
endif ()
if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
set (WAMR_BUILD_EXCE_HANDLING 0)
if (NOT DEFINED WAMR_VERSION_MINOR)
set (WAMR_VERSION_MINOR 0)
endif ()
if (NOT DEFINED WAMR_BUILD_GC)
set (WAMR_BUILD_GC 0)
if (NOT DEFINED WAMR_VERSION_PATCH)
set (WAMR_VERSION_PATCH 0)
endif ()
if (NOT DEFINED WAMR_BUILD_MEMORY64)
set (WAMR_BUILD_MEMORY64 0)
endif ()
if (NOT DEFINED WAMR_BUILD_MULTI_MEMORY)
set (WAMR_BUILD_MULTI_MEMORY 0)
endif ()
if (NOT DEFINED WAMR_BUILD_SHARED_MEMORY)
set(WAMR_BUILD_SHARED_MEMORY 0)
endif ()
if (NOT DEFINED WAMR_BUILD_STRINGREF)
set(WAMR_BUILD_STRINGREF 0)
endif ()
if (NOT DEFINED WAMR_BUILD_TAIL_CALL)
set (WAMR_BUILD_TAIL_CALL 0)
endif ()
########################################
# Compilation options to marco
configure_file(${WAMR_ROOT_DIR}/core/version.h.in ${WAMR_ROOT_DIR}/core/version.h @ONLY)
########################################
message ("-- Build Configurations:")
message (" Build as target ${WAMR_BUILD_TARGET}")
message (" Build for platform ${WAMR_BUILD_PLATFORM}")
message (" CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
message (" BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
################## running mode ##################
if (WAMR_BUILD_INTERP EQUAL 1)
message (" WAMR Interpreter enabled")
elseif (WAMR_BUILD_JIT EQUAL 1)
set (WAMR_BUILD_INTERP 1)
message (" WAMR Interpreter enabled due to WAMR JIT is enabled")
else ()
message (" WAMR Interpreter disabled")
endif ()
if (WAMR_BUILD_AOT EQUAL 1)
message (" WAMR AOT enabled")
else ()
message (" WAMR AOT disabled")
endif ()
if (WAMR_BUILD_JIT EQUAL 1)
if (WAMR_BUILD_LAZY_JIT EQUAL 1)
message (" WAMR LLVM Orc Lazy JIT enabled")
else ()
message (" WAMR LLVM MC JIT enabled")
endif ()
elseif (WAMR_BUILD_FAST_JIT EQUAL 1)
message (" WAMR Fast JIT enabled")
else ()
message (" WAMR JIT disabled")
endif ()
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
message (" Libc builtin enabled")
else ()
message (" Libc builtin disabled")
endif ()
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
message (" Libc WASI enabled with uvwasi implementation")
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
message (" Libc WASI enabled")
else ()
message (" Libc WASI disabled")
endif ()
if ((WAMR_BUILD_FAST_INTERP EQUAL 1) AND (WAMR_BUILD_INTERP EQUAL 1))
add_definitions (-DWASM_ENABLE_FAST_INTERP=1)
message (" Fast interpreter enabled")
@ -233,62 +180,28 @@ else ()
add_definitions (-DWASM_ENABLE_FAST_INTERP=0)
message (" Fast interpreter disabled")
endif ()
if (WAMR_BUILD_AOT EQUAL 1)
message (" WAMR AOT enabled")
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
message (" Multiple modules enabled")
else ()
message (" WAMR AOT disabled")
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
message (" Multiple modules disabled")
endif ()
if (WAMR_BUILD_FAST_JIT EQUAL 1)
if (WAMR_BUILD_LAZY_JIT EQUAL 1)
add_definitions("-DWASM_ENABLE_LAZY_JIT=1")
message (" WAMR Fast JIT enabled with Lazy Compilation")
else ()
message (" WAMR Fast JIT enabled with Eager Compilation")
endif ()
else ()
message (" WAMR Fast JIT disabled")
endif ()
if (WAMR_BUILD_JIT EQUAL 1)
add_definitions("-DWASM_ENABLE_JIT=1")
if (WAMR_BUILD_LAZY_JIT EQUAL 1)
add_definitions("-DWASM_ENABLE_LAZY_JIT=1")
message (" WAMR LLVM ORC JIT enabled with Lazy Compilation")
else ()
message (" WAMR LLVM ORC JIT enabled with Eager Compilation")
endif ()
else ()
message (" WAMR LLVM ORC JIT disabled")
endif ()
if (WAMR_BUILD_FAST_JIT EQUAL 1 AND WAMR_BUILD_JIT EQUAL 1
AND WAMR_BUILD_LAZY_JIT EQUAL 1)
message (" Multi-tier JIT enabled")
endif ()
################## test modes ##################
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
add_definitions (-DWASM_ENABLE_SPEC_TEST=1)
message (" spec test compatible mode is on")
endif ()
if (WAMR_BUILD_WASI_TEST EQUAL 1)
add_definitions (-DWASM_ENABLE_WASI_TEST=1)
message (" wasi test compatible mode is on")
endif ()
################## native ##################
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
message (" Libc builtin enabled")
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
message (" Bulk memory feature enabled")
else ()
message (" Libc builtin disabled")
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
endif ()
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
message (" Libc WASI enabled with uvwasi implementation\n"
" WANRING:: uvwasi does not currently provide the comprehensive\n"
" file system security properties provided by some WASI runtimes.\n"
" Full support for secure file system sandboxing may or may not\n"
" be implemented in future. In the mean time, DO NOT RELY ON IT\n"
" TO RUN UNTRUSTED CODE.")
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
message (" Libc WASI enabled")
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
message (" Shared memory enabled")
else ()
message (" Libc WASI disabled")
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
endif ()
if (WAMR_BUILD_THREAD_MGR EQUAL 1)
message (" Thread manager enabled")
@ -299,62 +212,12 @@ endif ()
if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
message (" Lib pthread semaphore enabled")
endif ()
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
message (" Lib wasi-threads enabled")
endif ()
if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
message (" Libc emcc enabled")
endif ()
if (WAMR_BUILD_LIB_RATS EQUAL 1)
message (" Lib rats enabled")
endif()
if ((WAMR_BUILD_LIB_SIMDE EQUAL 1))
message (" Lib simde enabled")
endif()
################## WAMR features ##################
if (WAMR_BUILD_MULTI_MODULE EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MODULE=1)
message (" Multiple modules enabled")
else ()
add_definitions (-DWASM_ENABLE_MULTI_MODULE=0)
message (" Multiple modules disabled")
endif ()
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_BULK_MEMORY=1)
else ()
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
message (" Shared memory enabled")
else ()
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0)
endif ()
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
add_definitions (-DWASM_ENABLE_SHARED_HEAP=1)
message (" Shared heap enabled")
endif()
if (WAMR_ENABLE_COPY_CALLSTACK EQUAL 1)
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=1)
message(" Copy callstack enabled")
else ()
add_definitions (-DWAMR_ENABLE_COPY_CALLSTACK=0)
message(" Copy callstack disabled")
endif()
if (WAMR_BUILD_MEMORY64 EQUAL 1)
# if native is 32-bit or cross-compiled to 32-bit
if (NOT WAMR_BUILD_TARGET MATCHES ".*64.*")
message (FATAL_ERROR "-- Memory64 is only available on the 64-bit platform/target")
endif()
add_definitions (-DWASM_ENABLE_MEMORY64=1)
set (WAMR_DISABLE_HW_BOUND_CHECK 1)
endif ()
if (WAMR_BUILD_MULTI_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_MULTI_MEMORY=1)
set (WAMR_BUILD_DEBUG_INTERP 0)
endif ()
if (WAMR_BUILD_MINI_LOADER EQUAL 1)
add_definitions (-DWASM_ENABLE_MINI_LOADER=1)
message (" WASM mini loader enabled")
@ -363,37 +226,17 @@ else ()
endif ()
if (WAMR_DISABLE_HW_BOUND_CHECK EQUAL 1)
add_definitions (-DWASM_DISABLE_HW_BOUND_CHECK=1)
add_definitions (-DWASM_DISABLE_STACK_HW_BOUND_CHECK=1)
message (" Hardware boundary check disabled")
else ()
add_definitions (-DWASM_DISABLE_HW_BOUND_CHECK=0)
if (WAMR_DISABLE_STACK_HW_BOUND_CHECK EQUAL 1)
add_definitions (-DWASM_DISABLE_STACK_HW_BOUND_CHECK=1)
message (" Hardware boundary check for native stack disabled")
else ()
add_definitions (-DWASM_DISABLE_STACK_HW_BOUND_CHECK=0)
endif ()
endif ()
if (WAMR_DISABLE_WAKEUP_BLOCKING_OP EQUAL 1)
add_definitions (-DWASM_DISABLE_WAKEUP_BLOCKING_OP=1)
message (" Wakeup of blocking operations disabled")
else ()
add_definitions (-DWASM_DISABLE_WAKEUP_BLOCKING_OP=0)
message (" Wakeup of blocking operations enabled")
endif ()
if (WAMR_BUILD_SIMD EQUAL 1)
if (WAMR_BUILD_TARGET MATCHES "RISCV64.*")
set(SIMD_ENABLED 0)
message (" SIMD disabled due to not supported on target RISCV64")
else()
set(SIMD_ENABLED 1)
if (NOT WAMR_BUILD_TARGET MATCHES "RISCV64.*")
add_definitions (-DWASM_ENABLE_SIMD=1)
message (" SIMD enabled")
else ()
message (" SIMD disabled due to not supported on target RISCV64")
endif ()
add_definitions(-DWASM_ENABLE_SIMD=${SIMD_ENABLED})
endif ()
if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
message (" AOT stack frame enabled")
endif ()
if (WAMR_BUILD_MEMORY_PROFILING EQUAL 1)
add_definitions (-DWASM_ENABLE_MEMORY_PROFILING=1)
@ -416,48 +259,17 @@ if (WAMR_BUILD_DUMP_CALL_STACK EQUAL 1)
endif ()
if (WAMR_BUILD_TAIL_CALL EQUAL 1)
add_definitions (-DWASM_ENABLE_TAIL_CALL=1)
message (" Tail call enabled")
endif ()
if (WAMR_BUILD_REF_TYPES EQUAL 1)
add_definitions (-DWASM_ENABLE_REF_TYPES=1)
endif ()
if (WAMR_BUILD_GC EQUAL 1)
if (WAMR_TEST_GC EQUAL 1)
message(" GC testing enabled")
endif()
endif ()
if (WAMR_BUILD_GC EQUAL 1 AND WAMR_BUILD_GC_PERF_PROFILING EQUAL 1)
add_definitions (-DWASM_ENABLE_GC_PERF_PROFILING=1)
message (" GC performance profiling enabled")
message (" Reference types enabled")
else ()
message (" GC performance profiling disabled")
endif ()
if (WAMR_BUILD_STRINGREF EQUAL 1)
if (NOT DEFINED WAMR_STRINGREF_IMPL_SOURCE)
message (" Using WAMR builtin implementation for stringref")
else ()
message (" Using custom implementation for stringref")
endif()
endif ()
if (WAMR_BUILD_PERF_PROFILING EQUAL 1 OR
WAMR_BUILD_DUMP_CALL_STACK EQUAL 1 OR
WAMR_BUILD_GC EQUAL 1)
# Enable AOT/JIT stack frame when perf-profiling, dump-call-stack
# or GC is enabled
if (WAMR_BUILD_AOT EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
endif ()
endif ()
if (WAMR_BUILD_EXCE_HANDLING EQUAL 1)
add_definitions (-DWASM_ENABLE_EXCE_HANDLING=1)
add_definitions (-DWASM_ENABLE_TAGS=1)
message (" Exception Handling enabled")
message (" Reference types disabled")
endif ()
if (DEFINED WAMR_BH_VPRINTF)
add_definitions (-DBH_VPRINTF=${WAMR_BH_VPRINTF})
endif ()
if (DEFINED WAMR_BH_LOG)
add_definitions (-DBH_LOG=${WAMR_BH_LOG})
endif ()
if (WAMR_DISABLE_APP_ENTRY EQUAL 1)
message (" WAMR application entry functions excluded")
endif ()
@ -467,240 +279,11 @@ endif ()
if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
message (" Debug AOT enabled")
endif ()
if (WAMR_BUILD_DYNAMIC_AOT_DEBUG EQUAL 1)
add_definitions (-DWASM_ENABLE_DYNAMIC_AOT_DEBUG=1)
message (" Dynamic AOT debug enabled")
endif ()
if (WAMR_BUILD_LOAD_CUSTOM_SECTION EQUAL 1)
add_definitions (-DWASM_ENABLE_LOAD_CUSTOM_SECTION=1)
message (" Load custom section enabled")
endif ()
if (WAMR_BUILD_GLOBAL_HEAP_POOL EQUAL 1)
add_definitions(-DWASM_ENABLE_GLOBAL_HEAP_POOL=1)
message (" Global heap pool enabled")
endif ()
if (WAMR_BUILD_GLOBAL_HEAP_SIZE GREATER 0)
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
message (" Custom global heap size: " ${WAMR_BUILD_GLOBAL_HEAP_SIZE})
else ()
# Spec test requires more heap pool size
if (WAMR_BUILD_SPEC_TEST EQUAL 1)
if (WAMR_BUILD_PLATFORM STREQUAL "linux-sgx")
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "100 * 1024 * 1024")
else ()
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "300 * 1024 * 1024")
endif ()
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
else ()
# By default, the global heap size is of 10 MB
math(EXPR WAMR_BUILD_GLOBAL_HEAP_SIZE "10 * 1024 * 1024")
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=${WAMR_BUILD_GLOBAL_HEAP_SIZE})
endif ()
endif ()
if (WAMR_BUILD_STACK_GUARD_SIZE GREATER 0)
add_definitions (-DWASM_STACK_GUARD_SIZE=${WAMR_BUILD_STACK_GUARD_SIZE})
message (" Custom stack guard size: " ${WAMR_BUILD_STACK_GUARD_SIZE})
endif ()
if (WAMR_BUILD_SGX_IPFS EQUAL 1)
add_definitions (-DWASM_ENABLE_SGX_IPFS=1)
message (" SGX IPFS enabled")
endif ()
if (WAMR_BUILD_WASI_NN EQUAL 1)
message (" WASI-NN enabled")
add_definitions (-DWASM_ENABLE_WASI_NN=1)
# Variant backends
if (NOT WAMR_BUILD_WASI_NN_TFLITE EQUAL 1 AND
NOT WAMR_BUILD_WASI_NN_OPENVINO EQUAL 1 AND
NOT WAMR_BUILD_WASI_NN_LLAMACPP EQUAL 1)
message (FATAL_ERROR " Need to select a backend for WASI-NN")
endif ()
if (WAMR_BUILD_WASI_NN_TFLITE EQUAL 1)
message (" WASI-NN: backend tflite enabled")
add_definitions (-DWASM_ENABLE_WASI_NN_TFLITE)
endif ()
if (WAMR_BUILD_WASI_NN_OPENVINO EQUAL 1)
message (" WASI-NN: backend openvino enabled")
add_definitions (-DWASM_ENABLE_WASI_NN_OPENVINO)
endif ()
if (WAMR_BUILD_WASI_NN_LLAMACPP EQUAL 1)
message (" WASI-NN: backend llamacpp enabled")
add_definitions (-DWASM_ENABLE_WASI_NN_LLAMACPP)
endif ()
# Variant devices
if (WAMR_BUILD_WASI_NN_ENABLE_GPU EQUAL 1)
message (" WASI-NN: GPU enabled")
add_definitions (-DWASM_ENABLE_WASI_NN_GPU=1)
endif ()
if (WAMR_BUILD_WASI_NN_ENABLE_EXTERNAL_DELEGATE EQUAL 1)
message (" WASI-NN: External Delegation enabled")
add_definitions (-DWASM_ENABLE_WASI_NN_EXTERNAL_DELEGATE=1)
endif ()
if (DEFINED WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH)
add_definitions (-DWASM_WASI_NN_EXTERNAL_DELEGATE_PATH="${WAMR_BUILD_WASI_NN_EXTERNAL_DELEGATE_PATH}")
endif ()
if (WAMR_BUILD_WASI_EPHEMERAL_NN EQUAL 1)
message (" WASI-NN: use 'wasi_ephemeral_nn' instead of 'wasi-nn'")
add_definitions (-DWASM_ENABLE_WASI_EPHEMERAL_NN=1)
endif()
endif ()
if (WAMR_BUILD_ALLOC_WITH_USER_DATA EQUAL 1)
add_definitions(-DWASM_MEM_ALLOC_WITH_USER_DATA=1)
endif()
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
add_definitions (-DWASM_ENABLE_WASM_CACHE=1)
message (" Wasm files cache enabled")
endif ()
if (WAMR_BUILD_MODULE_INST_CONTEXT EQUAL 1)
add_definitions (-DWASM_ENABLE_MODULE_INST_CONTEXT=1)
message (" Module instance context enabled")
endif ()
if (WAMR_BUILD_GC_HEAP_VERIFY EQUAL 1)
add_definitions (-DBH_ENABLE_GC_VERIFY=1)
message (" GC heap verification enabled")
endif ()
if ("$ENV{COLLECT_CODE_COVERAGE}" STREQUAL "1" OR COLLECT_CODE_COVERAGE EQUAL 1)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
add_definitions (-DCOLLECT_CODE_COVERAGE)
message (" Collect code coverage enabled")
endif ()
if (WAMR_BUILD_STATIC_PGO EQUAL 1)
add_definitions (-DWASM_ENABLE_STATIC_PGO=1)
message (" AOT static PGO enabled")
endif ()
if (WAMR_BUILD_TARGET STREQUAL "X86_64"
AND WAMR_BUILD_PLATFORM STREQUAL "linux")
if (WAMR_DISABLE_WRITE_GS_BASE EQUAL 1)
# disabled by user
set (DISABLE_WRITE_GS_BASE 1)
elseif (WAMR_DISABLE_WRITE_GS_BASE EQUAL 0)
# enabled by user
set (DISABLE_WRITE_GS_BASE 0)
elseif (CMAKE_CROSSCOMPILING)
# disabled in cross compilation environment
set (DISABLE_WRITE_GS_BASE 1)
else ()
# auto-detected by the compiler
set (TEST_WRGSBASE_SOURCE "${CMAKE_BINARY_DIR}/test_wrgsbase.c")
file (WRITE "${TEST_WRGSBASE_SOURCE}" "
#include <stdio.h>
#include <stdint.h>
int main() {
uint64_t value;
asm volatile (\"wrgsbase %0\" : : \"r\"(value));
printf(\"WRGSBASE instruction is available.\\n\");
return 0;
}")
# Try to compile and run the test program
try_run (TEST_WRGSBASE_RESULT
TEST_WRGSBASE_COMPILED
${CMAKE_BINARY_DIR}/test_wrgsbase
SOURCES ${TEST_WRGSBASE_SOURCE}
CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
#message("${TEST_WRGSBASE_COMPILED}, ${TEST_WRGSBASE_RESULT}")
if (TEST_WRGSBASE_RESULT EQUAL 0)
set (DISABLE_WRITE_GS_BASE 0)
else ()
set (DISABLE_WRITE_GS_BASE 1)
endif ()
endif ()
if (DISABLE_WRITE_GS_BASE EQUAL 1)
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1)
message (" Write linear memory base addr to x86 GS register disabled")
else ()
add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=0)
message (" Write linear memory base addr to x86 GS register enabled")
endif ()
endif ()
if (WAMR_CONFIGURABLE_BOUNDS_CHECKS EQUAL 1)
add_definitions (-DWASM_CONFIGURABLE_BOUNDS_CHECKS=1)
message (" Configurable bounds checks enabled")
endif ()
if (WAMR_BUILD_LINUX_PERF EQUAL 1)
add_definitions (-DWASM_ENABLE_LINUX_PERF=1)
message (" Linux perf support enabled")
endif ()
if (WAMR_BUILD_AOT EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
if (NOT DEFINED WAMR_BUILD_QUICK_AOT_ENTRY)
# Enable quick aot/jit entries by default
set (WAMR_BUILD_QUICK_AOT_ENTRY 1)
endif ()
if (WAMR_BUILD_QUICK_AOT_ENTRY EQUAL 1)
add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=1)
message (" Quick AOT/JIT entries enabled")
else ()
add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0)
message (" Quick AOT/JIT entries disabled")
endif ()
else ()
# Disable quick aot/jit entries for interp and fast-jit
add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0)
endif ()
if (WAMR_BUILD_AOT EQUAL 1)
if (NOT DEFINED WAMR_BUILD_AOT_INTRINSICS)
# Enable aot intrinsics by default
set (WAMR_BUILD_AOT_INTRINSICS 1)
endif ()
if (WAMR_BUILD_AOT_INTRINSICS EQUAL 1)
add_definitions (-DWASM_ENABLE_AOT_INTRINSICS=1)
message (" AOT intrinsics enabled")
else ()
add_definitions (-DWASM_ENABLE_AOT_INTRINSICS=0)
message (" AOT intrinsics disabled")
endif ()
else ()
# Disable aot intrinsics for interp, fast-jit and llvm-jit
add_definitions (-DWASM_ENABLE_AOT_INTRINSICS=0)
endif ()
if (WAMR_BUILD_ALLOC_WITH_USAGE EQUAL 1)
add_definitions(-DWASM_MEM_ALLOC_WITH_USAGE=1)
endif()
if (NOT WAMR_BUILD_SANITIZER STREQUAL "")
message (" Sanitizer ${WAMR_BUILD_SANITIZER} enabled")
endif ()
if (WAMR_BUILD_SHRUNK_MEMORY EQUAL 1)
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=1)
message (" Shrunk memory enabled")
else ()
add_definitions (-DWASM_ENABLE_SHRUNK_MEMORY=0)
message (" Shrunk memory disabled")
endif()
if (WAMR_BUILD_AOT_VALIDATOR EQUAL 1)
message (" AOT validator enabled")
add_definitions (-DWASM_ENABLE_AOT_VALIDATOR=1)
endif ()
########################################
# Show Phase4 Wasm proposals status.
########################################
message (
"-- About Wasm Proposals:\n"
" Always-on:\n"
" \"Multi-value\"\n"
" \"Non-trapping float-to-int conversions\"\n"
" \"Sign-extension operators\"\n"
" \"WebAssembly C and C++ API\"\n"
" Configurable. 0 is OFF. 1 is ON:\n"
" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
" \"Garbage collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
" \"Legacy Exception handling\" via WAMR_BUILD_EXCE_HANDLING: ${WAMR_BUILD_EXCE_HANDLING}\n"
" \"Memory64\" via WAMR_BUILD_MEMORY64: ${WAMR_BUILD_MEMORY64}\n"
" \"Multiple memories\" via WAMR_BUILD_MULTI_MEMORY: ${WAMR_BUILD_MULTI_MEMORY}\n"
" \"Reference Types\" via WAMR_BUILD_REF_TYPES: ${WAMR_BUILD_REF_TYPES}\n"
" \"Reference-Typed Strings\" via WAMR_BUILD_STRINGREF: ${WAMR_BUILD_STRINGREF}\n"
" \"Tail call\" via WAMR_BUILD_TAIL_CALL: ${WAMR_BUILD_TAIL_CALL}\n"
" \"Threads\" via WAMR_BUILD_SHARED_MEMORY: ${WAMR_BUILD_SHARED_MEMORY}\n"
" \"Typed Function References\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
" Unsupported (>= Phase4):\n"
" \"Branch Hinting\"\n"
" \"Custom Annotation Syntax in the Text Format\"\n"
" \"Exception handling\"\n"
" \"Extended Constant Expressions\"\n"
" \"Import/Export of Mutable Globals\"\n"
" \"JS String Builtins\"\n"
" \"Relaxed SIMD\"\n"
)

View File

@ -11,7 +11,7 @@ You can build an ESP-IDF project with wasm-micro-runtime as a component:
- In the newly created project folder edit the `CMakeList.txt`:
```
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

View File

@ -2,102 +2,56 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Set WAMR's build options
if("${IDF_TARGET}" STREQUAL "esp32c3")
set(WAMR_BUILD_TARGET "RISCV32")
else()
set(WAMR_BUILD_TARGET "XTENSA")
endif()
set(WAMR_BUILD_PLATFORM "esp-idf")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
if (NOT DEFINED WAMR_BUILD_INTERP)
set (WAMR_BUILD_INTERP 1)
endif ()
if (NOT DEFINED WAMR_BUILD_FAST_INTERP)
set (WAMR_BUILD_FAST_INTERP 1)
endif ()
if (NOT DEFINED WAMR_BUILD_AOT)
set (WAMR_BUILD_AOT 1)
endif ()
if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
set (WAMR_BUILD_LIBC_BUILTIN 1)
endif ()
if (NOT DEFINED WAMR_BUILD_APP_FRAMEWORK)
set (WAMR_BUILD_APP_FRAMEWORK 0)
endif ()
if (NOT CMAKE_BUILD_EARLY_EXPANSION)
if (WAMR_BUILD_TARGET STREQUAL "XTENSA")
idf_build_set_property(COMPILE_DEFINITIONS "-DBUILD_TARGET_XTENSA=1" APPEND)
endif ()
if (WAMR_BUILD_INTERP)
idf_build_set_property(COMPILE_DEFINITIONS "-DWASM_ENABLE_INTERP=1" APPEND)
endif ()
if (WAMR_BUILD_AOT)
idf_build_set_property(COMPILE_DEFINITIONS "-DWASM_ENABLE_AOT=1" APPEND)
endif ()
if (CONFIG_IDF_TARGET_ARCH_RISCV)
set (WAMR_BUILD_TARGET "RISCV32")
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
set (WAMR_BUILD_TARGET "XTENSA")
else ()
message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported")
endif ()
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
endif()
set (WAMR_BUILD_PLATFORM "esp-idf")
idf_component_register(SRCS ${WAMR_RUNTIME_LIB_SOURCE} ${PLATFORM_SHARED_SOURCE}
INCLUDE_DIRS ${IWASM_DIR}/include ${UTILS_SHARED_DIR} ${PLATFORM_SHARED_DIR} ${PLATFORM_SHARED_DIR}/../include
REQUIRES pthread
)
if (CONFIG_WAMR_BUILD_DEBUG)
set (CMAKE_BUILD_TYPE Debug)
else ()
set (CMAKE_BUILD_TYPE Release)
endif ()
if (CONFIG_WAMR_ENABLE_INTERP)
set (WAMR_BUILD_INTERP 1)
endif ()
if (CONFIG_WAMR_INTERP_FAST)
set (WAMR_BUILD_FAST_INTERP 1)
endif ()
if (CONFIG_WAMR_ENABLE_AOT)
set (WAMR_BUILD_AOT 1)
endif ()
if (CONFIG_WAMR_ENABLE_LIBC_BUILTIN)
set (WAMR_BUILD_LIBC_BUILTIN 1)
endif ()
if (CONFIG_WAMR_INTERP_LOADER_MINI)
set (WAMR_BUILD_MINI_LOADER 1)
endif ()
if (CONFIG_WAMR_ENABLE_MULTI_MODULE)
set (WAMR_BUILD_MULTI_MODULE 1)
endif ()
if (CONFIG_WAMR_ENABLE_SHARED_MEMORY)
set (WAMR_BUILD_SHARED_MEMORY 1)
endif ()
if (CONFIG_WAMR_ENABLE_MEMORY_PROFILING)
set (WAMR_BUILD_MEMORY_PROFILING 1)
endif ()
if (CONFIG_WAMR_ENABLE_PERF_PROFILING)
set (WAMR_BUILD_PERF_PROFILING 1)
endif ()
if (CONFIG_WAMR_ENABLE_REF_TYPES)
set (WAMR_BUILD_REF_TYPES 1)
endif ()
if (CONFIG_WAMR_ENABLE_LIBC_WASI)
set (WAMR_BUILD_LIBC_WASI 1)
endif ()
if (CONFIG_WAMR_ENABLE_LIB_PTHREAD)
set (WAMR_BUILD_LIB_PTHREAD 1)
endif ()
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
list (APPEND srcs "${WAMR_RUNTIME_LIB_SOURCE}"
"${PLATFORM_SHARED_SOURCE}")
set (include_dirs "${IWASM_DIR}/include"
"${UTILS_SHARED_DIR}"
"${PLATFORM_SHARED_DIR}"
"${PLATFORM_SHARED_DIR}/../include"
"${IWASM_COMMON_DIR}")
endif ()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${include_dirs}
REQUIRES pthread lwip esp_timer
KCONFIG ${CMAKE_CURRENT_LIST_DIR}/Kconfig)
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
if (CONFIG_IDF_TARGET_ARCH_RISCV)
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1)
elseif (CONFIG_IDF_TARGET_ARCH_XTENSA)
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_XTENSA=1)
endif ()
if (CONFIG_WAMR_ENABLE_AOT)
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DWASM_ENABLE_AOT=1)
endif ()
if (CONFIG_WAMR_ENABLE_INTERP)
target_compile_definitions(${COMPONENT_LIB} PUBLIC -DWASM_ENABLE_INTERP=1)
endif ()

View File

@ -1,77 +0,0 @@
menu "WASM Micro Runtime"
choice WAMR_BUILD_TYPE
prompt "Build type"
default WAMR_BUILD_RELEASE
config WAMR_BUILD_RELEASE
bool "Release"
config WAMR_BUILD_DEBUG
bool "Debug"
endchoice
config WAMR_ENABLE_AOT
bool "AOT"
default y
menuconfig WAMR_ENABLE_INTERP
bool "Interpreter"
default y
if WAMR_ENABLE_INTERP
choice WAMR_INTERP_MODE
prompt "Interpreter mode"
default WAMR_INTERP_FAST
config WAMR_INTERP_CLASSIC
bool "Classic"
config WAMR_INTERP_FAST
bool "Fast"
endchoice
choice WAMR_INTERP_LOADER_MODE
prompt "Loader mode"
default WAMR_INTERP_LOADER_NORMAL
config WAMR_INTERP_LOADER_NORMAL
bool "Normal"
config WAMR_INTERP_LOADER_MINI
bool "Mini"
endchoice
endif
config WAMR_ENABLE_LIB_PTHREAD
bool "Lib pthread"
default y
config WAMR_ENABLE_LIBC_BUILTIN
bool "Libc builtin"
default y
config WAMR_ENABLE_LIBC_WASI
bool "Libc WASI"
default y
config WAMR_ENABLE_MEMORY_PROFILING
bool "Memory profiling"
default n
config WAMR_ENABLE_MULTI_MODULE
bool "Multi module"
default n
config WAMR_ENABLE_PERF_PROFILING
bool "Performance profiling"
default n
config WAMR_ENABLE_REF_TYPES
bool "Reference types"
default n
config WAMR_ENABLE_SHARED_MEMORY
bool "Shared memory"
default n
endmenu

View File

@ -1,41 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
message(STATUS "involving boringssl...")
include(ExternalProject)
ExternalProject_Add(boringssl
PREFIX external/boringssl
# follow envoy, which tracks BoringSSL, which tracks Chromium
# https://github.com/envoyproxy/envoy/blob/main/bazel/repository_locations.bzl#L112
# chromium-105.0.5195.37 (linux/beta)
URL https://github.com/google/boringssl/archive/098695591f3a2665fccef83a3732ecfc99acdcdd.tar.gz
URL_HASH SHA256=e141448cf6f686b6e9695f6b6459293fd602c8d51efe118a83106752cf7e1280
DOWNLOAD_EXTRACT_TIMESTAMP NEW
# SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../external/boringssl
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/src/boringssl-build/libssl.a
${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/
&& ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/src/boringssl-build/libcrypto.a
${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/
&& ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/src/boringssl/src/include/openssl
${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/openssl
)
add_library(boringssl_ssl STATIC IMPORTED GLOBAL)
set_target_properties(
boringssl_ssl
PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/libssl.a
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/
)
add_dependencies(boringssl_ssl boringssl)
add_library(boringssl_crypto STATIC IMPORTED GLOBAL)
set_target_properties(
boringssl_crypto
PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/libcrypto.a
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/external/boringssl/
)
add_dependencies(boringssl_crypto boringssl)

View File

@ -1,56 +1,5 @@
diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt
index 9759b069fdc4..25b427f8bcf2 100644
--- a/lldb/bindings/CMakeLists.txt
+++ b/lldb/bindings/CMakeLists.txt
@@ -26,8 +26,6 @@ set(SWIG_COMMON_FLAGS
-features autodoc
-I${LLDB_SOURCE_DIR}/include
-I${CMAKE_CURRENT_SOURCE_DIR}
- -D__STDC_LIMIT_MACROS
- -D__STDC_CONSTANT_MACROS
${DARWIN_EXTRAS}
)
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index c9a6d0f06056..021c7683d170 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -1,8 +1,5 @@
/* Various liblldb typedefs that SWIG needs to know about. */
#define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */
-/* The ISO C99 standard specifies that in C++ implementations limit macros such
- as INT32_MAX should only be defined if __STDC_LIMIT_MACROS is. */
-#define __STDC_LIMIT_MACROS
%include "stdint.i"
%include "lldb/lldb-defines.h"
diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig
index b1ace4ff3b1e..5f8f4aa678c4 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -439,7 +439,7 @@ bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
%typemap(out) lldb::FileSP {
$result = nullptr;
- lldb::FileSP &sp = $1;
+ const lldb::FileSP &sp = $1;
if (sp) {
PythonFile pyfile = unwrapOrSetPythonException(PythonFile::FromFile(*sp));
if (!pyfile.IsValid())
diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h b/lldb/include/lldb/Breakpoint/Breakpoint.h
index f2e2a0d22784..426d1129bd10 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -9,6 +9,7 @@
#ifndef LLDB_BREAKPOINT_BREAKPOINT_H
#define LLDB_BREAKPOINT_BREAKPOINT_H
+#include <limits>
#include <memory>
#include <string>
#include <unordered_set>
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index dd7100c4616c..97d70daadbdc 100644
index dd7100c46..97d70daad 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -41,6 +41,7 @@
@ -80,7 +29,7 @@ index dd7100c4616c..97d70daadbdc 100644
///
/// Tries to resolve \a vm_addr as a file address (if \a
diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h
index be91929c62e1..8d876fc1fa2f 100644
index be91929c6..8d876fc1f 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -508,6 +508,17 @@ public:
@ -103,7 +52,7 @@ index be91929c62e1..8d876fc1fa2f 100644
} // namespace lldb_private
diff --git a/lldb/include/lldb/Expression/DWARFEvaluator.h b/lldb/include/lldb/Expression/DWARFEvaluator.h
new file mode 100644
index 000000000000..6811cbeae3d3
index 000000000..6811cbeae
--- /dev/null
+++ b/lldb/include/lldb/Expression/DWARFEvaluator.h
@@ -0,0 +1,110 @@
@ -219,7 +168,7 @@ index 000000000000..6811cbeae3d3
+#endif // LLDB_EXPRESSION_DWARFEVALUATOR_H
diff --git a/lldb/include/lldb/Expression/DWARFEvaluatorFactory.h b/lldb/include/lldb/Expression/DWARFEvaluatorFactory.h
new file mode 100644
index 000000000000..f3b496c580e4
index 000000000..f3b496c58
--- /dev/null
+++ b/lldb/include/lldb/Expression/DWARFEvaluatorFactory.h
@@ -0,0 +1,56 @@
@ -280,7 +229,7 @@ index 000000000000..f3b496c580e4
+
+#endif // LLDB_EXPRESSION_DWARFEVALUATORFACTORY_H
diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h
index 1490ac2d614a..35c741d4e6ba 100644
index 1490ac2d6..35c741d4e 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -120,6 +120,10 @@ public:
@ -314,7 +263,7 @@ index 1490ac2d614a..35c741d4e6ba 100644
GetLocationExpression(lldb::addr_t load_function_start,
lldb::addr_t addr) const;
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index aaa2470d2931..c15f2db52fbc 100644
index aaa2470d2..c15f2db52 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -1434,7 +1434,7 @@ public:
@ -327,7 +276,7 @@ index aaa2470d2931..c15f2db52fbc 100644
/// Read of memory from a process.
///
diff --git a/lldb/include/lldb/Target/ProcessTrace.h b/lldb/include/lldb/Target/ProcessTrace.h
index 7b9d6b13dd6f..9525fc9750fd 100644
index 7b9d6b13d..9525fc975 100644
--- a/lldb/include/lldb/Target/ProcessTrace.h
+++ b/lldb/include/lldb/Target/ProcessTrace.h
@@ -59,7 +59,7 @@ public:
@ -340,7 +289,7 @@ index 7b9d6b13dd6f..9525fc9750fd 100644
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
Status &error) override;
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index ad5298151e4a..5a3c0b27a738 100644
index ad5298151..5a3c0b27a 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -74,6 +74,7 @@ class Disassembler;
@ -352,7 +301,7 @@ index ad5298151e4a..5a3c0b27a738 100644
class EmulateInstruction;
class Environment;
diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h
index 2ed083ec8ae9..f4d500d198e8 100644
index 2ed083ec8..f4d500d19 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -113,6 +113,8 @@ typedef lldb::REPLSP (*REPLCreateInstance)(Status &error,
@ -365,7 +314,7 @@ index 2ed083ec8ae9..f4d500d198e8 100644
/// \{
typedef llvm::Expected<lldb::TraceSP> (*TraceCreateInstanceForSessionFile)(
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 19c97be15066..1647f93ec4f3 100644
index 19c97be15..1647f93ec 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -16,6 +16,7 @@
@ -387,7 +336,7 @@ index 19c97be15066..1647f93ec4f3 100644
+ return m_dwarf_evaluator_factory.get();
+}
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index fcaa868b083e..59a404d4a7e1 100644
index fcaa868b0..59a404d4a 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -1597,3 +1597,32 @@ bool PluginManager::CreateSettingForStructuredDataPlugin(
@ -424,7 +373,7 @@ index fcaa868b083e..59a404d4a7e1 100644
+ return GetDWARFEvaluatorFactoryInstances().GetCallbackAtIndex(idx);
+}
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index fb57c0fedf04..f92d6a54de94 100644
index fb57c0fed..f92d6a54d 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -538,7 +538,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
@ -437,7 +386,7 @@ index fb57c0fedf04..f92d6a54de94 100644
error.SetErrorStringWithFormat(
"read memory from 0x%" PRIx64 " failed (%u of %u bytes read)",
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 9c1ba99da1d0..b15b214b2a2f 100644
index 9c1ba99da..b15b214b2 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -735,7 +735,7 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
@ -450,7 +399,7 @@ index 9c1ba99da1d0..b15b214b2a2f 100644
data.SetData(data_sp);
return bytes_read;
diff --git a/lldb/source/Expression/CMakeLists.txt b/lldb/source/Expression/CMakeLists.txt
index bf94361dd6c1..4e76d547aeaf 100644
index bf94361dd..4e76d547a 100644
--- a/lldb/source/Expression/CMakeLists.txt
+++ b/lldb/source/Expression/CMakeLists.txt
@@ -1,5 +1,7 @@
@ -463,7 +412,7 @@ index bf94361dd6c1..4e76d547aeaf 100644
ExpressionVariable.cpp
diff --git a/lldb/source/Expression/DWARFEvaluator.cpp b/lldb/source/Expression/DWARFEvaluator.cpp
new file mode 100644
index 000000000000..06107e136197
index 000000000..06107e136
--- /dev/null
+++ b/lldb/source/Expression/DWARFEvaluator.cpp
@@ -0,0 +1,1952 @@
@ -2421,7 +2370,7 @@ index 000000000000..06107e136197
+}
diff --git a/lldb/source/Expression/DWARFEvaluatorFactory.cpp b/lldb/source/Expression/DWARFEvaluatorFactory.cpp
new file mode 100644
index 000000000000..c0612641204a
index 000000000..c06126412
--- /dev/null
+++ b/lldb/source/Expression/DWARFEvaluatorFactory.cpp
@@ -0,0 +1,57 @@
@ -2483,7 +2432,7 @@ index 000000000000..c0612641204a
+ object_address_ptr);
+}
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index a10546c1deae..4d13e4642af3 100644
index a10546c1d..4d13e4642 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -15,6 +15,8 @@
@ -4300,7 +4249,7 @@ index a10546c1deae..4d13e4642af3 100644
static DataExtractor ToDataExtractor(const llvm::DWARFLocationExpression &loc,
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 00e9ccb762c3..2137a1ac8324 100644
index 00e9ccb76..2137a1ac8 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -759,6 +759,24 @@ void CommandInterpreter::LoadCommandDictionary() {
@ -4329,7 +4278,7 @@ index 00e9ccb762c3..2137a1ac8324 100644
new CommandObjectRegexCommand(
*this, "kdp-remote",
diff --git a/lldb/source/Plugins/CMakeLists.txt b/lldb/source/Plugins/CMakeLists.txt
index 9181a4e47675..2be6ec3657c0 100644
index 9181a4e47..2be6ec365 100644
--- a/lldb/source/Plugins/CMakeLists.txt
+++ b/lldb/source/Plugins/CMakeLists.txt
@@ -2,6 +2,7 @@ add_subdirectory(ABI)
@ -4359,14 +4308,14 @@ index 9181a4e47675..2be6ec3657c0 100644
endif()
diff --git a/lldb/source/Plugins/DWARFEvaluator/CMakeLists.txt b/lldb/source/Plugins/DWARFEvaluator/CMakeLists.txt
new file mode 100644
index 000000000000..73fad41e1a72
index 000000000..73fad41e1
--- /dev/null
+++ b/lldb/source/Plugins/DWARFEvaluator/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(wasm)
diff --git a/lldb/source/Plugins/DWARFEvaluator/wasm/CMakeLists.txt b/lldb/source/Plugins/DWARFEvaluator/wasm/CMakeLists.txt
new file mode 100644
index 000000000000..e50b1bef7e69
index 000000000..e50b1bef7
--- /dev/null
+++ b/lldb/source/Plugins/DWARFEvaluator/wasm/CMakeLists.txt
@@ -0,0 +1,10 @@
@ -4382,7 +4331,7 @@ index 000000000000..e50b1bef7e69
+ )
diff --git a/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluator.cpp b/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluator.cpp
new file mode 100644
index 000000000000..fdda1991d19f
index 000000000..fdda1991d
--- /dev/null
+++ b/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluator.cpp
@@ -0,0 +1,126 @@
@ -4514,7 +4463,7 @@ index 000000000000..fdda1991d19f
+}
diff --git a/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluator.h b/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluator.h
new file mode 100644
index 000000000000..a01159064a39
index 000000000..a01159064
--- /dev/null
+++ b/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluator.h
@@ -0,0 +1,47 @@
@ -4567,7 +4516,7 @@ index 000000000000..a01159064a39
+#endif // LLDB_SOURCE_PLUGINS_DWARFEVALUATOR_WASM_WASMDWARFEVALUATOR_H
diff --git a/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluatorFactory.cpp b/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluatorFactory.cpp
new file mode 100644
index 000000000000..d43e96a34d37
index 000000000..d43e96a34
--- /dev/null
+++ b/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluatorFactory.cpp
@@ -0,0 +1,64 @@
@ -4637,7 +4586,7 @@ index 000000000000..d43e96a34d37
+}
diff --git a/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluatorFactory.h b/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluatorFactory.h
new file mode 100644
index 000000000000..8a946592a09a
index 000000000..8a946592a
--- /dev/null
+++ b/lldb/source/Plugins/DWARFEvaluator/wasm/WasmDWARFEvaluatorFactory.h
@@ -0,0 +1,55 @@
@ -4697,7 +4646,7 @@ index 000000000000..8a946592a09a
+
+#endif // LLDB_SOURCE_PLUGINS_DWARFEVALUATOR_WASM_WASMDWARFEVALUATORFACTORY_H
diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
index ae7e011eaa52..24ea75d1971c 100644
index ae7e011ea..24ea75d19 100644
--- a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
@@ -62,6 +62,15 @@ void DynamicLoaderWasmDYLD::DidAttach() {
@ -4717,7 +4666,7 @@ index ae7e011eaa52..24ea75d1971c 100644
ThreadPlanSP DynamicLoaderWasmDYLD::GetStepThroughTrampolinePlan(Thread &thread,
diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
index 5272da9ab33a..abc5523bfd70 100644
index 5272da9ab..abc5523bf 100644
--- a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -23,6 +23,7 @@
@ -4757,7 +4706,7 @@ index 5272da9ab33a..abc5523bfd70 100644
}
}
diff --git a/lldb/source/Plugins/Platform/CMakeLists.txt b/lldb/source/Plugins/Platform/CMakeLists.txt
index 5f284e517dca..6084cbc9378d 100644
index 5f284e517..6084cbc93 100644
--- a/lldb/source/Plugins/Platform/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/CMakeLists.txt
@@ -15,3 +15,4 @@
@ -4767,7 +4716,7 @@ index 5f284e517dca..6084cbc9378d 100644
+add_subdirectory(wasm-remote)
diff --git a/lldb/source/Plugins/Platform/wasm-remote/CMakeLists.txt b/lldb/source/Plugins/Platform/wasm-remote/CMakeLists.txt
new file mode 100644
index 000000000000..4a65765a5659
index 000000000..4a65765a5
--- /dev/null
+++ b/lldb/source/Plugins/Platform/wasm-remote/CMakeLists.txt
@@ -0,0 +1,10 @@
@ -4783,7 +4732,7 @@ index 000000000000..4a65765a5659
+ )
diff --git a/lldb/source/Plugins/Platform/wasm-remote/PlatformRemoteWasmServer.cpp b/lldb/source/Plugins/Platform/wasm-remote/PlatformRemoteWasmServer.cpp
new file mode 100644
index 000000000000..f26d11f00e5c
index 000000000..f26d11f00
--- /dev/null
+++ b/lldb/source/Plugins/Platform/wasm-remote/PlatformRemoteWasmServer.cpp
@@ -0,0 +1,139 @@
@ -4929,7 +4878,7 @@ index 000000000000..f26d11f00e5c
\ No newline at end of file
diff --git a/lldb/source/Plugins/Platform/wasm-remote/PlatformRemoteWasmServer.h b/lldb/source/Plugins/Platform/wasm-remote/PlatformRemoteWasmServer.h
new file mode 100644
index 000000000000..f306a79d3f4f
index 000000000..f306a79d3
--- /dev/null
+++ b/lldb/source/Plugins/Platform/wasm-remote/PlatformRemoteWasmServer.h
@@ -0,0 +1,37 @@
@ -4972,7 +4921,7 @@ index 000000000000..f306a79d3f4f
+#endif
\ No newline at end of file
diff --git a/lldb/source/Plugins/Plugins.def.in b/lldb/source/Plugins/Plugins.def.in
index bf54598fb2f3..b0bd7b9965fe 100644
index bf54598fb..b0bd7b996 100644
--- a/lldb/source/Plugins/Plugins.def.in
+++ b/lldb/source/Plugins/Plugins.def.in
@@ -31,6 +31,7 @@
@ -4984,7 +4933,7 @@ index bf54598fb2f3..b0bd7b9965fe 100644
#undef LLDB_PLUGIN
diff --git a/lldb/source/Plugins/Process/CMakeLists.txt b/lldb/source/Plugins/Process/CMakeLists.txt
index bea5bac9eb21..7a0855e02ca2 100644
index bea5bac9e..7a0855e02 100644
--- a/lldb/source/Plugins/Process/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/CMakeLists.txt
@@ -18,3 +18,4 @@ add_subdirectory(Utility)
@ -4993,7 +4942,7 @@ index bea5bac9eb21..7a0855e02ca2 100644
add_subdirectory(minidump)
+add_subdirectory(wasm)
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 12bc7390c729..707ab85e5615 100644
index 12bc7390c..707ab85e5 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -285,7 +285,7 @@ bool ProcessElfCore::IsAlive() { return true; }
@ -5006,7 +4955,7 @@ index 12bc7390c729..707ab85e5615 100644
// in core files we have it all cached our our core file anyway.
return DoReadMemory(addr, buf, size, error);
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index d8e3cc9ae3e1..f0bf9c4d3b00 100644
index d8e3cc9ae..f0bf9c4d3 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -84,7 +84,8 @@ public:
@ -5020,7 +4969,7 @@ index d8e3cc9ae3e1..f0bf9c4d3b00 100644
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
lldb_private::Status &error) override;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 6914b37348ea..bb8a056049f3 100644
index 6914b3734..bb8a05604 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -334,6 +334,11 @@ ConstString ProcessGDBRemote::GetPluginName() { return GetPluginNameStatic(); }
@ -5054,7 +5003,7 @@ index 6914b37348ea..bb8a056049f3 100644
}
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index fe04cdddd0f5..e4a14c64579a 100644
index fe04cdddd..e4a14c645 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -237,6 +237,8 @@ protected:
@ -5067,7 +5016,7 @@ index fe04cdddd0f5..e4a14c64579a 100644
enum {
eBroadcastBitAsyncContinue = (1 << 0),
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index 84548edb5caa..0ae6f7e4a177 100644
index 84548edb5..0ae6f7e4a 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -596,7 +596,7 @@ bool ProcessMachCore::WarnBeforeDetach() const { return false; }
@ -5080,7 +5029,7 @@ index 84548edb5caa..0ae6f7e4a177 100644
// in core files we have it all cached our our core file anyway.
return DoReadMemory(addr, buf, size, error);
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
index db77e96f1072..1c930896c743 100644
index db77e96f1..1c930896c 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -65,7 +65,8 @@ public:
@ -5094,7 +5043,7 @@ index db77e96f1072..1c930896c743 100644
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
lldb_private::Status &error) override;
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index 385557422758..d8bb21581086 100644
index 385557422..d8bb21581 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -374,7 +374,7 @@ bool ProcessMinidump::IsAlive() { return true; }
@ -5107,7 +5056,7 @@ index 385557422758..d8bb21581086 100644
// we have it all cached in our dump file anyway.
return DoReadMemory(addr, buf, size, error);
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
index 27b0da0047a5..e94ecab430c1 100644
index 27b0da004..e94ecab43 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -69,8 +69,8 @@ public:
@ -5123,7 +5072,7 @@ index 27b0da0047a5..e94ecab430c1 100644
Status &error) override;
diff --git a/lldb/source/Plugins/Process/wasm/CMakeLists.txt b/lldb/source/Plugins/Process/wasm/CMakeLists.txt
new file mode 100644
index 000000000000..61efb933fa62
index 000000000..61efb933f
--- /dev/null
+++ b/lldb/source/Plugins/Process/wasm/CMakeLists.txt
@@ -0,0 +1,12 @@
@ -5141,7 +5090,7 @@ index 000000000000..61efb933fa62
+ )
diff --git a/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
new file mode 100644
index 000000000000..9c0fc7b7f270
index 000000000..9c0fc7b7f
--- /dev/null
+++ b/lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
@@ -0,0 +1,261 @@
@ -5408,7 +5357,7 @@ index 000000000000..9c0fc7b7f270
+}
diff --git a/lldb/source/Plugins/Process/wasm/ProcessWasm.h b/lldb/source/Plugins/Process/wasm/ProcessWasm.h
new file mode 100644
index 000000000000..d3aece7a6554
index 000000000..d3aece7a6
--- /dev/null
+++ b/lldb/source/Plugins/Process/wasm/ProcessWasm.h
@@ -0,0 +1,128 @@
@ -5542,7 +5491,7 @@ index 000000000000..d3aece7a6554
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_WASM_PROCESSWASM_H
diff --git a/lldb/source/Plugins/Process/wasm/ThreadWasm.cpp b/lldb/source/Plugins/Process/wasm/ThreadWasm.cpp
new file mode 100644
index 000000000000..fa02073e7a52
index 000000000..fa02073e7
--- /dev/null
+++ b/lldb/source/Plugins/Process/wasm/ThreadWasm.cpp
@@ -0,0 +1,35 @@
@ -5583,7 +5532,7 @@ index 000000000000..fa02073e7a52
+}
diff --git a/lldb/source/Plugins/Process/wasm/ThreadWasm.h b/lldb/source/Plugins/Process/wasm/ThreadWasm.h
new file mode 100644
index 000000000000..0a33c07de994
index 000000000..0a33c07de
--- /dev/null
+++ b/lldb/source/Plugins/Process/wasm/ThreadWasm.h
@@ -0,0 +1,41 @@
@ -5630,7 +5579,7 @@ index 000000000000..0a33c07de994
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_WASM_THREADWASM_H
diff --git a/lldb/source/Plugins/Process/wasm/UnwindWasm.cpp b/lldb/source/Plugins/Process/wasm/UnwindWasm.cpp
new file mode 100644
index 000000000000..1a195cb9361a
index 000000000..1a195cb93
--- /dev/null
+++ b/lldb/source/Plugins/Process/wasm/UnwindWasm.cpp
@@ -0,0 +1,74 @@
@ -5711,7 +5660,7 @@ index 000000000000..1a195cb9361a
\ No newline at end of file
diff --git a/lldb/source/Plugins/Process/wasm/UnwindWasm.h b/lldb/source/Plugins/Process/wasm/UnwindWasm.h
new file mode 100644
index 000000000000..9bd1dac9a98a
index 000000000..9bd1dac9a
--- /dev/null
+++ b/lldb/source/Plugins/Process/wasm/UnwindWasm.h
@@ -0,0 +1,55 @@
@ -5771,7 +5720,7 @@ index 000000000000..9bd1dac9a98a
+
+#endif // lldb_UnwindWasm_h_
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index ccaf31317d75..c3ef5aebd46d 100644
index ccaf31317..c3ef5aebd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3212,8 +3212,13 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
@ -5790,7 +5739,7 @@ index ccaf31317d75..c3ef5aebd46d 100644
// DWARF doesn't specify if a DW_TAG_variable is a local, global
// or static variable, so we have to do a little digging:
diff --git a/lldb/source/Target/PathMappingList.cpp b/lldb/source/Target/PathMappingList.cpp
index b660c310ef31..cd76421cec18 100644
index b660c310e..cd76421ce 100644
--- a/lldb/source/Target/PathMappingList.cpp
+++ b/lldb/source/Target/PathMappingList.cpp
@@ -218,7 +218,12 @@ bool PathMappingList::ReverseRemapPath(const FileSpec &file, FileSpec &fixed) co
@ -5808,7 +5757,7 @@ index b660c310ef31..cd76421cec18 100644
return {};
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index a77ecddfbab6..e257f93508f6 100644
index a77ecddfb..e257f9350 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1970,6 +1970,12 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
@ -5825,7 +5774,7 @@ index a77ecddfbab6..e257f93508f6 100644
return 0;
}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 8ecc66b592ea..f148987915de 100644
index 8ecc66b59..f14898791 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1892,7 +1892,8 @@ Status Process::DisableSoftwareBreakpoint(BreakpointSite *bp_site) {
@ -5839,7 +5788,7 @@ index 8ecc66b592ea..f148987915de 100644
if (!GetDisableMemoryCache()) {
#if defined(VERIFY_MEMORY_READS)
diff --git a/lldb/source/Target/ProcessTrace.cpp b/lldb/source/Target/ProcessTrace.cpp
index c878a2ac4eb9..ad5945b0ad1f 100644
index c878a2ac4..ad5945b0a 100644
--- a/lldb/source/Target/ProcessTrace.cpp
+++ b/lldb/source/Target/ProcessTrace.cpp
@@ -88,7 +88,7 @@ void ProcessTrace::RefreshStateAfterStop() {}
@ -5852,7 +5801,7 @@ index c878a2ac4eb9..ad5945b0ad1f 100644
// we have it all cached in the trace files.
return DoReadMemory(addr, buf, size, error);
diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp b/lldb/source/Target/ThreadPlanStepRange.cpp
index 896e647bbb52..f76307016102 100644
index 896e647bb..f76307016 100644
--- a/lldb/source/Target/ThreadPlanStepRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepRange.cpp
@@ -334,7 +334,10 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
@ -5868,7 +5817,7 @@ index 896e647bbb52..f76307016102 100644
instructions->GetInstructionAtIndex(last_index);
size_t last_inst_size = last_inst->GetOpcode().GetByteSize();
diff --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp
index 4ec2e25c7e3b..24c88fe9ae4f 100644
index 4ec2e25c7..24c88fe9a 100644
--- a/lldb/source/Target/UnixSignals.cpp
+++ b/lldb/source/Target/UnixSignals.cpp
@@ -46,6 +46,8 @@ lldb::UnixSignalsSP UnixSignals::Create(const ArchSpec &arch) {
@ -5880,27 +5829,3 @@ index 4ec2e25c7e3b..24c88fe9ae4f 100644
default:
return std::make_shared<UnixSignals>();
}
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h b/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h
index 4310ba9ce9e0..297b3387999d 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/OrcRPCExecutorProcessControl.h
@@ -13,6 +13,7 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCRPCEXECUTORPROCESSCONTROL_H
#define LLVM_EXECUTIONENGINE_ORC_ORCRPCEXECUTORPROCESSCONTROL_H
+#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
#include "llvm/ExecutionEngine/Orc/Shared/RPCUtils.h"
#include "llvm/ExecutionEngine/Orc/Shared/RawByteChannel.h"
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index 753b1998c40c..27370c62dd6e 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -16,6 +16,7 @@
#include "llvm/Support/Compiler.h"
#include <cassert>
#include <climits>
+#include <limits>
#include <cmath>
#include <cstdint>
#include <cstring>

View File

@ -1,30 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set(_WAMR_BUILD_SCRIPTS_DIR "${CMAKE_CURRENT_LIST_DIR}")
function(install_iwasm_package)
install (EXPORT iwasmTargets
FILE iwasmTargets.cmake
NAMESPACE iwasm::
DESTINATION lib/cmake/iwasm
)
include (CMakePackageConfigHelpers)
configure_package_config_file (${_WAMR_BUILD_SCRIPTS_DIR}/iwasmConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake"
INSTALL_DESTINATION lib/cmake/iwasm
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfigVersion.cmake"
VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}
COMPATIBILITY SameMajorVersion
)
install (FILES
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/iwasmConfigVersion.cmake"
DESTINATION lib/cmake/iwasm
)
endfunction()

View File

@ -1 +0,0 @@
requests==2.32.3

View File

@ -1,6 +1,7 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
if (NOT DEFINED WAMR_ROOT_DIR)
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../)
endif ()
@ -10,14 +11,15 @@ endif ()
if (NOT DEFINED IWASM_DIR)
set (IWASM_DIR ${WAMR_ROOT_DIR}/core/iwasm)
endif ()
if (NOT DEFINED APP_MGR_DIR)
set (APP_MGR_DIR ${WAMR_ROOT_DIR}/core/app-mgr)
endif ()
if (NOT DEFINED APP_FRAMEWORK_DIR)
set (APP_FRAMEWORK_DIR ${WAMR_ROOT_DIR}/core/app-framework)
endif ()
if (NOT DEFINED DEPS_DIR)
set (DEPS_DIR ${WAMR_ROOT_DIR}/core/deps)
endif ()
if (NOT DEFINED SHARED_PLATFORM_CONFIG)
# CMake file for platform configuration. The PLATFORM_SHARED_SOURCE variable
# should point to a list of platform-specfic source files to compile.
set (SHARED_PLATFORM_CONFIG ${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
endif ()
if (DEFINED EXTRA_SDK_INCLUDE_PATH)
message(STATUS, "EXTRA_SDK_INCLUDE_PATH = ${EXTRA_SDK_INCLUDE_PATH} ")
@ -48,43 +50,30 @@ if (NOT DEFINED WAMR_BUILD_TARGET)
endif ()
################ optional according to settings ################
if (WAMR_BUILD_FAST_JIT EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
# Enable classic interpreter if Fast JIT or LLVM JIT is enabled
set (WAMR_BUILD_INTERP 1)
set (WAMR_BUILD_FAST_INTERP 0)
endif ()
if (WAMR_BUILD_INTERP EQUAL 1)
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
endif ()
if (WAMR_BUILD_FAST_JIT EQUAL 1)
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
message ("Fast JIT currently not supported on Windows")
set (WAMR_BUILD_FAST_JIT 0)
else ()
include (${IWASM_DIR}/fast-jit/iwasm_fast_jit.cmake)
if (WAMR_BUILD_INTERP EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1
OR WAMR_BUILD_FAST_JIT EQUAL 1)
if (WAMR_BUILD_FAST_JIT EQUAL 1)
set (WAMR_BUILD_FAST_INTERP 0)
endif ()
endif ()
if (WAMR_BUILD_JIT EQUAL 1)
# Enable AOT if LLVM JIT is enabled
set (WAMR_BUILD_AOT 1)
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
endif ()
if (WAMR_BUILD_AOT EQUAL 1)
include (${IWASM_DIR}/aot/iwasm_aot.cmake)
if (WAMR_BUILD_JIT EQUAL 1)
include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
endif ()
endif ()
if (WAMR_BUILD_STRINGREF EQUAL 1)
set (WAMR_BUILD_GC 1)
if (NOT WAMR_BUILD_JIT EQUAL 1 AND WAMR_BUILD_FAST_JIT EQUAL 1)
include (${IWASM_DIR}/fast-jit/iwasm_fast_jit.cmake)
endif ()
if (WAMR_BUILD_GC EQUAL 1)
include (${IWASM_DIR}/common/gc/iwasm_gc.cmake)
# Enable the dependent feature if GC is enabled
set (WAMR_BUILD_REF_TYPES 1)
if (WAMR_BUILD_APP_FRAMEWORK EQUAL 1)
include (${APP_FRAMEWORK_DIR}/app_framework.cmake)
include (${SHARED_DIR}/coap/lib_coap.cmake)
include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
endif ()
if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
@ -93,10 +82,8 @@ endif ()
if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
include (${IWASM_DIR}/libraries/libc-uvwasi/libc_uvwasi.cmake)
set (WAMR_BUILD_MODULE_INST_CONTEXT 1)
elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
set (WAMR_BUILD_MODULE_INST_CONTEXT 1)
endif ()
if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
@ -104,15 +91,7 @@ if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
set (WAMR_BUILD_LIB_PTHREAD 1)
endif ()
if (WAMR_BUILD_WASI_NN EQUAL 1)
include (${IWASM_DIR}/libraries/wasi-nn/cmake/wasi_nn.cmake)
endif ()
if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
set (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE 0)
message ("Lib pthread semaphore currently not supported on Windows")
endif ()
include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake)
# Enable the dependent feature if lib pthread is enabled
set (WAMR_BUILD_THREAD_MGR 1)
@ -120,18 +99,6 @@ if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
set (WAMR_BUILD_SHARED_MEMORY 1)
endif ()
if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1)
include (${IWASM_DIR}/libraries/lib-wasi-threads/lib_wasi_threads.cmake)
# Enable the dependent feature if lib wasi threads is enabled
set (WAMR_BUILD_THREAD_MGR 1)
set (WAMR_BUILD_BULK_MEMORY 1)
set (WAMR_BUILD_SHARED_MEMORY 1)
endif ()
if (WAMR_BUILD_SHARED_HEAP EQUAL 1)
include (${IWASM_DIR}/libraries/shared-heap/shared_heap.cmake)
endif ()
if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
set (WAMR_BUILD_THREAD_MGR 1)
include (${IWASM_DIR}/libraries/debug-engine/debug_engine.cmake)
@ -155,10 +122,6 @@ if (WAMR_BUILD_LIB_RATS EQUAL 1)
include (${IWASM_DIR}/libraries/lib-rats/lib_rats.cmake)
endif ()
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
include (${WAMR_ROOT_DIR}/build-scripts/involve_boringssl.cmake)
endif ()
####################### Common sources #######################
if (NOT MSVC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
@ -168,18 +131,6 @@ endif ()
# include the build config template file
include (${CMAKE_CURRENT_LIST_DIR}/config_common.cmake)
if (WAMR_BUILD_SIMD EQUAL 1 AND WAMR_BUILD_FAST_INTERP EQUAL 1)
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
message(STATUS "SIMDe doesnt support platform " ${WAMR_BUILD_PLATFORM})
set(WAMR_BUILD_SIMDE 0)
else()
include (${IWASM_DIR}/libraries/simde/simde.cmake)
set (WAMR_BUILD_SIMDE 1)
endif()
else()
set(WAMR_BUILD_SIMDE 0)
endif ()
include_directories (${IWASM_DIR}/include)
file (GLOB header
@ -187,13 +138,9 @@ file (GLOB header
)
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
enable_language (ASM_MASM)
else()
enable_language (ASM)
endif()
enable_language (ASM)
include (${SHARED_PLATFORM_CONFIG})
include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
include (${IWASM_DIR}/common/iwasm_common.cmake)
include (${SHARED_DIR}/utils/shared_utils.cmake)
@ -205,20 +152,19 @@ set (source_all
${UTILS_SHARED_SOURCE}
${LIBC_BUILTIN_SOURCE}
${LIBC_WASI_SOURCE}
${WASI_NN_SOURCES}
${IWASM_COMMON_SOURCE}
${IWASM_INTERP_SOURCE}
${IWASM_AOT_SOURCE}
${IWASM_COMPL_SOURCE}
${IWASM_FAST_JIT_SOURCE}
${IWASM_GC_SOURCE}
${LIB_WASI_THREADS_SOURCE}
${WASM_APP_LIB_SOURCE_ALL}
${NATIVE_INTERFACE_SOURCE}
${APP_MGR_SOURCE}
${LIB_PTHREAD_SOURCE}
${THREAD_MGR_SOURCE}
${LIBC_EMCC_SOURCE}
${LIB_RATS_SOURCE}
${DEBUG_ENGINE_SOURCE}
${LIB_SHARED_HEAP_SOURCE}
)
set (WAMR_RUNTIME_LIB_SOURCE ${source_all})

View File

@ -1,28 +0,0 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
if(NOT WAMR_ROOT_DIR)
# if from wamr-compiler
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
endif()
set(WAMR_VERSION_MAJOR 2)
set(WAMR_VERSION_MINOR 3)
set(WAMR_VERSION_PATCH 0)
message("-- WAMR version: ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}")
# Configure the version header file
configure_file(
${WAMR_ROOT_DIR}/core/version.h.in
${WAMR_ROOT_DIR}/core/version.h
)
# Set the library version and SOVERSION
function(set_version_info target)
set_target_properties(${target}
PROPERTIES
VERSION ${WAMR_VERSION_MAJOR}.${WAMR_VERSION_MINOR}.${WAMR_VERSION_PATCH}
SOVERSION ${WAMR_VERSION_MAJOR}
)
endfunction()

92
ci/Dockerfile Normal file
View File

@ -0,0 +1,92 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# tie the ${VARIANT} and a llvm binary release together
# please find a matched version on https://github.com/llvm/llvm-project/releases
ARG VARIANT=focal
FROM ubuntu:${VARIANT}
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Asian/Shanghai
RUN apt update \
&& apt install -y apt-transport-https apt-utils build-essential \
ca-certificates curl g++-multilib git gnupg \
libgcc-9-dev lib32gcc-9-dev lsb-release \
ninja-build ocaml ocamlbuild python2.7 \
software-properties-common tree tzdata \
unzip valgrind vim wget zip
#
# CMAKE (https://apt.kitware.com/)
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null \
&& echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ bionic main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null \
&& apt update \
&& rm /usr/share/keyrings/kitware-archive-keyring.gpg \
&& apt install -y kitware-archive-keyring \
&& apt install -y cmake
#
# install emsdk (may not necessary ?)
RUN cd /opt \
&& git clone https://github.com/emscripten-core/emsdk.git
RUN cd /opt/emsdk \
&& git pull \
&& ./emsdk install 2.0.26 \
&& ./emsdk activate 2.0.26 \
&& echo "source /opt/emsdk/emsdk_env.sh" >> /root/.bashrc
#
# install clang and llvm release
ARG CLANG_VER=13.0.0
RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${CLANG_VER}/clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz -P /opt
RUN cd /opt \
&& tar xf clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz \
&& ln -sf clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04 clang-llvm
RUN rm /opt/clang+llvm-${CLANG_VER}-x86_64-linux-gnu-ubuntu-20.04.tar.xz
#
# install wasi-sdk
ARG WASI_SDK_VER=14
RUN wget -c https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VER}/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -P /opt
RUN tar xf /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz -C /opt \
&& ln -fs /opt/wasi-sdk-${WASI_SDK_VER}.0 /opt/wasi-sdk
RUN rm /opt/wasi-sdk-${WASI_SDK_VER}.0-linux.tar.gz
#
#install wabt
ARG WABT_VER=1.0.24
RUN wget -c https://github.com/WebAssembly/wabt/releases/download/${WABT_VER}/wabt-${WABT_VER}-ubuntu.tar.gz -P /opt
RUN tar xf /opt/wabt-${WABT_VER}-ubuntu.tar.gz -C /opt \
&& ln -fs /opt/wabt-${WABT_VER} /opt/wabt
RUN rm /opt/wabt-${WABT_VER}-ubuntu.tar.gz
#
# install bazelisk
ARG BAZELISK_VER=1.10.1
RUN mkdir /opt/bazelisk
RUN wget -c https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VER}/bazelisk-linux-amd64 -P /opt/bazelisk
RUN chmod a+x /opt/bazelisk/bazelisk-linux-amd64 \
&& ln -fs /opt/bazelisk/bazelisk-linux-amd64 /opt/bazelisk/bazel
#
# install
RUN apt update && apt install -y clang-format
# set path
ENV PATH "$PATH:/opt/wasi-sdk/bin:/opt/wabt/bin:/opt/binaryen/bin:/opt/bazelisk:/opt/clang-llvm/bin"
RUN echo "export PATH=/opt/wasi-sdk/bin:/opt/wabt/bin:/opt/binaryen/bin:/opt/bazelisk:/opt/clang-llvm/bin:${PATH}" >> /root/.bashrc
#
# PS
RUN echo "PS1='\n[ \u@wamr-dev-docker \W ]\n$ '" >> /root/.bashrc
# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*
VOLUME /workspace
WORKDIR /workspace

View File

@ -9,12 +9,12 @@ readonly VARIANT=$(lsb_release -c | awk '{print $2}')
docker build \
--memory=4G --cpu-quota=50000 \
-t wamr_dev_${VARIANT}:0.1 -f "${ROOT}"/.devcontainer/Dockerfile "${ROOT}"/.devcontainer \
-t wamr_dev_${VARIANT}:0.1 -f "${CURRENT_PATH}"/Dockerfile "${CURRENT_PATH}" \
&& docker run --rm -it \
--cap-add=SYS_PTRACE \
--cpus=".5" \
--memory=4G \
--mount type=bind,src="${ROOT}",dst=/workspaces \
--mount type=bind,src="${ROOT}",dst=/workspace \
--name wamr_build_env \
--security-opt=seccomp=unconfined \
wamr_dev_${VARIANT}:0.1 \

View File

@ -5,7 +5,7 @@
#
import argparse
import re
from pathlib import Path
import pathlib
import re
import shlex
import shutil
@ -13,14 +13,15 @@ import subprocess
import sys
import unittest
CLANG_FORMAT_CMD = "clang-format-14"
GIT_CLANG_FORMAT_CMD = "git-clang-format-14"
CLANG_FORMAT_CMD = "clang-format-12"
GIT_CLANG_FORMAT_CMD = "git-clang-format-12"
# glob style patterns
EXCLUDE_PATHS = [
"**/.git/*",
"**/.github/*",
"**/.vscode/*",
"**/assembly-script/*",
"**/build/*",
"**/build-scripts/*",
"**/ci/*",
@ -29,10 +30,12 @@ EXCLUDE_PATHS = [
"**/samples/wasm-c-api/src/*.*",
"**/samples/workload/*",
"**/test-tools/wasi-sdk/*",
"**/test-tools/IoT-APP-Store-Demo/*",
"**/tests/wamr-test-suites/workspace/*",
"**/wamr-sdk/*",
]
C_SUFFIXES = [".c", ".cc", ".cpp", ".h"]
C_SUFFIXES = [".c", ".cpp", ".h"]
INVALID_DIR_NAME_SEGMENT = r"([a-zA-Z0-9]+\_[a-zA-Z0-9]+)"
INVALID_FILE_NAME_SEGMENT = r"([a-zA-Z0-9]+\-[a-zA-Z0-9]+)"
@ -46,18 +49,18 @@ def locate_command(command: str) -> bool:
def is_excluded(path: str) -> bool:
path = Path(path).resolve()
path = pathlib.Path(path).resolve()
for exclude_path in EXCLUDE_PATHS:
if path.match(exclude_path):
return True
return False
def pre_flight_check(root: Path) -> bool:
def pre_flight_check(root: pathlib) -> bool:
def check_aspell(root):
return True
def check_clang_format(root: Path) -> bool:
def check_clang_foramt(root: pathlib) -> bool:
if not locate_command(CLANG_FORMAT_CMD):
return False
@ -74,10 +77,10 @@ def pre_flight_check(root: Path) -> bool:
def check_git_clang_format() -> bool:
return locate_command(GIT_CLANG_FORMAT_CMD)
return check_aspell(root) and check_clang_format(root) and check_git_clang_format()
return check_aspell(root) and check_clang_foramt(root) and check_git_clang_format()
def run_clang_format(file_path: Path, root: Path) -> bool:
def run_clang_format(file_path: pathlib, root: pathlib) -> bool:
try:
subprocess.check_call(
shlex.split(
@ -91,31 +94,22 @@ def run_clang_format(file_path: Path, root: Path) -> bool:
return False
def run_clang_format_diff(root: Path, commits: str) -> bool:
def run_clang_format_diff(root: pathlib, commits: str) -> bool:
"""
Use `clang-format-14` or `git-clang-format-14` to check code format of
Use `clang-format-12` or `git-clang-format-12` to check code format of
the PR, with a commit range specified. It is required to format the
code before committing the PR, or it might fail to pass the CI check:
1. Install clang-format-14.0.0
You can download the package from
https://github.com/llvm/llvm-project/releases
and install it.
For Debian/Ubuntu, we can probably use
`sudo apt-get install clang-format-14`.
Homebrew has it as a part of llvm@14.
```shell
brew install llvm@14
/usr/local/opt/llvm@14/bin/clang-format
```
1. Install clang-format-12.0.0
Normally we can install it by `sudo apt-get install clang-format-12`,
or download the `clang+llvm-12.0.0-xxx-tar.xz` package from
https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0
and install it
2. Format the C/C++ source file
``` shell
cd path/to/wamr/root
clang-format-14 --style file -i path/to/file
clang-format-12 --style file -i path/to/file
```
The code wrapped by `/* clang-format off */` and `/* clang-format on */`
@ -154,7 +148,7 @@ def run_clang_format_diff(root: Path, commits: str) -> bool:
found = False
for summary in [x for x in diff_content if x.startswith("diff --git")]:
# b/path/to/file -> path/to/file
with_invalid_format = re.split(r"\s+", summary)[-1][2:]
with_invalid_format = re.split("\s+", summary)[-1][2:]
if not is_excluded(with_invalid_format):
print(f"--- {with_invalid_format} failed on code style checking.")
found = True
@ -164,11 +158,11 @@ def run_clang_format_diff(root: Path, commits: str) -> bool:
return False
def run_aspell(file_path: Path, root: Path) -> bool:
def run_aspell(file_path: pathlib, root: pathlib) -> bool:
return True
def check_dir_name(path: Path, root: Path) -> bool:
def check_dir_name(path: pathlib, root: pathlib) -> bool:
m = re.search(INVALID_DIR_NAME_SEGMENT, str(path.relative_to(root).parent))
if m:
print(f"--- found a character '_' in {m.groups()} in {path}")
@ -176,23 +170,7 @@ def check_dir_name(path: Path, root: Path) -> bool:
return not m
def check_file_name(path: Path) -> bool:
"""
file names should not contain any character '-'
but some names are well known and use '-' as the separator, e.g.:
- docker-compose
- package-lock
- vite-env.d
"""
if path.stem in [
"docker-compose",
"package-lock",
"vite-env.d",
"osv-scanner",
]:
return True
def check_file_name(path: pathlib) -> bool:
m = re.search(INVALID_FILE_NAME_SEGMENT, path.stem)
if m:
print(f"--- found a character '-' in {m.groups()} in {path}")
@ -200,7 +178,7 @@ def check_file_name(path: Path) -> bool:
return not m
def parse_commits_range(root: Path, commits: str) -> list:
def parse_commits_range(root: pathlib, commits: str) -> list:
GIT_LOG_CMD = f"git log --pretty='%H' {commits}"
try:
ret = subprocess.check_output(
@ -212,7 +190,7 @@ def parse_commits_range(root: Path, commits: str) -> list:
return []
def analysis_new_item_name(root: Path, commit: str) -> bool:
def analysis_new_item_name(root: pathlib, commit: str) -> bool:
"""
For any file name in the repo, it is required to use '_' to replace '-'.
@ -241,7 +219,7 @@ def analysis_new_item_name(root: Path, commit: str) -> bool:
continue
new_item = match.group(1)
new_item = Path(new_item).resolve()
new_item = pathlib.Path(new_item).resolve()
if new_item.is_file():
if not check_file_name(new_item):
@ -260,7 +238,7 @@ def analysis_new_item_name(root: Path, commit: str) -> bool:
return False
def process_entire_pr(root: Path, commits: str) -> bool:
def process_entire_pr(root: pathlib, commits: str) -> bool:
if not commits:
print("Please provide a commits range")
return False
@ -293,7 +271,7 @@ def main() -> int:
)
options = parser.parse_args()
wamr_root = Path(__file__).parent.joinpath("..").resolve()
wamr_root = pathlib.Path(__file__).parent.joinpath("..").resolve()
if not pre_flight_check(wamr_root):
return False
@ -304,23 +282,23 @@ def main() -> int:
# run with python3 -m unitest ci/coding_guidelines_check.py
class TestCheck(unittest.TestCase):
def test_check_dir_name_failed(self):
root = Path("/root/Workspace/")
root = pathlib.Path("/root/Workspace/")
new_file_path = root.joinpath("core/shared/platform/esp_idf/espid_memmap.c")
self.assertFalse(check_dir_name(new_file_path, root))
def test_check_dir_name_pass(self):
root = Path("/root/Workspace/")
root = pathlib.Path("/root/Workspace/")
new_file_path = root.joinpath("core/shared/platform/esp-idf/espid_memmap.c")
self.assertTrue(check_dir_name(new_file_path, root))
def test_check_file_name_failed(self):
new_file_path = Path(
new_file_path = pathlib.Path(
"/root/Workspace/core/shared/platform/esp-idf/espid-memmap.c"
)
self.assertFalse(check_file_name(new_file_path))
def test_check_file_name_pass(self):
new_file_path = Path(
new_file_path = pathlib.Path(
"/root/Workspace/core/shared/platform/esp-idf/espid_memmap.c"
)
self.assertTrue(check_file_name(new_file_path))

View File

@ -1,32 +0,0 @@
#!/bin/bash
# Copyright (C) 2023 Amazon.com Inc. or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# This is a sample of pre-commit hook that can be used to make your code fit the WAMR CI code style requirements.
# You need to have clang-format-12 installed to use this hook.
# To add this pre-commit hook, copy it to <path_to_wamr>/.git/hooks/pre-commit
# (you don't need any extensions here)
# Function to check if a file has a C or C++ extension
is_c_or_cpp_file() {
file="$1"
if [[ "$filename" =~ \.(h|c|cpp)$ ]]; then
return 0
else
return 1
fi
}
# Loop through staged files and apply command "abc" to C and C++ files
for staged_file in $(git diff --cached --name-only); do
if is_c_or_cpp_file "$staged_file"; then
clang-format-12 -Werror --style file --dry-run "$staged_file" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Issues are found in $staged_file. Applying the fix"
clang-format-12 --style file -i "$staged_file"
fi
git add "$staged_file" # Add the modified file back to staging
fi
done

View File

@ -1,15 +0,0 @@
#!/bin/bash
# Copyright (C) 2023 Amazon.com Inc. or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# This script executes some commands to make your onboarding with WAMR easier.
# For example, setting pre-commit hook that will make your code complaint with the
# code style requirements checked in WAMR CI
echo "Copy the pre-commit hook to your hooks folder"
cp pre_commit_hook_sample ../.git/hooks/pre-commit
# Feel free to propose your commands to this script to make developing WAMR easier
echo "Setup is done"

View File

@ -1,128 +0,0 @@
#!/usr/bin/env python3
#
# Copyright (C) 2023 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
import argparse
import time
from pathlib import Path
import subprocess, shlex
SCRIPT_DIR = Path(__file__).parent.resolve()
REPO_ROOT_DIR = SCRIPT_DIR.parent
SAMPLE_CODE_FILE = REPO_ROOT_DIR / 'product-mini/app-samples/hello-world/main.c'
WASM_OUT_FILE = SCRIPT_DIR / 'out.wasm'
parser = argparse.ArgumentParser(
description="Validate the customized lldb with sample code"
)
parser.add_argument(
"-l", "--lldb", dest='lldb', default='lldb', help="path to lldb executable"
)
parser.add_argument(
"-w", "--wamr", dest='wamr', default='iwasm', help="path to iwasm executable"
)
parser.add_argument(
"-p", "--port", dest='port', default='1234', help="debug server listen port"
)
parser.add_argument(
"-v", "--verbose", dest='verbose', action='store_true', default=False, help="display lldb stdout"
)
options = parser.parse_args()
lldb_command_epilogue = '-o q'
test_cases = {
'run_to_exit': '-o c',
'func_breakpoint': '-o "b main" -o c -o c',
'line_breakpoint': '-o "b main.c:12" -o c -o c',
'break_on_unknown_func': '-o "b not_a_func" -o c',
'watch_point': '-o "b main" -o c -o "watchpoint set variable buf" -o c -o "fr v buf" -o c',
}
# Step1: Build wasm module with debug information
build_cmd = f'/opt/wasi-sdk/bin/clang -g -O0 -o {WASM_OUT_FILE} {SAMPLE_CODE_FILE}'
try:
print(f'building wasm module ...', end='', flush=True)
subprocess.check_call(shlex.split(build_cmd))
print(f'\t OK')
except subprocess.CalledProcessError:
print("Failed to build wasm module with debug information")
exit(1)
def print_process_output(p):
try:
outs, errs = p.communicate(timeout=2)
print("stdout:")
print(outs)
print("stderr:")
print(errs)
except subprocess.TimeoutExpired:
print("Failed to get process output")
# Step2: Launch WAMR in debug mode and validate lldb commands
iteration = 0
for case, cmd in test_cases.items():
lldb_command_prologue = f'{options.lldb} -o "process connect -p wasm connect://127.0.0.1:{int(options.port) + iteration}"'
wamr_cmd = f'{options.wamr} -g=127.0.0.1:{int(options.port) + iteration} {WASM_OUT_FILE}'
iteration += 1
has_error = False
print(f'validating case [{case}] ...', end='', flush=True)
lldb_cmd = f'{lldb_command_prologue} {cmd} {lldb_command_epilogue}'
wamr_process = subprocess.Popen(shlex.split(
wamr_cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
time.sleep(0.1)
if (wamr_process.poll() != None):
print("\nWAMR doesn't wait for lldb connection")
print_process_output(wamr_process)
exit(1)
lldb_process = subprocess.Popen(shlex.split(
lldb_cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
if (options.verbose):
while (lldb_process.poll() is None):
print(lldb_process.stdout.read(), end='', flush=True)
try:
if (lldb_process.wait(5) != 0):
print(f"\nFailed to validate case [{case}]")
print_process_output(lldb_process)
has_error = True
if wamr_process.wait(2) != 0:
print("\nWAMR process doesn't exit normally")
print_process_output(wamr_process)
has_error = True
except subprocess.TimeoutExpired:
print(f"\nFailed to validate case [{case}]")
print("wamr output:")
print_process_output(wamr_process)
print("lldb output:")
print_process_output(lldb_process)
has_error = True
finally:
if (lldb_process.poll() == None):
print(f'\nterminating lldb process [{lldb_process.pid}]')
lldb_process.kill()
if (wamr_process.poll() == None):
print(f'terminating wamr process [{wamr_process.pid}]')
wamr_process.kill()
if (has_error):
exit(1)
print(f'\t OK')
# wait 100ms to ensure the socket is closed
time.sleep(0.1)
print('Validate lldb success')
exit(0)

View File

@ -0,0 +1,125 @@
Application framework
=======
## Directory structure
This folder "app-native-shared" is for the source files shared by both WASM APP and native runtime
- The c files in this directory are compiled into both the WASM APP and runtime.
- The header files for distributing to SDK are placed in the "bi-inc" folder.
This folder "template" contains a pre-defined directory structure for a framework component. The developers can copy the template folder to create new components to the application framework.
Every other subfolder is framework component. Each component contains two library parts: **app and native**.
- The "base" component provide timer API and inter-app communication support. It must be enabled if other components are selected.
- Under the "app" folder of a component, the subfolder "wa_inc" holds all header files that should be included by the WASM applications
## Application framework basic model
The app framework is built on top of two fundamental operations:
- [Native calls into WASM function](../../doc/embed_wamr.md)
- [WASM app calls into native API](../../doc/export_native_api.md)
Asynchronized programming model is supported for WASM applications
- Every WASM app has its own sandbox and thread
- Queue and messaging
<img src="../../doc/pics/app_framework.PNG" style="zoom:67%;" />
## Customized building of app framework
A component can be compilation configurable to the runtime. The wamr SDK tool "build_sdk.sh" supports menu config to select app components for building a customized runtime.
A number of CMAKE variables are defined to control build of framework and components. You can create a cmake file for defining these variables and include it in the CMakeList.txt for your software, or pass it in "-x" argument when run the [build_sdk.sh](../../wamr-sdk/build_sdk.sh) for building the runtime SDK.
```cmake
set (WAMR_BUILD_APP_FRAMEWORK 1)
set (WAMR_BUILD_APP_LIST WAMR_APP_BUILD_BASE)
```
Variables:
- **WAMR_BUILD_APP_FRAMEWORK**: enable the application framework
- **WAMR_BUILD_APP_LIST**: the selected components to be built into the final runtime
The configuration file can be generated through the wamr-sdk menu config:
```bash
cd wamr-sdk
./build_sdk -n [profile] -i
```
## Create new components
Generally you should follow following steps to create a new component:
- Copy the “template” for creating a new folder
- Implement the app part
- If your component exports native function to WASM, ensure your created a header file under app for declaring the function prototype.
- If you component provides header files for the WASM applications to include, ensure it is placed under subfolder "wa_inc".
- Implement the native part
- If your native function is exported to WASM, you need to create an inl file for the registration. It can be any file name, assuming the file name is "my_component.inl" here:
```c
//use right signature for your functions
EXPORT_WASM_API_WITH_SIG(wasm_my_component_api_1, "(i*~)i"),
EXPORT_WASM_API_WITH_SIG(wasm_my_component_api_2, "(i)i"),
```
- Ensure "wasm_lib.cmake" is provided as it will be included by the WAMR SDK building script
- Add a definition in "wasm_lib.cmake" for your component, e.g.
```cmake
add_definitions (-DAPP_FRAMEWORK_MY_COMPONENT)
```
- Modify the file [app_ext_lib_export.c](./app_ext_lib_export.c) to register native APIs exported for the new introduced component. Skip it if not exporting native functions.
```
#include "lib_export.h"
...
#ifdef APP_FRAMEWORK_MY_COMPONENT // this definition is created in wasm_lib.cmake
#include "my_component_native_api.h"
#endif
static NativeSymbol extended_native_symbol_defs[] = {
...
#ifdef APP_FRAMEWORK_MY_COMPONENT
#include "my_component.inl"
#endif
};
```
## Sensor component working flow
![](../../doc/pics/sensor_callflow.PNG)

View File

@ -0,0 +1,11 @@
Notes:
=======
This folder is for the source files shared by both WASM APP and native runtime
- The c files in this directory are compiled into both the WASM APP and runtime.
- The header files for distributing to SDK are placed in the "bi-inc" folder.

View File

@ -0,0 +1,870 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bi-inc/attr_container.h"
typedef union jvalue {
bool z;
int8_t b;
uint16_t c;
int16_t s;
int32_t i;
int64_t j;
float f;
double d;
} jvalue;
static inline int16_t
get_int16(const char *buf)
{
int16_t ret;
bh_memcpy_s(&ret, sizeof(int16_t), buf, sizeof(int16_t));
return ret;
}
static inline uint16_t
get_uint16(const char *buf)
{
return get_int16(buf);
}
static inline int32_t
get_int32(const char *buf)
{
int32_t ret;
bh_memcpy_s(&ret, sizeof(int32_t), buf, sizeof(int32_t));
return ret;
}
static inline uint32_t
get_uint32(const char *buf)
{
return get_int32(buf);
}
static inline int64_t
get_int64(const char *buf)
{
int64_t ret;
bh_memcpy_s(&ret, sizeof(int64_t), buf, sizeof(int64_t));
return ret;
}
static inline uint64_t
get_uint64(const char *buf)
{
return get_int64(buf);
}
static inline void
set_int16(char *buf, int16_t v)
{
bh_memcpy_s(buf, sizeof(int16_t), &v, sizeof(int16_t));
}
static inline void
set_uint16(char *buf, uint16_t v)
{
bh_memcpy_s(buf, sizeof(uint16_t), &v, sizeof(uint16_t));
}
static inline void
set_int32(char *buf, int32_t v)
{
bh_memcpy_s(buf, sizeof(int32_t), &v, sizeof(int32_t));
}
static inline void
set_uint32(char *buf, uint32_t v)
{
bh_memcpy_s(buf, sizeof(uint32_t), &v, sizeof(uint32_t));
}
static inline void
set_int64(char *buf, int64_t v)
{
bh_memcpy_s(buf, sizeof(int64_t), &v, sizeof(int64_t));
}
static inline void
set_uint64(char *buf, uint64_t v)
{
bh_memcpy_s(buf, sizeof(uint64_t), &v, sizeof(uint64_t));
}
char *
attr_container_get_attr_begin(const attr_container_t *attr_cont,
uint32_t *p_total_length, uint16_t *p_attr_num)
{
char *p = (char *)attr_cont->buf;
uint16_t str_len, attr_num;
uint32_t total_length;
/* skip total length */
total_length = get_uint32(p);
p += sizeof(uint32_t);
if (!total_length)
return NULL;
/* tag length */
str_len = get_uint16(p);
p += sizeof(uint16_t);
if (!str_len)
return NULL;
/* tag content */
p += str_len;
if ((uint32_t)(p - attr_cont->buf) >= total_length)
return NULL;
/* attribute num */
attr_num = get_uint16(p);
p += sizeof(uint16_t);
if ((uint32_t)(p - attr_cont->buf) >= total_length)
return NULL;
if (p_total_length)
*p_total_length = total_length;
if (p_attr_num)
*p_attr_num = attr_num;
/* first attribute */
return p;
}
static char *
attr_container_get_attr_next(const char *curr_attr)
{
char *p = (char *)curr_attr;
uint8_t type;
/* key length and key */
p += sizeof(uint16_t) + get_uint16(p);
type = *p++;
/* Short type to Boolean type */
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN) {
p += 1 << (type & 3);
return p;
}
/* String type */
else if (type == ATTR_TYPE_STRING) {
p += sizeof(uint16_t) + get_uint16(p);
return p;
}
/* ByteArray type */
else if (type == ATTR_TYPE_BYTEARRAY) {
p += sizeof(uint32_t) + get_uint32(p);
return p;
}
return NULL;
}
static const char *
attr_container_find_attr(const attr_container_t *attr_cont, const char *key)
{
uint32_t total_length;
uint16_t str_len, attr_num, i;
const char *p = attr_cont->buf;
if (!key)
return NULL;
if (!(p = attr_container_get_attr_begin(attr_cont, &total_length,
&attr_num)))
return NULL;
for (i = 0; i < attr_num; i++) {
/* key length */
if (!(str_len = get_uint16(p)))
return NULL;
if (str_len == strlen(key) + 1
&& memcmp(p + sizeof(uint16_t), key, str_len) == 0) {
if ((uint32_t)(p + sizeof(uint16_t) + str_len - attr_cont->buf)
>= total_length)
return NULL;
return p;
}
if (!(p = attr_container_get_attr_next(p)))
return NULL;
}
return NULL;
}
char *
attr_container_get_attr_end(const attr_container_t *attr_cont)
{
uint32_t total_length;
uint16_t attr_num, i;
char *p;
if (!(p = attr_container_get_attr_begin(attr_cont, &total_length,
&attr_num)))
return NULL;
for (i = 0; i < attr_num; i++)
if (!(p = attr_container_get_attr_next(p)))
return NULL;
return p;
}
static char *
attr_container_get_msg_end(attr_container_t *attr_cont)
{
char *p = attr_cont->buf;
return p + get_uint32(p);
}
uint16_t
attr_container_get_attr_num(const attr_container_t *attr_cont)
{
uint16_t str_len;
/* skip total length */
const char *p = attr_cont->buf + sizeof(uint32_t);
str_len = get_uint16(p);
/* skip tag length and tag */
p += sizeof(uint16_t) + str_len;
/* attribute num */
return get_uint16(p);
}
static void
attr_container_inc_attr_num(attr_container_t *attr_cont)
{
uint16_t str_len, attr_num;
/* skip total length */
char *p = attr_cont->buf + sizeof(uint32_t);
str_len = get_uint16(p);
/* skip tag length and tag */
p += sizeof(uint16_t) + str_len;
/* attribute num */
attr_num = get_uint16(p) + 1;
set_uint16(p, attr_num);
}
attr_container_t *
attr_container_create(const char *tag)
{
attr_container_t *attr_cont;
int length, tag_length;
char *p;
tag_length = tag ? strlen(tag) + 1 : 1;
length = offsetof(attr_container_t, buf) +
/* total length + tag length + tag + reserved 100 bytes */
sizeof(uint32_t) + sizeof(uint16_t) + tag_length + 100;
if (!(attr_cont = attr_container_malloc(length))) {
attr_container_printf(
"Create attr_container failed: allocate memory failed.\r\n");
return NULL;
}
memset(attr_cont, 0, length);
p = attr_cont->buf;
/* total length */
set_uint32(p, length - offsetof(attr_container_t, buf));
p += 4;
/* tag length, tag */
set_uint16(p, tag_length);
p += 2;
if (tag)
bh_memcpy_s(p, tag_length, tag, tag_length);
return attr_cont;
}
void
attr_container_destroy(const attr_container_t *attr_cont)
{
if (attr_cont)
attr_container_free((char *)attr_cont);
}
static bool
check_set_attr(attr_container_t **p_attr_cont, const char *key)
{
uint32_t flags;
if (!p_attr_cont || !*p_attr_cont || !key || strlen(key) == 0) {
attr_container_printf(
"Set attribute failed: invalid input arguments.\r\n");
return false;
}
flags = get_uint32((char *)*p_attr_cont);
if (flags & ATTR_CONT_READONLY_SHIFT) {
attr_container_printf(
"Set attribute failed: attribute container is readonly.\r\n");
return false;
}
return true;
}
bool
attr_container_set_attr(attr_container_t **p_attr_cont, const char *key,
int type, const void *value, int value_length)
{
attr_container_t *attr_cont, *attr_cont1;
uint16_t str_len;
uint32_t total_length, attr_len;
char *p, *p1, *attr_end, *msg_end, *attr_buf;
if (!check_set_attr(p_attr_cont, key)) {
return false;
}
attr_cont = *p_attr_cont;
p = attr_cont->buf;
total_length = get_uint32(p);
if (!(attr_end = attr_container_get_attr_end(attr_cont))) {
attr_container_printf("Set attr failed: get attr end failed.\r\n");
return false;
}
msg_end = attr_container_get_msg_end(attr_cont);
/* key len + key + '\0' + type */
attr_len = sizeof(uint16_t) + strlen(key) + 1 + 1;
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN)
attr_len += 1 << (type & 3);
else if (type == ATTR_TYPE_STRING)
attr_len += sizeof(uint16_t) + value_length;
else if (type == ATTR_TYPE_BYTEARRAY)
attr_len += sizeof(uint32_t) + value_length;
if (!(p = attr_buf = attr_container_malloc(attr_len))) {
attr_container_printf("Set attr failed: allocate memory failed.\r\n");
return false;
}
/* Set the attr buf */
str_len = (uint16_t)(strlen(key) + 1);
set_uint16(p, str_len);
p += sizeof(uint16_t);
bh_memcpy_s(p, str_len, key, str_len);
p += str_len;
*p++ = type;
if (type >= ATTR_TYPE_SHORT && type <= ATTR_TYPE_BOOLEAN)
bh_memcpy_s(p, 1 << (type & 3), value, 1 << (type & 3));
else if (type == ATTR_TYPE_STRING) {
set_uint16(p, value_length);
p += sizeof(uint16_t);
bh_memcpy_s(p, value_length, value, value_length);
}
else if (type == ATTR_TYPE_BYTEARRAY) {
set_uint32(p, value_length);
p += sizeof(uint32_t);
bh_memcpy_s(p, value_length, value, value_length);
}
if ((p = (char *)attr_container_find_attr(attr_cont, key))) {
/* key found */
p1 = attr_container_get_attr_next(p);
if (p1 - p == attr_len) {
bh_memcpy_s(p, attr_len, attr_buf, attr_len);
attr_container_free(attr_buf);
return true;
}
if ((uint32_t)(p1 - p + msg_end - attr_end) >= attr_len) {
memmove(p, p1, attr_end - p1);
bh_memcpy_s(p + (attr_end - p1), attr_len, attr_buf, attr_len);
attr_container_free(attr_buf);
return true;
}
total_length += attr_len + 100;
if (!(attr_cont1 = attr_container_malloc(offsetof(attr_container_t, buf)
+ total_length))) {
attr_container_printf(
"Set attr failed: allocate memory failed.\r\n");
attr_container_free(attr_buf);
return false;
}
bh_memcpy_s(attr_cont1, p - (char *)attr_cont, attr_cont,
p - (char *)attr_cont);
bh_memcpy_s((char *)attr_cont1 + (unsigned)(p - (char *)attr_cont),
attr_end - p1, p1, attr_end - p1);
bh_memcpy_s((char *)attr_cont1 + (unsigned)(p - (char *)attr_cont)
+ (unsigned)(attr_end - p1),
attr_len, attr_buf, attr_len);
p = attr_cont1->buf;
set_uint32(p, total_length);
*p_attr_cont = attr_cont1;
/* Free original buffer */
attr_container_free(attr_cont);
attr_container_free(attr_buf);
return true;
}
else {
/* key not found */
if ((uint32_t)(msg_end - attr_end) >= attr_len) {
bh_memcpy_s(attr_end, msg_end - attr_end, attr_buf, attr_len);
attr_container_inc_attr_num(attr_cont);
attr_container_free(attr_buf);
return true;
}
total_length += attr_len + 100;
if (!(attr_cont1 = attr_container_malloc(offsetof(attr_container_t, buf)
+ total_length))) {
attr_container_printf(
"Set attr failed: allocate memory failed.\r\n");
attr_container_free(attr_buf);
return false;
}
bh_memcpy_s(attr_cont1, attr_end - (char *)attr_cont, attr_cont,
attr_end - (char *)attr_cont);
bh_memcpy_s((char *)attr_cont1
+ (unsigned)(attr_end - (char *)attr_cont),
attr_len, attr_buf, attr_len);
attr_container_inc_attr_num(attr_cont1);
p = attr_cont1->buf;
set_uint32(p, total_length);
*p_attr_cont = attr_cont1;
/* Free original buffer */
attr_container_free(attr_cont);
attr_container_free(attr_buf);
return true;
}
return false;
}
bool
attr_container_set_short(attr_container_t **p_attr_cont, const char *key,
short value)
{
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_SHORT, &value,
2);
}
bool
attr_container_set_int(attr_container_t **p_attr_cont, const char *key,
int value)
{
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_INT, &value, 4);
}
bool
attr_container_set_int64(attr_container_t **p_attr_cont, const char *key,
int64_t value)
{
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_INT64, &value,
8);
}
bool
attr_container_set_byte(attr_container_t **p_attr_cont, const char *key,
int8_t value)
{
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_BYTE, &value, 1);
}
bool
attr_container_set_uint16(attr_container_t **p_attr_cont, const char *key,
uint16_t value)
{
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_UINT16, &value,
2);
}
bool
attr_container_set_float(attr_container_t **p_attr_cont, const char *key,
float value)
{
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_FLOAT, &value,
4);
}
bool
attr_container_set_double(attr_container_t **p_attr_cont, const char *key,
double value)
{
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_DOUBLE, &value,
8);
}
bool
attr_container_set_bool(attr_container_t **p_attr_cont, const char *key,
bool value)
{
int8_t value1 = value ? 1 : 0;
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_BOOLEAN, &value1,
1);
}
bool
attr_container_set_string(attr_container_t **p_attr_cont, const char *key,
const char *value)
{
if (!value) {
attr_container_printf("Set attr failed: invald input arguments.\r\n");
return false;
}
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_STRING, value,
strlen(value) + 1);
}
bool
attr_container_set_bytearray(attr_container_t **p_attr_cont, const char *key,
const int8_t *value, unsigned length)
{
if (!value) {
attr_container_printf("Set attr failed: invald input arguments.\r\n");
return false;
}
return attr_container_set_attr(p_attr_cont, key, ATTR_TYPE_BYTEARRAY, value,
length);
}
static const char *
attr_container_get_attr(const attr_container_t *attr_cont, const char *key)
{
const char *attr_addr;
if (!attr_cont || !key) {
attr_container_printf(
"Get attribute failed: invalid input arguments.\r\n");
return NULL;
}
if (!(attr_addr = attr_container_find_attr(attr_cont, key))) {
attr_container_printf("Get attribute failed: lookup key failed.\r\n");
return false;
}
/* key len + key + '\0' */
return attr_addr + 2 + strlen(key) + 1;
}
#define TEMPLATE_ATTR_BUF_TO_VALUE(attr, key, var_name) \
do { \
jvalue val; \
const char *addr = attr_container_get_attr(attr, key); \
uint8_t type; \
if (!addr) \
return 0; \
val.j = 0; \
type = *(uint8_t *)addr++; \
switch (type) { \
case ATTR_TYPE_SHORT: \
case ATTR_TYPE_INT: \
case ATTR_TYPE_INT64: \
case ATTR_TYPE_BYTE: \
case ATTR_TYPE_UINT16: \
case ATTR_TYPE_FLOAT: \
case ATTR_TYPE_DOUBLE: \
case ATTR_TYPE_BOOLEAN: \
bh_memcpy_s(&val, sizeof(val.var_name), addr, \
1 << (type & 3)); \
break; \
case ATTR_TYPE_STRING: \
{ \
unsigned len = get_uint16(addr); \
addr += 2; \
if (len > sizeof(val.var_name)) \
len = sizeof(val.var_name); \
bh_memcpy_s(&val.var_name, sizeof(val.var_name), addr, len); \
break; \
} \
case ATTR_TYPE_BYTEARRAY: \
{ \
unsigned len = get_uint32(addr); \
addr += 4; \
if (len > sizeof(val.var_name)) \
len = sizeof(val.var_name); \
bh_memcpy_s(&val.var_name, sizeof(val.var_name), addr, len); \
break; \
} \
default: \
bh_assert(0); \
break; \
} \
return val.var_name; \
} while (0)
short
attr_container_get_as_short(const attr_container_t *attr_cont, const char *key)
{
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, s);
}
int
attr_container_get_as_int(const attr_container_t *attr_cont, const char *key)
{
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, i);
}
int64_t
attr_container_get_as_int64(const attr_container_t *attr_cont, const char *key)
{
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, j);
}
int8_t
attr_container_get_as_byte(const attr_container_t *attr_cont, const char *key)
{
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, b);
}
uint16_t
attr_container_get_as_uint16(const attr_container_t *attr_cont, const char *key)
{
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, s);
}
float
attr_container_get_as_float(const attr_container_t *attr_cont, const char *key)
{
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, f);
}
double
attr_container_get_as_double(const attr_container_t *attr_cont, const char *key)
{
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, d);
}
bool
attr_container_get_as_bool(const attr_container_t *attr_cont, const char *key)
{
TEMPLATE_ATTR_BUF_TO_VALUE(attr_cont, key, z);
}
const int8_t *
attr_container_get_as_bytearray(const attr_container_t *attr_cont,
const char *key, unsigned *array_length)
{
const char *addr = attr_container_get_attr(attr_cont, key);
uint8_t type;
uint32_t length;
if (!addr)
return NULL;
if (!array_length) {
attr_container_printf("Get attribute failed: invalid input arguments.");
return NULL;
}
type = *(uint8_t *)addr++;
switch (type) {
case ATTR_TYPE_SHORT:
case ATTR_TYPE_INT:
case ATTR_TYPE_INT64:
case ATTR_TYPE_BYTE:
case ATTR_TYPE_UINT16:
case ATTR_TYPE_FLOAT:
case ATTR_TYPE_DOUBLE:
case ATTR_TYPE_BOOLEAN:
length = 1 << (type & 3);
break;
case ATTR_TYPE_STRING:
length = get_uint16(addr);
addr += 2;
break;
case ATTR_TYPE_BYTEARRAY:
length = get_uint32(addr);
addr += 4;
break;
default:
return NULL;
}
*array_length = length;
return (const int8_t *)addr;
}
char *
attr_container_get_as_string(const attr_container_t *attr_cont, const char *key)
{
unsigned array_length;
return (char *)attr_container_get_as_bytearray(attr_cont, key,
&array_length);
}
const char *
attr_container_get_tag(const attr_container_t *attr_cont)
{
return attr_cont ? attr_cont->buf + sizeof(uint32_t) + sizeof(uint16_t)
: NULL;
}
bool
attr_container_contain_key(const attr_container_t *attr_cont, const char *key)
{
if (!attr_cont || !key || !strlen(key)) {
attr_container_printf(
"Check contain key failed: invalid input arguments.\r\n");
return false;
}
return attr_container_find_attr(attr_cont, key) ? true : false;
}
unsigned int
attr_container_get_serialize_length(const attr_container_t *attr_cont)
{
const char *p;
if (!attr_cont) {
attr_container_printf("Get container serialize length failed: invalid "
"input arguments.\r\n");
return 0;
}
p = attr_cont->buf;
return sizeof(uint16_t) + get_uint32(p);
}
bool
attr_container_serialize(char *buf, const attr_container_t *attr_cont)
{
const char *p;
uint16_t flags;
uint32_t length;
if (!buf || !attr_cont) {
attr_container_printf(
"Container serialize failed: invalid input arguments.\r\n");
return false;
}
p = attr_cont->buf;
length = sizeof(uint16_t) + get_uint32(p);
bh_memcpy_s(buf, length, attr_cont, length);
/* Set readonly */
flags = get_uint16((const char *)attr_cont);
set_uint16(buf, flags | (1 << ATTR_CONT_READONLY_SHIFT));
return true;
}
bool
attr_container_is_constant(const attr_container_t *attr_cont)
{
uint16_t flags;
if (!attr_cont) {
attr_container_printf(
"Container check const: invalid input arguments.\r\n");
return false;
}
flags = get_uint16((const char *)attr_cont);
return (flags & (1 << ATTR_CONT_READONLY_SHIFT)) ? true : false;
}
void
attr_container_dump(const attr_container_t *attr_cont)
{
uint32_t total_length;
uint16_t attr_num, i, type;
const char *p, *tag, *key;
jvalue value;
if (!attr_cont)
return;
tag = attr_container_get_tag(attr_cont);
if (!tag)
return;
attr_container_printf("Attribute container dump:\n");
attr_container_printf("Tag: %s\n", tag);
p = attr_container_get_attr_begin(attr_cont, &total_length, &attr_num);
if (!p)
return;
attr_container_printf("Attribute list:\n");
for (i = 0; i < attr_num; i++) {
key = p + 2;
/* Skip key len and key */
p += 2 + get_uint16(p);
type = *p++;
attr_container_printf(" key: %s", key);
switch (type) {
case ATTR_TYPE_SHORT:
bh_memcpy_s(&value.s, sizeof(int16_t), p, sizeof(int16_t));
attr_container_printf(", type: short, value: 0x%x\n",
value.s & 0xFFFF);
p += 2;
break;
case ATTR_TYPE_INT:
bh_memcpy_s(&value.i, sizeof(int32_t), p, sizeof(int32_t));
attr_container_printf(", type: int, value: 0x%x\n", value.i);
p += 4;
break;
case ATTR_TYPE_INT64:
bh_memcpy_s(&value.j, sizeof(uint64_t), p, sizeof(uint64_t));
attr_container_printf(", type: int64, value: 0x%llx\n",
(long long unsigned int)(value.j));
p += 8;
break;
case ATTR_TYPE_BYTE:
bh_memcpy_s(&value.b, 1, p, 1);
attr_container_printf(", type: byte, value: 0x%x\n",
value.b & 0xFF);
p++;
break;
case ATTR_TYPE_UINT16:
bh_memcpy_s(&value.c, sizeof(uint16_t), p, sizeof(uint16_t));
attr_container_printf(", type: uint16, value: 0x%x\n", value.c);
p += 2;
break;
case ATTR_TYPE_FLOAT:
bh_memcpy_s(&value.f, sizeof(float), p, sizeof(float));
attr_container_printf(", type: float, value: %f\n", value.f);
p += 4;
break;
case ATTR_TYPE_DOUBLE:
bh_memcpy_s(&value.d, sizeof(double), p, sizeof(double));
attr_container_printf(", type: double, value: %f\n", value.d);
p += 8;
break;
case ATTR_TYPE_BOOLEAN:
bh_memcpy_s(&value.z, 1, p, 1);
attr_container_printf(", type: bool, value: 0x%x\n", value.z);
p++;
break;
case ATTR_TYPE_STRING:
attr_container_printf(", type: string, value: %s\n",
p + sizeof(uint16_t));
p += sizeof(uint16_t) + get_uint16(p);
break;
case ATTR_TYPE_BYTEARRAY:
attr_container_printf(", type: byte array, length: %d\n",
get_uint32(p));
p += sizeof(uint32_t) + get_uint32(p);
break;
default:
bh_assert(0);
break;
}
}
attr_container_printf("\n");
}

View File

@ -0,0 +1,424 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _ATTR_CONTAINER_H_
#define _ATTR_CONTAINER_H_
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdbool.h>
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Attribute type */
enum {
ATTR_TYPE_BEGIN = 1,
ATTR_TYPE_SHORT = ATTR_TYPE_BEGIN,
ATTR_TYPE_INT,
ATTR_TYPE_INT64,
ATTR_TYPE_BYTE,
ATTR_TYPE_UINT16,
ATTR_TYPE_FLOAT,
ATTR_TYPE_DOUBLE,
ATTR_TYPE_BOOLEAN,
ATTR_TYPE_STRING,
ATTR_TYPE_BYTEARRAY,
ATTR_TYPE_END = ATTR_TYPE_BYTEARRAY
};
#define ATTR_CONT_READONLY_SHIFT 2
typedef struct attr_container {
/* container flag:
* bit0, bit1 denote the implemenation algorithm, 00: buffer, 01: link list
* bit2 denotes the readonly flag: 1 is readonly and attr cannot be set
*/
char flags[2];
/**
* Buffer format
* for buffer implementation:
* buf length (4 bytes)
* tag length (2 bytes)
* tag
* attr num (2bytes)
* attr[0..n-1]:
* attr key length (2 bytes)
* attr type (1byte)
* attr value (length depends on attr type)
*/
char buf[1];
} attr_container_t;
/**
* Create attribute container
*
* @param tag tag of current attribute container
*
* @return the created attribute container, NULL if failed
*/
attr_container_t *
attr_container_create(const char *tag);
/**
* Destroy attribute container
*
* @param attr_cont the attribute container to destroy
*/
void
attr_container_destroy(const attr_container_t *attr_cont);
/**
* Set short attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_short(attr_container_t **p_attr_cont, const char *key,
short value);
/**
* Set int attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_int(attr_container_t **p_attr_cont, const char *key,
int value);
/**
* Set int64 attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_int64(attr_container_t **p_attr_cont, const char *key,
int64_t value);
/**
* Set byte attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_byte(attr_container_t **p_attr_cont, const char *key,
int8_t value);
/**
* Set uint16 attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_uint16(attr_container_t **p_attr_cont, const char *key,
uint16_t value);
/**
* Set float attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_float(attr_container_t **p_attr_cont, const char *key,
float value);
/**
* Set double attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_double(attr_container_t **p_attr_cont, const char *key,
double value);
/**
* Set bool attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_bool(attr_container_t **p_attr_cont, const char *key,
bool value);
/**
* Set string attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the attribute value
*
* @return true if success, false otherwise
*/
bool
attr_container_set_string(attr_container_t **p_attr_cont, const char *key,
const char *value);
/**
* Set bytearray attribute in attribute container
*
* @param p_attr_cont pointer to attribute container to set attribute, and
* return the new attribute container if it is re-created
* @param key the attribute key
* @param value the bytearray buffer
* @param length the bytearray length
*
* @return true if success, false otherwise
*/
bool
attr_container_set_bytearray(attr_container_t **p_attr_cont, const char *key,
const int8_t *value, unsigned length);
/**
* Get tag of current attribute container
*
* @param attr_cont the attribute container
*
* @return tag of current attribute container
*/
const char *
attr_container_get_tag(const attr_container_t *attr_cont);
/**
* Get attribute number of current attribute container
*
* @param attr_cont the attribute container
*
* @return attribute number of current attribute container
*/
uint16_t
attr_container_get_attr_num(const attr_container_t *attr_cont);
/**
* Whether the attribute container contains an attribute key.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return true if key is contained in message, false otherwise
*/
bool
attr_container_contain_key(const attr_container_t *attr_cont, const char *key);
/**
* Get attribute from attribute container and return it as short value,
* return 0 if attribute isn't found in message.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the short value of the attribute, 0 if key isn't found
*/
short
attr_container_get_as_short(const attr_container_t *attr_cont, const char *key);
/**
* Get attribute from attribute container and return it as int value,
* return 0 if attribute isn't found in message.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the int value of the attribute, 0 if key isn't found
*/
int
attr_container_get_as_int(const attr_container_t *attr_cont, const char *key);
/**
* Get attribute from attribute container and return it as int64 value,
* return 0 if attribute isn't found in attribute container.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the long value of the attribute, 0 if key isn't found
*/
int64_t
attr_container_get_as_int64(const attr_container_t *attr_cont, const char *key);
/**
* Get attribute from attribute container and return it as byte value,
* return 0 if attribute isn't found in attribute container.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the byte value of the attribute, 0 if key isn't found
*/
int8_t
attr_container_get_as_byte(const attr_container_t *attr_cont, const char *key);
/**
* Get attribute from attribute container and return it as uint16 value,
* return 0 if attribute isn't found in attribute container.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the char value of the attribute, 0 if key isn't found
*/
uint16_t
attr_container_get_as_uint16(const attr_container_t *attr_cont,
const char *key);
/**
* Get attribute from attribute container and return it as float value,
* return 0 if attribute isn't found in attribute container.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the float value of the attribute, 0 if key isn't found
*/
float
attr_container_get_as_float(const attr_container_t *attr_cont, const char *key);
/**
* Get attribute from attribute container and return it as double value,
* return 0 if attribute isn't found in attribute container.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the double value of the attribute, 0 if key isn't found
*/
double
attr_container_get_as_double(const attr_container_t *attr_cont,
const char *key);
/**
* Get attribute from attribute container and return it as bool value,
* return false if attribute isn't found in attribute container.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the bool value of the attribute, 0 if key isn't found
*/
bool
attr_container_get_as_bool(const attr_container_t *attr_cont, const char *key);
/**
* Get attribute from attribute container and return it as string value,
* return NULL if attribute isn't found in attribute container.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the string value of the attribute, NULL if key isn't found
*/
char *
attr_container_get_as_string(const attr_container_t *attr_cont,
const char *key);
/**
* Get attribute from attribute container and return it as bytearray value,
* return 0 if attribute isn't found in attribute container.
*
* @param attr_cont the attribute container
* @param key the attribute key
*
* @return the bytearray value of the attribute, NULL if key isn't found
*/
const int8_t *
attr_container_get_as_bytearray(const attr_container_t *attr_cont,
const char *key, unsigned *array_length);
/**
* Get the buffer size of attribute container
*
* @param attr_cont the attribute container
*
* @return the buffer size of attribute container
*/
unsigned
attr_container_get_serialize_length(const attr_container_t *attr_cont);
/**
* Serialize attribute container to a buffer
*
* @param buf the buffer to receive the serialized data
* @param attr_cont the attribute container to be serialized
*
* @return true if success, false otherwise
*/
bool
attr_container_serialize(char *buf, const attr_container_t *attr_cont);
/**
* Whether the attribute container is const, or set attribute isn't supported
*
* @param attr_cont the attribute container
*
* @return true if const, false otherwise
*/
bool
attr_container_is_constant(const attr_container_t *attr_cont);
void
attr_container_dump(const attr_container_t *attr_cont);
#ifndef attr_container_malloc
#define attr_container_malloc WA_MALLOC
#endif
#ifndef attr_container_free
#define attr_container_free WA_FREE
#endif
#ifndef attr_container_printf
#define attr_container_printf printf
#endif
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif /* end of _ATTR_CONTAINER_H_ */

View File

@ -0,0 +1,155 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _SHARED_UTILS_H_
#define _SHARED_UTILS_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
#define FMT_ATTR_CONTAINER 99
#define FMT_APP_RAW_BINARY 98
/* the request structure */
typedef struct request {
// message id
uint32 mid;
// url of the request
char *url;
// action of the request, can be PUT/GET/POST/DELETE
int action;
// payload format, currently only support attr_container_t type
int fmt;
// payload of the request, currently only support attr_container_t type
void *payload;
// length in bytes of the payload
int payload_len;
// sender of the request
unsigned long sender;
} request_t;
/* the response structure */
typedef struct response {
// message id
uint32 mid;
// status of the response
int status;
// payload format
int fmt;
// payload of the response,
void *payload;
// length in bytes of the payload
int payload_len;
// receiver of the response
unsigned long reciever;
} response_t;
int
check_url_start(const char *url, int url_len, const char *leading_str);
bool
match_url(char *pattern, char *matched);
char *
find_key_value(char *buffer, int buffer_len, char *key, char *value,
int value_len, char delimiter);
request_t *
clone_request(request_t *request);
void
request_cleaner(request_t *request);
response_t *
clone_response(response_t *response);
void
response_cleaner(response_t *response);
/**
* @brief Set fields of response.
*
* @param response pointer of the response to be set
* @param status status of response
* @param fmt format of the response payload
* @param payload payload of the response
* @param payload_len length in bytes of the response payload
*
* @return pointer to the response
*
* @warning the response pointer MUST NOT be NULL
*/
response_t *
set_response(response_t *response, int status, int fmt, const char *payload,
int payload_len);
/**
* @brief Make a response for a request.
*
* @param request pointer of the request
* @param response pointer of the response to be made
*
* @return pointer to the response
*
* @warning the request and response pointers MUST NOT be NULL
*/
response_t *
make_response_for_request(request_t *request, response_t *response);
/**
* @brief Initialize a request.
*
* @param request pointer of the request to be initialized
* @param url url of the request
* @param action action of the request
* @param fmt format of the request payload
* @param payload payload of the request
* @param payload_len length in bytes of the request payload
*
* @return pointer to the request
*
* @warning the request pointer MUST NOT be NULL
*/
request_t *
init_request(request_t *request, char *url, int action, int fmt, void *payload,
int payload_len);
char *
pack_request(request_t *request, int *size);
request_t *
unpack_request(char *packet, int size, request_t *request);
char *
pack_response(response_t *response, int *size);
response_t *
unpack_response(char *packet, int size, response_t *response);
void
free_req_resp_packet(char *packet);
char *
wa_strdup(const char *str);
#ifdef __cplusplus
}
#endif
#endif /* end of _SHARED_UTILS_H_ */

View File

@ -0,0 +1,101 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_SHARED_UTILS_H
#define WAMR_GRAPHIC_LIBRARY_SHARED_UTILS_H
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
/* Object native function IDs */
enum {
OBJ_FUNC_ID_DEL,
OBJ_FUNC_ID_DEL_ASYNC,
OBJ_FUNC_ID_CLEAN,
OBJ_FUNC_ID_SET_EVT_CB,
OBJ_FUNC_ID_ALIGN,
/* Number of functions */
_OBJ_FUNC_ID_NUM,
};
/* Button native function IDs */
enum {
BTN_FUNC_ID_CREATE,
BTN_FUNC_ID_SET_TOGGLE,
BTN_FUNC_ID_SET_STATE,
BTN_FUNC_ID_TOGGLE,
BTN_FUNC_ID_SET_INK_IN_TIME,
BTN_FUNC_ID_SET_INK_WAIT_TIME,
BTN_FUNC_ID_SET_INK_OUT_TIME,
BTN_FUNC_ID_GET_STATE,
BTN_FUNC_ID_GET_TOGGLE,
BTN_FUNC_ID_GET_INK_IN_TIME,
BTN_FUNC_ID_GET_INK_WAIT_TIME,
BTN_FUNC_ID_GET_INK_OUT_TIME,
/* Number of functions */
_BTN_FUNC_ID_NUM,
};
/* Check box native function IDs */
enum {
CB_FUNC_ID_CREATE,
CB_FUNC_ID_SET_TEXT,
CB_FUNC_ID_SET_STATIC_TEXT,
CB_FUNC_ID_GET_TEXT,
CB_FUNC_ID_GET_TEXT_LENGTH,
/* Number of functions */
_CB_FUNC_ID_NUM,
};
/* List native function IDs */
enum {
LIST_FUNC_ID_CREATE,
LIST_FUNC_ID_ADD_BTN,
/* Number of functions */
_LIST_FUNC_ID_NUM,
};
/* Label native function IDs */
enum {
LABEL_FUNC_ID_CREATE,
LABEL_FUNC_ID_SET_TEXT,
LABEL_FUNC_ID_SET_ARRAY_TEXT,
LABEL_FUNC_ID_SET_STATIC_TEXT,
LABEL_FUNC_ID_SET_LONG_MODE,
LABEL_FUNC_ID_SET_ALIGN,
LABEL_FUNC_ID_SET_RECOLOR,
LABEL_FUNC_ID_SET_BODY_DRAW,
LABEL_FUNC_ID_SET_ANIM_SPEED,
LABEL_FUNC_ID_SET_TEXT_SEL_START,
LABEL_FUNC_ID_SET_TEXT_SEL_END,
LABEL_FUNC_ID_GET_TEXT,
LABEL_FUNC_ID_GET_TEXT_LENGTH,
LABEL_FUNC_ID_GET_LONG_MODE,
LABEL_FUNC_ID_GET_ALIGN,
LABEL_FUNC_ID_GET_RECOLOR,
LABEL_FUNC_ID_GET_BODY_DRAW,
LABEL_FUNC_ID_GET_ANIM_SPEED,
LABEL_FUNC_ID_GET_LETTER_POS,
LABEL_FUNC_ID_GET_TEXT_SEL_START,
LABEL_FUNC_ID_GET_TEXT_SEL_END,
LABEL_FUNC_ID_INS_TEXT,
LABEL_FUNC_ID_CUT_TEXT,
/* Number of functions */
_LABEL_FUNC_ID_NUM,
};
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_SHARED_UTILS_H */

View File

@ -0,0 +1,15 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set (NATIVE_INTERFACE_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${NATIVE_INTERFACE_DIR})
file (GLOB_RECURSE source_all ${NATIVE_INTERFACE_DIR}/*.c)
set (NATIVE_INTERFACE_SOURCE ${source_all})
set (WASM_APP_BI_INC_DIR "${NATIVE_INTERFACE_DIR}/bi-inc")
LIST (APPEND RUNTIME_LIB_HEADER_LIST "${NATIVE_INTERFACE_DIR}/native_interface.h")

View File

@ -0,0 +1,13 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _NATIVE_INTERFACE_H_
#define _NATIVE_INTERFACE_H_
/* Note: the bh_plaform.h is the only head file separately
implemented by both [app] and [native] worlds */
#include "bh_platform.h"
#endif /* end of _NATIVE_INTERFACE_H */

View File

@ -0,0 +1,493 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
#include "bi-inc/shared_utils.h"
/* Serialization of request and response message
*
* Choices:
* We considered a few options:
* 1. coap
* 2. flatbuffer
* 3. cbor
* 4. attr-containers of our own
* 5. customized serialization for request/response
*
* Now we choose the #5 mainly because we need to quickly get the URL for
* dispatching and sometimes we want to change the URL in the original packet.
* the request format: fixed part: version: (1 byte), code (1 byte), fmt(2
* byte), mid (4 bytes), sender_id(4 bytes), url_len(2 bytes),
* payload_len(4bytes) dynamic part: url (bytes in url_len), payload
*
* response format:
* fixed part: (1 byte), code (1 byte), fmt(2 byte), mid (4 bytes), sender_id(4
* bytes), payload_len(4bytes) dynamic part: payload
*/
#define REQUES_PACKET_VER 1
#define REQUEST_PACKET_FIX_PART_LEN 18
#define REQUEST_PACKET_URL_OFFSET REQUEST_PACKET_FIX_PART_LEN
#define REQUEST_PACKET_URL_LEN \
*((uint16 *)((char *)buffer + 12)) /* to ensure little endian */
#define REQUEST_PACKET_PAYLOAD_LEN \
*((uint32 *)((char *)buffer + 14)) /* to ensure little endian */
#define REQUEST_PACKET_URL(buffer) ((char *)buffer + REQUEST_PACKET_URL_OFFSET)
#define REQUEST_PACKET_PAYLOAD(buffer) \
((char *)buffer + REQUEST_PACKET_URL_OFFSET \
+ REQUEST_PACKET_URL_LEN(buffer))
#define RESPONSE_PACKET_FIX_PART_LEN 16
char *
pack_request(request_t *request, int *size)
{
int url_len = strlen(request->url) + 1;
int len = REQUEST_PACKET_FIX_PART_LEN + url_len + request->payload_len;
uint16 u16;
uint32 u32;
char *packet;
if ((packet = (char *)WA_MALLOC(len)) == NULL)
return NULL;
/* TODO: ensure little endian for words and dwords */
*packet = REQUES_PACKET_VER;
*((uint8 *)(packet + 1)) = request->action;
u16 = htons(request->fmt);
memcpy(packet + 2, &u16, 2);
u32 = htonl(request->mid);
memcpy(packet + 4, &u32, 4);
u32 = htonl(request->sender);
memcpy(packet + 8, &u32, 4);
u16 = htons(url_len);
memcpy(packet + 12, &u16, 2);
u32 = htonl(request->payload_len);
memcpy(packet + 14, &u32, 4);
strcpy(packet + REQUEST_PACKET_URL_OFFSET, request->url);
memcpy(packet + REQUEST_PACKET_URL_OFFSET + url_len, request->payload,
request->payload_len);
*size = len;
return packet;
}
void
free_req_resp_packet(char *packet)
{
WA_FREE(packet);
}
request_t *
unpack_request(char *packet, int size, request_t *request)
{
uint16 url_len, u16;
uint32 payload_len, u32;
if (*packet != REQUES_PACKET_VER) {
return NULL;
}
if (size < REQUEST_PACKET_FIX_PART_LEN) {
return NULL;
}
memcpy(&u16, packet + 12, 2);
url_len = ntohs(u16);
memcpy(&u32, packet + 14, 4);
payload_len = ntohl(u32);
if (size != (REQUEST_PACKET_FIX_PART_LEN + url_len + payload_len)) {
return NULL;
}
if (*(packet + REQUEST_PACKET_FIX_PART_LEN + url_len - 1) != 0) {
return NULL;
}
request->action = *((uint8 *)(packet + 1));
memcpy(&u16, packet + 2, 2);
request->fmt = ntohs(u16);
memcpy(&u32, packet + 4, 4);
request->mid = ntohl(u32);
memcpy(&u32, packet + 8, 4);
request->sender = ntohl(u32);
request->payload_len = payload_len;
request->url = REQUEST_PACKET_URL(packet);
if (payload_len > 0)
request->payload = packet + REQUEST_PACKET_URL_OFFSET + url_len;
else
request->payload = NULL;
return request;
}
char *
pack_response(response_t *response, int *size)
{
int len = RESPONSE_PACKET_FIX_PART_LEN + response->payload_len;
uint16 u16;
uint32 u32;
char *packet;
if ((packet = (char *)WA_MALLOC(len)) == NULL)
return NULL;
/* TODO: ensure little endian for words and dwords */
*packet = REQUES_PACKET_VER;
*((uint8 *)(packet + 1)) = response->status;
u16 = htons(response->fmt);
memcpy(packet + 2, &u16, 2);
u32 = htonl(response->mid);
memcpy(packet + 4, &u32, 4);
u32 = htonl(response->reciever);
memcpy(packet + 8, &u32, 4);
u32 = htonl(response->payload_len);
memcpy(packet + 12, &u32, 4);
memcpy(packet + RESPONSE_PACKET_FIX_PART_LEN, response->payload,
response->payload_len);
*size = len;
return packet;
}
response_t *
unpack_response(char *packet, int size, response_t *response)
{
uint16 u16;
uint32 payload_len, u32;
if (*packet != REQUES_PACKET_VER)
return NULL;
if (size < RESPONSE_PACKET_FIX_PART_LEN)
return NULL;
memcpy(&u32, packet + 12, 4);
payload_len = ntohl(u32);
if (size != (RESPONSE_PACKET_FIX_PART_LEN + payload_len))
return NULL;
response->status = *((uint8 *)(packet + 1));
memcpy(&u16, packet + 2, 2);
response->fmt = ntohs(u16);
memcpy(&u32, packet + 4, 4);
response->mid = ntohl(u32);
memcpy(&u32, packet + 8, 4);
response->reciever = ntohl(u32);
response->payload_len = payload_len;
if (payload_len > 0)
response->payload = packet + RESPONSE_PACKET_FIX_PART_LEN;
else
response->payload = NULL;
return response;
}
request_t *
clone_request(request_t *request)
{
/* deep clone */
request_t *req = (request_t *)WA_MALLOC(sizeof(request_t));
if (req == NULL)
return NULL;
memset(req, 0, sizeof(*req));
req->action = request->action;
req->fmt = request->fmt;
req->url = wa_strdup(request->url);
req->sender = request->sender;
req->mid = request->mid;
if (req->url == NULL)
goto fail;
req->payload_len = request->payload_len;
if (request->payload_len) {
req->payload = (char *)WA_MALLOC(request->payload_len);
if (!req->payload)
goto fail;
memcpy(req->payload, request->payload, request->payload_len);
}
else {
/* when payload_len is 0, the payload may be used for
carrying some handle or integer */
req->payload = request->payload;
}
return req;
fail:
request_cleaner(req);
return NULL;
}
void
request_cleaner(request_t *request)
{
if (request->url != NULL)
WA_FREE(request->url);
if (request->payload != NULL && request->payload_len > 0)
WA_FREE(request->payload);
WA_FREE(request);
}
void
response_cleaner(response_t *response)
{
if (response->payload != NULL && response->payload_len > 0)
WA_FREE(response->payload);
WA_FREE(response);
}
response_t *
clone_response(response_t *response)
{
response_t *clone = (response_t *)WA_MALLOC(sizeof(response_t));
if (clone == NULL)
return NULL;
memset(clone, 0, sizeof(*clone));
clone->fmt = response->fmt;
clone->mid = response->mid;
clone->status = response->status;
clone->reciever = response->reciever;
clone->payload_len = response->payload_len;
if (clone->payload_len) {
clone->payload = (char *)WA_MALLOC(response->payload_len);
if (!clone->payload)
goto fail;
memcpy(clone->payload, response->payload, response->payload_len);
}
else {
/* when payload_len is 0, the payload may be used for
carrying some handle or integer */
clone->payload = response->payload;
}
return clone;
fail:
response_cleaner(clone);
return NULL;
}
response_t *
set_response(response_t *response, int status, int fmt, const char *payload,
int payload_len)
{
response->payload = (void *)payload;
response->payload_len = payload_len;
response->status = status;
response->fmt = fmt;
return response;
}
response_t *
make_response_for_request(request_t *request, response_t *response)
{
response->mid = request->mid;
response->reciever = request->sender;
return response;
}
static unsigned int mid = 0;
request_t *
init_request(request_t *request, char *url, int action, int fmt, void *payload,
int payload_len)
{
request->url = url;
request->action = action;
request->fmt = fmt;
request->payload = payload;
request->payload_len = payload_len;
request->mid = ++mid;
return request;
}
/*
check if the "url" is starting with "leading_str"
return: 0 - not match; >0 - the offset of matched url, include any "/" at the
end notes:
1. it ensures the leading_str "/abc" can pass "/abc/cde" and "/abc/, but fail
"/ab" and "/abcd". leading_str "/abc/" can pass "/abc"
2. it omit the '/' at the first char
3. it ensure the leading_str "/abc" can pass "/abc?cde
*/
int
check_url_start(const char *url, int url_len, const char *leading_str)
{
int offset = 0;
if (*leading_str == '/')
leading_str++;
if (url_len > 0 && *url == '/') {
url_len--;
url++;
offset++;
}
int len = strlen(leading_str);
if (len == 0)
return 0;
/* ensure leading_str not end with "/" */
if (leading_str[len - 1] == '/') {
len--;
if (len == 0)
return 0;
}
/* equal length */
if (url_len == len) {
if (memcmp(url, leading_str, url_len) == 0) {
return (offset + len);
}
else {
return 0;
}
}
if (url_len < len)
return 0;
else if (memcmp(url, leading_str, len) != 0)
return 0;
else if (url[len] != '/' && url[len] != '?')
return 0;
else
return (offset + len + 1);
}
// * @pattern:
// * sample 1: /abcd, match /abcd only
// * sample 2: /abcd/ match match "/abcd" and "/abcd/*"
// * sample 3: /abcd*, match any url started with "/abcd"
// * sample 4: /abcd/*, exclude "/abcd"
bool
match_url(char *pattern, char *matched)
{
if (*pattern == '/')
pattern++;
if (*matched == '/')
matched++;
int matched_len = strlen(matched);
if (matched_len == 0)
return false;
if (matched[matched_len - 1] == '/') {
matched_len--;
if (matched_len == 0)
return false;
}
int len = strlen(pattern);
if (len == 0)
return false;
if (pattern[len - 1] == '/') {
len--;
if (strncmp(pattern, matched, len) != 0)
return false;
if (len == matched_len)
return true;
if (matched_len > len && matched[len] == '/')
return true;
return false;
}
else if (pattern[len - 1] == '*') {
if (pattern[len - 2] == '/') {
if (strncmp(pattern, matched, len - 1) == 0)
return true;
else
return false;
}
else {
return (strncmp(pattern, matched, len - 1) == 0);
}
}
else {
return (strcmp(pattern, matched) == 0);
}
}
/*
* get the value of the key from following format buffer:
* key1=value1;key2=value2;key3=value3
*/
char *
find_key_value(char *buffer, int buffer_len, char *key, char *value,
int value_len, char delimiter)
{
char *p = buffer;
int remaining = buffer_len;
int key_len = strlen(key);
while (*p != 0 && remaining > 0) {
while (*p == ' ' || *p == delimiter) {
p++;
remaining--;
}
if (remaining <= key_len)
return NULL;
/* find the key */
if (0 == strncmp(p, key, key_len) && p[key_len] == '=') {
p += (key_len + 1);
remaining -= (key_len + 1);
char *v = value;
memset(value, 0, value_len);
value_len--; /* ensure last char is 0 */
while (*p != delimiter && remaining > 0 && value_len > 0) {
*v++ = *p++;
remaining--;
value_len--;
}
return value;
}
/* goto next key */
while (*p != delimiter && remaining > 0) {
p++;
remaining--;
}
}
return NULL;
}

View File

@ -0,0 +1,38 @@
#include "lib_export.h"
#ifdef APP_FRAMEWORK_SENSOR
#include "sensor_native_api.h"
#endif
#ifdef APP_FRAMEWORK_CONNECTION
#include "connection_native_api.h"
#endif
#ifdef APP_FRAMEWORK_WGL
#include "gui_native_api.h"
#endif
/* More header file here */
static NativeSymbol extended_native_symbol_defs[] = {
#ifdef APP_FRAMEWORK_SENSOR
#include "runtime_sensor.inl"
#endif
#ifdef APP_FRAMEWORK_CONNECTION
#include "connection.inl"
#endif
#ifdef APP_FRAMEWORK_WGL
#include "wamr_gui.inl"
#endif
/* More inl file here */
};
int
get_ext_lib_export_apis(NativeSymbol **p_ext_lib_apis)
{
*p_ext_lib_apis = extended_native_symbol_defs;
return sizeof(extended_native_symbol_defs) / sizeof(NativeSymbol);
}

View File

@ -0,0 +1,93 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
add_definitions (-DWASM_ENABLE_APP_FRAMEWORK=1)
set (APP_FRAMEWORK_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
LIST (APPEND WASM_APP_LIB_SOURCE_ALL ${CMAKE_CURRENT_LIST_DIR}/app_ext_lib_export.c)
endif()
# app-native-shared and base are required
include (${APP_FRAMEWORK_ROOT_DIR}/app-native-shared/native_interface.cmake)
LIST (APPEND WASM_APP_SOURCE_ALL ${NATIVE_INTERFACE_SOURCE})
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
function (add_module_native arg)
message ("Add native module ${ARGV0}")
include (${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/wasm_lib.cmake)
file (GLOB header
${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/*.h
${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native/*.inl
)
LIST (APPEND WASM_APP_LIBS_DIR ${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/native)
set (WASM_APP_LIBS_DIR ${WASM_APP_LIBS_DIR} PARENT_SCOPE)
LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
set (RUNTIME_LIB_HEADER_LIST ${RUNTIME_LIB_HEADER_LIST} PARENT_SCOPE)
LIST (APPEND WASM_APP_LIB_SOURCE_ALL ${WASM_APP_LIB_CURRENT_SOURCE})
set (WASM_APP_LIB_SOURCE_ALL ${WASM_APP_LIB_SOURCE_ALL} PARENT_SCOPE)
endfunction ()
function (add_module_app arg)
message ("Add app module ${ARGV0}")
include (${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/app/wasm_app.cmake)
LIST (APPEND WASM_APP_WA_INC_DIR_LIST "${APP_FRAMEWORK_ROOT_DIR}/${ARGV0}/app/wa-inc")
set (WASM_APP_WA_INC_DIR_LIST ${WASM_APP_WA_INC_DIR_LIST} PARENT_SCOPE)
LIST (APPEND WASM_APP_NAME ${ARGV0})
set (WASM_APP_NAME ${WASM_APP_NAME} PARENT_SCOPE)
LIST (APPEND WASM_APP_SOURCE_ALL ${WASM_APP_CURRENT_SOURCE})
set (WASM_APP_SOURCE_ALL ${WASM_APP_SOURCE_ALL} PARENT_SCOPE)
endfunction ()
if ("${WAMR_BUILD_APP_LIST}" STREQUAL "WAMR_APP_BUILD_ALL")
# add all modules under this folder
SUBDIRLIST(SUBDIRS ${APP_FRAMEWORK_ROOT_DIR})
FOREACH(subdir ${SUBDIRS})
if ("${subdir}" STREQUAL "app-native-shared")
continue()
endif ()
if ("${subdir}" STREQUAL "template")
continue()
endif ()
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
add_module_native (${subdir})
else ()
add_module_app (${subdir})
endif ()
ENDFOREACH()
else ()
# add each module in the list
FOREACH (dir IN LISTS WAMR_BUILD_APP_LIST)
string(REPLACE "WAMR_APP_BUILD_" "" dir ${dir})
string(TOLOWER ${dir} dir)
if ( NOT DEFINED APP_FRAMEWORK_INCLUDE_TYPE )
add_module_native (${dir})
else ()
add_module_app (${dir})
endif ()
ENDFOREACH (dir)
endif()

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bh_platform.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
*
*
*/
static bool
is_little_endian()
{
long i = 0x01020304;
unsigned char *c = (unsigned char *)&i;
return (*c == 0x04) ? true : false;
}
static void
swap32(uint8 *pData)
{
uint8 value = *pData;
*pData = *(pData + 3);
*(pData + 3) = value;
value = *(pData + 1);
*(pData + 1) = *(pData + 2);
*(pData + 2) = value;
}
static void
swap16(uint8 *pData)
{
uint8 value = *pData;
*(pData) = *(pData + 1);
*(pData + 1) = value;
}
uint32
htonl(uint32 value)
{
uint32 ret;
if (is_little_endian()) {
ret = value;
swap32((uint8 *)&ret);
return ret;
}
return value;
}
uint32
ntohl(uint32 value)
{
return htonl(value);
}
uint16
htons(uint16 value)
{
uint16 ret;
if (is_little_endian()) {
ret = value;
swap16((uint8 *)&ret);
return ret;
}
return value;
}
uint16
ntohs(uint16 value)
{
return htons(value);
}
char *
wa_strdup(const char *s)
{
char *s1 = NULL;
if (s && (s1 = WA_MALLOC(strlen(s) + 1)))
memcpy(s1, s, strlen(s) + 1);
return s1;
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_
#define DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_
#include <stdbool.h>
typedef unsigned char uint8;
typedef char int8;
typedef unsigned short uint16;
typedef short int16;
typedef unsigned int uint32;
typedef int int32;
#ifndef NULL
#define NULL ((void *)0)
#endif
#ifndef __cplusplus
#define true 1
#define false 0
#define inline __inline
#endif
// all wasm-app<->native shared source files should use WA_MALLOC/WA_FREE.
// they will be mapped to different implementations in each side
#ifndef WA_MALLOC
#define WA_MALLOC malloc
#endif
#ifndef WA_FREE
#define WA_FREE free
#endif
uint32
htonl(uint32 value);
uint32
ntohl(uint32 value);
uint16
htons(uint16 value);
uint16
ntohs(uint16 value);
// We are not worried for the WASM world since the sandbox will catch it.
#define bh_memcpy_s(dst, dst_len, src, src_len) memcpy(dst, src, src_len)
#ifdef NDEBUG
#define bh_assert(v) (void)0
#else
#define bh_assert(v) \
do { \
if (!(v)) { \
int _count; \
printf("ASSERTION FAILED: %s, at %s, line %d", #v, __FILE__, \
__LINE__); \
_count = printf("\n"); \
printf("%d\n", _count / (_count - 1)); \
} \
} while (0)
#endif
#endif /* DEPS_IWASM_APP_LIBS_BASE_BH_PLATFORM_H_ */

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _REQ_RESP_API_H_
#define _REQ_RESP_API_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
bool
wasm_response_send(const char *buf, int size);
void
wasm_register_resource(const char *url);
void
wasm_post_request(const char *buf, int size);
void
wasm_sub_event(const char *url);
#ifdef __cplusplus
}
#endif
#endif /* end of _REQ_RESP_API_H_ */

View File

@ -0,0 +1,365 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "bi-inc/attr_container.h"
#include "wa-inc/request.h"
#include "wa-inc/timer_wasm_app.h"
#include "bi-inc/shared_utils.h"
#include "wasm_app.h"
#include "req_resp_api.h"
#include "timer_api.h"
#define TRANSACTION_TIMEOUT_MS 5000
typedef enum { Reg_Event, Reg_Request } reg_type_t;
typedef struct _res_register {
struct _res_register *next;
const char *url;
reg_type_t reg_type;
void (*request_handler)(request_t *);
} res_register_t;
typedef struct transaction {
struct transaction *next;
int mid;
unsigned int time; /* start time */
response_handler_f handler;
void *user_data;
} transaction_t;
static res_register_t *g_resources = NULL;
static transaction_t *g_transactions = NULL;
static user_timer_t g_trans_timer = NULL;
static transaction_t *
transaction_find(int mid)
{
transaction_t *t = g_transactions;
while (t) {
if (t->mid == mid)
return t;
t = t->next;
}
return NULL;
}
/*
* new transaction is added to the tail of the list, so the list
* is sorted by expiry time naturally.
*/
static void
transaction_add(transaction_t *trans)
{
transaction_t *t;
if (g_transactions == NULL) {
g_transactions = trans;
return;
}
t = g_transactions;
while (t) {
if (t->next == NULL) {
t->next = trans;
return;
}
}
}
static void
transaction_remove(transaction_t *trans)
{
transaction_t *prev = NULL, *current = g_transactions;
while (current) {
if (current == trans) {
if (prev == NULL) {
g_transactions = current->next;
free(current);
return;
}
prev->next = current->next;
free(current);
return;
}
prev = current;
current = current->next;
}
}
static bool
is_event_type(request_t *req)
{
return req->action == COAP_EVENT;
}
static bool
register_url_handler(const char *url, request_handler_f request_handler,
reg_type_t reg_type)
{
res_register_t *r = g_resources;
while (r) {
if (reg_type == r->reg_type && strcmp(r->url, url) == 0) {
r->request_handler = request_handler;
return true;
}
r = r->next;
}
r = (res_register_t *)malloc(sizeof(res_register_t));
if (r == NULL)
return false;
memset(r, 0, sizeof(*r));
r->url = strdup(url);
if (!r->url) {
free(r);
return false;
}
r->request_handler = request_handler;
r->reg_type = reg_type;
r->next = g_resources;
g_resources = r;
// tell app mgr to route this url to me
if (reg_type == Reg_Request)
wasm_register_resource(url);
else
wasm_sub_event(url);
return true;
}
bool
api_register_resource_handler(const char *url,
request_handler_f request_handler)
{
return register_url_handler(url, request_handler, Reg_Request);
}
static void
transaction_timeout_handler(user_timer_t timer)
{
transaction_t *cur, *expired = NULL;
unsigned int elpased_ms, now = wasm_get_sys_tick_ms();
/*
* Since he transaction list is sorted by expiry time naturally,
* we can easily get all expired transactions.
* */
cur = g_transactions;
while (cur) {
if (now < cur->time)
elpased_ms = now + (0xFFFFFFFF - cur->time) + 1;
else
elpased_ms = now - cur->time;
if (elpased_ms >= TRANSACTION_TIMEOUT_MS) {
g_transactions = cur->next;
cur->next = expired;
expired = cur;
cur = g_transactions;
}
else {
break;
}
}
/* call each transaction's handler with response set to NULL */
cur = expired;
while (cur) {
transaction_t *tmp = cur;
cur->handler(NULL, cur->user_data);
cur = cur->next;
free(tmp);
}
/*
* If the transaction list is not empty, restart the timer according
* to the first transaction. Otherwise, stop the timer.
*/
if (g_transactions != NULL) {
unsigned int elpased_ms, ms_to_expiry, now = wasm_get_sys_tick_ms();
if (now < g_transactions->time) {
elpased_ms = now + (0xFFFFFFFF - g_transactions->time) + 1;
}
else {
elpased_ms = now - g_transactions->time;
}
ms_to_expiry = TRANSACTION_TIMEOUT_MS - elpased_ms;
api_timer_restart(g_trans_timer, ms_to_expiry);
}
else {
api_timer_cancel(g_trans_timer);
g_trans_timer = NULL;
}
}
void
api_send_request(request_t *request, response_handler_f response_handler,
void *user_data)
{
int size;
char *buffer;
transaction_t *trans;
if ((trans = (transaction_t *)malloc(sizeof(transaction_t))) == NULL) {
printf(
"send request: allocate memory for request transaction failed!\n");
return;
}
memset(trans, 0, sizeof(transaction_t));
trans->handler = response_handler;
trans->mid = request->mid;
trans->time = wasm_get_sys_tick_ms();
trans->user_data = user_data;
if ((buffer = pack_request(request, &size)) == NULL) {
printf("send request: pack request failed!\n");
free(trans);
return;
}
transaction_add(trans);
/* if the trans is the 1st one, start the timer */
if (trans == g_transactions) {
/* assert(g_trans_timer == NULL); */
if (g_trans_timer == NULL) {
g_trans_timer = api_timer_create(TRANSACTION_TIMEOUT_MS, false,
true, transaction_timeout_handler);
}
}
wasm_post_request(buffer, size);
free_req_resp_packet(buffer);
}
/*
*
* APIs for the native layers to callback for request/response arrived to this
* app
*
*/
void
on_response(char *buffer, int size)
{
response_t response[1];
transaction_t *trans;
if (NULL == unpack_response(buffer, size, response)) {
printf("unpack response failed\n");
return;
}
if ((trans = transaction_find(response->mid)) == NULL) {
printf("cannot find the transaction\n");
return;
}
/*
* When the 1st transaction get response:
* 1. If the 2nd trans exist, restart the timer according to its expiry
* time;
* 2. Otherwise, stop the timer since there is no more transactions;
*/
if (trans == g_transactions) {
if (trans->next != NULL) {
unsigned int elpased_ms, ms_to_expiry, now = wasm_get_sys_tick_ms();
if (now < trans->next->time) {
elpased_ms = now + (0xFFFFFFFF - trans->next->time) + 1;
}
else {
elpased_ms = now - trans->next->time;
}
ms_to_expiry = TRANSACTION_TIMEOUT_MS - elpased_ms;
api_timer_restart(g_trans_timer, ms_to_expiry);
}
else {
api_timer_cancel(g_trans_timer);
g_trans_timer = NULL;
}
}
trans->handler(response, trans->user_data);
transaction_remove(trans);
}
void
on_request(char *buffer, int size)
{
request_t request[1];
bool is_event;
res_register_t *r = g_resources;
if (NULL == unpack_request(buffer, size, request)) {
printf("unpack request failed\n");
return;
}
is_event = is_event_type(request);
while (r) {
if ((is_event && r->reg_type == Reg_Event)
|| (!is_event && r->reg_type == Reg_Request)) {
if (check_url_start(request->url, strlen(request->url), r->url)
> 0) {
r->request_handler(request);
return;
}
}
r = r->next;
}
printf("on_request: exit. no service handler\n");
}
void
api_response_send(response_t *response)
{
int size;
char *buffer = pack_response(response, &size);
if (buffer == NULL)
return;
wasm_response_send(buffer, size);
free_req_resp_packet(buffer);
}
/// event api
bool
api_publish_event(const char *url, int fmt, void *payload, int payload_len)
{
int size;
request_t request[1];
init_request(request, (char *)url, COAP_EVENT, fmt, payload, payload_len);
char *buffer = pack_request(request, &size);
if (buffer == NULL)
return false;
wasm_post_request(buffer, size);
free_req_resp_packet(buffer);
return true;
}
bool
api_subscribe_event(const char *url, request_handler_f handler)
{
return register_url_handler(url, handler, Reg_Event);
}

View File

@ -0,0 +1,100 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include <stdlib.h>
#include <string.h>
#include "wa-inc/timer_wasm_app.h"
#include "timer_api.h"
#if 1
#include <stdio.h>
#else
#define printf (...)
#endif
struct user_timer {
struct user_timer *next;
int timer_id;
void (*user_timer_callback)(user_timer_t);
};
struct user_timer *g_timers = NULL;
user_timer_t
api_timer_create(int interval, bool is_period, bool auto_start,
on_user_timer_update_f on_timer_update)
{
int timer_id = wasm_create_timer(interval, is_period, auto_start);
// TODO
struct user_timer *timer =
(struct user_timer *)malloc(sizeof(struct user_timer));
if (timer == NULL) {
// TODO: remove the timer_id
printf("### api_timer_create malloc faild!!! \n");
return NULL;
}
memset(timer, 0, sizeof(*timer));
timer->timer_id = timer_id;
timer->user_timer_callback = on_timer_update;
if (g_timers == NULL)
g_timers = timer;
else {
timer->next = g_timers;
g_timers = timer;
}
return timer;
}
void
api_timer_cancel(user_timer_t timer)
{
user_timer_t t = g_timers, prev = NULL;
wasm_timer_cancel(timer->timer_id);
while (t) {
if (t == timer) {
if (prev == NULL) {
g_timers = t->next;
free(t);
}
else {
prev->next = t->next;
free(t);
}
return;
}
else {
prev = t;
t = t->next;
}
}
}
void
api_timer_restart(user_timer_t timer, int interval)
{
wasm_timer_restart(timer->timer_id, interval);
}
void
on_timer_callback(int timer_id)
{
struct user_timer *t = g_timers;
while (t) {
if (t->timer_id == timer_id) {
t->user_timer_callback(t);
break;
}
t = t->next;
}
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _TIMER_API_H_
#define _TIMER_API_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int timer_id_t;
timer_id_t
wasm_create_timer(int interval, bool is_period, bool auto_start);
void
wasm_timer_destroy(timer_id_t timer_id);
void
wasm_timer_cancel(timer_id_t timer_id);
void
wasm_timer_restart(timer_id_t timer_id, int interval);
uint32
wasm_get_sys_tick_ms(void);
#ifdef __cplusplus
}
#endif
#endif /* end of _TIMER_API_H_ */

View File

@ -0,0 +1,171 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _AEE_REQUEST_H_
#define _AEE_REQUEST_H_
#include "bi-inc/shared_utils.h"
#ifdef __cplusplus
extern "C" {
#endif
/* CoAP request method codes */
typedef enum {
COAP_GET = 1,
COAP_POST,
COAP_PUT,
COAP_DELETE,
COAP_EVENT = (COAP_DELETE + 2)
} coap_method_t;
/* CoAP response codes */
typedef enum {
NO_ERROR = 0,
CREATED_2_01 = 65, /* CREATED */
DELETED_2_02 = 66, /* DELETED */
VALID_2_03 = 67, /* NOT_MODIFIED */
CHANGED_2_04 = 68, /* CHANGED */
CONTENT_2_05 = 69, /* OK */
CONTINUE_2_31 = 95, /* CONTINUE */
BAD_REQUEST_4_00 = 128, /* BAD_REQUEST */
UNAUTHORIZED_4_01 = 129, /* UNAUTHORIZED */
BAD_OPTION_4_02 = 130, /* BAD_OPTION */
FORBIDDEN_4_03 = 131, /* FORBIDDEN */
NOT_FOUND_4_04 = 132, /* NOT_FOUND */
METHOD_NOT_ALLOWED_4_05 = 133, /* METHOD_NOT_ALLOWED */
NOT_ACCEPTABLE_4_06 = 134, /* NOT_ACCEPTABLE */
PRECONDITION_FAILED_4_12 = 140, /* BAD_REQUEST */
REQUEST_ENTITY_TOO_LARGE_4_13 = 141, /* REQUEST_ENTITY_TOO_LARGE */
UNSUPPORTED_MEDIA_TYPE_4_15 = 143, /* UNSUPPORTED_MEDIA_TYPE */
INTERNAL_SERVER_ERROR_5_00 = 160, /* INTERNAL_SERVER_ERROR */
NOT_IMPLEMENTED_5_01 = 161, /* NOT_IMPLEMENTED */
BAD_GATEWAY_5_02 = 162, /* BAD_GATEWAY */
SERVICE_UNAVAILABLE_5_03 = 163, /* SERVICE_UNAVAILABLE */
GATEWAY_TIMEOUT_5_04 = 164, /* GATEWAY_TIMEOUT */
PROXYING_NOT_SUPPORTED_5_05 = 165, /* PROXYING_NOT_SUPPORTED */
/* Erbium errors */
MEMORY_ALLOCATION_ERROR = 192,
PACKET_SERIALIZATION_ERROR,
/* Erbium hooks */
MANUAL_RESPONSE,
PING_RESPONSE
} coap_status_t;
/**
* @typedef request_handler_f
*
* @brief Define the signature of callback function for API
* api_register_resource_handler() to handle request or for API
* api_subscribe_event() to handle event.
*
* @param request pointer of the request to be handled
*
* @see api_register_resource_handler
* @see api_subscribe_event
*/
typedef void (*request_handler_f)(request_t *request);
/**
* @typedef response_handler_f
*
* @brief Define the signature of callback function for API
* api_send_request() to handle response of a request.
*
* @param response pointer of the response to be handled
* @param user_data user data associated with the request which is set when
* calling api_send_request().
*
* @see api_send_request
*/
typedef void (*response_handler_f)(response_t *response, void *user_data);
/*
*****************
* Request APIs
*****************
*/
/**
* @brief Register resource.
*
* @param url url of the resource
* @param handler callback function to handle the request to the resource
*
* @return true if success, false otherwise
*/
bool
api_register_resource_handler(const char *url, request_handler_f handler);
/**
* @brief Send request asynchronously.
*
* @param request pointer of the request to be sent
* @param response_handler callback function to handle the response
* @param user_data user data
*/
void
api_send_request(request_t *request, response_handler_f response_handler,
void *user_data);
/**
* @brief Send response.
*
* @param response pointer of the response to be sent
*
* @par
* @code
* void res1_handler(request_t *request)
* {
* response_t response[1];
* make_response_for_request(request, response);
* set_response(response, DELETED_2_02, 0, NULL, 0);
* api_response_send(response);
* }
* @endcode
*/
void
api_response_send(response_t *response);
/*
*****************
* Event APIs
*****************
*/
/**
* @brief Publish an event.
*
* @param url url of the event
* @param fmt format of the event payload
* @param payload payload of the event
* @param payload_len length in bytes of the event payload
*
* @return true if success, false otherwise
*/
bool
api_publish_event(const char *url, int fmt, void *payload, int payload_len);
/**
* @brief Subscribe an event.
*
* @param url url of the event
* @param handler callback function to handle the event.
*
* @return true if success, false otherwise
*/
bool
api_subscribe_event(const char *url, request_handler_f handler);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _AEE_TIMER_H_
#define _AEE_TIMER_H_
#include "bh_platform.h"
#ifdef __cplusplus
extern "C" {
#endif
/* board producer define user_timer */
struct user_timer;
typedef struct user_timer *user_timer_t;
/**
* @typedef on_user_timer_update_f
*
* @brief Define the signature of callback function for API api_timer_create().
*
* @param timer the timer
*
* @see api_timer_create
*/
typedef void (*on_user_timer_update_f)(user_timer_t timer);
/*
*****************
* Timer APIs
*****************
*/
/**
* @brief Create timer.
*
* @param interval timer interval
* @param is_period whether the timer is periodic
* @param auto_start whether start the timer immediately after created
* @param on_timer_update callback function called when timer expired
*
* @return the timer created if success, NULL otherwise
*/
user_timer_t
api_timer_create(int interval, bool is_period, bool auto_start,
on_user_timer_update_f on_timer_update);
/**
* @brief Cancel timer.
*
* @param timer the timer to cancel
*/
void
api_timer_cancel(user_timer_t timer);
/**
* @brief Restart timer.
*
* @param timer the timer to cancel
* @param interval the timer interval
*/
void
api_timer_restart(user_timer_t timer, int interval);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,13 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set (WASM_APP_BASE_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${WASM_APP_BASE_DIR})
add_definitions (-DWASM_ENABLE_BASE_LIB)
file (GLOB_RECURSE source_all ${WASM_APP_BASE_DIR}/*.c)
set (WASM_APP_CURRENT_SOURCE ${source_all})
set (WASM_APP_BASE_DIR ${WASM_APP_BASE_DIR} PARENT_SCOPE)

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef _LIB_AEE_H_
#define _LIB_AEE_H_
#include "bi-inc/shared_utils.h"
#include "bi-inc/attr_container.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* end of _LIB_AEE_H_ */

View File

@ -0,0 +1,14 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
EXPORT_WASM_API_WITH_SIG(wasm_register_resource, "($)"),
EXPORT_WASM_API_WITH_SIG(wasm_response_send, "(*~)i"),
EXPORT_WASM_API_WITH_SIG(wasm_post_request, "(*~)"),
EXPORT_WASM_API_WITH_SIG(wasm_sub_event, "($)"),
EXPORT_WASM_API_WITH_SIG(wasm_create_timer, "(iii)i"),
EXPORT_WASM_API_WITH_SIG(wasm_timer_destroy, "(i)"),
EXPORT_WASM_API_WITH_SIG(wasm_timer_cancel, "(i)"),
EXPORT_WASM_API_WITH_SIG(wasm_timer_restart, "(ii)"),
EXPORT_WASM_API_WITH_SIG(wasm_get_sys_tick_ms, "()i"),

Some files were not shown because too many files have changed in this diff Show More