From f8d0e96d95f3ceb825881815e38139dc663abb4f Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 20 Feb 2024 11:24:21 +0400 Subject: [PATCH] fixes related to build under vc2022 on windows arm64 --- .gitignore | 3 +- CMakeLists.txt | 4 +- contrib/CMakeLists.txt | 2 +- contrib/db/libmdbx/src/CMakeLists.txt | 55 --------------------------- src/common/callstack_helper.cpp | 6 +++ src/crypto/tree-hash.c | 1 + tests/CMakeLists.txt | 2 +- 7 files changed, 13 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index 04985b7f..7518f4e9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ ._.DS_Store Thumbs.db ._* -.idea \ No newline at end of file +.idea +.vs/* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 39e3aff0..a151f1ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") endif() if(MSVC) - add_definitions("/D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D__SSE4_1__") + add_definitions("/D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0") add_compile_options(/bigobj /Zm1000 /Z7 /MP2 /W3 /GS- /wd4996 /wd4503 /wd4345 /wd4091 /FIinline_c.h) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10485760 /DEBUG dbghelp.lib crypt32.lib") if(STATIC) @@ -224,7 +224,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") elseif(APPLE) find_package(Boost 1.71 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale) else() - find_package(Boost 1.70 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale) + find_package(Boost 1.70 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale log) endif() diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 601672d5..a3220829 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -28,7 +28,7 @@ endif() set_property(TARGET upnpc-static mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat PROPERTY FOLDER "unused") if(MSVC) - set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused") + #set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused") endif() diff --git a/contrib/db/libmdbx/src/CMakeLists.txt b/contrib/db/libmdbx/src/CMakeLists.txt index 04aead5f..7dfc94aa 100644 --- a/contrib/db/libmdbx/src/CMakeLists.txt +++ b/contrib/db/libmdbx/src/CMakeLists.txt @@ -45,61 +45,6 @@ if(CC_HAS_VISIBILITY AND (LTO_ENABLED OR INTERPROCEDURAL_OPTIMIZATION)) set_target_properties(mdbx PROPERTIES LINK_FLAGS "-fvisibility=hidden") endif() -if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - if(MSVC) - if(NOT MSVC_LIB_EXE) - # Find lib.exe - get_filename_component(CL_NAME ${CMAKE_C_COMPILER} NAME) - string(REPLACE cl.exe lib.exe MSVC_LIB_EXE ${CL_NAME}) - find_program(MSVC_LIB_EXE ${MSVC_LIB_EXE}) - endif() - if(MSVC_LIB_EXE) - message(STATUS "Found MSVC's lib tool: ${MSVC_LIB_EXE}") - set(MDBX_NTDLL_EXTRA_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.lib) - add_custom_command(OUTPUT ${MDBX_NTDLL_EXTRA_IMPLIB} - COMMENT "Create extra-import-library for ntdll.dll" - MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" - COMMAND ${MSVC_LIB_EXE} /def:"${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" /out:"${MDBX_NTDLL_EXTRA_IMPLIB}" ${INITIAL_CMAKE_STATIC_LINKER_FLAGS}) - else() - message(SEND_ERROR "MSVC's lib tool not found") - endif() - elseif(MINGW OR MINGW64) - if(NOT DLLTOOL) - # Find dlltool - get_filename_component(GCC_NAME ${CMAKE_C_COMPILER} NAME) - string(REPLACE gcc dlltool DLLTOOL_NAME ${GCC_NAME}) - find_program(DLLTOOL NAMES ${DLLTOOL_NAME}) - endif() - if(DLLTOOL) - message(STATUS "Found dlltool: ${DLLTOOL}") - set(MDBX_NTDLL_EXTRA_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.a") - add_custom_command(OUTPUT ${MDBX_NTDLL_EXTRA_IMPLIB} - COMMENT "Create extra-import-library for ntdll.dll" - MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" - COMMAND ${DLLTOOL} -d "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" -l "${MDBX_NTDLL_EXTRA_IMPLIB}") - else() - message(SEND_ERROR "dlltool not found") - endif() - endif() -endif() - -target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ${CMAKE_THREAD_LIBS_INIT}) -if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ntdll.lib) - if(MDBX_NTDLL_EXTRA_IMPLIB) - # LY: Sometimes Cmake requires a nightmarish magic for simple things. - # 1) create a target out of the library compilation result - add_custom_target(ntdll_extra_target DEPENDS ${MDBX_NTDLL_EXTRA_IMPLIB}) - # 2) create an library target out of the library compilation result - add_library(ntdll_extra STATIC IMPORTED GLOBAL) - add_dependencies(ntdll_extra ntdll_extra_target) - # 3) specify where the library is (and where to find the headers) - set_target_properties(ntdll_extra - PROPERTIES - IMPORTED_LOCATION ${MDBX_NTDLL_EXTRA_IMPLIB}) - target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ntdll_extra) - endif() -endif() set_target_properties(mdbx PROPERTIES INTERPROCEDURAL_OPTIMIZATION $ diff --git a/src/common/callstack_helper.cpp b/src/common/callstack_helper.cpp index 74bcc557..b84fe5a8 100644 --- a/src/common/callstack_helper.cpp +++ b/src/common/callstack_helper.cpp @@ -137,11 +137,17 @@ namespace tools STACKFRAME64 frame; memset(&frame, 0, sizeof frame); +#ifndef _M_ARM64 frame.AddrPC.Offset = context.Rip; +#endif frame.AddrPC.Mode = AddrModeFlat; +#ifndef _M_ARM64 frame.AddrStack.Offset = context.Rsp; +#endif frame.AddrStack.Mode = AddrModeFlat; +#ifndef _M_ARM64 frame.AddrFrame.Offset = context.Rbp; +#endif frame.AddrFrame.Mode = AddrModeFlat; IMAGEHLP_LINE64 line = { 0 }; diff --git a/src/crypto/tree-hash.c b/src/crypto/tree-hash.c index 87423fb8..b700e64a 100644 --- a/src/crypto/tree-hash.c +++ b/src/crypto/tree-hash.c @@ -8,6 +8,7 @@ #include #include "hash-ops.h" +#include "malloc.h" void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) { assert(count > 0); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 628b40a0..71b544c1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,7 +28,7 @@ add_executable(net_load_tests_srv net_load_tests/srv.cpp) add_dependencies(coretests version) -target_link_libraries(coretests rpc wallet currency_core common crypto zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(coretests rpc wallet currency_core common crypto zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) target_link_libraries(functional_tests rpc wallet currency_core crypto common zlibstatic ethash libminiupnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) target_link_libraries(hash-tests crypto ethash) target_link_libraries(hash-target-tests crypto currency_core ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})