mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 15:05:19 +00:00
6b1d81650d
Add flag `LoadArgs.clone_wasm_binary` to control whether to clone the wasm/aot binary in wasm-c-api module. If false, API `wasm_module_new_ex` won't clone the binary, which may reduce the footprint. Add flag `LoadArgs.wasm_binary_freeable` to control whether the wasm/aot binary may be freed after instantiation for wamr API `wasm_runtime_load_ex`, if yes, then for some running modes, the wasm/aot module doesn't refer to the input binary again so developer can free it after instantiation to reduce the footprint. And add API `wasm_module_is_underlying_binary_freeable` and `wasm_runtime_is_underlying_binary_freeable` to check whether the input binary can be freed after instantiation for wasm-c-api and wamr api. And add sample to illustrate it.
65 lines
1.5 KiB
Bash
Executable File
65 lines
1.5 KiB
Bash
Executable File
#
|
|
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
#
|
|
|
|
#!/bin/bash
|
|
|
|
CURR_DIR=$PWD
|
|
WAMR_DIR=${PWD}/../..
|
|
OUT_DIR=${PWD}/out
|
|
|
|
WASM_APPS=${PWD}/wasm-apps
|
|
|
|
|
|
rm -rf ${OUT_DIR}
|
|
mkdir ${OUT_DIR}
|
|
mkdir ${OUT_DIR}/wasm-apps
|
|
|
|
|
|
echo "#####################build basic project"
|
|
cd ${CURR_DIR}
|
|
mkdir -p cmake_build
|
|
cd cmake_build
|
|
cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BH_VPRINTF=my_vprintf -DWAMR_BH_LOG=my_log
|
|
make -j ${nproc}
|
|
if [ $? != 0 ];then
|
|
echo "BUILD_FAIL basic exit as $?\n"
|
|
exit 2
|
|
fi
|
|
|
|
cp -a basic ${OUT_DIR}
|
|
|
|
echo -e "\n"
|
|
|
|
echo "#####################build wasm apps"
|
|
|
|
cd ${WASM_APPS}
|
|
|
|
for i in `ls *.c`
|
|
do
|
|
APP_SRC="$i"
|
|
OUT_FILE=${i%.*}.wasm
|
|
|
|
# use WAMR SDK to build out the .wasm binary
|
|
/opt/wasi-sdk/bin/clang \
|
|
--target=wasm32 -O0 -z stack-size=4096 -Wl,--initial-memory=65536 \
|
|
--sysroot=${WAMR_DIR}/wamr-sdk/app/libc-builtin-sysroot \
|
|
-Wl,--allow-undefined-file=${WAMR_DIR}/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt \
|
|
-Wl,--strip-all,--no-entry -nostdlib \
|
|
-Wl,--export=generate_float \
|
|
-Wl,--export=float_to_string \
|
|
-Wl,--export=calculate\
|
|
-Wl,--export=mul7\
|
|
-Wl,--allow-undefined \
|
|
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
|
|
|
|
|
|
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
|
|
echo "build ${OUT_FILE} success"
|
|
else
|
|
echo "build ${OUT_FILE} fail"
|
|
fi
|
|
done
|
|
echo "####################build wasm apps done"
|