Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Add wasi toolchain #328

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
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
42 changes: 29 additions & 13 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,21 @@ jobs:
- build
- test

wasi:
executor: linux-clang-latest
resource_class: small
environment:
TOOLCHAIN: wasm32-wasi
CMAKE_OPTIONS: -DEVMONE_TESTING=OFF
steps:
- run:
name: "Install WASI SDK"
command: |
sudo mkdir /opt/wasi-sdk && cd /opt/wasi-sdk
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz | sudo tar -xz --strip=1
find .
- build

workflows:
version: 2
evmone:
Expand Down Expand Up @@ -600,16 +615,17 @@ workflows:
ignore: /.*/
tags:
only: /^v[0-9].*/
- state-tests
- blockchain-tests
- cmake-min
- gcc-min
- clang-min
- gcc-latest-coverage
- gcc-latest-memcheck
- clang-latest-sanitizers
- clang-latest-coverage
- macos-asan
- xcode-min
- gcc-32bit
- fuzzing
# - state-tests
# - blockchain-tests
# - cmake-min
# - gcc-min
# - clang-min
# - gcc-latest-coverage
# - gcc-latest-memcheck
# - clang-latest-sanitizers
# - clang-latest-coverage
# - macos-asan
# - xcode-min
# - gcc-32bit
# - fuzzing
- wasi
9 changes: 7 additions & 2 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

include(hunter_cmake_args)

hunter_cmake_args(
# Need to use this, because overriding via hunter_cmake_args is not working,
# due to precendence rules.
hunter_config(
ethash
CMAKE_ARGS -DETHASH_BUILD_ETHASH=OFF
VERSION 1.0.0-evmone
URL https://github.com/chfast/ethash/archive/v1.0.0.tar.gz
SHA1 75e64b885be0ad90f0fad8e8e718f02d4b0edac8
CMAKE_ARGS ETHASH_BUILD_ETHASH=OFF ETHASH_BUILD_TESTS=OFF
)

hunter_config(
Expand Down
24 changes: 24 additions & 0 deletions cmake/toolchains/wasm32-wasi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES WASI_SDK_PREFIX)

if(NOT DEFINED WASI_SDK_PREFIX)
if(DEFINED ENV{WASI_SDK_PREFIX})
set(WASI_SDK_PREFIX $ENV{WASI_SDK_PREFIX})
else()
# Set default value of WASI_SDK_PREFIX
set(WASI_SDK_PREFIX /opt/wasi-sdk)
endif()
else()
set(ENV{WASI_SDK_PREFIX} ${WASI_SDK_PREFIX})
endif()

if(NOT WASI_SDK_PREFIX STREQUAL /opt/wasi-sdk)
# Set --sysroot. Not necessary if WASI_SDK_PATH is /opt/wasi-sdk.
set(CMAKE_SYSROOT ${WASI_SDK_PREFIX}/share/wasi-sysroot)
endif()

include(${WASI_SDK_PREFIX}/share/cmake/wasi-sdk.cmake)

# Override the default in wasi-sdk.cmake which sets it at "WASI"
# That does not exists in CMake Platforms, and as a result falls back to the host
# toolchain, which on macOS includes extra linker flags.
set(CMAKE_SYSTEM_NAME Linux)
14 changes: 7 additions & 7 deletions lib/evmone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ add_library(evmone
vm.cpp
vm.hpp
)
target_compile_features(evmone PUBLIC cxx_std_20)
target_link_libraries(evmone PUBLIC evmc::evmc intx::intx PRIVATE ethash::keccak)
target_compile_features(evmone PUBLIC cxx_std_17)
target_link_libraries(evmone PUBLIC evmc::evmc intx::intx PRIVATE evmc::instructions ethash::keccak)
target_include_directories(evmone PUBLIC
$<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
Expand All @@ -55,11 +55,11 @@ set_target_properties(
SOVERSION ${PROJECT_SOVERSION}
)

if(NOT SANITIZE)
# On Linux, check if all symbols in evmone are resolved during linking.
target_link_options(evmone PRIVATE $<$<PLATFORM_ID:Linux>:LINKER:--no-undefined>)
endif()
#if(NOT SANITIZE)
# # On Linux, check if all symbols in evmone are resolved during linking.
# target_link_options(evmone PRIVATE $<$<PLATFORM_ID:Linux>:LINKER:--no-undefined>)
#endif()

set_source_files_properties(vm.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}")

add_standalone_library(evmone)
#add_standalone_library(evmone)