diff --git a/CMakeLists.txt b/CMakeLists.txt index 450f1569e..a89aec981 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,8 +43,8 @@ if(DEFINED WASI_SDK_PREFIX) install(DIRECTORY ${WASI_SDK_PREFIX}/ USE_SOURCE_PERMISSIONS DESTINATION . COMPONENT WASI EXCLUDE_FROM_ALL) elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") ExternalProject_Add(wasi-sdk - URL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz - URL_HASH SHA256=d900abc826eec1955b9afd250e7cc2496338abbf6c440d86a313c06e42083fa1 + URL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz + URL_HASH SHA256=7030139d495a19fbeccb9449150c2b1531e15d8fb74419872a719a7580aad0f9 CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/external/eos-vm b/external/eos-vm index f2163478d..cc4d920e5 160000 --- a/external/eos-vm +++ b/external/eos-vm @@ -1 +1 @@ -Subproject commit f2163478deffb22d084e79c95b25241a7a1ad098 +Subproject commit cc4d920e52ffa301b1a1be000ee778ba011513c3 diff --git a/libraries/psibase/native/src/ExecutionContext.cpp b/libraries/psibase/native/src/ExecutionContext.cpp index 0cb0a5762..dbc1db526 100644 --- a/libraries/psibase/native/src/ExecutionContext.cpp +++ b/libraries/psibase/native/src/ExecutionContext.cpp @@ -19,8 +19,12 @@ using eosio::vm::span; namespace psibase { struct ExecutionContextImpl; - using rhf_t = eosio::vm::registered_host_functions; + using rhf_t = eosio::vm::registered_host_functions; +#ifdef __x86_64__ using backend_t = eosio::vm::backend; +#else + using backend_t = eosio::vm::backend; +#endif // Rethrow with detailed info template @@ -70,10 +74,12 @@ namespace psibase struct BackendEntry { - Checksum256 hash; - VMOptions vmOptions; - std::unique_ptr backend; + Checksum256 hash; + VMOptions vmOptions; + std::unique_ptr backend; +#ifdef __x86_64__ std::shared_ptr debug; +#endif auto byHash() const { return std::tie(hash, vmOptions); } }; @@ -201,6 +207,7 @@ namespace psibase { psio::input_stream s{reinterpret_cast(c->code.data()), c->code.size()}; +#ifdef __x86_64__ if (dwarf::has_debug_info(s)) { debug_eos_vm::debug_instr_map debug; @@ -215,6 +222,9 @@ namespace psibase backend.backend = std::make_unique(c->code, nullptr, vmOptions); backend.debug = dwarf::register_with_debugger(backend.backend->get_module()); } +#else + backend.backend = std::make_unique(c->code, nullptr, vmOptions); +#endif } }); } @@ -310,7 +320,7 @@ namespace psibase std::uint32_t ExecutionContext::remainingStack() const { - return impl->backend.backend->get_context()._remaining_call_depth; + return impl->backend.backend->get_context().get_remaining_call_depth(); } void ExecutionContext::execProcessTransaction(ActionContext& actionContext) diff --git a/libraries/psibase/sdk/psibase-wasm-opt b/libraries/psibase/sdk/psibase-wasm-opt index 9add76f0c..daba26248 100755 --- a/libraries/psibase/sdk/psibase-wasm-opt +++ b/libraries/psibase/sdk/psibase-wasm-opt @@ -6,5 +6,5 @@ # generates code that won't run on psibase. if which wasm-opt >/dev/null 2>&1 then - wasm-opt --disable-sign-ext --enable-simd --enable-bulk-memory "$@" + wasm-opt --enable-sign-ext --enable-nontrapping-float-to-int --enable-simd --enable-bulk-memory "$@" fi diff --git a/libraries/psibase/sdk/toolchain.cmake b/libraries/psibase/sdk/toolchain.cmake index 02fa629a2..c13d3bceb 100644 --- a/libraries/psibase/sdk/toolchain.cmake +++ b/libraries/psibase/sdk/toolchain.cmake @@ -44,7 +44,7 @@ set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES WASI_SDK_PREFIX) if(NOT __psibase_toolchain_included) set(__psibase_toolchain_included 1) - string(APPEND CMAKE_CXX_FLAGS_INIT "-mno-sign-ext -msimd128") + string(APPEND CMAKE_CXX_FLAGS_INIT "-msign-ext -msimd128 -mnontrapping-fptoint -mbulk-memory") string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -ggdb") string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -ggdb") string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -ggdb") diff --git a/programs/psitest/main.cpp b/programs/psitest/main.cpp index f4e8d2f5f..3700fb569 100644 --- a/programs/psitest/main.cpp +++ b/programs/psitest/main.cpp @@ -48,7 +48,11 @@ void eosio::vm::machine_code_writer; diff --git a/services/system/VerifyEcSys/CMakeLists.txt b/services/system/VerifyEcSys/CMakeLists.txt index bef10fb55..5c5706a33 100644 --- a/services/system/VerifyEcSys/CMakeLists.txt +++ b/services/system/VerifyEcSys/CMakeLists.txt @@ -8,7 +8,7 @@ function(add suffix) add_custom_command(TARGET VerifyEcSys${suffix} POST_BUILD COMMAND wasm-ctor-eval -c prestart - --enable-bulk-memory + --enable-sign-ext --enable-nontrapping-float-to-int --enable-simd --enable-bulk-memory VerifyEcSys-prestart${suffix}.wasm -o ${ROOT_BINARY_DIR}/VerifyEcSys${suffix}.wasm ) diff --git a/wasm/CMakeLists.txt b/wasm/CMakeLists.txt index ae3772e3d..349004d22 100644 --- a/wasm/CMakeLists.txt +++ b/wasm/CMakeLists.txt @@ -71,13 +71,15 @@ endmacro() include(GNUInstallDirs) install(FILES ${ROOT_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/psibase/licenses COMPONENT libpsibase) +set(WASM_FEATURES -msign-ext -mnontrapping-fptoint -msimd128 -mbulk-memory) + add_library(wasm-base INTERFACE) -target_compile_options(wasm-base INTERFACE -mno-sign-ext -fno-exceptions -DCOMPILING_WASM -mthread-model single -O3) -target_link_options(wasm-base INTERFACE -mno-sign-ext -B${ROOT_SOURCE_DIR}/libraries/psibase/sdk/psibase- -Wl,--strip-all -O3 -L${ROOT_BINARY_DIR}/wasm/deps/lib) +target_compile_options(wasm-base INTERFACE ${WASM_FEATURES} -fno-exceptions -DCOMPILING_WASM -mthread-model single -O3) +target_link_options(wasm-base INTERFACE ${WASM_FEATURES} -B${ROOT_SOURCE_DIR}/libraries/psibase/sdk/psibase- -Wl,--strip-all -O3 -L${ROOT_BINARY_DIR}/wasm/deps/lib) add_library(wasm-base-debug INTERFACE) -target_compile_options(wasm-base-debug INTERFACE -mno-sign-ext -fno-exceptions -DCOMPILING_WASM -mthread-model single -ggdb) -target_link_options(wasm-base-debug INTERFACE -mno-sign-ext -ggdb -L${ROOT_BINARY_DIR}/wasm/deps/lib) +target_compile_options(wasm-base-debug INTERFACE ${WASM_FEATURES} -fno-exceptions -DCOMPILING_WASM -mthread-model single -ggdb) +target_link_options(wasm-base-debug INTERFACE ${WASM_FEATURES} -ggdb -L${ROOT_BINARY_DIR}/wasm/deps/lib) function(target_mapped_include_directories target type) target_include_directories(${target} ${type} ${ARGN})