Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit c2d600c

Browse files
authored
Merge pull request #5102 from ethereum/build-interpreter
Ship the interpreter
2 parents 2c542ca + d8a66f7 commit c2d600c

File tree

7 files changed

+118
-113
lines changed

7 files changed

+118
-113
lines changed

CMakeLists.txt

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
1-
# ------------------------------------------------------------------------------
2-
# This file is part of cpp-ethereum.
3-
#
4-
# cpp-ethereum is free software: you can redistribute it and/or modify
5-
# it under the terms of the GNU General Public License as published by
6-
# the Free Software Foundation, either version 3 of the License, or
7-
# (at your option) any later version.
8-
#
9-
# cpp-ethereum is distributed in the hope that it will be useful,
10-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
# GNU General Public License for more details.
13-
#
14-
# You should have received a copy of the GNU General Public License
15-
# along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>
16-
#
17-
# (c) 2014-2016 cpp-ethereum contributors.
18-
#------------------------------------------------------------------------------
1+
# Aleth: Ethereum C++ client, tools and libraries.
2+
# Copyright 2018 Aleth Autors.
3+
# Licensed under the GNU General Public License, Version 3. See the LICENSE file.
194

205
cmake_minimum_required(VERSION 3.5.1)
216

@@ -25,7 +10,13 @@ include(CableBuildType)
2510
include(CableToolchains)
2611
include(GNUInstallDirs)
2712

28-
cable_configure_toolchain(DEFAULT cxx11)
13+
if(UNIX)
14+
# Build deps with PIC to allow building shared libraries.
15+
set(toolchain cxx11-pic)
16+
else()
17+
set(toolchain cxx11)
18+
endif()
19+
cable_configure_toolchain(DEFAULT ${toolchain})
2920

3021
set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The path to the cmake directory")
3122
list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR})

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ install:
4545
before_build: |
4646
if not exist build mkdir build
4747
cd build
48-
cmake -G "Visual Studio 14 2015 Win64" .. -DTESTS=%TESTS% -DEVMJIT=OFF
48+
cmake -G "Visual Studio 14 2015 Win64" .. -DALETH_INTERPRETER_SHARED=ON
4949
build_script: |
5050
cmake --build . --config %CONFIGURATION% --target package
5151
test_script:

circle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ defaults:
4646
working_directory: ~/build
4747
command: |
4848
ETHEREUM_TEST_PATH=~/project/test/jsontests \
49-
test/testeth -t GeneralStateTests -- --vm interpreter
49+
test/testeth -t GeneralStateTests -- --vm libaleth-interpreter/libaleth-interpreter.so
5050
5151
store-package: &store-package
5252
store_artifacts:
@@ -122,6 +122,7 @@ jobs:
122122
- GENERATOR: Ninja
123123
- BUILD_PARALLEL_JOBS: 8
124124
- TEST_PARALLEL_JOBS: 8
125+
- CMAKE_OPTIONS: -DALETH_INTERPRETER_SHARED=ON
125126
docker:
126127
- image: ethereum/cpp-build-env:2
127128
steps:
@@ -169,7 +170,6 @@ jobs:
169170
- *save-deps-cache
170171
- *store-package
171172
- *test
172-
- *test-evmc-interpreter
173173
- *upload-coverage-data
174174

175175
macos-xcode90:

cmake/EthCompilerSettings.cmake

Lines changed: 87 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,103 +18,110 @@ include(EthCheckCXXCompilerFlag)
1818

1919
eth_add_cxx_compiler_flag_if_supported(-fstack-protector-strong have_stack_protector_strong_support)
2020
if(NOT have_stack_protector_strong_support)
21-
eth_add_cxx_compiler_flag_if_supported(-fstack-protector)
21+
eth_add_cxx_compiler_flag_if_supported(-fstack-protector)
2222
endif()
2323

2424
eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough)
2525

2626
if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
27-
# Enables all the warnings about constructions that some users consider questionable,
28-
# and that are easy to avoid. Also enable some extra warning flags that are not
29-
# enabled by -Wall. Finally, treat at warnings-as-errors, which forces developers
30-
# to fix warnings as they arise, so they don't accumulate "to be fixed later".
31-
add_compile_options(-Wall)
32-
add_compile_options(-Wextra)
33-
add_compile_options(-Werror)
34-
35-
# Disable warnings about unknown pragmas (which is enabled by -Wall).
36-
add_compile_options(-Wno-unknown-pragmas)
37-
38-
# Configuration-specific compiler settings.
39-
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DETH_DEBUG")
40-
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
41-
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
42-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
43-
44-
option(USE_LD_GOLD "Use GNU gold linker" ON)
45-
if (USE_LD_GOLD)
46-
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
47-
if ("${LD_VERSION}" MATCHES "GNU gold")
48-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
49-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
50-
endif ()
51-
endif ()
52-
53-
# Check GCC compiler version.
54-
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
55-
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.8)
56-
message(FATAL_ERROR "This compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is not supported. GCC 4.8 or newer is required.")
57-
endif()
58-
59-
# Stop if buggy clang compiler detected.
60-
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES AppleClang)
61-
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 8.4)
62-
message(FATAL_ERROR "This compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is not able to compile required libff. Install clang 4+ from Homebrew or XCode 9.")
63-
endif()
64-
endif()
27+
# Enables all the warnings about constructions that some users consider questionable,
28+
# and that are easy to avoid. Also enable some extra warning flags that are not
29+
# enabled by -Wall. Finally, treat at warnings-as-errors, which forces developers
30+
# to fix warnings as they arise, so they don't accumulate "to be fixed later".
31+
add_compile_options(-Wall)
32+
add_compile_options(-Wextra)
33+
add_compile_options(-Werror)
34+
35+
# Disable warnings about unknown pragmas (which is enabled by -Wall).
36+
add_compile_options(-Wno-unknown-pragmas)
37+
38+
# Configuration-specific compiler settings.
39+
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g -DETH_DEBUG")
40+
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
41+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
42+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
43+
44+
option(USE_LD_GOLD "Use GNU gold linker" ON)
45+
if (USE_LD_GOLD)
46+
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
47+
if ("${LD_VERSION}" MATCHES "GNU gold")
48+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
49+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
50+
endif ()
51+
endif ()
52+
53+
# Hide all symbols by default.
54+
add_compile_options(-fvisibility=hidden)
55+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
56+
# Do not export symbols from dependencies.
57+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,ALL")
58+
endif()
59+
60+
# Check GCC compiler version.
61+
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
62+
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 5)
63+
message(FATAL_ERROR "This compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is not supported. GCC 5 or newer is required.")
64+
endif()
65+
66+
# Stop if buggy clang compiler detected.
67+
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES AppleClang)
68+
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 8.4)
69+
message(FATAL_ERROR "This compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is not able to compile required libff. Install clang 4+ from Homebrew or XCode 9.")
70+
endif()
71+
endif()
6572

6673
# The major alternative compiler to GCC/Clang is Microsoft's Visual C++ compiler, only available on Windows.
6774
elseif (MSVC)
6875

69-
add_compile_options(/MP) # enable parallel compilation
70-
add_compile_options(/EHsc) # specify Exception Handling Model in msvc
71-
add_compile_options(/WX) # enable warnings-as-errors
72-
add_compile_options(/wd4068) # disable unknown pragma warning (4068)
73-
add_compile_options(/wd4996) # disable unsafe function warning (4996)
74-
add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503)
75-
add_compile_options(/wd4267) # disable conversion from 'size_t' to 'type', possible loss of data (4267)
76-
add_compile_options(/wd4180) # disable qualifier applied to function type has no meaning; ignored (4180)
77-
add_compile_options(/wd4290) # disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (4290)
78-
add_compile_options(/wd4297) # disable <vector>'s function assumed not to throw an exception but does (4297)
79-
add_compile_options(/wd4244) # disable conversion from 'type1' to 'type2', possible loss of data (4244)
80-
add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800)
81-
add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement
82-
add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions
83-
add_compile_options(-DMINIUPNP_STATICLIB) # define miniupnp static library
84-
85-
# Always use Release variant of C++ runtime.
86-
# We don't want to provide Debug variants of all dependencies. Some default
87-
# flags set by CMake must be tweaked.
88-
string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
89-
string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
90-
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
91-
string(REPLACE "/MDd" "/MD" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
92-
string(REPLACE "/D_DEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
93-
string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
94-
set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS OFF)
95-
96-
# disable empty object file warning
97-
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
98-
# warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
99-
# warning LNK4099: pdb was not found with lib
100-
# stack size 16MB
101-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099,4075 /STACK:16777216")
76+
add_compile_options(/MP) # enable parallel compilation
77+
add_compile_options(/EHsc) # specify Exception Handling Model in msvc
78+
add_compile_options(/WX) # enable warnings-as-errors
79+
add_compile_options(/wd4068) # disable unknown pragma warning (4068)
80+
add_compile_options(/wd4996) # disable unsafe function warning (4996)
81+
add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503)
82+
add_compile_options(/wd4267) # disable conversion from 'size_t' to 'type', possible loss of data (4267)
83+
add_compile_options(/wd4180) # disable qualifier applied to function type has no meaning; ignored (4180)
84+
add_compile_options(/wd4290) # disable C++ exception specification ignored except to indicate a function is not __declspec(nothrow) (4290)
85+
add_compile_options(/wd4297) # disable <vector>'s function assumed not to throw an exception but does (4297)
86+
add_compile_options(/wd4244) # disable conversion from 'type1' to 'type2', possible loss of data (4244)
87+
add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800)
88+
add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement
89+
add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions
90+
add_compile_options(-DMINIUPNP_STATICLIB) # define miniupnp static library
91+
92+
# Always use Release variant of C++ runtime.
93+
# We don't want to provide Debug variants of all dependencies. Some default
94+
# flags set by CMake must be tweaked.
95+
string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
96+
string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
97+
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
98+
string(REPLACE "/MDd" "/MD" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
99+
string(REPLACE "/D_DEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
100+
string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
101+
set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS OFF)
102+
103+
# disable empty object file warning
104+
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
105+
# warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
106+
# warning LNK4099: pdb was not found with lib
107+
# stack size 16MB
108+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099,4075 /STACK:16777216")
102109

103110
# If you don't have GCC, Clang or VC++ then you are on your own. Good luck!
104111
else ()
105-
message(WARNING "Your compiler is not tested, if you run into any issues, we'd welcome any patches.")
112+
message(WARNING "Your compiler is not tested, if you run into any issues, we'd welcome any patches.")
106113
endif ()
107114

108115
if (SANITIZE)
109-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=${SANITIZE}")
110-
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
111-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/sanitizer-blacklist.txt")
112-
endif()
116+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=${SANITIZE}")
117+
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
118+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/sanitizer-blacklist.txt")
119+
endif()
113120
endif()
114121

115122
option(COVERAGE "Build with code coverage support" OFF)
116123
if(COVERAGE)
117-
add_compile_options(-g --coverage)
118-
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
119-
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
124+
add_compile_options(-g --coverage)
125+
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
126+
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
120127
endif()

evmc

Submodule evmc updated from cb2288b to 8dc2793

libaleth-interpreter/CMakeLists.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,30 @@
22
# Copyright 2018 Aleth Autors.
33
# Licensed under the GNU General Public License, Version 3. See the LICENSE file.
44

5-
if(ALETH_INTERPRETER_SHARED)
6-
set(library_type SHARED)
7-
else()
8-
set(library_type STATIC)
9-
endif()
10-
11-
add_library(
12-
aleth-interpreter
13-
${library_type}
5+
set(
6+
sources
147
interpreter.h
158
VM.cpp
169
VM.h
1710
VMCalls.cpp
1811
VMConfig.h
1912
VMOpt.cpp
2013
)
14+
add_library(aleth-interpreter STATIC ${sources})
2115
target_link_libraries(aleth-interpreter PRIVATE devcore aleth-buildinfo evmc::evmc evmc::instructions)
2216

17+
if(ALETH_INTERPRETER_SHARED)
18+
# Build aleth-interpreter additionally as a shared library to include it in the package
19+
add_library(aleth-interpreter-shared SHARED ${sources})
20+
target_link_libraries(aleth-interpreter-shared PRIVATE devcore aleth-buildinfo evmc::evmc evmc::instructions)
21+
set_target_properties(aleth-interpreter-shared PROPERTIES OUTPUT_NAME aleth-interpreter)
22+
install(TARGETS aleth-interpreter-shared EXPORT alethTargets
23+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
24+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
25+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
26+
)
27+
endif()
28+
2329
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
2430
target_compile_options(aleth-interpreter PRIVATE -fstack-usage)
2531
endif()

libaleth-interpreter/interpreter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#pragma once
77

88
#include <evmc/evmc.h>
9+
#include <evmc/utils.h>
910

1011
#if __cplusplus
1112
extern "C" {
@@ -15,7 +16,7 @@ extern "C" {
1516
#define NOEXCEPT
1617
#endif
1718

18-
struct evmc_instance* evmc_create_interpreter() NOEXCEPT;
19+
EVMC_EXPORT struct evmc_instance* evmc_create_interpreter() NOEXCEPT;
1920

2021
#if __cplusplus
2122
}

0 commit comments

Comments
 (0)