Enable wasm cache loading in wasm-c-api (#1759)

Use sha256 to hash binary file content. If the incoming wasm binary is
cached before, wasm_module_new() simply returns the existed one.

Use -DWAMR_BUILD_WASM_CACHE=0/1 to control the feature.
OpenSSL 1.1.1 is required if the feature is enabled.
This commit is contained in:
liang.he
2022-12-05 12:25:26 +08:00
committed by GitHub
parent 84a23d43ec
commit f6d67c1cda
6 changed files with 107 additions and 2 deletions

View File

@ -130,6 +130,9 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
# STATIC LIBRARY
add_library(iwasm_static STATIC ${WAMR_RUNTIME_LIB_SOURCE})
if (WAMR_BUILD_WASM_CACHE EQUAL 1)
target_link_libraries(iwasm_static OpenSSL::SSL)
endif ()
set_target_properties (iwasm_static PROPERTIES OUTPUT_NAME vmlib)
install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
@ -138,6 +141,9 @@ install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
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 (WAMR_BUILD_WASM_CACHE EQUAL 1)
target_link_libraries(iwasm_shared OpenSSL::SSL)
endif ()
if (MINGW)
target_link_libraries (iwasm_shared -lWs2_32)