This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
wasm-micro-runtime/samples/workload/meshoptimizer/codecbench.patch
Wenyong Huang a5188f5574
Add checks to avoid wasm_runtime_malloc memory with size 0 (#507)
In some platforms, allocating memory with size 0 may return NULL but not an empty memory block, which causes runtime load, instantiate or execute wasm/aot file failed. We add checks to try to avoid allocating memory in runtime if the size is 0. And in wasm_runtime_malloc/free, output warning if allocate memory with size 0 and free memory with NULL ptr.
Also fix some coding style issues, fix handle riscv32 ilp32d issue, and fix several wasm-c-api issues.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
2021-01-28 16:16:02 +08:00

49 lines
1.3 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ffdb4da..a397427 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -127,3 +127,43 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/meshoptimizerConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/meshoptimizerConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/meshoptimizer)
+
+##################################################
+# codecbench
+##################################################
+add_executable(codecbench tools/codecbench.cpp ${SOURCES})
+
+set_target_properties(codecbench PROPERTIES OUTPUT_NAME codecbench.wasm)
+
+target_compile_options(codecbench
+ PUBLIC
+ -O3 -msimd128
+ -std=c++11
+ -Wno-unused-function
+ -Wno-unused-variable
+)
+
+target_link_options(codecbench
+ PUBLIC
+ LINKER:-allow-undefined,--demangle,--export=malloc,--export=free
+)
+
+find_program(WASM_OPT
+ NAMES wasm-opt
+ PATHS /opt/binaryen-version_97/bin /opt/binaryen/bin
+)
+
+if (NOT WASM_OPT)
+ message(WARNING "can not find wasm-opt and will not optimize any wasm module")
+endif()
+
+add_custom_target(codecbench.opt ALL
+ COMMAND
+ ${WASM_OPT} -Oz --enable-simd -o codecbench.opt.wasm codecbench.wasm
+ BYPRODUCTS
+ ${CMAKE_CURRENT_BINARY_DIR}/codecbench.opt.wasm
+ WORKING_DIRECTORY
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+add_dependencies(codecbench.opt codecbench)