From c296f1664f3912e3e8173f937fc3f0e3c92a1b2c Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Thu, 24 Mar 2022 19:16:36 -0500 Subject: [PATCH 1/6] Basic vcpkg integration. --- .gitmodules | 3 ++ CMakeLists.txt | 23 ++++++++++--- cmake/FindCLN.cmake | 8 ----- cmake/FindCVC4.cmake | 33 ------------------ cmake/FindGMP.cmake | 8 ----- cmake/FindZ3.cmake | 51 ---------------------------- cmake/fmtlib.cmake | 20 ----------- cmake/jsoncpp.cmake | 70 --------------------------------------- cmake/range-v3.cmake | 38 --------------------- libsolutil/CMakeLists.txt | 2 +- libsolutil/JSON.cpp | 4 +-- vcpkg | 1 + vcpkg.json | 19 +++++++++++ 13 files changed, 45 insertions(+), 235 deletions(-) create mode 100644 .gitmodules delete mode 100644 cmake/FindCLN.cmake delete mode 100644 cmake/FindCVC4.cmake delete mode 100644 cmake/FindGMP.cmake delete mode 100644 cmake/FindZ3.cmake delete mode 100644 cmake/fmtlib.cmake delete mode 100644 cmake/jsoncpp.cmake delete mode 100644 cmake/range-v3.cmake create mode 160000 vcpkg create mode 100644 vcpkg.json diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000000..c7f30b90d2c2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vcpkg"] + path = vcpkg + url = https://github.com/aarlt/vcpkg.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 759f69a538ff..f3aae434e2d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,21 @@ cmake_minimum_required(VERSION 3.13.0) +#set(vcpkg "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") +#if (NOT CMAKE_TOOLCHAIN_FILE) +# if (EXISTS "${vcpkg}") +# set(CMAKE_TOOLCHAIN_FILE "${vcpkg}" +# CACHE FILEPATH "CMake toolchain file") +# else() +# set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" +# CACHE FILEPATH "CMake toolchain file") +# endif() +# message(STATUS "vcpkg toolchain found: ${CMAKE_TOOLCHAIN_FILE}") +#endif () + +set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" + CACHE FILEPATH "CMake toolchain file") +message(STATUS "vcpkg toolchain found: ${CMAKE_TOOLCHAIN_FILE}") + set(ETH_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/cmake" CACHE PATH "The the path to the cmake directory") list(APPEND CMAKE_MODULE_PATH ${ETH_CMAKE_DIR}) @@ -41,10 +57,9 @@ include(EthCcache) # Let's find our dependencies include(EthDependencies) -include(fmtlib) -include(jsoncpp) -include(range-v3) -include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) +find_package(fmt CONFIG REQUIRED) +find_package(jsoncpp CONFIG REQUIRED) +find_package(range-v3 CONFIG REQUIRED) find_package(Threads) diff --git a/cmake/FindCLN.cmake b/cmake/FindCLN.cmake deleted file mode 100644 index 0b574ab9f7cb..000000000000 --- a/cmake/FindCLN.cmake +++ /dev/null @@ -1,8 +0,0 @@ -find_library(CLN_LIBRARY NAMES cln) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CLN DEFAULT_MSG CLN_LIBRARY) - -if(CLN_FOUND AND NOT TARGET CLN::CLN) - add_library(CLN::CLN UNKNOWN IMPORTED) - set_property(TARGET CLN::CLN PROPERTY IMPORTED_LOCATION ${CLN_LIBRARY}) -endif() diff --git a/cmake/FindCVC4.cmake b/cmake/FindCVC4.cmake deleted file mode 100644 index 887b907b8320..000000000000 --- a/cmake/FindCVC4.cmake +++ /dev/null @@ -1,33 +0,0 @@ -if (USE_CVC4) - find_path(CVC4_INCLUDE_DIR cvc4/cvc4.h) - find_library(CVC4_LIBRARY NAMES cvc4) - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(CVC4 DEFAULT_MSG CVC4_LIBRARY CVC4_INCLUDE_DIR) - if(CVC4_FOUND) - # CVC4 may depend on either CLN or GMP. - # We can assume that the one it requires is present on the system, - # so we quietly try to find both and link against them, if they are - # present. - find_package(CLN QUIET) - find_package(GMP QUIET) - - set(CVC4_LIBRARIES ${CVC4_LIBRARY}) - - if (CLN_FOUND) - set(CVC4_LIBRARIES ${CVC4_LIBRARIES} CLN::CLN) - endif () - - if (GMP_FOUND) - set(CVC4_LIBRARIES ${CVC4_LIBRARIES} GMP::GMP) - endif () - - if (NOT TARGET CVC4::CVC4) - add_library(CVC4::CVC4 UNKNOWN IMPORTED) - set_property(TARGET CVC4::CVC4 PROPERTY IMPORTED_LOCATION ${CVC4_LIBRARY}) - set_property(TARGET CVC4::CVC4 PROPERTY INTERFACE_LINK_LIBRARIES ${CVC4_LIBRARIES}) - set_property(TARGET CVC4::CVC4 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CVC4_INCLUDE_DIR}) - endif() - endif() -else() - set(CVC4_FOUND FALSE) -endif() diff --git a/cmake/FindGMP.cmake b/cmake/FindGMP.cmake deleted file mode 100644 index c3a0265429b8..000000000000 --- a/cmake/FindGMP.cmake +++ /dev/null @@ -1,8 +0,0 @@ -find_library(GMP_LIBRARY NAMES gmp) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GMP DEFAULT_MSG GMP_LIBRARY) - -if(GMP_FOUND AND NOT TARGET GMP::GMP) - add_library(GMP::GMP UNKNOWN IMPORTED) - set_property(TARGET GMP::GMP PROPERTY IMPORTED_LOCATION ${GMP_LIBRARY}) -endif() diff --git a/cmake/FindZ3.cmake b/cmake/FindZ3.cmake deleted file mode 100644 index 092b8636b8e9..000000000000 --- a/cmake/FindZ3.cmake +++ /dev/null @@ -1,51 +0,0 @@ -if (USE_Z3) - # Save and clear Z3_FIND_VERSION, since the - # Z3 config module cannot handle version requirements. - set(Z3_FIND_VERSION_ORIG ${Z3_FIND_VERSION}) - set(Z3_FIND_VERSION) - # Try to find Z3 using its stock cmake files. - find_package(Z3 QUIET CONFIG) - # Restore Z3_FIND_VERSION for find_package_handle_standard_args. - set(Z3_FIND_VERSION ${Z3_FIND_VERSION_ORIG}) - set(Z3_FIND_VERSION_ORIG) - - include(FindPackageHandleStandardArgs) - - if (Z3_FOUND) - set(Z3_VERSION ${Z3_VERSION_STRING}) - find_package_handle_standard_args(Z3 CONFIG_MODE) - else() - find_path(Z3_INCLUDE_DIR NAMES z3++.h PATH_SUFFIXES z3) - find_library(Z3_LIBRARY NAMES z3) - find_program(Z3_EXECUTABLE z3 PATH_SUFFIXES bin) - - if(Z3_INCLUDE_DIR AND Z3_LIBRARY) - if(Z3_EXECUTABLE) - execute_process (COMMAND ${Z3_EXECUTABLE} -version - OUTPUT_VARIABLE libz3_version_str - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REGEX REPLACE "^Z3 version ([0-9.]+).*" "\\1" - Z3_VERSION_STRING "${libz3_version_str}") - unset(libz3_version_str) - else() - message(WARNING "Could not determine the version of z3, since the z3 executable was not found.") - set(Z3_VERSION_STRING "0.0.0") - endif() - endif() - mark_as_advanced(Z3_VERSION_STRING z3_DIR) - - find_package_handle_standard_args(Z3 - REQUIRED_VARS Z3_LIBRARY Z3_INCLUDE_DIR - VERSION_VAR Z3_VERSION_STRING) - - if (NOT TARGET z3::libz3) - add_library(z3::libz3 UNKNOWN IMPORTED) - set_property(TARGET z3::libz3 PROPERTY IMPORTED_LOCATION ${Z3_LIBRARY}) - set_property(TARGET z3::libz3 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Z3_INCLUDE_DIR}) - endif() - endif() -else() - set(Z3_FOUND FALSE) -endif() diff --git a/cmake/fmtlib.cmake b/cmake/fmtlib.cmake deleted file mode 100644 index 5ed196cea04d..000000000000 --- a/cmake/fmtlib.cmake +++ /dev/null @@ -1,20 +0,0 @@ -include(FetchContent) - -FetchContent_Declare( - fmtlib - PREFIX "${CMAKE_BINARY_DIR}/deps" - DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" - DOWNLOAD_NAME fmt-8.0.1.tar.gz - URL https://github.com/fmtlib/fmt/archive/8.0.1.tar.gz - URL_HASH SHA256=b06ca3130158c625848f3fb7418f235155a4d389b2abc3a6245fb01cb0eb1e01 -) - -if (CMAKE_VERSION VERSION_LESS "3.14.0") - FetchContent_GetProperties(fmtlib) - if (NOT fmtlib_POPULATED) - FetchContent_Populate(fmtlib) - add_subdirectory(${fmtlib_SOURCE_DIR} ${fmtlib_BINARY_DIR}) - endif() -else() - FetchContent_MakeAvailable(fmtlib) -endif() diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake deleted file mode 100644 index 29b8f5f05138..000000000000 --- a/cmake/jsoncpp.cmake +++ /dev/null @@ -1,70 +0,0 @@ -include(ExternalProject) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") - set(JSONCPP_CMAKE_COMMAND emcmake cmake) -else() - set(JSONCPP_CMAKE_COMMAND ${CMAKE_COMMAND}) -endif() - -set(prefix "${CMAKE_BINARY_DIR}/deps") -set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") -set(JSONCPP_INCLUDE_DIR "${prefix}/include") - -# TODO: Investigate why this breaks some emscripten builds and -# check whether this can be removed after updating the emscripten -# versions used in the CI runs. -if(EMSCRIPTEN) - # Do not include all flags in CMAKE_CXX_FLAGS for emscripten, - # but only use -std=c++17. Using all flags causes build failures - # at the moment. - set(JSONCPP_CXX_FLAGS -std=c++17) -else() - # jsoncpp uses implicit casts for comparing integer and - # floating point numbers. This causes clang-10 (used by ossfuzz builder) - # to error on the implicit conversions. Here, we request jsoncpp - # to unconditionally use static casts for these conversions by defining the - # JSON_USE_INT64_DOUBLE_CONVERSION preprocessor macro. Doing so, - # not only gets rid of the implicit conversion error that clang-10 produces - # but also forces safer behavior in general. - set(JSONCPP_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_USE_INT64_DOUBLE_CONVERSION") -endif() - -set(byproducts "") -if(CMAKE_VERSION VERSION_GREATER 3.1) - set(byproducts BUILD_BYPRODUCTS "${JSONCPP_LIBRARY}") -endif() - -# Propagate CMAKE_MSVC_RUNTIME_LIBRARY on Windows builds, if set. -if (WIN32 AND POLICY CMP0091 AND CMAKE_MSVC_RUNTIME_LIBRARY) - list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW") - list(APPEND JSONCPP_CMAKE_ARGS "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}") -endif() - -ExternalProject_Add(jsoncpp-project - PREFIX "${prefix}" - DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" - DOWNLOAD_NAME jsoncpp-1.9.3.tar.gz - URL https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz - URL_HASH SHA256=8593c1d69e703563d94d8c12244e2e18893eeb9a8a9f8aa3d09a327aa45c8f7d - CMAKE_COMMAND ${JSONCPP_CMAKE_COMMAND} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_INSTALL_LIBDIR=lib - # Build static lib but suitable to be included in a shared lib. - -DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS} - -DJSONCPP_WITH_EXAMPLE=OFF - -DJSONCPP_WITH_TESTS=OFF - -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF - -DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - ${JSONCPP_CMAKE_ARGS} - ${byproducts} -) - -# Create jsoncpp imported library -add_library(jsoncpp STATIC IMPORTED) -file(MAKE_DIRECTORY ${JSONCPP_INCLUDE_DIR}) # Must exist. -set_property(TARGET jsoncpp PROPERTY IMPORTED_LOCATION ${JSONCPP_LIBRARY}) -set_property(TARGET jsoncpp PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR}) -set_property(TARGET jsoncpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR}) -add_dependencies(jsoncpp jsoncpp-project) diff --git a/cmake/range-v3.cmake b/cmake/range-v3.cmake deleted file mode 100644 index d6d9cb773010..000000000000 --- a/cmake/range-v3.cmake +++ /dev/null @@ -1,38 +0,0 @@ -include(ExternalProject) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") - set(RANGE_V3_CMAKE_COMMAND emcmake cmake) -else() - set(RANGE_V3_CMAKE_COMMAND ${CMAKE_COMMAND}) -endif() - -set(prefix "${CMAKE_BINARY_DIR}/deps") -set(RANGE_V3_INCLUDE_DIR "${prefix}/include") - -ExternalProject_Add(range-v3-project - PREFIX "${prefix}" - DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads" - DOWNLOAD_NAME range-v3-0.11.0.tar.gz - URL https://github.com/ericniebler/range-v3/archive/0.11.0.tar.gz - URL_HASH SHA256=376376615dbba43d3bef75aa590931431ecb49eb36d07bb726a19f680c75e20c - CMAKE_COMMAND ${RANGE_V3_CMAKE_COMMAND} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DBUILD_TESTING=OFF - -DRANGES_CXX_STD=${CMAKE_CXX_STANDARD} - -DRANGE_V3_DOCS=OFF - -DRANGE_V3_EXAMPLES=OFF - -DRANGE_V3_TESTS=OFF - -DRANGES_BUILD_CALENDAR_EXAMPLE=OFF - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - BUILD_BYPRODUCTS "${RANGE_V3_INCLUDE_DIR}/range/v3/all.hpp" -) - -# Create range-v3 imported library -add_library(range-v3 INTERFACE IMPORTED) -file(MAKE_DIRECTORY ${RANGE_V3_INCLUDE_DIR}) # Must exist. -set_target_properties(range-v3 PROPERTIES - INTERFACE_COMPILE_OPTIONS "\$<\$:/permissive->" - INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${RANGE_V3_INCLUDE_DIR} - INTERFACE_INCLUDE_DIRECTORIES ${RANGE_V3_INCLUDE_DIR}) -add_dependencies(range-v3 range-v3-project) diff --git a/libsolutil/CMakeLists.txt b/libsolutil/CMakeLists.txt index e055317be706..8795aa0b05df 100644 --- a/libsolutil/CMakeLists.txt +++ b/libsolutil/CMakeLists.txt @@ -42,7 +42,7 @@ set(sources ) add_library(solutil ${sources}) -target_link_libraries(solutil PUBLIC jsoncpp Boost::boost Boost::filesystem Boost::system range-v3) +target_link_libraries(solutil PRIVATE Boost::boost Boost::filesystem Boost::system range-v3 jsoncpp_static) target_include_directories(solutil PUBLIC "${CMAKE_SOURCE_DIR}") add_dependencies(solutil solidity_BuildInfo.h) diff --git a/libsolutil/JSON.cpp b/libsolutil/JSON.cpp index d27982acb364..1eb494eba32a 100644 --- a/libsolutil/JSON.cpp +++ b/libsolutil/JSON.cpp @@ -33,8 +33,8 @@ using namespace std; static_assert( - (JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 3), - "Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.3." + (JSONCPP_VERSION_MAJOR == 1) && (JSONCPP_VERSION_MINOR == 9) && (JSONCPP_VERSION_PATCH == 5), + "Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.5." ); namespace solidity::util diff --git a/vcpkg b/vcpkg new file mode 160000 index 000000000000..c1dc3a612528 --- /dev/null +++ b/vcpkg @@ -0,0 +1 @@ +Subproject commit c1dc3a6125284a9e0c60e95aee05cd809db9fa0b diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000000..7fd598f0d719 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", + "name": "solidity", + "version": "0.8.13", + "dependencies": [ + "boost-system", + "boost-filesystem", + "boost-test", + "boost-program-options", + "boost-multiprecision", + "boost-bimap", + "boost-assign", + "boost-process", + "range-v3", + "fmt", + "jsoncpp", + "z3" + ] +} From a14a7b23ee6793b326bbca321eaeabcf779d83bd Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Fri, 25 Mar 2022 00:14:35 -0500 Subject: [PATCH 2/6] soltest: fix Boost::Test usage. --- CMakeLists.txt | 1 + test/CMakeLists.txt | 2 +- test/boostTest.cpp | 17 ++++------------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3aae434e2d9..0031bdddf528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ include(EthCcache) # Let's find our dependencies include(EthDependencies) +find_package(Boost REQUIRED COMPONENTS filesystem system unit_test_framework program_options) find_package(fmt CONFIG REQUIRED) find_package(jsoncpp CONFIG REQUIRED) find_package(range-v3 CONFIG REQUIRED) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 255218c1592e..33d050bd0df5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -201,7 +201,7 @@ add_executable(soltest ${sources} ${solcli_sources} ${yul_phaser_sources} ) -target_link_libraries(soltest PRIVATE solcli libsolc yul solidity smtutil solutil phaser Boost::boost yulInterpreter evmasm Boost::filesystem Boost::program_options Boost::unit_test_framework evmc) +target_link_libraries(soltest PRIVATE solcli libsolc yul solidity smtutil solutil phaser Boost::boost yulInterpreter evmasm Boost::filesystem Boost::program_options evmc) # Special compilation flag for Visual Studio (version 2019 at least affected) diff --git a/test/boostTest.cpp b/test/boostTest.cpp index 1cc512c325c3..fe0820b66ee4 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -29,7 +29,8 @@ #pragma warning(push) #pragma warning(disable:4535) // calling _set_se_translator requires /EHa #endif -#include +#define BOOST_TEST_NO_MAIN +#include #include #if defined(_MSC_VER) #pragma warning(pop) @@ -217,11 +218,7 @@ void initializeOptions() } -// TODO: Prototype -- why isn't this declared in the boost headers? -// TODO: replace this with a (global) fixture. -test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ); - -test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) +test_suite* solidity_init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) { using namespace solidity::test; @@ -291,17 +288,11 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) return nullptr; } -// BOOST_TEST_DYN_LINK should be defined if user want to link against shared boost test library -#ifdef BOOST_TEST_DYN_LINK - // Because we want to have customized initialization function and support shared boost libraries at the same time, // we are forced to customize the entry point. // see: https://www.boost.org/doc/libs/1_67_0/libs/test/doc/html/boost_test/adv_scenarios/shared_lib_customizations/init_func.html int main(int argc, char* argv[]) { - auto init_unit_test = []() -> bool { init_unit_test_suite(0, nullptr); return true; }; - return boost::unit_test::unit_test_main(init_unit_test, argc, argv); + return ::boost::unit_test::unit_test_main(solidity_init_unit_test_suite, argc, argv); } - -#endif From 8258a0a15231bfc5ca78ba9af9a0cd6c6d700b9e Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Fri, 25 Mar 2022 00:16:04 -0500 Subject: [PATCH 3/6] Rename Instruction::MSIZE to Instruction::_MSIZE. --- libevmasm/Assembly.cpp | 2 +- libevmasm/Instruction.cpp | 4 ++-- libevmasm/Instruction.h | 2 +- libevmasm/SemanticInformation.cpp | 10 +++++----- libevmasm/SimplificationRule.h | 2 +- libyul/backends/evm/EVMDialect.cpp | 2 +- test/libevmasm/Optimiser.cpp | 4 ++-- .../tools/yulInterpreter/EVMInstructionInterpreter.cpp | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 43e06ef9bac9..e79574b740ee 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -426,7 +426,7 @@ map const& Assembly::optimiseInternal( AssemblyItems optimisedItems; bool usesMSize = ranges::any_of(m_items, [](AssemblyItem const& _i) { - return _i == AssemblyItem{Instruction::MSIZE} || _i.type() == VerbatimBytecode; + return _i == AssemblyItem{Instruction::_MSIZE} || _i.type() == VerbatimBytecode; }); auto iter = m_items.begin(); diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index e2ce48b7f104..4227e9beecb6 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -90,7 +90,7 @@ std::map const solidity::evmasm::c_instructions = { "JUMP", Instruction::JUMP }, { "JUMPI", Instruction::JUMPI }, { "PC", Instruction::PC }, - { "MSIZE", Instruction::MSIZE }, + { "MSIZE", Instruction::_MSIZE}, { "GAS", Instruction::GAS }, { "JUMPDEST", Instruction::JUMPDEST }, { "PUSH1", Instruction::PUSH1 }, @@ -237,7 +237,7 @@ static std::map const c_instructionInfo = { Instruction::JUMP, { "JUMP", 0, 1, 0, true, Tier::Mid } }, { Instruction::JUMPI, { "JUMPI", 0, 2, 0, true, Tier::High } }, { Instruction::PC, { "PC", 0, 0, 1, false, Tier::Base } }, - { Instruction::MSIZE, { "MSIZE", 0, 0, 1, false, Tier::Base } }, + { Instruction::_MSIZE, { "MSIZE", 0, 0, 1, false, Tier::Base } }, { Instruction::GAS, { "GAS", 0, 0, 1, false, Tier::Base } }, { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, 0, true, Tier::Special } }, { Instruction::PUSH1, { "PUSH1", 1, 0, 1, false, Tier::VeryLow } }, diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 52bda8bf1d9d..02a6b2c67df9 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -98,7 +98,7 @@ enum class Instruction: uint8_t JUMP, ///< alter the program counter JUMPI, ///< conditionally alter the program counter PC, ///< get the program counter - MSIZE, ///< get the size of active memory + _MSIZE, ///< get the size of active memory GAS, ///< get the amount of available gas JUMPDEST, ///< set a potential jump destination diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index acbcaa5c0f3c..a005f1d6d518 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -141,7 +141,7 @@ vector SemanticInformation::readWriteOperations( Operation{Location::Storage, Effect::Read, {}, {}, {}}, Operation{Location::Storage, Effect::Write, {}, {}, {}} }; - case Instruction::MSIZE: + case Instruction::_MSIZE: // This is just to satisfy the assert below. return vector{}; default: @@ -176,7 +176,7 @@ bool SemanticInformation::breaksCSEAnalysisBlock(AssemblyItem const& _item, bool return false; if (_item.instruction() == Instruction::GAS || _item.instruction() == Instruction::PC) return true; // GAS and PC assume a specific order of opcodes - if (_item.instruction() == Instruction::MSIZE) + if (_item.instruction() == Instruction::_MSIZE) return true; // msize is modified already by memory access, avoid that for now InstructionInfo info = instructionInfo(_item.instruction()); if (_item.instruction() == Instruction::SSTORE) @@ -300,7 +300,7 @@ bool SemanticInformation::isDeterministic(AssemblyItem const& _item) case Instruction::CREATE2: case Instruction::GAS: case Instruction::PC: - case Instruction::MSIZE: // depends on previous writes and reads, not only on content + case Instruction::_MSIZE: // depends on previous writes and reads, not only on content case Instruction::BALANCE: // depends on previous calls case Instruction::SELFBALANCE: // depends on previous calls case Instruction::EXTCODESIZE: @@ -331,7 +331,7 @@ bool SemanticInformation::movable(Instruction _instruction) case Instruction::RETURNDATASIZE: case Instruction::SLOAD: case Instruction::PC: - case Instruction::MSIZE: + case Instruction::_MSIZE: case Instruction::GAS: return false; default: @@ -376,7 +376,7 @@ SemanticInformation::Effect SemanticInformation::memory(Instruction _instruction case Instruction::CREATE2: case Instruction::KECCAK256: case Instruction::MLOAD: - case Instruction::MSIZE: + case Instruction::_MSIZE: case Instruction::RETURN: case Instruction::REVERT: case Instruction::LOG0: diff --git a/libevmasm/SimplificationRule.h b/libevmasm/SimplificationRule.h index d548a00dfb39..97ebeece8091 100644 --- a/libevmasm/SimplificationRule.h +++ b/libevmasm/SimplificationRule.h @@ -134,7 +134,7 @@ struct EVMBuiltins static auto constexpr SLOAD = PatternGenerator{}; static auto constexpr SSTORE = PatternGenerator{}; static auto constexpr PC = PatternGenerator{}; - static auto constexpr MSIZE = PatternGenerator{}; + static auto constexpr MSIZE = PatternGenerator{}; static auto constexpr GAS = PatternGenerator{}; static auto constexpr LOG0 = PatternGenerator{}; static auto constexpr LOG1 = PatternGenerator{}; diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 35fa5f88ebc4..c26d666dab26 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -71,7 +71,7 @@ pair createEVMFunction( f.controlFlowSideEffects.canRevert = false; } } - f.isMSize = _instruction == evmasm::Instruction::MSIZE; + f.isMSize = _instruction == evmasm::Instruction::_MSIZE; f.literalArguments.clear(); f.instruction = _instruction; f.generateCode = [_instruction]( diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index 44fbde9274ea..4ffd8c49c236 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -70,7 +70,7 @@ namespace AssemblyItems input = addDummyLocations(_input); bool usesMsize = ranges::any_of(_input, [](AssemblyItem const& _i) { - return _i == AssemblyItem{Instruction::MSIZE} || _i.type() == VerbatimBytecode; + return _i == AssemblyItem{Instruction::_MSIZE} || _i.type() == VerbatimBytecode; }); evmasm::CommonSubexpressionEliminator cse(_state); BOOST_REQUIRE(cse.feedItems(input.begin(), input.end(), usesMsize) == input.end()); @@ -100,7 +100,7 @@ namespace AssemblyItems optimisedItems; bool usesMSize = ranges::any_of(_input, [](AssemblyItem const& _i) { - return _i == AssemblyItem{Instruction::MSIZE} || _i.type() == VerbatimBytecode; + return _i == AssemblyItem{Instruction::_MSIZE} || _i.type() == VerbatimBytecode; }); auto iter = _input.begin(); diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index 810cf9d181c0..66c562320320 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -287,7 +287,7 @@ u256 EVMInstructionInterpreter::eval( return 0; case Instruction::PC: return 0x77; - case Instruction::MSIZE: + case Instruction::_MSIZE: return m_state.msize; case Instruction::GAS: return 0x99; From 2672be7ccf234a591c460e9e84dd0470048c7a9f Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Fri, 25 Mar 2022 12:38:47 -0500 Subject: [PATCH 4/6] Add git submodule update --init --recursive. --- scripts/build.sh | 2 ++ scripts/build_emscripten.sh | 2 ++ scripts/ci/build.sh | 2 ++ scripts/ci/build_emscripten.sh | 2 ++ scripts/ci/build_ossfuzz.sh | 2 ++ test/boostTest.cpp | 2 ++ 6 files changed, 12 insertions(+) diff --git a/scripts/build.sh b/scripts/build.sh index 6edd60bd9b07..8996c1db0767 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -e +git submodule update --init --recursive + ROOTDIR="$(dirname "$0")/.." BUILDDIR="${ROOTDIR}/build" diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 16e9078f3231..12ddbb8d7627 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -28,6 +28,8 @@ set -e +git submodule update --init --recursive + if test -z "$1"; then BUILD_DIR="emscripten_build" else diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index 87138fb05622..4c3140d36d61 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -ex +git submodule update --init --recursive + ROOTDIR="$(dirname "$0")/../.." cd "${ROOTDIR}" diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index 55d2288c3daf..a58dd18504aa 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -34,6 +34,8 @@ set -ev +git submodule update --init --recursive + if test -z "$1"; then BUILD_DIR="emscripten_build" else diff --git a/scripts/ci/build_ossfuzz.sh b/scripts/ci/build_ossfuzz.sh index 1240b6877f1a..74bf9be4fa50 100755 --- a/scripts/ci/build_ossfuzz.sh +++ b/scripts/ci/build_ossfuzz.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -ex +git submodule update --init --recursive + ROOTDIR="/root/project" BUILDDIR="${ROOTDIR}/build" mkdir -p "${BUILDDIR}" && mkdir -p "$BUILDDIR/deps" diff --git a/test/boostTest.cpp b/test/boostTest.cpp index fe0820b66ee4..4181acba79a2 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -218,6 +218,8 @@ void initializeOptions() } +test_suite* solidity_init_unit_test_suite( int /*argc*/, char* /*argv*/[] ); + test_suite* solidity_init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) { using namespace solidity::test; From c74bca8c679bcdad6390315c7d8be1feba78400e Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Fri, 25 Mar 2022 12:51:44 -0500 Subject: [PATCH 5/6] apt-get install curl zip unzip tar. --- scripts/build.sh | 2 ++ scripts/build_emscripten.sh | 2 ++ scripts/ci/build.sh | 2 ++ scripts/ci/build_emscripten.sh | 2 ++ scripts/ci/build_ossfuzz.sh | 2 ++ 5 files changed, 10 insertions(+) diff --git a/scripts/build.sh b/scripts/build.sh index 8996c1db0767..b3b832ca1c8d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -e +apt-get update +apt-get install curl zip unzip tar git submodule update --init --recursive ROOTDIR="$(dirname "$0")/.." diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 12ddbb8d7627..9c1c55aa5b32 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -28,6 +28,8 @@ set -e +apt-get update +apt-get install curl zip unzip tar git submodule update --init --recursive if test -z "$1"; then diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index 4c3140d36d61..c6a932c5e7f4 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -ex +apt-get update +apt-get install curl zip unzip tar git submodule update --init --recursive ROOTDIR="$(dirname "$0")/../.." diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index a58dd18504aa..4fa5e051d687 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -34,6 +34,8 @@ set -ev +apt-get update +apt-get install curl zip unzip tar git submodule update --init --recursive if test -z "$1"; then diff --git a/scripts/ci/build_ossfuzz.sh b/scripts/ci/build_ossfuzz.sh index 74bf9be4fa50..2586c67e4cac 100755 --- a/scripts/ci/build_ossfuzz.sh +++ b/scripts/ci/build_ossfuzz.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -ex +apt-get update +apt-get install curl zip unzip tar git submodule update --init --recursive ROOTDIR="/root/project" From ebf3f6156da23b34c47b47f0767fa743d4aad800 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Fri, 25 Mar 2022 12:53:55 -0500 Subject: [PATCH 6/6] apt-get install -y curl zip unzip tar. --- scripts/build.sh | 2 +- scripts/build_emscripten.sh | 2 +- scripts/ci/build.sh | 2 +- scripts/ci/build_emscripten.sh | 2 +- scripts/ci/build_ossfuzz.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index b3b832ca1c8d..fefca88d925a 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,7 +2,7 @@ set -e apt-get update -apt-get install curl zip unzip tar +apt-get install -y curl zip unzip tar git submodule update --init --recursive ROOTDIR="$(dirname "$0")/.." diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 9c1c55aa5b32..38f99ddc0203 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -29,7 +29,7 @@ set -e apt-get update -apt-get install curl zip unzip tar +apt-get install -y curl zip unzip tar git submodule update --init --recursive if test -z "$1"; then diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index c6a932c5e7f4..40f5b41b8dc7 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -2,7 +2,7 @@ set -ex apt-get update -apt-get install curl zip unzip tar +apt-get install -y curl zip unzip tar git submodule update --init --recursive ROOTDIR="$(dirname "$0")/../.." diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index 4fa5e051d687..f6f248a10507 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -35,7 +35,7 @@ set -ev apt-get update -apt-get install curl zip unzip tar +apt-get install -y curl zip unzip tar git submodule update --init --recursive if test -z "$1"; then diff --git a/scripts/ci/build_ossfuzz.sh b/scripts/ci/build_ossfuzz.sh index 2586c67e4cac..f3b13f5d9e7b 100755 --- a/scripts/ci/build_ossfuzz.sh +++ b/scripts/ci/build_ossfuzz.sh @@ -2,7 +2,7 @@ set -ex apt-get update -apt-get install curl zip unzip tar +apt-get install -y curl zip unzip tar git submodule update --init --recursive ROOTDIR="/root/project"