From f37e84b78bd489b59285df51166f8bd74baa4b29 Mon Sep 17 00:00:00 2001 From: cassandras-lies <203535133+cassandras-lies@users.noreply.github.com> Date: Mon, 7 Apr 2025 09:28:59 +0000 Subject: [PATCH] Fix build with newer CMake and LLVM versions. --- scripts/prebuild.bat | 4 + scripts/prebuild.sh | 10 +- src/deps/CMakeLists/secp256k1/CMakeLists.txt | 2 +- src/deps/patches/boost-patch.patch | 271 ++++++++++++++++++- src/deps/patches/openssl-cmake-patch.patch | 25 ++ 5 files changed, 300 insertions(+), 12 deletions(-) create mode 100644 src/deps/patches/openssl-cmake-patch.patch diff --git a/scripts/prebuild.bat b/scripts/prebuild.bat index 7797567..be0f33a 100644 --- a/scripts/prebuild.bat +++ b/scripts/prebuild.bat @@ -6,6 +6,8 @@ :: Initialize submodules. cd .. git submodule update --init --recursive +git submodule foreach "git clean -fxd" +git submodule foreach "git reset --hard" :: Copy CMakeLists. copy src\deps\CMakeLists\sparkmobile\CMakeLists.txt src\deps\sparkmobile\ @@ -16,6 +18,8 @@ cd src\deps\sparkmobile git apply ..\patches\windows\windows_patch.patch cd ..\boost-cmake git apply ..\patches\boost-patch.patch +cd ..\openssl-cmake +git apply ..\patches\openssl-cmake-patch.patch :: Navigate back to scripts. cd ..\..\..\scripts diff --git a/scripts/prebuild.sh b/scripts/prebuild.sh index 0759302..3b16009 100755 --- a/scripts/prebuild.sh +++ b/scripts/prebuild.sh @@ -4,11 +4,17 @@ set -e cd .. git submodule update --init --recursive +git submodule foreach "git clean -fxd" +git submodule foreach "git reset --hard" cp src/deps/CMakeLists/sparkmobile/CMakeLists.txt src/deps/sparkmobile/ cp src/deps/CMakeLists/secp256k1/CMakeLists.txt src/deps/sparkmobile/secp256k1/ pushd src/deps/boost-cmake - git apply ../patches/boost-patch.patch || true -popd \ No newline at end of file + git apply ../patches/boost-patch.patch +popd + +pushd src/deps/openssl-cmake + git apply ../patches/openssl-cmake-patch.patch +popd diff --git a/src/deps/CMakeLists/secp256k1/CMakeLists.txt b/src/deps/CMakeLists/secp256k1/CMakeLists.txt index 7be3da2..25e6fa5 100644 --- a/src/deps/CMakeLists/secp256k1/CMakeLists.txt +++ b/src/deps/CMakeLists/secp256k1/CMakeLists.txt @@ -1,6 +1,6 @@ # Copyright (c) 2017 The Bitcoin developers -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) project(secp256k1_spark) SET(ENABLE_MODULE_ECDH 1) diff --git a/src/deps/patches/boost-patch.patch b/src/deps/patches/boost-patch.patch index 69743a8..57f0f0d 100644 --- a/src/deps/patches/boost-patch.patch +++ b/src/deps/patches/boost-patch.patch @@ -1,14 +1,43 @@ -Subject: [PATCH] boost-patch +From fe0568321e4e72940fc2062f37bfca63ab21773d Mon Sep 17 00:00:00 2001 +From: cassandras-lies <203535133+cassandras-lies@users.noreply.github.com> +Date: Sun, 27 Apr 2025 13:39:07 +0000 +Subject: [PATCH] Fix compilation with CMake 4 and LLVM 17 + --- -Index: CMakeLists.txt -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== + CMakeLists.txt | 44 +++++++++++++++-- + cmake/Modules/StandaloneBuild.cmake | 2 +- + patch/1.63.0/context_0001_arm64_cpu.patch | 47 ------------------- + ...context_0002_macOS_execution_context.patch | 23 --------- + patches/integral_wrapper.patch | 19 ++++++++ + patches/that_future.patch | 19 ++++++++ + repack.sh | 44 ----------------- + 7 files changed, 80 insertions(+), 118 deletions(-) + delete mode 100644 patch/1.63.0/context_0001_arm64_cpu.patch + delete mode 100644 patch/1.63.0/context_0002_macOS_execution_context.patch + create mode 100644 patches/integral_wrapper.patch + create mode 100644 patches/that_future.patch + delete mode 100755 repack.sh + diff --git a/CMakeLists.txt b/CMakeLists.txt ---- a/CMakeLists.txt (revision 40cb41d86eab0d7fdc18af4b04b733f8cc852d2a) -+++ b/CMakeLists.txt (date 1732142456631) -@@ -21,6 +21,16 @@ +index 16d48dc..52fd3d9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,9 +1,11 @@ +-cmake_minimum_required(VERSION 3.12) ++cmake_minimum_required(VERSION 3.10) + project(Boost-CMake) + +-option(BOOST_DISABLE_TESTS "Do not build test targets, even if building standalone" OFF) ++add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) + +-set(BOOST_URL "https://boostorg.jfrog.io/artifactory/main/release/1.71.0/source/boost_1_71_0.tar.bz2" CACHE STRING "Boost download URL") ++option(BOOST_DISABLE_TESTS "Do not build test targets, even if building standalone" ON) ++ ++set(BOOST_URL "https://archives.boost.io/release/1.71.0/source/boost_1_71_0.tar.bz2" CACHE STRING "Boost download URL") + set(BOOST_URL_SHA256 "d73a8da01e8bf8c7eda40b4c84915071a8c8a0df4a6734537ddde4a8580524ee" CACHE STRING "Boost download URL SHA256 checksum") + + include(FetchContent) +@@ -21,6 +23,42 @@ if(NOT Boost_POPULATED) set(BOOST_SOURCE ${boost_SOURCE_DIR}) endif() @@ -21,7 +50,231 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt +endif() +message(STATUS "Copying: ${SOURCE_FILE} to ${DESTINATION_DIR}") +file(COPY ${SOURCE_FILE} DESTINATION ${DESTINATION_DIR}) ++ ++# Define your patch directory and source root ++set(PATCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/patches") ++set(SOURCE_ROOT "${BOOST_SOURCE}") ++ ++# Get all patch files ++file(GLOB PATCH_FILES "${PATCH_DIR}/*.patch") ++ ++# Build a list of commands to apply each patch ++set(PATCH_COMMANDS "") ++foreach(PATCH_FILE ${PATCH_FILES}) ++ list(APPEND PATCH_COMMANDS ++ COMMAND ${CMAKE_COMMAND} -E echo "Applying patch: ${PATCH_FILE}" ++ COMMAND ${CMAKE_COMMAND} -E chdir ${SOURCE_ROOT} patch -F -p0 < "${PATCH_FILE}" ++ ) ++endforeach() ++ ++# Add a marker file to avoid reapplying patches ++add_custom_command( ++ OUTPUT "${SOURCE_ROOT}/.patched" ++ ${PATCH_COMMANDS} ++ COMMAND ${CMAKE_COMMAND} -E touch "${SOURCE_ROOT}/.patched" ++ COMMENT "Applying all patches in ${PATCH_DIR}" ++) ++ ++add_custom_target(apply_patches ALL DEPENDS "${SOURCE_ROOT}/.patched") + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) include(CheckBoostVersion) +diff --git a/cmake/Modules/StandaloneBuild.cmake b/cmake/Modules/StandaloneBuild.cmake +index 22083ce..a945102 100644 +--- a/cmake/Modules/StandaloneBuild.cmake ++++ b/cmake/Modules/StandaloneBuild.cmake +@@ -1,7 +1,7 @@ + if(CMAKE_CURRENT_SOURCE_DIR STREQUAL "${CMAKE_SOURCE_DIR}") + message(STATUS "Standalone mode detected") + set(BOOST_STANDALONE ON) +- set(CMAKE_CXX_STANDARD 11) ++ set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) + enable_testing() +diff --git a/patch/1.63.0/context_0001_arm64_cpu.patch b/patch/1.63.0/context_0001_arm64_cpu.patch +deleted file mode 100644 +index 977eba4..0000000 +--- a/patch/1.63.0/context_0001_arm64_cpu.patch ++++ /dev/null +@@ -1,47 +0,0 @@ +-From 26b61a67cf1d384796e5ae2f207c5b6fa56015e5 Mon Sep 17 00:00:00 2001 +-From: Oliver Kowalke +-Date: Thu, 5 Jan 2017 10:38:47 -0800 +-Subject: [PATCH] remove directive '.cpu' for ARM64/AAPCS/ELF +- +---- +- src/asm/jump_arm64_aapcs_elf_gas.S | 1 - +- src/asm/make_arm64_aapcs_elf_gas.S | 1 - +- src/asm/ontop_arm64_aapcs_elf_gas.S | 1 - +- 3 files changed, 3 deletions(-) +- +-diff --git a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +-index 7c0c2fa..1b8ce9e 100644 +---- a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +-+++ b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S +-@@ -51,7 +51,6 @@ +- * * +- *******************************************************/ +- +--.cpu generic+fp+simd +- .text +- .align 2 +- .global jump_fcontext +-diff --git a/libs/context/src/asm/make_arm64_aapcs_elf_gas.S b/libs/context/src/asm/make_arm64_aapcs_elf_gas.S +-index e71a91c..c1fa843 100644 +---- a/libs/context/src/asm/make_arm64_aapcs_elf_gas.S +-+++ b/libs/context/src/asm/make_arm64_aapcs_elf_gas.S +-@@ -51,7 +51,6 @@ +- * * +- *******************************************************/ +- +--.cpu generic+fp+simd +- .text +- .align 2 +- .global make_fcontext +-diff --git a/libs/context/src/asm/ontop_arm64_aapcs_elf_gas.S b/libs/context/src/asm/ontop_arm64_aapcs_elf_gas.S +-index 7e3b047..02a3b07 100644 +---- a/libs/context/src/asm/ontop_arm64_aapcs_elf_gas.S +-+++ b/libs/context/src/asm/ontop_arm64_aapcs_elf_gas.S +-@@ -51,7 +51,6 @@ +- * * +- *******************************************************/ +- +--.cpu generic+fp+simd +- .text +- .align 2 +- .global ontop_fcontext +diff --git a/patch/1.63.0/context_0002_macOS_execution_context.patch b/patch/1.63.0/context_0002_macOS_execution_context.patch +deleted file mode 100644 +index e3fb420..0000000 +--- a/patch/1.63.0/context_0002_macOS_execution_context.patch ++++ /dev/null +@@ -1,23 +0,0 @@ +-From 3167d4dfb82aa74fcf41c755d6c9bc7a3401bfea Mon Sep 17 00:00:00 2001 +-From: Timo Sandmann +-Date: Sun, 8 Jan 2017 18:24:20 +0100 +-Subject: [PATCH] Fixes #38 +- +-Use correct type cast and tuple extracting for pointer to transfered data tuples +---- +- include/boost/context/execution_context_v2.hpp | 2 +- +- 1 file changed, 1 insertion(+), 1 deletion(-) +- +-diff --git a/boost/context/execution_context_v2.hpp b/boost/context/execution_context_v2.hpp +-index 33b9bda..bbd4eb1 100644 +---- a/boost/context/execution_context_v2.hpp +-+++ b/boost/context/execution_context_v2.hpp +-@@ -103,7 +103,7 @@ class record { +- +- transfer_t run( transfer_t t) { +- Ctx from{ t.fctx }; +-- typename Ctx::args_tpl_t args = std::move( * static_cast< typename Ctx::args_tpl_t * >( t.data) ); +-+ typename Ctx::args_tpl_t args = std::move( std::get<1>( * static_cast< std::tuple< std::exception_ptr, typename Ctx::args_tpl_t > * >( t.data) ) ); +- auto tpl = std::tuple_cat( +- params_, +- std::forward_as_tuple( std::move( from) ), +diff --git a/patches/integral_wrapper.patch b/patches/integral_wrapper.patch +new file mode 100644 +index 0000000..277ba34 +--- /dev/null ++++ b/patches/integral_wrapper.patch +@@ -0,0 +1,19 @@ ++*** boost/mpl/aux_/integral_wrapper.hpp Thu Apr 10 15:16:33 2025 ++--- boost/mpl/aux_/integral_wrapper.hpp Thu Apr 10 15:19:07 2025 ++*************** ++*** 56,62 **** ++ // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC), ++ // while some other don't like 'value + 1' (Borland), and some don't like ++ // either ++! #if BOOST_WORKAROUND(__EDG_VERSION__, <= 243) ++ private: ++ BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, next_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1))); ++ BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, prior_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1))); ++--- 56,62 ---- ++ // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC), ++ // while some other don't like 'value + 1' (Borland), and some don't like ++ // either ++! #if BOOST_WORKAROUND(__EDG_VERSION__, <= 243) || __cplusplus >= 201703L ++ private: ++ BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, next_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1))); ++ BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, prior_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1))); +diff --git a/patches/that_future.patch b/patches/that_future.patch +new file mode 100644 +index 0000000..22253c0 +--- /dev/null ++++ b/patches/that_future.patch +@@ -0,0 +1,19 @@ ++*** boost/thread/future.hpp Thu Apr 10 21:24:34 2025 ++--- boost/thread/future.hpp Thu Apr 10 21:25:04 2025 ++*************** ++*** 4669,4675 **** ++ } ++ run_it& operator=(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT { ++ if (this != &x) { ++! that_=x.that; ++ x.that_.reset(); ++ } ++ return *this; ++--- 4669,4675 ---- ++ } ++ run_it& operator=(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT { ++ if (this != &x) { ++! that_=x.that_; ++ x.that_.reset(); ++ } ++ return *this; +diff --git a/repack.sh b/repack.sh +deleted file mode 100755 +index adea206..0000000 +--- a/repack.sh ++++ /dev/null +@@ -1,44 +0,0 @@ +-#!/usr/bin/env bash +- +-set -e +- +-BOOST_VERSION=1.67.0 +- +-function finish { +- rm -rf ${tmp_dir} +-} +-trap finish EXIT +- +-out_dir=$(pwd) +-patch_dir=$(pwd)/patch/${BOOST_VERSION} +-tmp_dir=$(mktemp -d) +- +-echo "Downloading Boost ${BOOST_VERSION}..." +-curl -L "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION//\./_}.tar.bz2" > ${tmp_dir}/boost_${BOOST_VERSION}.tar.bz2 +- +-mkdir -p ${tmp_dir}/extract +-cd ${tmp_dir}/extract +-echo "Extracting archive..." +-tar xf ${tmp_dir}/boost_${BOOST_VERSION}.tar.bz2 +- +-cd boost_* +- +-if [ -d "${patch_dir}" ]; then +- mkdir patch +- for f in ${patch_dir}/*.patch; do +- echo "Applying patch ${f}..." +- git apply --verbose $f +- cp $f patch/ +- done +-fi +- +-echo "Removing extra files..." +-find . -name "doc" -print0 | xargs -0 -- rm -rf +-find . -name "*.htm*" -delete +-find . -name "*.png" -delete +-find . -name "*.bmp" -delete +-find . -name "*.jpg" -delete +- +-cd .. +-echo "Recompressing archive..." +-tar cfJ ${out_dir}/boost_${BOOST_VERSION//./_}.tar.xz boost_* +-- +2.39.5 (Apple Git-154) + diff --git a/src/deps/patches/openssl-cmake-patch.patch b/src/deps/patches/openssl-cmake-patch.patch new file mode 100644 index 0000000..47a39f9 --- /dev/null +++ b/src/deps/patches/openssl-cmake-patch.patch @@ -0,0 +1,25 @@ +From 31afa2f9c874e00a9c275a80cf729943ff93ab2e Mon Sep 17 00:00:00 2001 +From: cassandras-lies <203535133+cassandras-lies@users.noreply.github.com> +Date: Thu, 10 Apr 2025 14:15:39 +0000 +Subject: [PATCH] Fix compilation with newer CMake. + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e93be8f..deb0c1d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -23,7 +23,7 @@ + # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + # SOFTWARE. +-cmake_minimum_required( VERSION 3.1.0 ) ++cmake_minimum_required( VERSION 3.10.0 ) + set( CMAKE_LEGACY_CYGWIN_WIN32 0 ) + project( openssl ) + +-- +2.39.5 (Apple Git-154) +