diff --git a/.gitmodules b/.gitmodules index f2c1eb62c5..6ef39354df 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,9 +10,6 @@ [submodule "libraries/native/softfloat"] path = libraries/native/softfloat url = https://github.com/AntelopeIO/berkeley-softfloat-3 -[submodule "tools/external/eos-vm"] - path = tools/external/eos-vm - url = https://github.com/AntelopeIO/eos-vm [submodule "tools/external/antler-proj"] path = tools/external/antler-proj - url = https://github.com/AntelopeIO/antler-proj + url = https://github.com/AntelopeIO/antler-proj \ No newline at end of file diff --git a/libraries/eosiolib/CMakeLists.txt b/libraries/eosiolib/CMakeLists.txt index 805cccbc05..a716dde5bb 100644 --- a/libraries/eosiolib/CMakeLists.txt +++ b/libraries/eosiolib/CMakeLists.txt @@ -1,72 +1,49 @@ -set(PARENT_PROJECT_NAME ${PROJECT_NAME}) - file(GLOB HEADERS "*.hpp" "*.h") -if (${PARENT_PROJECT_NAME} STREQUAL "cdt_tools") - project(native_eosio) - add_library( ${PROJECT_NAME} - eosiolib.cpp - crypto.cpp - malloc.cpp - ${HEADERS} ) - target_compile_definitions(${PROJECT_NAME} PUBLIC EOSIO_NATIVE EOSIOLIB_DISABLE_MALLOC) - target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/../libraries/eosiolib/core - ${CMAKE_SOURCE_DIR}/../libraries/meta_refl/include) - target_compile_options(${PROJECT_NAME} PUBLIC -fPIC -fexceptions -fno-rtti) - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0") - target_compile_options(${PROJECT_NAME} PUBLIC -Wno-attributes) - else() - target_compile_options(${PROJECT_NAME} PUBLIC -Wno-attributes=gnu::eosio_wasm_import) - target_compile_options(${PROJECT_NAME} PUBLIC -Wno-attributes=eosio::ignore) - endif() - endif() -else() - add_library(eosio - eosiolib.cpp - crypto.cpp - ${HEADERS}) +add_library(eosio + eosiolib.cpp + crypto.cpp + ${HEADERS}) - add_library(eosio_malloc - malloc.cpp - ${HEADERS}) +add_library(eosio_malloc + malloc.cpp + ${HEADERS}) - add_library(eosio_dsm - simple_malloc.cpp - ${HEADERS}) +add_library(eosio_dsm + simple_malloc.cpp + ${HEADERS}) - add_library(eosio_cmem - memory.cpp - ${HEADERS}) +add_library(eosio_cmem + memory.cpp + ${HEADERS}) - set_target_properties(eosio_malloc PROPERTIES LINKER_LANGUAGE C) +set_target_properties(eosio_malloc PROPERTIES LINKER_LANGUAGE C) - target_include_directories(eosio PUBLIC - ${CMAKE_SOURCE_DIR}/libc/cdt-musl/include - ${CMAKE_SOURCE_DIR}/libc/cdt-musl/src/internal - ${CMAKE_SOURCE_DIR}/libc/cdt-musl/src/crypt - ${CMAKE_SOURCE_DIR}/libc/cdt-musl/arch/eos - ${CMAKE_SOURCE_DIR}/libc++/cdt-libcxx/include - ${CMAKE_SOURCE_DIR}) +target_include_directories(eosio PUBLIC + ${CMAKE_SOURCE_DIR}/libc/cdt-musl/include + ${CMAKE_SOURCE_DIR}/libc/cdt-musl/src/internal + ${CMAKE_SOURCE_DIR}/libc/cdt-musl/src/crypt + ${CMAKE_SOURCE_DIR}/libc/cdt-musl/arch/eos + ${CMAKE_SOURCE_DIR}/libc++/cdt-libcxx/include + ${CMAKE_SOURCE_DIR}) - target_link_libraries( eosio c c++ ) - add_custom_command( TARGET eosio POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) - add_custom_command( TARGET eosio_malloc POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) - add_custom_command( TARGET eosio_dsm POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) - add_custom_command( TARGET eosio_cmem POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) +target_link_libraries( eosio c c++ ) +add_custom_command( TARGET eosio POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) +add_custom_command( TARGET eosio_malloc POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) +add_custom_command( TARGET eosio_dsm POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) +add_custom_command( TARGET eosio_cmem POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) - if (ENABLE_NATIVE_COMPILER) - add_native_library(native_eosio - eosiolib.cpp - crypto.cpp - malloc.cpp - ${HEADERS}) +if (ENABLE_NATIVE_COMPILER) + add_native_library(native_eosio + eosiolib.cpp + crypto.cpp + malloc.cpp + ${HEADERS}) - add_dependencies( native_eosio eosio ) - add_custom_command( TARGET native_eosio POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) - endif() + add_dependencies( native_eosio eosio ) + add_custom_command( TARGET native_eosio POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) +endif() - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../eosiolib DESTINATION ${BASE_BINARY_DIR}/include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp") -endif() \ No newline at end of file +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../eosiolib DESTINATION ${BASE_BINARY_DIR}/include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp") diff --git a/libraries/eosiolib/capi/eosio/db.h b/libraries/eosiolib/capi/eosio/db.h index ae58579b46..e21f20caf7 100644 --- a/libraries/eosiolib/capi/eosio/db.h +++ b/libraries/eosiolib/capi/eosio/db.h @@ -6,8 +6,6 @@ #pragma once #include "types.h" -#include "eosio/types.hpp" - #ifdef __cplusplus extern "C" { #endif diff --git a/libraries/eosiolib/capi/eosio/types.h b/libraries/eosiolib/capi/eosio/types.h index b3f54915b9..9350b9b4d1 100644 --- a/libraries/eosiolib/capi/eosio/types.h +++ b/libraries/eosiolib/capi/eosio/types.h @@ -32,12 +32,7 @@ typedef uint64_t capi_name; /** * EOSIO Public Key. K1 and R1 keys are 34 bytes. Newer keys can be variable-sized */ -struct -#ifdef __GNUC__ -__attribute__((deprecated("newer public key types cannot be represented as a fixed size structure, use char[] instead"))) -#else -__attribute__((deprecated("newer public key types cannot be represented as a fixed size structure", "char[]"))) -#endif +struct __attribute__((deprecated("newer public key types cannot be represented as a fixed size structure", "char[]"))) capi_public_key { char data[34]; }; @@ -45,12 +40,7 @@ capi_public_key { /** * EOSIO Signature. K1 and R1 signatures are 66 bytes. Newer signatures can be variable-sized */ -struct -#ifdef __GNUC__ -__attribute__((deprecated("newer public key types cannot be represented as a fixed size structure, use char[] instead"))) -#else -__attribute__((deprecated("newer public key types cannot be represented as a fixed size structure", "char[]"))) -#endif +struct __attribute__((deprecated("newer signature types cannot be represented as a fixed size structure", "char[]"))) capi_signature { uint8_t data[66]; }; diff --git a/libraries/eosiolib/contracts/eosio/action.hpp b/libraries/eosiolib/contracts/eosio/action.hpp index ecd71a8b4d..d043931e25 100644 --- a/libraries/eosiolib/contracts/eosio/action.hpp +++ b/libraries/eosiolib/contracts/eosio/action.hpp @@ -323,12 +323,12 @@ namespace eosio { /** * Name of the account the action is intended for */ - eosio::name account; + name account; /** * Name of the action */ - eosio::name name; + name name; /** * List of permissions that authorize this action diff --git a/libraries/eosiolib/core/eosio/datastream.hpp b/libraries/eosiolib/core/eosio/datastream.hpp index 7b9cb4e75c..2097df5c7f 100644 --- a/libraries/eosiolib/core/eosio/datastream.hpp +++ b/libraries/eosiolib/core/eosio/datastream.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include namespace eosio { diff --git a/libraries/eosiolib/core/eosio/fixed_bytes.hpp b/libraries/eosiolib/core/eosio/fixed_bytes.hpp index 812117b4d6..97cbf40bb8 100644 --- a/libraries/eosiolib/core/eosio/fixed_bytes.hpp +++ b/libraries/eosiolib/core/eosio/fixed_bytes.hpp @@ -4,7 +4,6 @@ */ #pragma once #include "datastream.hpp" -#include "types.hpp" #include #include diff --git a/libraries/eosiolib/core/eosio/print.hpp b/libraries/eosiolib/core/eosio/print.hpp index de8db22ae6..c2ee216fdc 100644 --- a/libraries/eosiolib/core/eosio/print.hpp +++ b/libraries/eosiolib/core/eosio/print.hpp @@ -5,7 +5,7 @@ #pragma once #include #include -#include "types.hpp" + namespace eosio { diff --git a/libraries/eosiolib/core/eosio/reflect.hpp b/libraries/eosiolib/core/eosio/reflect.hpp index bd74557254..683342638b 100644 --- a/libraries/eosiolib/core/eosio/reflect.hpp +++ b/libraries/eosiolib/core/eosio/reflect.hpp @@ -3,4 +3,4 @@ #include #define CDT_REFLECT(...) \ - BLUEGRASS_META_REFL(__VA_ARGS__); + BLUEGRASS_META_REFL(__VA_ARGS__); \ diff --git a/libraries/eosiolib/core/eosio/types.hpp b/libraries/eosiolib/core/eosio/types.hpp deleted file mode 100644 index af5c5d7075..0000000000 --- a/libraries/eosiolib/core/eosio/types.hpp +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @file - * @copyright defined in eos/LICENSE - */ -#pragma once - -#ifdef __GNUC__ -typedef __int128 int128_t; -typedef unsigned __int128 uint128_t; -#endif \ No newline at end of file diff --git a/libraries/eosiolib/malloc.cpp b/libraries/eosiolib/malloc.cpp index 9f936b2933..2f3585baa9 100644 --- a/libraries/eosiolib/malloc.cpp +++ b/libraries/eosiolib/malloc.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "core/eosio/check.hpp" #include "core/eosio/print.hpp" @@ -526,8 +525,6 @@ namespace eosio { } /// namespace eosio extern "C" { -#ifndef EOSIOLIB_DISABLE_MALLOC - void* malloc(size_t size) { return eosio::memory_heap.malloc(size); } @@ -545,6 +542,5 @@ void* realloc(void* ptr, size_t size) { void free(void* ptr) { return eosio::memory_heap.free(ptr); } -#endif } diff --git a/libraries/meta_refl/include/bluegrass/meta/function_traits.hpp b/libraries/meta_refl/include/bluegrass/meta/function_traits.hpp index 1614d4e522..f02731bbfc 100644 --- a/libraries/meta_refl/include/bluegrass/meta/function_traits.hpp +++ b/libraries/meta_refl/include/bluegrass/meta/function_traits.hpp @@ -34,7 +34,7 @@ #define BLUEGRASS_HAS_TEMPLATE_MEMBER(ARG, NAME) \ bluegrass::meta::overloaded { \ - [](auto&& f, std::enable_if_t> && \ + [&](auto&& f, std::enable_if_t> && \ bluegrass::meta::detail::pass_type< \ decltype(&std::decay_t::type::template NAME)>(), int> = 0) constexpr { \ return true; \ diff --git a/libraries/native/CMakeLists.txt b/libraries/native/CMakeLists.txt index 19ad02f238..68ed5238ab 100644 --- a/libraries/native/CMakeLists.txt +++ b/libraries/native/CMakeLists.txt @@ -1,5 +1,3 @@ -set(PARENT_PROJECT_NAME ${PROJECT_NAME}) - project(native LANGUAGES CXX ASM) if (NOT __APPLE) @@ -8,10 +6,8 @@ else() set(CRT_ASM macho_crt.s) endif() -if (NOT ${PARENT_PROJECT_NAME} MATCHES "cdt_tools") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-everything -allow-sse") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-everything -allow-sse") -endif() +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-everything -allow-sse") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-everything -allow-sse") file(GLOB HEADERS "*.hpp" "*.h") @@ -336,29 +332,15 @@ list( APPEND softfloat_sources ${softfloat_headers} ) add_library ( sf STATIC ${softfloat_sources} ) target_include_directories( sf PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/source/include" "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/source/8086-SSE" "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/build/Linux-x86_64-GCC" ${CMAKE_SOURCE_DIR}) -if (${PARENT_PROJECT_NAME} STREQUAL "cdt_tools") - add_library(${PROJECT_NAME} STATIC ${softfloat_sources} intrinsics.cpp crt_lib.cpp) - - target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/../libraries/eosiolib/core - ${CMAKE_SOURCE_DIR}/../libraries/eosiolib/contracts - ${CMAKE_SOURCE_DIR}/../libraries/eosiolib/capi - ${CMAKE_SOURCE_DIR}/../libraries/meta_refl/include) - # suppress executable stack warning. this is due to absence of .note.GNU-stack - target_link_libraries(${PROJECT_NAME} PUBLIC "-Wl,-z,noexecstack") -else() - add_native_library ( native STATIC ${softfloat_sources} intrinsics.cpp crt.cpp ${CRT_ASM}) -endif() - +add_native_library ( native STATIC ${softfloat_sources} intrinsics.cpp crt.cpp ${CRT_ASM} ) target_include_directories( native PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/source/include" "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/source/8086-SSE" "${CMAKE_CURRENT_SOURCE_DIR}/softfloat/build/Linux-x86_64-GCC" ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/eosiolib/capi ${CMAKE_SOURCE_DIR}/eosiolib/contracts ${CMAKE_SOURCE_DIR}/eosiolib/core) add_dependencies(native native_eosio) -if (NOT ${PARENT_PROJECT_NAME} MATCHES "cdt_tools") - add_custom_command( TARGET native POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) +add_custom_command( TARGET native POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) - add_custom_command( TARGET sf POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) +add_custom_command( TARGET sf POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${BASE_BINARY_DIR}/lib ) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${BASE_BINARY_DIR}/include/eosio FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "softfloat" EXCLUDE) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${BASE_BINARY_DIR}/include/eosio FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "softfloat" EXCLUDE) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/native DESTINATION ${BASE_BINARY_DIR}/include/eosiolib FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "softfloat" EXCLUDE) -endif() \ No newline at end of file +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/native DESTINATION ${BASE_BINARY_DIR}/include/eosiolib FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "softfloat" EXCLUDE) diff --git a/libraries/native/crt.cpp b/libraries/native/crt.cpp index d75c6c44f6..112820eda0 100644 --- a/libraries/native/crt.cpp +++ b/libraries/native/crt.cpp @@ -64,9 +64,6 @@ extern "C" { } } - jmp_buf* __get_jmp_buf() { - return ___env_ptr; - } void __set_env_test() { ___env_ptr = &test_env; } diff --git a/libraries/native/crt_lib.cpp b/libraries/native/crt_lib.cpp deleted file mode 100644 index 1f5021b257..0000000000 --- a/libraries/native/crt_lib.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "native/eosio/crt.hpp" - -#include - -eosio::cdt::output_stream std_out; -eosio::cdt::output_stream std_err; - -bool ___disable_output = false; -bool ___has_failed = false; -bool ___earlier_unit_test_has_failed = false; -static jmp_buf env; -static jmp_buf test_env; -jmp_buf* ___env_ptr = &env; - -jmp_buf* __get_jmp_buf() { - return ___env_ptr; -} -void __set_env_test() { - ___env_ptr = &test_env; -} -void __reset_env() { - ___env_ptr = &env; -} - -void _prints_l(const char* cstr, uint32_t len, uint8_t which) { - for (int i=0; i < len; i++) { - if (which == eosio::cdt::output_stream_kind::std_out) - std_out.push(cstr[i]); - else if (which == eosio::cdt::output_stream_kind::std_err) - std_err.push(cstr[i]); - if (!___disable_output) { - std::putc(cstr[i], which == eosio::cdt::output_stream_kind::std_out ? stdout : stderr); - } - } -} -void _prints(const char* cstr, uint8_t which) { - for (int i=0; cstr[i] != '\0'; i++) { - if (which == eosio::cdt::output_stream_kind::std_out) - std_out.push(cstr[i]); - else if (which == eosio::cdt::output_stream_kind::std_err) - std_err.push(cstr[i]); - if (!___disable_output) - std::putc(cstr[i], which == eosio::cdt::output_stream_kind::std_out ? stdout : stderr); - } -} \ No newline at end of file diff --git a/libraries/native/native/eosio/crt.hpp b/libraries/native/native/eosio/crt.hpp index 9e9d23e3fb..5d81a60015 100644 --- a/libraries/native/native/eosio/crt.hpp +++ b/libraries/native/native/eosio/crt.hpp @@ -4,7 +4,6 @@ #include namespace eosio { namespace cdt { - enum output_stream_kind { std_out, std_err, @@ -26,15 +25,10 @@ namespace eosio { namespace cdt { extern eosio::cdt::output_stream std_out; extern eosio::cdt::output_stream std_err; +extern "C" jmp_buf* ___env_ptr; +extern "C" char* ___heap_ptr; extern "C" { - extern jmp_buf* ___env_ptr; - extern char* ___heap_ptr; - extern bool ___disable_output; - extern bool ___has_failed; - extern bool ___earlier_unit_test_has_failed; - - jmp_buf* __get_jmp_buf(); void __set_env_test(); void __reset_env(); void _prints_l(const char* cstr, uint32_t len, uint8_t which); diff --git a/modules/CDTMacros.cmake.in b/modules/CDTMacros.cmake.in index 99ddd0ee8b..f40559c093 100644 --- a/modules/CDTMacros.cmake.in +++ b/modules/CDTMacros.cmake.in @@ -20,7 +20,7 @@ endmacro() macro (add_native_library TARGET) add_library( ${TARGET} ${ARGN} ) - target_compile_options( ${TARGET} PUBLIC -fnative -fPIC ) + target_compile_options( ${TARGET} PUBLIC -fnative ) endmacro() macro (add_native_executable TARGET) @@ -37,17 +37,3 @@ macro (add_native_executable TARGET) endif() endmacro() -macro (add_native_shared_lib TARGET) - set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) - add_library( ${TARGET} SHARED ${ARGN} ) - target_compile_options( ${TARGET} PUBLIC -fnative ) - get_target_property(BINOUTPUT ${TARGET} BINARY_DIR) - if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND APPLE) - target_compile_options( ${TARGET} PUBLIC -g ) - find_program ( name NAMES "dsymutil" ) - if ( name ) - add_custom_command( TARGET ${TARGET} POST_BUILD COMMAND dsymutil ${BINOUTPUT}/${TARGET} ) - endif() - endif() -endmacro() - diff --git a/modules/CDTWasmToolchain.cmake.in b/modules/CDTWasmToolchain.cmake.in index 4343fdb787..c22b1a7a85 100644 --- a/modules/CDTWasmToolchain.cmake.in +++ b/modules/CDTWasmToolchain.cmake.in @@ -21,7 +21,6 @@ set(WASM_LINKER "@CDT_ROOT_DIR@/bin/cdt-ld") set(CMAKE_C_LINK_EXECUTABLE "${WASM_LINKER} -o ") set(CMAKE_CXX_LINK_EXECUTABLE "${WASM_LINKER} -o ") -set(CMAKE_CXX_CREATE_SHARED_LIBRARY "${WASM_LINKER} -shared -o ") set(CMAKE_EXECUTABLE_SUFFIX_C ".wasm") set(CMAKE_EXECUTABLE_SUFFIX_CXX ".wasm") diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 06d53ee67c..df4ebf1698 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.5) -project(cdt_tools) find_package(LLVM REQUIRED CONFIG) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") @@ -26,9 +25,7 @@ add_definitions(${LLVM_DEFINITIONS}) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(CMAKE_CXX_STANDARD 17) set(EOSIO_STACK_SIZE 8192) -set(ENABLE_NATIVE_COMPILER TRUE) macro (add_tool name) set(LLVM_LINK_COMPONENTS support) @@ -75,14 +72,11 @@ macro (add_tool name) add_custom_command( TARGET ${name} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR}/bin/ ) endmacro() -add_subdirectory(../libraries/eosiolib ${CMAKE_BINARY_DIR}/eosiolib) -add_subdirectory(../libraries/native ${CMAKE_BINARY_DIR}/native) add_subdirectory(abidiff) add_subdirectory(cc) add_subdirectory(ld) add_subdirectory(init) add_subdirectory(external) -#add_subdirectory(antler-run) # TODO: add back when it will be ready configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/compiler_options.hpp.in ${CMAKE_BINARY_DIR}/compiler_options.hpp) diff --git a/tools/antler-run/CMakeLists.txt b/tools/antler-run/CMakeLists.txt deleted file mode 100644 index c4e2071402..0000000000 --- a/tools/antler-run/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -project(antler-run) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/antler-run.cpp ${CMAKE_BINARY_DIR}/antler-run.cpp) -find_package(eos-vm) - -set(TOOLS_DIR ${CMAKE_SOURCE_DIR}) -set(LIB_DIR ${CMAKE_SOURCE_DIR}/../libraries) -set(CDT_NO_START TRUE) - -include_directories(${LIB_DIR}) - -add_tool(antler-run) -target_compile_options(${PROJECT_NAME} PUBLIC -ldl) -set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath,\"\\$ORIGIN/../lib\"") -target_include_directories(${PROJECT_NAME} PUBLIC ${TOOLS_DIR}/external/eos-vm/include - ${LIB_DIR}/eosiolib/contracts - ${LIB_DIR}/eosiolib/core - ${LIB_DIR}/eosiolib/capi - ${LIB_DIR}/eosiolib/native - ${LIB_DIR}/native - ${LIB_DIR}/meta_refl/include) -target_link_libraries(${PROJECT_NAME} native_eosio native) \ No newline at end of file diff --git a/tools/antler-run/antler-run.cpp b/tools/antler-run/antler-run.cpp deleted file mode 100644 index 521f7617f8..0000000000 --- a/tools/antler-run/antler-run.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "options.hpp" -#include "file-utils.hpp" - -#include -#include -#include - -#include -#include - -#include -#include - -#include "llvm/Support/CommandLine.h" - -using namespace eosio; -using namespace eosio::cdt; -using namespace eosio::native; -using namespace eosio::vm; -using namespace llvm; - -int main(int argc, const char **argv) { - - cl::SetVersionPrinter([](llvm::raw_ostream& os) { - os << "Antler-run version ${VERSION_FULL}" << "\n"; - }); - - cl::ParseCommandLineOptions(argc, argv); - - const auto& contract_path = contract_path_opt.getValue(); - - if (test_so_opt) { - auto contract_type = utils::get_file_type(contract_path.c_str()); - if ( contract_type != utils::file_type::elf_shared_object ) { - fprintf(stderr, "not a shared object file: %s\n", file_type_str(contract_type).c_str()); - } - // TODO: add check for neccesary exports - // TODO: add unit test that generates shared object and executes runner with this flag - return 0; - } - - const auto& node_url = nodeos_url_opt.getValue(); - const auto& node_port = nodeos_port_opt.getValue(); - const auto& action = action_name_opt.getValue(); - const auto& account = register_opt.getValue(); - - //TODO add runner implementation here - - return 0; -} \ No newline at end of file diff --git a/tools/antler-run/file-utils.hpp b/tools/antler-run/file-utils.hpp deleted file mode 100644 index b54f8924c9..0000000000 --- a/tools/antler-run/file-utils.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include -#include - -namespace eosio { namespace utils { - -enum class file_type { - uninitialized, - non_elf_other, - elf_object, - elf_executable, - elf_shared_object, - elf_core_dump, - wasm -}; - -inline file_type get_file_type(const char* path) { - std::fstream file; - file.open(path, std::fstream::in | std::fstream::binary); - assert(file.is_open()); - - std::vector buf(17); - file.read(buf.data(), buf.size()); - - if (buf[0] == 0x7F && - buf[1] == 'E' && - buf[2] == 'L' && - buf[3] == 'F') { - //ELF binary - switch (buf[16]) { - case 1: - return file_type::elf_object; - case 2: - return file_type::elf_executable; - case 3: - return file_type::elf_shared_object; - case 4: - return file_type::elf_core_dump; - } - } else { - uint32_t wasm_magic; - memcpy(&wasm_magic, buf.data(), sizeof(wasm_magic)); - if (wasm_magic == eosio::vm::magic) - return file_type::wasm; - - return file_type::non_elf_other; - } - - return file_type::uninitialized; -} - -inline std::string file_type_str(file_type t) { - switch (t) { - case file_type::non_elf_other: - return "non elf"; - case file_type::elf_object: - return "object"; - case file_type::elf_executable: - return "executable"; - case file_type::elf_shared_object: - return "shared object"; - case file_type::elf_core_dump: - return "core dump"; - case file_type::wasm: - return "wasm"; - case file_type::uninitialized: - default: - return "uninitialized"; - } -} - -}} // eosio::utils \ No newline at end of file diff --git a/tools/antler-run/options.hpp b/tools/antler-run/options.hpp deleted file mode 100644 index 3f65f18041..0000000000 --- a/tools/antler-run/options.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include "llvm/Support/CommandLine.h" - -#include - -static llvm::cl::OptionCategory AntlerRunOptions("Runner options"); - -llvm::cl::opt contract_path_opt ( "contract", - llvm::cl::desc("Smart contract path to debug. It could be either wasm or native shared object"), - llvm::cl::cat(AntlerRunOptions), - llvm::cl::Required ); -llvm::cl::opt test_so_opt ( "test", - llvm::cl::desc("Test that shared object is loadable and has neccesary exports"), - llvm::cl::cat(AntlerRunOptions), - llvm::cl::ZeroOrMore ); -llvm::cl::opt nodeos_url_opt ( "nodeos-url", - llvm::cl::desc("`nodeos` URL"), - llvm::cl::cat(AntlerRunOptions), - llvm::cl::ZeroOrMore ); -llvm::cl::opt nodeos_port_opt ( "nodeos-port", - llvm::cl::desc("`nodeos` port"), - llvm::cl::cat(AntlerRunOptions), - llvm::cl::ZeroOrMore ); -llvm::cl::opt action_name_opt ( "call-action", - llvm::cl::desc("Action that will be called"), - llvm::cl::cat(AntlerRunOptions), - llvm::cl::ZeroOrMore ); -llvm::cl::opt register_opt ( "register", - llvm::cl::desc("Register an account name to be debuggable through `nodeos`"), - llvm::cl::cat(AntlerRunOptions), - llvm::cl::ZeroOrMore ); diff --git a/tools/external/CMakeLists.txt b/tools/external/CMakeLists.txt index e486f2dcb0..4f5e28cc78 100644 --- a/tools/external/CMakeLists.txt +++ b/tools/external/CMakeLists.txt @@ -1,3 +1,2 @@ add_subdirectory(wabt) -add_subdirectory(eos-vm) add_subdirectory(antler-proj) \ No newline at end of file diff --git a/tools/external/eos-vm b/tools/external/eos-vm deleted file mode 160000 index 1592261e96..0000000000 --- a/tools/external/eos-vm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1592261e96a5ebb4a5f261d7167c0723ca941b9b diff --git a/tools/include/compiler_options.hpp.in b/tools/include/compiler_options.hpp.in index 038e52f911..e94e8d57e2 100644 --- a/tools/include/compiler_options.hpp.in +++ b/tools/include/compiler_options.hpp.in @@ -132,11 +132,6 @@ static cl::opt fnative_opt( cl::desc("Compile and link for x86-64"), cl::ZeroOrMore, cl::cat(LD_CAT)); -static cl::opt fshared_opt( - "shared", - cl::desc("Make shared object native library"), - cl::ZeroOrMore, - cl::cat(LD_CAT)); static cl::opt fuse_main_opt( "fuse-main", cl::desc("Use main as entry"), @@ -361,11 +356,6 @@ static cl::opt warn_action_read_only_opt( "warn-action-read-only", cl::desc("Issue a warning if a read-only action uses a write API and continue compilation"), cl::cat(EosioCompilerToolCategory)); -static cl::opt fPIC_opt( - "fPIC", - cl::desc("Generate position independent code. This option is used for shared libraries"), - cl::Optional, - cl::cat(LD_CAT)); /// end c/c++ options /// begin c++ options @@ -402,7 +392,6 @@ struct Options { std::vector abigen_resources; bool debug; bool native; - bool shared_lib; std::pair abi_version; bool has_o_opt; bool has_contract_opt; @@ -416,7 +405,7 @@ static void GetCompDefaults(std::vector& copts) { copts.emplace_back(std::string("-D__eosio_cdt_major__=")+"${VERSION_MAJOR}"); copts.emplace_back(std::string("-D__eosio_cdt_minor__=")+"${VERSION_MINOR}"); copts.emplace_back(std::string("-D__eosio_cdt_patchlevel__=")+"${VERSION_PATCH}"); - if (!fnative_opt && !fshared_opt) { + if (!fnative_opt) { copts.emplace_back("--target=wasm32"); copts.emplace_back("-ffreestanding"); copts.emplace_back("-nostdlib"); @@ -451,7 +440,7 @@ static void GetCompDefaults(std::vector& copts) { copts.emplace_back("-DBOOST_DISABLE_ASSERTS"); copts.emplace_back("-DBOOST_EXCEPTION_DISABLE"); copts.emplace_back("-U__APPLE__"); - if (!fnative_opt && !fshared_opt) { + if (!fnative_opt) { copts.emplace_back("-Xclang"); copts.emplace_back("-load"); copts.emplace_back("-Xclang"); @@ -478,7 +467,7 @@ static void GetCompDefaults(std::vector& copts) { #ifdef ONLY_LD static void GetLdDefaults(std::vector& ldopts) { - if (!fnative_opt && !fshared_opt) { + if (!fnative_opt) { if (!allow_names_opt) { ldopts.emplace_back("--gc-sections"); ldopts.emplace_back("--strip-all"); @@ -565,22 +554,13 @@ static void GetLdDefaults(std::vector& ldopts) { sdkpath.resize(sdkpath.size()-1); ldopts.insert(ldopts.end(), {"-syslibroot", sdkpath}); #endif - if (fshared_opt) { - ldopts.emplace_back("-shared"); - } - else { - ldopts.emplace_back("-static"); - } + ldopts.emplace_back("-static"); ldopts.insert(ldopts.end(), {"-lnative_c++", "-lnative_c", "-lnative_eosio", "-lnative", "-lnative_rt"}); } } #endif static Options CreateOptions(bool add_defaults=true) { - if (fshared_opt && fnative_opt) { - throw std::runtime_error("Both -fnative and -fshared was specified. Only one of them should be present."); - } - std::string output_fn; std::vector inputs; std::vector agresources; @@ -760,7 +740,7 @@ static Options CreateOptions(bool add_defaults=true) { copts.emplace_back("-I"+sysroot_opt+"/include/libc"); // only allow capi for native builds and for eosio-cc - if (fnative_opt || fshared_opt) { + if (fnative_opt) { copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/capi"); copts.emplace_back("-I"+sysroot_opt+"/include/eosiolib/native"); } @@ -786,7 +766,7 @@ static Options CreateOptions(bool add_defaults=true) { agopts.emplace_back("--sysroot="+eosio::cdt::whereami::where()+"/../"); ldopts.emplace_back("-L"+eosio::cdt::whereami::where()+"/../lib"); - if (fnative_opt || fshared_opt) { + if (fnative_opt) { copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/capi"); copts.emplace_back("-I"+eosio::cdt::whereami::where()+"/../include/eosiolib/native"); } @@ -825,12 +805,8 @@ static Options CreateOptions(bool add_defaults=true) { copts.emplace_back("-W"+warn); } - if (fPIC_opt) { - copts.emplace_back("-fPIC"); - } - #endif - if (!fnative_opt && !fshared_opt) { + if (!fnative_opt) { #ifdef ONLY_LD if (stack_canary_opt) { ldopts.emplace_back("--stack-canary"); @@ -870,22 +846,11 @@ static Options CreateOptions(bool add_defaults=true) { for ( auto library : l_opt ) { ldopts.emplace_back("-l"+library); } - auto replace_extension = [&](auto& str){ - if (fnative_opt) { - llvm::sys::path::replace_extension(str, ""); - } - else if (fshared_opt) { - llvm::sys::path::replace_extension(str, ".so"); - } - else { - llvm::sys::path::replace_extension(str, ".wasm"); - } - }; if (o_opt.empty()) { #ifndef ONLY_LD if (inputs.size() == 1) { llvm::SmallString<256> fn = llvm::sys::path::filename(inputs[0]); - replace_extension(fn); + llvm::sys::path::replace_extension(fn, fnative_opt ? "" : ".wasm"); output_fn = fn.str(); } else { output_fn = "a.out"; @@ -896,7 +861,7 @@ static Options CreateOptions(bool add_defaults=true) { if (inputs.size() == 1) { llvm::SmallString<256> fn = llvm::sys::path::filename(inputs[0]); llvm::sys::path::replace_extension(fn, ""); - replace_extension(fn); + llvm::sys::path::replace_extension(fn, fnative_opt ? "" : ".wasm"); output_fn = fn.str(); ldopts.emplace_back("-o"+output_fn); } else { @@ -913,7 +878,7 @@ static Options CreateOptions(bool add_defaults=true) { has_o_opt = true; } - if (!fnative_opt && !fshared_opt) { + if (!fnative_opt) { #ifndef ONLY_LD if (!imports_opt.empty()) { ldopts.emplace_back("-imports="+imports_opt); @@ -970,9 +935,6 @@ static Options CreateOptions(bool add_defaults=true) { } if (fnative_opt) ldopts.emplace_back("-fnative"); - else if (fshared_opt) { - ldopts.emplace_back("-shared"); - } if (fuse_main_opt) ldopts.emplace_back("-fuse-main"); @@ -995,8 +957,8 @@ static Options CreateOptions(bool add_defaults=true) { } #ifndef ONLY_LD - return {output_fn, inputs, link, abigen, no_missing_ricardian_clause_opt, pp_only, pp_dir, abigen_output, abigen_contract, copts, ldopts, agopts, agresources, debug, fnative_opt, fshared_opt, {abi_version_major, abi_version_minor}, has_o_opt, has_contract_opt, warn_action_read_only}; + return {output_fn, inputs, link, abigen, no_missing_ricardian_clause_opt, pp_only, pp_dir, abigen_output, abigen_contract, copts, ldopts, agopts, agresources, debug, fnative_opt, {abi_version_major, abi_version_minor}, has_o_opt, has_contract_opt, warn_action_read_only}; #else - return {output_fn, {}, link, abigen, no_missing_ricardian_clause_opt, pp_only, pp_dir, abigen_output, abigen_contract, copts, ldopts, agopts, agresources, debug, fnative_opt, fshared_opt, {abi_version_major, abi_version_minor}, has_o_opt, has_contract_opt, warn_action_read_only}; + return {output_fn, {}, link, abigen, no_missing_ricardian_clause_opt, pp_only, pp_dir, abigen_output, abigen_contract, copts, ldopts, agopts, agresources, debug, fnative_opt, {abi_version_major, abi_version_minor}, has_o_opt, has_contract_opt, warn_action_read_only}; #endif } diff --git a/tools/ld/cdt-ld.cpp.in b/tools/ld/cdt-ld.cpp.in index 89fda6a7cd..6bb649c800 100644 --- a/tools/ld/cdt-ld.cpp.in +++ b/tools/ld/cdt-ld.cpp.in @@ -22,7 +22,7 @@ int main(int argc, const char **argv) { Options opts = CreateOptions(); std::string line; - if (opts.native || opts.shared_lib) { + if (opts.native) { #ifdef __APPLE__ if (!eosio::cdt::environment::exec_subprogram("ld", opts.ld_options, true)) #else @@ -41,7 +41,7 @@ int main(int argc, const char **argv) { } // finally any post processing - if (!fno_post_pass_opt && !opts.native && !opts.shared_lib) { + if (!fno_post_pass_opt && !opts.native) { if ( !llvm::sys::fs::exists( opts.eosio_pp_dir+"/eosio-pp" ) ) { std::cerr << "Error: eosio.pp not found! (Try reinstalling eosio.cdt)" << std::endl; return -1;