From 5965b02aef7e8e8e6441259cb07e8f7a703c3627 Mon Sep 17 00:00:00 2001 From: selsta Date: Thu, 29 Jun 2023 16:08:03 +0200 Subject: [PATCH 1/4] cmake: set cpp17 standard --- CMakeLists.txt | 2 +- README.md | 2 +- contrib/depends/toolchain.cmake.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f96017c6a..085e628d32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ enable_language(C ASM) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/README.md b/README.md index 062bf11045..f0c0fe7fde 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ library archives (`.a`). | Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Void pkg | Fedora pkg | Optional | Purpose | | ------------ | ------------- | -------- | -------------------- | ------------ | ------------------ | ------------------- | -------- | --------------- | -| GCC | 5 | NO | `build-essential` | `base-devel` | `base-devel` | `gcc` | NO | | +| GCC | 7 | NO | `build-essential` | `base-devel` | `base-devel` | `gcc` | NO | | | CMake | 3.5 | NO | `cmake` | `cmake` | `cmake` | `cmake` | NO | | | pkg-config | any | NO | `pkg-config` | `base-devel` | `base-devel` | `pkgconf` | NO | | | Boost | 1.58 | NO | `libboost-all-dev` | `boost` | `boost-devel` | `boost-devel` | NO | C++ libraries | diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in index e5c0cbbb81..6fe4618aea 100644 --- a/contrib/depends/toolchain.cmake.in +++ b/contrib/depends/toolchain.cmake.in @@ -92,7 +92,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") SET(PORT OFF) SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/") SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") - SET(CMAKE_CXX_STANDARD 14) + SET(CMAKE_CXX_STANDARD 17) SET(LLVM_ENABLE_PIC OFF) SET(LLVM_ENABLE_PIE OFF) elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") From 5136974da96fbdc25ec6334975319a6d728aae6f Mon Sep 17 00:00:00 2001 From: selsta Date: Thu, 29 Jun 2023 16:56:46 +0200 Subject: [PATCH 2/4] device: boost -> std locks to fix c++17 compilation --- src/device/device_ledger.cpp | 9 +++------ src/device/device_ledger.hpp | 7 +++---- src/device_trezor/device_trezor_base.hpp | 15 +++++++-------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp index 27d080a1c2..009ee16cab 100644 --- a/src/device/device_ledger.cpp +++ b/src/device/device_ledger.cpp @@ -34,9 +34,6 @@ #include "cryptonote_basic/subaddress_index.h" #include "cryptonote_core/cryptonote_tx_utils.h" -#include -#include - namespace hw { namespace ledger { @@ -322,10 +319,10 @@ namespace hw { //automatic lock one more level on device ensuring the current thread is allowed to use it #define AUTO_LOCK_CMD() \ /* lock both mutexes without deadlock*/ \ - boost::lock(device_locker, command_locker); \ + std::lock(device_locker, command_locker); \ /* make sure both already-locked mutexes are unlocked at the end of scope */ \ - boost::lock_guard lock1(device_locker, boost::adopt_lock); \ - boost::lock_guard lock2(command_locker, boost::adopt_lock) + std::lock_guard lock1(device_locker, std::adopt_lock); \ + std::lock_guard lock2(command_locker, std::adopt_lock) //lock the device for a long sequence void device_ledger::lock(void) { diff --git a/src/device/device_ledger.hpp b/src/device/device_ledger.hpp index 0712741602..b65943f0ca 100644 --- a/src/device/device_ledger.hpp +++ b/src/device/device_ledger.hpp @@ -35,8 +35,7 @@ #include "device.hpp" #include "log.hpp" #include "device_io_hid.hpp" -#include -#include +#include namespace hw { @@ -140,8 +139,8 @@ namespace hw { class device_ledger : public hw::device { private: // Locker for concurrent access - mutable boost::recursive_mutex device_locker; - mutable boost::mutex command_locker; + mutable std::recursive_mutex device_locker; + mutable std::mutex command_locker; //IO hw::io::device_io_hid hw_device; diff --git a/src/device_trezor/device_trezor_base.hpp b/src/device_trezor/device_trezor_base.hpp index df6e42b1ff..e0fc2aafbb 100644 --- a/src/device_trezor/device_trezor_base.hpp +++ b/src/device_trezor/device_trezor_base.hpp @@ -32,13 +32,12 @@ #include +#include #include #include "device/device.hpp" #include "device/device_default.hpp" #include "device/device_cold.hpp" #include -#include -#include #include "cryptonote_config.h" #include "trezor.hpp" @@ -49,12 +48,12 @@ //automatic lock one more level on device ensuring the current thread is allowed to use it #define TREZOR_AUTO_LOCK_CMD() \ /* lock both mutexes without deadlock*/ \ - boost::lock(device_locker, command_locker); \ + std::lock(device_locker, command_locker); \ /* make sure both already-locked mutexes are unlocked at the end of scope */ \ - boost::lock_guard lock1(device_locker, boost::adopt_lock); \ - boost::lock_guard lock2(command_locker, boost::adopt_lock) + std::lock_guard lock1(device_locker, std::adopt_lock); \ + std::lock_guard lock2(command_locker, std::adopt_lock) -#define TREZOR_AUTO_LOCK_DEVICE() boost::lock_guard lock1_device(device_locker) +#define TREZOR_AUTO_LOCK_DEVICE() std::lock_guard lock1_device(device_locker) namespace hw { namespace trezor { @@ -86,8 +85,8 @@ namespace trezor { protected: // Locker for concurrent access - mutable boost::recursive_mutex device_locker; - mutable boost::mutex command_locker; + mutable std::recursive_mutex device_locker; + mutable std::mutex command_locker; std::shared_ptr m_transport; i_device_callback * m_callback; From df9f3806716461f016dcd709b450a5605aafbe78 Mon Sep 17 00:00:00 2001 From: selsta Date: Thu, 29 Jun 2023 21:31:01 +0200 Subject: [PATCH 3/4] cmake: set BOOST_NO_AUTO_PTR to fix c++17 compilation --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 085e628d32..8e5f5b48c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1077,6 +1077,7 @@ if (WIN32) endif() find_package(Boost 1.58 QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS}) add_definitions(-DBOOST_ASIO_ENABLE_SEQUENTIAL_STRAND_ALLOCATION) +add_definitions(-DBOOST_NO_AUTO_PTR) set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES}) if(NOT Boost_FOUND) From b4491c1072b7a3e09c4d64041be16a311743e00c Mon Sep 17 00:00:00 2001 From: selsta Date: Thu, 29 Jun 2023 22:53:07 +0200 Subject: [PATCH 4/4] cmake: set -fno-aligned-allocation on macOS ARM We set a deployment target that is lower than 10.14, which means we have to disable aligned allocation otherwise compilation fails. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e5f5b48c8..99baba2ba6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -999,6 +999,9 @@ else() if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -DGTEST_HAS_TR1_TUPLE=0") + if(ARM) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-aligned-allocation") + endif() endif() set(DEBUG_FLAGS "-g3")