From 84a79fc0b932c2d7757a683a7bffb18530ea29ba Mon Sep 17 00:00:00 2001 From: krigga Date: Wed, 27 Mar 2024 12:53:34 +0300 Subject: [PATCH 1/2] Add portable WASM version of funcfiftlib --- crypto/CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 29b954664..256824a64 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -411,6 +411,27 @@ if (USE_EMSCRIPTEN) target_link_options(funcfiftlib PRIVATE --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/funcfiftlib/funcfiftlib-prejs.js) target_link_options(funcfiftlib PRIVATE -fexceptions) target_compile_options(funcfiftlib PRIVATE -fexceptions -fno-stack-protector) + + add_executable(funcfiftlib-portable funcfiftlib/funcfiftlib.cpp ${FUNC_LIB_SOURCE}) + target_include_directories(funcfiftlib-portable PUBLIC $) + target_link_libraries(funcfiftlib-portable PUBLIC fift-lib src_parser git) + target_link_options(funcfiftlib-portable PRIVATE -sEXPORTED_RUNTIME_METHODS=FS,ccall,cwrap,UTF8ToString,stringToUTF8,lengthBytesUTF8,addFunction,removeFunction,setValue) + target_link_options(funcfiftlib-portable PRIVATE -sEXPORTED_FUNCTIONS=_func_compile,_version,_malloc,_free,_setThrew) + target_link_options(funcfiftlib-portable PRIVATE -sEXPORT_NAME=CompilerModule) + target_link_options(funcfiftlib-portable PRIVATE -sERROR_ON_UNDEFINED_SYMBOLS=0) + target_link_options(funcfiftlib-portable PRIVATE -sFILESYSTEM=1) + target_link_options(funcfiftlib-portable PRIVATE -Oz) + target_link_options(funcfiftlib-portable PRIVATE -sIGNORE_MISSING_MAIN=1) + target_link_options(funcfiftlib-portable PRIVATE -sAUTO_NATIVE_LIBRARIES=0) + target_link_options(funcfiftlib-portable PRIVATE -sMODULARIZE=1) + target_link_options(funcfiftlib-portable PRIVATE -sTOTAL_MEMORY=33554432) + target_link_options(funcfiftlib-portable PRIVATE -sALLOW_MEMORY_GROWTH=1) + target_link_options(funcfiftlib-portable PRIVATE -sALLOW_TABLE_GROWTH=1) + target_link_options(funcfiftlib-portable PRIVATE --embed-file ${CMAKE_CURRENT_SOURCE_DIR}/fift/lib@/fiftlib) + target_link_options(funcfiftlib-portable PRIVATE --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/funcfiftlib/funcfiftlib-prejs.js) + target_link_options(funcfiftlib-portable PRIVATE -sENVIRONMENT=web) + target_link_options(funcfiftlib-portable PRIVATE -fexceptions) + target_compile_options(funcfiftlib-portable PRIVATE -fexceptions -fno-stack-protector) endif() add_executable(tlbc tl/tlbc.cpp) From ffe0a1c63073dda0a0dd0e14f199b83fe5b05e66 Mon Sep 17 00:00:00 2001 From: krigga Date: Wed, 27 Mar 2024 12:57:15 +0300 Subject: [PATCH 2/2] Add funcfiftlib-portable to workflow script --- assembly/wasm/fift-func-wasm-build-ubuntu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assembly/wasm/fift-func-wasm-build-ubuntu.sh b/assembly/wasm/fift-func-wasm-build-ubuntu.sh index 9ca23cc00..d1e6a86aa 100644 --- a/assembly/wasm/fift-func-wasm-build-ubuntu.sh +++ b/assembly/wasm/fift-func-wasm-build-ubuntu.sh @@ -138,7 +138,7 @@ emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release \ test $? -eq 0 || { echo "Can't configure TON with emmake "; exit 1; } cp -R ../crypto/smartcont ../crypto/fift/lib crypto -emmake make -j16 funcfiftlib func fift tlbc emulator-emscripten +emmake make -j16 funcfiftlib funcfiftlib-portable func fift tlbc emulator-emscripten test $? -eq 0 || { echo "Can't compile TON with emmake "; exit 1; }