Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/ProjectWAVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ExternalProject_Add(wavm
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=Release
-DLLVM_DIR=${LLVM_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=OFF
-DCMAKE_CXX_FLAGS=${flags}
-DCMAKE_C_FLAGS=${flags}
INSTALL_COMMAND ""
Expand Down
4 changes: 2 additions & 2 deletions cmake/ProjectWabt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ ExternalProject_Add(wabt
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=Release
-DWITH_EXCEPTIONS=ON
-DWITH_EXCEPTIONS=OFF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this needs to be turned off?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It matches wabt default build options.
This breaks some EEI. Long term it would be worth to re-implement EEI without exceptions.

-DBUILD_TESTS=OFF
-DBUILD_TOOLS=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=OFF
-DCMAKE_CXX_FLAGS=-fvisibility=hidden
-DCMAKE_C_FLAGS=-fvisibility=hidden
INSTALL_COMMAND ""
Expand Down
29 changes: 29 additions & 0 deletions scripts/static-build-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

#git clone --single-branch --branch benchmarking-static-lib https://github.com/ewasm/hera
# cd hera
# git submodule update --init

mkdir -p build
cd build
cmake -DBUILD_SHARED_LIBS=OFF -DHERA_BINARYEN=ON -DHERA_WABT=ON -DHERA_WAVM=ON -DHERA_DEBUGGING=OFF ..
cmake --build .

cd deps/src/binaryen-build/lib/
for f in *.a; do ar x $f; done
ar r -s -c libbinaryenfull.a *.o
rm *.o
cd ../../../../


cd deps/src/wavm-build/lib
for f in *.a; do ar x $f; done
ar r -s -c libwavm.a *.o
rm *.o
cd ../../../../

# apt-get install llvm-6.0-dev
# llvm .so file is needed for libwavm.a to be usable

# some flags might be unnecessary
#cgo LDFLAGS: /root/hera/build/src/libhera.a -L/root/hera/build/src/ -lhera -L/root/hera/build/deps/src/wabt-build/ -lwabt /root/hera/build/deps/src/binaryen-build/lib/libbinaryenfull.a /root/hera/build/deps/src/wavm-build/lib/libwavm.a -L/usr/lib/llvm-6.0/build/lib/ -lLLVM -rdynamic -lstdc++ -Wl,-unresolved-symbols=ignore-all

2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ endif()
target_include_directories(hera
PUBLIC $<BUILD_INTERFACE:${hera_include_dir}>$<INSTALL_INTERFACE:include>
)
target_link_libraries(hera PUBLIC evmc::evmc PRIVATE hera-buildinfo evmc::instructions)
target_link_libraries(hera PUBLIC evmc::evmc PUBLIC hera-buildinfo evmc::instructions)
if(NOT WIN32)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(hera PROPERTIES LINK_FLAGS "-Wl,--no-undefined")
Expand Down
4 changes: 4 additions & 0 deletions src/binaryen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,15 @@ void BinaryenEngine::verifyContract(wasm::Module & module)
"Contract export (\"memory\") missing."
);

/*
***** in the metering benchmarks, inline-block and inline-super both export the inline useGas functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do they export it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a workaround to make the wast code use the debug name useGas for the function (if the inline function wasn't exported, its name would get mangled by the metering injector).

// just going to comment this out since here since we need to change Hera for static libs anyway
ensureCondition(
module.exports.size() == 2,
ContractValidationFailure,
"Contract exports more than (\"main\") and (\"memory\")."
);
*/

// The existence of this is ensured above.
wasm::Export* main_export = module.getExport(wasm::Name("main"));
Expand Down
5 changes: 4 additions & 1 deletion src/hera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ struct hera_instance : evmc_instance {
bool metering = false;
map<evmc_address, bytes> contract_preload_list;

hera_instance() noexcept : evmc_instance({EVMC_ABI_VERSION, "hera", hera_get_buildinfo()->project_version, nullptr, nullptr, nullptr, nullptr, nullptr}) {}
// hera_instance() noexcept : evmc_instance({EVMC_ABI_VERSION, "hera", hera_get_buildinfo()->project_version, nullptr, nullptr, nullptr, nullptr, nullptr}) {}
// fix error with geth+evmc: /tmp/go-build940146972/b001/runtime.test: symbol lookup error: /tmp/go-build940146972/b001/runtime.test: undefined symbol: hera_get_buildinfo
hera_instance() noexcept : evmc_instance({EVMC_ABI_VERSION, "hera", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}) {}

};

const evmc_address sentinelAddress = { .bytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xa } };
Expand Down