From 6f8fcdab03e3e9df222f582cc20861d253a3becb Mon Sep 17 00:00:00 2001 From: somerandomcryptoguy <139346562+somerandomcryptoguy@users.noreply.github.com> Date: Sat, 19 Jul 2025 12:25:45 +0100 Subject: [PATCH] fixed make depends for all major platforms (#26) * fixed 'make depends' building * fixed capture vars for MacOS * fixed Linux build for make depends --------- Co-authored-by: Some Random Crypto Guy --- contrib/depends/hosts/darwin.mk | 2 +- contrib/depends/hosts/mingw32.mk | 2 +- contrib/depends/packages/boost.mk | 28 +++++------ contrib/depends/packages/native_cctools.mk | 7 +-- contrib/depends/packages/native_clang.mk | 16 ++++-- contrib/depends/packages/native_libtapi.mk | 18 +------ contrib/depends/packages/ncurses.mk | 1 + contrib/depends/packages/packages.mk | 50 +++++++++---------- contrib/depends/packages/unbound.mk | 22 ++++---- .../depends/patches/boost/fix_arm_arch.patch | 11 ---- .../depends/patches/boost/fix_aroptions.patch | 28 ----------- .../unbound/disable-glibc-reallocarray.patch | 14 ------ .../depends/patches/unbound/no-expat.patch | 20 ++++++++ contrib/depends/toolchain.cmake.in | 2 +- src/cryptonote_core/blockchain.cpp | 6 +-- 15 files changed, 93 insertions(+), 134 deletions(-) delete mode 100644 contrib/depends/patches/boost/fix_arm_arch.patch delete mode 100644 contrib/depends/patches/boost/fix_aroptions.patch delete mode 100644 contrib/depends/patches/unbound/disable-glibc-reallocarray.patch create mode 100644 contrib/depends/patches/unbound/no-expat.patch diff --git a/contrib/depends/hosts/darwin.mk b/contrib/depends/hosts/darwin.mk index 9a96e2601..9c4da268a 100644 --- a/contrib/depends/hosts/darwin.mk +++ b/contrib/depends/hosts/darwin.mk @@ -1,4 +1,4 @@ -OSX_MIN_VERSION=10.13 +OSX_MIN_VERSION=11.0 LD64_VERSION=609 ifeq (aarch64, $(host_arch)) CC_target=arm64-apple-$(host_os) diff --git a/contrib/depends/hosts/mingw32.mk b/contrib/depends/hosts/mingw32.mk index 775331223..58a9a929d 100644 --- a/contrib/depends/hosts/mingw32.mk +++ b/contrib/depends/hosts/mingw32.mk @@ -1,4 +1,4 @@ -mingw32_CFLAGS=-pipe -pthread +mingw32_CFLAGS=-pipe mingw32_CXXFLAGS=$(mingw32_CFLAGS) mingw32_ARFLAGS=cr diff --git a/contrib/depends/packages/boost.mk b/contrib/depends/packages/boost.mk index 402fc84a5..b44bbb721 100644 --- a/contrib/depends/packages/boost.mk +++ b/contrib/depends/packages/boost.mk @@ -1,19 +1,17 @@ -package=boost -$(package)_version=1.66.0 +package=boost +$(package)_version=1.84.0 $(package)_download_path=https://archives.boost.io/release/$($(package)_version)/source/ -$(package)_file_name=$(package)_$(subst .,_,$($(package)_version)).tar.gz -$(package)_sha256_hash=bd0df411efd9a585e5a2212275f8762079fed8842264954675a4fddc46cfcf60 -$(package)_dependencies=libiconv -$(package)_patches=fix_aroptions.patch fix_arm_arch.patch +$(package)_file_name=$(package)_$(subst .,_,$($(package)_version)).tar.bz2 +$(package)_sha256_hash=cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454 define $(package)_set_vars $(package)_config_opts_release=variant=release $(package)_config_opts_debug=variant=debug -$(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam +$(package)_config_opts+=--layout=system --user-config=user-config.jam variant=release $(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1 $(package)_config_opts_linux=threadapi=pthread runtime-link=shared $(package)_config_opts_android=threadapi=pthread runtime-link=static target-os=android -$(package)_config_opts_darwin=--toolset=darwin runtime-link=shared +$(package)_config_opts_darwin=--toolset=darwin runtime-link=shared target-os=darwin $(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static $(package)_config_opts_x86_64_mingw32=address-model=64 $(package)_config_opts_i686_mingw32=address-model=32 @@ -22,20 +20,20 @@ $(package)_toolset_$(host_os)=gcc $(package)_archiver_$(host_os)=$($(package)_ar) $(package)_toolset_darwin=darwin $(package)_archiver_darwin=$($(package)_libtool) -$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization,locale -$(package)_cxxflags=-std=c++11 -$(package)_cxxflags_linux=-fPIC -$(package)_cxxflags_freebsd=-fPIC -DBOOST_ASIO_HAS_STD_STRING_VIEW=1 +$(package)_config_libraries_$(host_os)="chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization" +$(package)_config_libraries_mingw32="chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization,locale" +$(package)_cxxflags=-std=c++17 +$(package)_cxxflags_linux+=-fPIC +$(package)_cxxflags_freebsd+=-fPIC +$(package)_cxxflags_darwin+=-ffile-prefix-map=$($(package)_extract_dir)=/usr endef define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/fix_aroptions.patch &&\ - patch -p1 < $($(package)_patch_dir)/fix_arm_arch.patch &&\ echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : \"$($(package)_cxxflags) $($(package)_cppflags)\" \"$($(package)_ldflags)\" \"$(boost_archiver_$(host_os))\" \"$($(package)_arflags)\" \"$(host_STRIP)\" \"$(host_RANLIB)\" \"$(host_WINDRES)\" : ;" > user-config.jam endef define $(package)_config_cmds - ./bootstrap.sh --without-icu --with-libraries=$(boost_config_libraries) + ./bootstrap.sh --without-icu --with-libraries=$(boost_config_libraries_$(host_os)) endef define $(package)_build_cmds diff --git a/contrib/depends/packages/native_cctools.mk b/contrib/depends/packages/native_cctools.mk index 8c1ea4c62..85f96b7aa 100644 --- a/contrib/depends/packages/native_cctools.mk +++ b/contrib/depends/packages/native_cctools.mk @@ -5,17 +5,18 @@ $(package)_download_file=$($(package)_version).tar.gz $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=70a7189418c2086d20c299c5d59250cf5940782c778892ccc899c66516ed240e $(package)_build_subdir=cctools -$(package)_dependencies=native_clang native_libtapi $(package)_patches=no-build-date.patch +$(package)_dependencies=native_libtapi define $(package)_set_vars $(package)_config_opts=--target=$(host) --disable-lto-support --with-libtapi=$(host_prefix) $(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib -$(package)_cc=$(host_prefix)/native/bin/clang -$(package)_cxx=$(host_prefix)/native/bin/clang++ +$(package)_cc=$(clang_prog) +$(package)_cxx=$(clangxx_prog) endef define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub cctools && \ patch -p1 < $($(package)_patch_dir)/no-build-date.patch endef diff --git a/contrib/depends/packages/native_clang.mk b/contrib/depends/packages/native_clang.mk index 4ff21ada0..ff49dddcf 100644 --- a/contrib/depends/packages/native_clang.mk +++ b/contrib/depends/packages/native_clang.mk @@ -1,9 +1,15 @@ package=native_clang -$(package)_version=9.0.0 -$(package)_download_path=https://releases.llvm.org/$($(package)_version) -$(package)_download_file=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz -$(package)_file_name=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz -$(package)_sha256_hash=a23b082b30c128c9831dbdd96edad26b43f56624d0ad0ea9edec506f5385038d +#$(package)_version=9.0.0 +#$(package)_download_path=https://releases.llvm.org/$($(package)_version) +#$(package)_download_file=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz +#$(package)_file_name=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-18.04.tar.xz +#$(package)_sha256_hash=a23b082b30c128c9831dbdd96edad26b43f56624d0ad0ea9edec506f5385038d + +$(package)_version=12.0.0 +$(package)_download_path=https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(package)_version) +$(package)_download_file=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-20.04.tar.xz +$(package)_file_name=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-20.04.tar.xz +$(package)_sha256_hash=a9ff205eb0b73ca7c86afc6432eed1c2d49133bd0d49e47b15be59bbf0dd292e define $(package)_extract_cmds echo $($(package)_sha256_hash) $($(package)_source) | sha256sum -c &&\ diff --git a/contrib/depends/packages/native_libtapi.mk b/contrib/depends/packages/native_libtapi.mk index c5625501a..36234a001 100644 --- a/contrib/depends/packages/native_libtapi.mk +++ b/contrib/depends/packages/native_libtapi.mk @@ -4,30 +4,16 @@ $(package)_download_path=https://github.com/tpoechtrager/apple-libtapi/archive $(package)_download_file=$($(package)_version).tar.gz $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=62e419c12d1c9fad67cc1cd523132bc00db050998337c734c15bc8d73cc02b61 -$(package)_build_subdir=build -$(package)_dependencies=native_clang $(package)_patches=no_embed_git_rev.patch define $(package)_preprocess_cmds patch -p1 -i $($(package)_patch_dir)/no_embed_git_rev.patch endef -define $(package)_config_cmds - echo -n $(build_prefix) > INSTALLPREFIX; \ - CC=$(host_prefix)/native/bin/clang CXX=$(host_prefix)/native/bin/clang++ \ - cmake -DCMAKE_INSTALL_PREFIX=$(build_prefix) \ - -DLLVM_INCLUDE_TESTS=OFF \ - -DCMAKE_BUILD_TYPE=RELEASE \ - -DTAPI_REPOSITORY_STRING="1100.0.11" \ - -DTAPI_FULL_VERSION="11.0.0" \ - -DCMAKE_CXX_FLAGS="-I $($(package)_extract_dir)/src/llvm/projects/clang/include -I $($(package)_build_dir)/projects/clang/include" \ - $($(package)_extract_dir)/src/llvm -endef - define $(package)_build_cmds - $(MAKE) clangBasic && $(MAKE) libtapi + CC=$(clang_prog) CXX=$(clangxx_prog) INSTALLPREFIX=$($(package)_staging_prefix_dir) ./build.sh endef define $(package)_stage_cmds - $(MAKE) DESTDIR=$($(package)_staging_dir) install-libtapi install-tapi-headers + ./install.sh endef diff --git a/contrib/depends/packages/ncurses.mk b/contrib/depends/packages/ncurses.mk index fb1d92c65..004c29372 100644 --- a/contrib/depends/packages/ncurses.mk +++ b/contrib/depends/packages/ncurses.mk @@ -46,6 +46,7 @@ define $(package)_set_vars endef define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . && \ cp $($(package)_patch_dir)/fallback.c ncurses endef diff --git a/contrib/depends/packages/packages.mk b/contrib/depends/packages/packages.mk index d2d1eca85..886095bfa 100644 --- a/contrib/depends/packages/packages.mk +++ b/contrib/depends/packages/packages.mk @@ -1,38 +1,34 @@ -packages:=boost openssl zeromq libiconv expat unbound +native_packages := native_protobuf +packages := boost openssl zeromq unbound sodium protobuf -# ccache is useless in gitian builds -ifneq ($(GITIAN),1) -native_packages := native_ccache +ifneq ($(host_os),android) +packages += libusb endif -hardware_packages := hidapi protobuf libusb -hardware_native_packages := native_protobuf - -android_native_packages = android_ndk -android_packages = ncurses readline sodium - -darwin_native_packages = $(hardware_native_packages) -darwin_packages = ncurses readline sodium $(hardware_packages) - -# not really native... -freebsd_native_packages = freebsd_base -freebsd_packages = ncurses readline sodium - -linux_packages = eudev ncurses readline sodium $(hardware_packages) -linux_native_packages = $(hardware_native_packages) - -ifeq ($(build_tests),ON) -packages += gtest +ifneq ($(host_os),freebsd) +ifneq ($(host_os),android) +packages += hidapi +endif endif -ifneq ($(host_arch),riscv64) -linux_packages += unwind +ifneq ($(host_os),mingw32) +packages += ncurses readline endif -mingw32_packages = icu4c sodium $(hardware_packages) -mingw32_native_packages = $(hardware_native_packages) +mingw32_native_packages := +mingw32_packages = icu4c libiconv + +linux_native_packages := +linux_packages := eudev + +freebsd_native_packages := freebsd_base +freebsd_packages := ifneq ($(build_os),darwin) -darwin_native_packages += darwin_sdk native_clang native_cctools native_libtapi +darwin_native_packages := darwin_sdk native_clang native_cctools native_libtapi endif +darwin_packages := + +android_native_packages := android_ndk +android_packages := diff --git a/contrib/depends/packages/unbound.mk b/contrib/depends/packages/unbound.mk index 254636bca..1184a8c95 100644 --- a/contrib/depends/packages/unbound.mk +++ b/contrib/depends/packages/unbound.mk @@ -1,26 +1,26 @@ package=unbound -$(package)_version=1.19.1 +$(package)_version=1.22.0 $(package)_download_path=https://www.nlnetlabs.nl/downloads/$(package)/ $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=bc1d576f3dd846a0739adc41ffaa702404c6767d2b6082deb9f2f97cbb24a3a9 -$(package)_dependencies=openssl expat -$(package)_patches=disable-glibc-reallocarray.patch - +$(package)_sha256_hash=c5dd1bdef5d5685b2cedb749158dd152c52d44f65529a34ac15cd88d4b1b3d43 +$(package)_dependencies=openssl +$(package)_patches=no-expat.patch define $(package)_set_vars $(package)_config_opts=--disable-shared --enable-static --without-pyunbound --prefix=$(host_prefix) - $(package)_config_opts+=--with-libexpat=$(host_prefix) --with-ssl=$(host_prefix) --with-libevent=no + $(package)_config_opts+=--with-libexpat=no --with-ssl=$(host_prefix) --with-libevent=no $(package)_config_opts+=--without-pythonmodule --disable-flto --with-pthreads --with-libunbound-only - $(package)_config_opts_linux=--with-pic $(package)_config_opts_w64=--enable-static-exe --sysconfdir=/etc --prefix=$(host_prefix) --target=$(host_prefix) $(package)_config_opts_x86_64_darwin=ac_cv_func_SHA384_Init=yes $(package)_build_opts_mingw32=LDFLAGS="$($(package)_ldflags) -lpthread" $(package)_cflags_mingw32+="-D_WIN32_WINNT=0x600" endef +# Remove blobs define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/disable-glibc-reallocarray.patch &&\ - autoconf + patch -p1 < $($(package)_patch_dir)/no-expat.patch &&\ + rm configure~ doc/*.odp doc/*.pdf contrib/*.tar.gz contrib/*.tar.bz2 &&\ + rm -rf testdata dnscrypt/testdata endef define $(package)_config_cmds @@ -34,3 +34,7 @@ endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install endef + +define $(package)_postprocess_cmds + rm -rf share +endef diff --git a/contrib/depends/patches/boost/fix_arm_arch.patch b/contrib/depends/patches/boost/fix_arm_arch.patch deleted file mode 100644 index 3cf6b6f4e..000000000 --- a/contrib/depends/patches/boost/fix_arm_arch.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- boost_1_64_0/tools/build/src/tools/darwin.jam.O 2017-04-17 03:22:26.000000000 +0100 -+++ boost_1_64_0/tools/build/src/tools/darwin.jam 2022-05-04 17:26:29.984464447 +0000 -@@ -505,7 +505,7 @@ - if $(instruction-set) { - options = -arch$(_)$(instruction-set) ; - } else { -- options = -arch arm ; -+# options = -arch arm ; - } - } - } diff --git a/contrib/depends/patches/boost/fix_aroptions.patch b/contrib/depends/patches/boost/fix_aroptions.patch deleted file mode 100644 index 5b2ec1006..000000000 --- a/contrib/depends/patches/boost/fix_aroptions.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- boost_1_64_0/tools/build/src/tools/gcc.jam.O 2017-04-17 03:22:26.000000000 +0100 -+++ boost_1_64_0/tools/build/src/tools/gcc.jam 2019-11-15 15:46:16.957937137 +0000 -@@ -243,6 +243,8 @@ - { - ECHO notice: using gcc archiver :: $(condition) :: $(archiver[1]) ; - } -+ local arflags = [ feature.get-values : $(options) ] ; -+ toolset.flags gcc.archive .ARFLAGS $(condition) : $(arflags) ; - - # - Ranlib. - local ranlib = [ common.get-invocation-command gcc -@@ -970,6 +972,7 @@ - # logic in intel-linux, but that is hardly worth the trouble as on Linux, 'ar' - # is always available. - .AR = ar ; -+.ARFLAGS = rc ; - .RANLIB = ranlib ; - - toolset.flags gcc.archive AROPTIONS ; -@@ -1011,7 +1014,7 @@ - # - actions piecemeal archive - { -- "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)" -+ "$(.AR)" $(AROPTIONS) $(.ARFLAGS) "$(<)" "$(>)" - "$(.RANLIB)" "$(<)" - } - diff --git a/contrib/depends/patches/unbound/disable-glibc-reallocarray.patch b/contrib/depends/patches/unbound/disable-glibc-reallocarray.patch deleted file mode 100644 index d66a821ad..000000000 --- a/contrib/depends/patches/unbound/disable-glibc-reallocarray.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/configure.ac b/configure.ac -index 5c7da197..e2b25288 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1702,6 +1702,9 @@ AC_LINK_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT - #ifndef _OPENBSD_SOURCE - #define _OPENBSD_SOURCE 1 - #endif -+#ifdef __linux__ -+# error reallocarray() is currently disabled on Linux to support glibc < 2.26 -+#endif - #include - int main(void) { - void* p = reallocarray(NULL, 10, 100); diff --git a/contrib/depends/patches/unbound/no-expat.patch b/contrib/depends/patches/unbound/no-expat.patch new file mode 100644 index 000000000..7d1c854f8 --- /dev/null +++ b/contrib/depends/patches/unbound/no-expat.patch @@ -0,0 +1,20 @@ +diff --git a/configure b/configure +index a41e3e1e..7d6a58f0 100755 +--- a/configure ++++ b/configure +@@ -22053,6 +22053,7 @@ else $as_nop + withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" + fi + ++if test x_$withval = x_yes -o x_$withval != x_no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libexpat" >&5 + printf %s "checking for libexpat... " >&6; } + found_libexpat="no" +@@ -22090,6 +22091,7 @@ else $as_nop + ac_have_decl=0 + fi + printf "%s\n" "#define HAVE_DECL_XML_STOPPARSER $ac_have_decl" >>confdefs.h ++fi + + + # hiredis (redis C client for cachedb) diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in index fc502c596..ffa89e087 100644 --- a/contrib/depends/toolchain.cmake.in +++ b/contrib/depends/toolchain.cmake.in @@ -91,7 +91,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") SET(BREW OFF) SET(PORT OFF) SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/") - SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") + SET(CMAKE_OSX_DEPLOYMENT_TARGET "11.0") SET(CMAKE_CXX_STANDARD 17) SET(LLVM_ENABLE_PIC OFF) SET(LLVM_ENABLE_PIE OFF) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index d11ecead2..5ced780de 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1427,8 +1427,8 @@ std::tuple Blockchain::validate_treasury_payout(const transaction& // find the treasury output const auto [tx_key, onetime_address, anchor_enc, viewtag] = treasury_data; - //const auto expected_output_key = std::get<1>(treasury_output_data); - const auto &output = std::find_if(tx.vout.begin(), tx.vout.end(), [&onetime_address](const tx_out &o) { + const auto &oa = onetime_address; // Alias to support capture compatibility on MacOS + const auto &output = std::find_if(tx.vout.begin(), tx.vout.end(), [&oa](const tx_out &o) { std::string output_key; if (o.target.type() == typeid(txout_to_carrot_v1)) { output_key = epee::string_tools::pod_to_hex(boost::get(o.target).key); @@ -1436,7 +1436,7 @@ std::tuple Blockchain::validate_treasury_payout(const transaction& return false; } - return output_key == onetime_address; + return output_key == oa; }); if (output == tx.vout.end()) {