Skip to content

Commit f37e84b

Browse files
Fix build with newer CMake and LLVM versions.
1 parent e8c5026 commit f37e84b

File tree

5 files changed

+300
-12
lines changed

5 files changed

+300
-12
lines changed

scripts/prebuild.bat

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
:: Initialize submodules.
77
cd ..
88
git submodule update --init --recursive
9+
git submodule foreach "git clean -fxd"
10+
git submodule foreach "git reset --hard"
911

1012
:: Copy CMakeLists.
1113
copy src\deps\CMakeLists\sparkmobile\CMakeLists.txt src\deps\sparkmobile\
@@ -16,6 +18,8 @@ cd src\deps\sparkmobile
1618
git apply ..\patches\windows\windows_patch.patch
1719
cd ..\boost-cmake
1820
git apply ..\patches\boost-patch.patch
21+
cd ..\openssl-cmake
22+
git apply ..\patches\openssl-cmake-patch.patch
1923

2024
:: Navigate back to scripts.
2125
cd ..\..\..\scripts

scripts/prebuild.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ set -e
44

55
cd ..
66
git submodule update --init --recursive
7+
git submodule foreach "git clean -fxd"
8+
git submodule foreach "git reset --hard"
79

810
cp src/deps/CMakeLists/sparkmobile/CMakeLists.txt src/deps/sparkmobile/
911
cp src/deps/CMakeLists/secp256k1/CMakeLists.txt src/deps/sparkmobile/secp256k1/
1012

1113

1214
pushd src/deps/boost-cmake
13-
git apply ../patches/boost-patch.patch || true
14-
popd
15+
git apply ../patches/boost-patch.patch
16+
popd
17+
18+
pushd src/deps/openssl-cmake
19+
git apply ../patches/openssl-cmake-patch.patch
20+
popd

src/deps/CMakeLists/secp256k1/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) 2017 The Bitcoin developers
22

3-
cmake_minimum_required(VERSION 3.1)
3+
cmake_minimum_required(VERSION 3.5)
44
project(secp256k1_spark)
55

66
SET(ENABLE_MODULE_ECDH 1)

src/deps/patches/boost-patch.patch

+262-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,43 @@
1-
Subject: [PATCH] boost-patch
1+
From fe0568321e4e72940fc2062f37bfca63ab21773d Mon Sep 17 00:00:00 2001
2+
From: cassandras-lies <203535133+cassandras-lies@users.noreply.github.com>
3+
Date: Sun, 27 Apr 2025 13:39:07 +0000
4+
Subject: [PATCH] Fix compilation with CMake 4 and LLVM 17
5+
26
---
3-
Index: CMakeLists.txt
4-
IDEA additional info:
5-
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
6-
<+>UTF-8
7-
===================================================================
7+
CMakeLists.txt | 44 +++++++++++++++--
8+
cmake/Modules/StandaloneBuild.cmake | 2 +-
9+
patch/1.63.0/context_0001_arm64_cpu.patch | 47 -------------------
10+
...context_0002_macOS_execution_context.patch | 23 ---------
11+
patches/integral_wrapper.patch | 19 ++++++++
12+
patches/that_future.patch | 19 ++++++++
13+
repack.sh | 44 -----------------
14+
7 files changed, 80 insertions(+), 118 deletions(-)
15+
delete mode 100644 patch/1.63.0/context_0001_arm64_cpu.patch
16+
delete mode 100644 patch/1.63.0/context_0002_macOS_execution_context.patch
17+
create mode 100644 patches/integral_wrapper.patch
18+
create mode 100644 patches/that_future.patch
19+
delete mode 100755 repack.sh
20+
821
diff --git a/CMakeLists.txt b/CMakeLists.txt
9-
--- a/CMakeLists.txt (revision 40cb41d86eab0d7fdc18af4b04b733f8cc852d2a)
10-
+++ b/CMakeLists.txt (date 1732142456631)
11-
@@ -21,6 +21,16 @@
22+
index 16d48dc..52fd3d9 100644
23+
--- a/CMakeLists.txt
24+
+++ b/CMakeLists.txt
25+
@@ -1,9 +1,11 @@
26+
-cmake_minimum_required(VERSION 3.12)
27+
+cmake_minimum_required(VERSION 3.10)
28+
project(Boost-CMake)
29+
30+
-option(BOOST_DISABLE_TESTS "Do not build test targets, even if building standalone" OFF)
31+
+add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
32+
33+
-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")
34+
+option(BOOST_DISABLE_TESTS "Do not build test targets, even if building standalone" ON)
35+
+
36+
+set(BOOST_URL "https://archives.boost.io/release/1.71.0/source/boost_1_71_0.tar.bz2" CACHE STRING "Boost download URL")
37+
set(BOOST_URL_SHA256 "d73a8da01e8bf8c7eda40b4c84915071a8c8a0df4a6734537ddde4a8580524ee" CACHE STRING "Boost download URL SHA256 checksum")
38+
39+
include(FetchContent)
40+
@@ -21,6 +23,42 @@ if(NOT Boost_POPULATED)
1241
set(BOOST_SOURCE ${boost_SOURCE_DIR})
1342
endif()
1443

@@ -21,7 +50,231 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt
2150
+endif()
2251
+message(STATUS "Copying: ${SOURCE_FILE} to ${DESTINATION_DIR}")
2352
+file(COPY ${SOURCE_FILE} DESTINATION ${DESTINATION_DIR})
53+
+
54+
+# Define your patch directory and source root
55+
+set(PATCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/patches")
56+
+set(SOURCE_ROOT "${BOOST_SOURCE}")
57+
+
58+
+# Get all patch files
59+
+file(GLOB PATCH_FILES "${PATCH_DIR}/*.patch")
60+
+
61+
+# Build a list of commands to apply each patch
62+
+set(PATCH_COMMANDS "")
63+
+foreach(PATCH_FILE ${PATCH_FILES})
64+
+ list(APPEND PATCH_COMMANDS
65+
+ COMMAND ${CMAKE_COMMAND} -E echo "Applying patch: ${PATCH_FILE}"
66+
+ COMMAND ${CMAKE_COMMAND} -E chdir ${SOURCE_ROOT} patch -F -p0 < "${PATCH_FILE}"
67+
+ )
68+
+endforeach()
69+
+
70+
+# Add a marker file to avoid reapplying patches
71+
+add_custom_command(
72+
+ OUTPUT "${SOURCE_ROOT}/.patched"
73+
+ ${PATCH_COMMANDS}
74+
+ COMMAND ${CMAKE_COMMAND} -E touch "${SOURCE_ROOT}/.patched"
75+
+ COMMENT "Applying all patches in ${PATCH_DIR}"
76+
+)
77+
+
78+
+add_custom_target(apply_patches ALL DEPENDS "${SOURCE_ROOT}/.patched")
2479
+
2580
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
2681
include(CheckBoostVersion)
2782

83+
diff --git a/cmake/Modules/StandaloneBuild.cmake b/cmake/Modules/StandaloneBuild.cmake
84+
index 22083ce..a945102 100644
85+
--- a/cmake/Modules/StandaloneBuild.cmake
86+
+++ b/cmake/Modules/StandaloneBuild.cmake
87+
@@ -1,7 +1,7 @@
88+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL "${CMAKE_SOURCE_DIR}")
89+
message(STATUS "Standalone mode detected")
90+
set(BOOST_STANDALONE ON)
91+
- set(CMAKE_CXX_STANDARD 11)
92+
+ set(CMAKE_CXX_STANDARD 17)
93+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
94+
set(CMAKE_CXX_EXTENSIONS OFF)
95+
enable_testing()
96+
diff --git a/patch/1.63.0/context_0001_arm64_cpu.patch b/patch/1.63.0/context_0001_arm64_cpu.patch
97+
deleted file mode 100644
98+
index 977eba4..0000000
99+
--- a/patch/1.63.0/context_0001_arm64_cpu.patch
100+
+++ /dev/null
101+
@@ -1,47 +0,0 @@
102+
-From 26b61a67cf1d384796e5ae2f207c5b6fa56015e5 Mon Sep 17 00:00:00 2001
103+
-From: Oliver Kowalke <oliver.kowalke@gmail.com>
104+
-Date: Thu, 5 Jan 2017 10:38:47 -0800
105+
-Subject: [PATCH] remove directive '.cpu' for ARM64/AAPCS/ELF
106+
-
107+
----
108+
- src/asm/jump_arm64_aapcs_elf_gas.S | 1 -
109+
- src/asm/make_arm64_aapcs_elf_gas.S | 1 -
110+
- src/asm/ontop_arm64_aapcs_elf_gas.S | 1 -
111+
- 3 files changed, 3 deletions(-)
112+
-
113+
-diff --git a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S
114+
-index 7c0c2fa..1b8ce9e 100644
115+
---- a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S
116+
-+++ b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S
117+
-@@ -51,7 +51,6 @@
118+
- * *
119+
- *******************************************************/
120+
-
121+
--.cpu generic+fp+simd
122+
- .text
123+
- .align 2
124+
- .global jump_fcontext
125+
-diff --git a/libs/context/src/asm/make_arm64_aapcs_elf_gas.S b/libs/context/src/asm/make_arm64_aapcs_elf_gas.S
126+
-index e71a91c..c1fa843 100644
127+
---- a/libs/context/src/asm/make_arm64_aapcs_elf_gas.S
128+
-+++ b/libs/context/src/asm/make_arm64_aapcs_elf_gas.S
129+
-@@ -51,7 +51,6 @@
130+
- * *
131+
- *******************************************************/
132+
-
133+
--.cpu generic+fp+simd
134+
- .text
135+
- .align 2
136+
- .global make_fcontext
137+
-diff --git a/libs/context/src/asm/ontop_arm64_aapcs_elf_gas.S b/libs/context/src/asm/ontop_arm64_aapcs_elf_gas.S
138+
-index 7e3b047..02a3b07 100644
139+
---- a/libs/context/src/asm/ontop_arm64_aapcs_elf_gas.S
140+
-+++ b/libs/context/src/asm/ontop_arm64_aapcs_elf_gas.S
141+
-@@ -51,7 +51,6 @@
142+
- * *
143+
- *******************************************************/
144+
-
145+
--.cpu generic+fp+simd
146+
- .text
147+
- .align 2
148+
- .global ontop_fcontext
149+
diff --git a/patch/1.63.0/context_0002_macOS_execution_context.patch b/patch/1.63.0/context_0002_macOS_execution_context.patch
150+
deleted file mode 100644
151+
index e3fb420..0000000
152+
--- a/patch/1.63.0/context_0002_macOS_execution_context.patch
153+
+++ /dev/null
154+
@@ -1,23 +0,0 @@
155+
-From 3167d4dfb82aa74fcf41c755d6c9bc7a3401bfea Mon Sep 17 00:00:00 2001
156+
-From: Timo Sandmann <mail@timosandmann.de>
157+
-Date: Sun, 8 Jan 2017 18:24:20 +0100
158+
-Subject: [PATCH] Fixes #38
159+
-
160+
-Use correct type cast and tuple extracting for pointer to transfered data tuples
161+
----
162+
- include/boost/context/execution_context_v2.hpp | 2 +-
163+
- 1 file changed, 1 insertion(+), 1 deletion(-)
164+
-
165+
-diff --git a/boost/context/execution_context_v2.hpp b/boost/context/execution_context_v2.hpp
166+
-index 33b9bda..bbd4eb1 100644
167+
---- a/boost/context/execution_context_v2.hpp
168+
-+++ b/boost/context/execution_context_v2.hpp
169+
-@@ -103,7 +103,7 @@ class record {
170+
-
171+
- transfer_t run( transfer_t t) {
172+
- Ctx from{ t.fctx };
173+
-- typename Ctx::args_tpl_t args = std::move( * static_cast< typename Ctx::args_tpl_t * >( t.data) );
174+
-+ 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) ) );
175+
- auto tpl = std::tuple_cat(
176+
- params_,
177+
- std::forward_as_tuple( std::move( from) ),
178+
diff --git a/patches/integral_wrapper.patch b/patches/integral_wrapper.patch
179+
new file mode 100644
180+
index 0000000..277ba34
181+
--- /dev/null
182+
+++ b/patches/integral_wrapper.patch
183+
@@ -0,0 +1,19 @@
184+
+*** boost/mpl/aux_/integral_wrapper.hpp Thu Apr 10 15:16:33 2025
185+
+--- boost/mpl/aux_/integral_wrapper.hpp Thu Apr 10 15:19:07 2025
186+
+***************
187+
+*** 56,62 ****
188+
+ // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC),
189+
+ // while some other don't like 'value + 1' (Borland), and some don't like
190+
+ // either
191+
+! #if BOOST_WORKAROUND(__EDG_VERSION__, <= 243)
192+
+ private:
193+
+ BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, next_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1)));
194+
+ BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, prior_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1)));
195+
+--- 56,62 ----
196+
+ // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC),
197+
+ // while some other don't like 'value + 1' (Borland), and some don't like
198+
+ // either
199+
+! #if BOOST_WORKAROUND(__EDG_VERSION__, <= 243) || __cplusplus >= 201703L
200+
+ private:
201+
+ BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, next_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1)));
202+
+ BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, prior_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1)));
203+
diff --git a/patches/that_future.patch b/patches/that_future.patch
204+
new file mode 100644
205+
index 0000000..22253c0
206+
--- /dev/null
207+
+++ b/patches/that_future.patch
208+
@@ -0,0 +1,19 @@
209+
+*** boost/thread/future.hpp Thu Apr 10 21:24:34 2025
210+
+--- boost/thread/future.hpp Thu Apr 10 21:25:04 2025
211+
+***************
212+
+*** 4669,4675 ****
213+
+ }
214+
+ run_it& operator=(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT {
215+
+ if (this != &x) {
216+
+! that_=x.that;
217+
+ x.that_.reset();
218+
+ }
219+
+ return *this;
220+
+--- 4669,4675 ----
221+
+ }
222+
+ run_it& operator=(BOOST_THREAD_RV_REF(run_it) x) BOOST_NOEXCEPT {
223+
+ if (this != &x) {
224+
+! that_=x.that_;
225+
+ x.that_.reset();
226+
+ }
227+
+ return *this;
228+
diff --git a/repack.sh b/repack.sh
229+
deleted file mode 100755
230+
index adea206..0000000
231+
--- a/repack.sh
232+
+++ /dev/null
233+
@@ -1,44 +0,0 @@
234+
-#!/usr/bin/env bash
235+
-
236+
-set -e
237+
-
238+
-BOOST_VERSION=1.67.0
239+
-
240+
-function finish {
241+
- rm -rf ${tmp_dir}
242+
-}
243+
-trap finish EXIT
244+
-
245+
-out_dir=$(pwd)
246+
-patch_dir=$(pwd)/patch/${BOOST_VERSION}
247+
-tmp_dir=$(mktemp -d)
248+
-
249+
-echo "Downloading Boost ${BOOST_VERSION}..."
250+
-curl -L "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION//\./_}.tar.bz2" > ${tmp_dir}/boost_${BOOST_VERSION}.tar.bz2
251+
-
252+
-mkdir -p ${tmp_dir}/extract
253+
-cd ${tmp_dir}/extract
254+
-echo "Extracting archive..."
255+
-tar xf ${tmp_dir}/boost_${BOOST_VERSION}.tar.bz2
256+
-
257+
-cd boost_*
258+
-
259+
-if [ -d "${patch_dir}" ]; then
260+
- mkdir patch
261+
- for f in ${patch_dir}/*.patch; do
262+
- echo "Applying patch ${f}..."
263+
- git apply --verbose $f
264+
- cp $f patch/
265+
- done
266+
-fi
267+
-
268+
-echo "Removing extra files..."
269+
-find . -name "doc" -print0 | xargs -0 -- rm -rf
270+
-find . -name "*.htm*" -delete
271+
-find . -name "*.png" -delete
272+
-find . -name "*.bmp" -delete
273+
-find . -name "*.jpg" -delete
274+
-
275+
-cd ..
276+
-echo "Recompressing archive..."
277+
-tar cfJ ${out_dir}/boost_${BOOST_VERSION//./_}.tar.xz boost_*
278+
--
279+
2.39.5 (Apple Git-154)
280+
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 31afa2f9c874e00a9c275a80cf729943ff93ab2e Mon Sep 17 00:00:00 2001
2+
From: cassandras-lies <203535133+cassandras-lies@users.noreply.github.com>
3+
Date: Thu, 10 Apr 2025 14:15:39 +0000
4+
Subject: [PATCH] Fix compilation with newer CMake.
5+
6+
---
7+
CMakeLists.txt | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/CMakeLists.txt b/CMakeLists.txt
11+
index e93be8f..deb0c1d 100644
12+
--- a/CMakeLists.txt
13+
+++ b/CMakeLists.txt
14+
@@ -23,7 +23,7 @@
15+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17+
# SOFTWARE.
18+
-cmake_minimum_required( VERSION 3.1.0 )
19+
+cmake_minimum_required( VERSION 3.10.0 )
20+
set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
21+
project( openssl )
22+
23+
--
24+
2.39.5 (Apple Git-154)
25+

0 commit comments

Comments
 (0)