Skip to content

Commit

Permalink
Pull WasmEdge version with prefixed debug library (#1954)
Browse files Browse the repository at this point in the history
* Pull WasmEdge version with prefixed debug library

* Small fixes in storage explorer

* Change default build type to Debug
  • Loading branch information
Harrm authored Jan 26, 2024
1 parent 03c91ac commit d135372
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ set(CMAKE_TOOLCHAIN_FILE
"${CMAKE_SOURCE_DIR}/cmake/toolchain/cxx20.cmake"
CACHE FILEPATH "Default toolchain")

if (NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()

set(HUNTER_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE})

include("cmake/Hunter/init.cmake")

add_compile_options(-gdwarf-4)
Expand Down
3 changes: 2 additions & 1 deletion cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ if ("${WASM_COMPILER}" STREQUAL "WasmEdge")

hunter_config(
WasmEdge
VERSION 0.13.3
URL https://github.com/Harrm/WasmEdge/archive/f9ef1de1679dd86c62c998a28fc8875e32c187f6.zip
SHA1 2bd770546623afb6083e67a3e6bad819f36dfd72
CMAKE_ARGS
WASMEDGE_BUILD_STATIC_LIB=ON
WASMEDGE_BUILD_SHARED_LIB=OFF
Expand Down
7 changes: 6 additions & 1 deletion cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ find_package(zstd CONFIG REQUIRED)

if ("${WASM_COMPILER}" STREQUAL "WasmEdge")
hunter_add_package(WasmEdge)
find_library(WASM_EDGE_LIBRARY NAMES libwasmedge.a REQUIRED PATHS "${WASMEDGE_ROOT}")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
find_library(WASM_EDGE_LIBRARY NAMES libwasmedged.a REQUIRED PATHS "${WASMEDGE_ROOT}")
else()
find_library(WASM_EDGE_LIBRARY NAMES libwasmedge.a REQUIRED PATHS "${WASMEDGE_ROOT}")
endif()

add_library(WasmEdge::WasmEdge STATIC IMPORTED)
set_property(TARGET WasmEdge::WasmEdge PROPERTY IMPORTED_LOCATION "${WASM_EDGE_LIBRARY}")
target_link_libraries(WasmEdge::WasmEdge INTERFACE curses zstd::libzstd_static)
Expand Down
1 change: 0 additions & 1 deletion core/application/app_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ namespace kagome::application {
virtual RuntimeExecutionMethod runtimeExecMethod() const = 0;

enum class RuntimeInterpreter {
Off,
WasmEdge,
Binaryen,
};
Expand Down
2 changes: 1 addition & 1 deletion core/application/impl/app_configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace {
const auto def_runtime_exec_method =
kagome::application::AppConfiguration::RuntimeExecutionMethod::Interpret;
const auto def_runtime_interpreter =
kagome::application::AppConfiguration::RuntimeInterpreter::Off;
kagome::application::AppConfiguration::RuntimeInterpreter::WasmEdge;
const auto def_use_wavm_cache_ = false;
const auto def_purge_wavm_cache_ = false;
const auto def_offchain_worker_mode =
Expand Down
13 changes: 7 additions & 6 deletions core/injector/application_injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,13 @@ namespace {
application::AppConfiguration::RuntimeInterpreter;
switch (method) {
case RuntimeExecutionMethod::Interpret:
if (interpreter == RuntimeInterpreter::Binaryen) {
return std::static_pointer_cast<CommonType>(
injector.template create<sptr<InterpretedType>>());
} else if (interpreter == RuntimeInterpreter::WasmEdge) {
return std::static_pointer_cast<CommonType>(
injector.template create<sptr<CompiledType>>());
switch (interpreter) {
case RuntimeInterpreter::Binaryen:
return std::static_pointer_cast<CommonType>(
injector.template create<sptr<InterpretedType>>());
case RuntimeInterpreter::WasmEdge:
return std::static_pointer_cast<CommonType>(
injector.template create<sptr<CompiledType>>());
}
case RuntimeExecutionMethod::Compile:
return std::static_pointer_cast<CommonType>(
Expand Down
6 changes: 3 additions & 3 deletions core/utils/storage_explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class InspectBlockCommand : public Command {
if (body_opt_res.has_error()) {
throwError("Internal error: {}}", body_opt_res.error());
}
if (body_opt_res.value().has_value()) {
if (!body_opt_res.value().has_value()) {
throwError("Block body not found for '{}'", args[1]);
}
const auto &body = body_opt_res.value().value();
Expand Down Expand Up @@ -251,7 +251,7 @@ class RemoveBlockCommand : public Command {
if (hash_opt_res.has_error()) {
throwError("Internal error: {}}", hash_opt_res.error());
}
if (hash_opt_res.value().has_value()) {
if (!hash_opt_res.value().has_value()) {
throwError("Block not found for '{}'", args[1]);
}
const auto &hash = hash_opt_res.value().value();
Expand Down Expand Up @@ -367,7 +367,7 @@ class SearchChainCommand : public Command {
if (hash_opt_res.has_error()) {
throwError("Internal error: {}}", hash_opt_res.error());
}
if (hash_opt_res.value().has_value()) {
if (!hash_opt_res.value().has_value()) {
throwError("Start block header {} not found", start);
}
const auto &hash = hash_opt_res.value().value();
Expand Down

0 comments on commit d135372

Please sign in to comment.