From cb759353bc2eec4179fd349adf6cbc37ab02004e Mon Sep 17 00:00:00 2001 From: Melvin Carvalho Date: Thu, 8 Jan 2026 11:21:03 +0100 Subject: [PATCH] Fix build on Ubuntu 22.04+ (GCC 11+, Boost 1.74) - Remove ALIGN(64) from blake2 structs inside #pragma pack(1) - Move parallel state structs outside pack block - Fix blake2s array-of-1 alignment issue - Use boost::placeholders instead of std::placeholders with boost::bind - Add Dockerfile for reproducible builds with BDB 4.8 from source Fixes #137 --- Dockerfile.build | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/blake2.h | 8 +++++--- src/blake2s-ref.c | 10 +++++----- src/main.cpp | 20 ++++++++++---------- src/rpcserver.cpp | 4 ++-- 5 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 Dockerfile.build diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000000..5b94442c66 --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,46 @@ +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +# Install build dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + libtool \ + autotools-dev \ + autoconf \ + pkg-config \ + libssl-dev \ + libboost-all-dev \ + libsodium-dev \ + libminiupnpc-dev \ + git \ + wget \ + && rm -rf /var/lib/apt/lists/* + +# Build BDB 4.8 from source (Bitcoin PPA no longer maintained) +RUN wget -q http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz \ + && echo "12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef db-4.8.30.NC.tar.gz" | sha256sum -c \ + && tar -xzf db-4.8.30.NC.tar.gz \ + && sed -i 's/__atomic_compare_exchange/__atomic_compare_exchange_db/g' db-4.8.30.NC/dbinc/atomic.h \ + && cd db-4.8.30.NC/build_unix \ + && ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=/usr/local \ + && make -j$(nproc) \ + && make install \ + && cd / && rm -rf db-4.8.30.NC db-4.8.30.NC.tar.gz + +WORKDIR /bitmark + +# Copy source +COPY . . + +# Clean any previous build artifacts +RUN make clean 2>/dev/null || true +RUN rm -f Makefile src/Makefile + +# Build +RUN ./autogen.sh +RUN ./configure --without-gui --disable-tests LDFLAGS="-L/usr/local/lib/" CPPFLAGS="-I/usr/local/include/ -DBOOST_BIND_GLOBAL_PLACEHOLDERS" +RUN make -j$(nproc) + +# Output binaries to /output +RUN mkdir -p /output && cp src/bitmarkd src/bitmark-cli /output/ diff --git a/src/blake2.h b/src/blake2.h index f8aba833ed..200c4a4693 100644 --- a/src/blake2.h +++ b/src/blake2.h @@ -61,7 +61,7 @@ extern "C" { uint8_t personal[BLAKE2S_PERSONALBYTES]; // 32 } blake2s_param; - ALIGN( 64 ) typedef struct __blake2s_state + typedef struct __blake2s_state { uint32_t h[8]; uint32_t t[2]; @@ -86,7 +86,7 @@ extern "C" { uint8_t personal[BLAKE2B_PERSONALBYTES]; // 64 } blake2b_param; - ALIGN( 64 ) typedef struct __blake2b_state + typedef struct __blake2b_state { uint64_t h[8]; uint64_t t[2]; @@ -96,6 +96,9 @@ extern "C" { uint8_t last_node; } blake2b_state; +#pragma pack(pop) + + // These structs contain aligned types, must be outside pack(1) typedef struct __blake2sp_state { blake2s_state S[8][1]; @@ -111,7 +114,6 @@ extern "C" { uint8_t buf[4 * BLAKE2B_BLOCKBYTES]; size_t buflen; } blake2bp_state; -#pragma pack(pop) // Streaming API int blake2s_init( blake2s_state *S, const uint8_t outlen ); diff --git a/src/blake2s-ref.c b/src/blake2s-ref.c index 9de1cb72ce..ae2ad01b0b 100644 --- a/src/blake2s-ref.c +++ b/src/blake2s-ref.c @@ -352,7 +352,7 @@ int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen ) int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ) { - blake2s_state S[1]; + blake2s_state S; /* Verify parameters */ if ( NULL == in ) return -1; @@ -363,15 +363,15 @@ int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen if( keylen > 0 ) { - if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1; + if( blake2s_init_key( &S, outlen, key, keylen ) < 0 ) return -1; } else { - if( blake2s_init( S, outlen ) < 0 ) return -1; + if( blake2s_init( &S, outlen ) < 0 ) return -1; } - blake2s_update( S, ( const uint8_t * )in, inlen ); - blake2s_final( S, out, outlen ); + blake2s_update( &S, ( const uint8_t * )in, inlen ); + blake2s_final( &S, out, outlen ); return 0; } diff --git a/src/main.cpp b/src/main.cpp index 9d127bae75..7e9a38a3d6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -155,21 +155,21 @@ struct CMainSignals { } void RegisterWallet(CWalletInterface* pwalletIn) { - g_signals.SyncTransaction.connect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - g_signals.EraseTransaction.connect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, std::placeholders::_1)); - g_signals.UpdatedTransaction.connect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, std::placeholders::_1)); - g_signals.SetBestChain.connect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, std::placeholders::_1)); - g_signals.Inventory.connect(boost::bind(&CWalletInterface::Inventory, pwalletIn, std::placeholders::_1)); + g_signals.SyncTransaction.connect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3)); + g_signals.EraseTransaction.connect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, boost::placeholders::_1)); + g_signals.UpdatedTransaction.connect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, boost::placeholders::_1)); + g_signals.SetBestChain.connect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, boost::placeholders::_1)); + g_signals.Inventory.connect(boost::bind(&CWalletInterface::Inventory, pwalletIn, boost::placeholders::_1)); g_signals.Broadcast.connect(boost::bind(&CWalletInterface::ResendWalletTransactions, pwalletIn)); } void UnregisterWallet(CWalletInterface* pwalletIn) { g_signals.Broadcast.disconnect(boost::bind(&CWalletInterface::ResendWalletTransactions, pwalletIn)); - g_signals.Inventory.disconnect(boost::bind(&CWalletInterface::Inventory, pwalletIn, std::placeholders::_1)); - g_signals.SetBestChain.disconnect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, std::placeholders::_1)); - g_signals.UpdatedTransaction.disconnect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, std::placeholders::_1)); - g_signals.EraseTransaction.disconnect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, std::placeholders::_1)); - g_signals.SyncTransaction.disconnect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + g_signals.Inventory.disconnect(boost::bind(&CWalletInterface::Inventory, pwalletIn, boost::placeholders::_1)); + g_signals.SetBestChain.disconnect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, boost::placeholders::_1)); + g_signals.UpdatedTransaction.disconnect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, boost::placeholders::_1)); + g_signals.EraseTransaction.disconnect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, boost::placeholders::_1)); + g_signals.SyncTransaction.disconnect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3)); } void UnregisterAllWallets() { diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 8805bf25bc..030c402d19 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -547,7 +547,7 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor > accep boost::ref(context), fUseSSL, conn, - _1)); + boost::placeholders::_1)); } @@ -769,7 +769,7 @@ void RPCRunLater(const std::string& name, boost::function func, int6 boost::shared_ptr(new deadline_timer(*rpc_io_service)))); } deadlineTimers[name]->expires_from_now(posix_time::seconds(nSeconds)); - deadlineTimers[name]->async_wait(boost::bind(RPCRunHandler, _1, func)); + deadlineTimers[name]->async_wait(boost::bind(RPCRunHandler, boost::placeholders::_1, func)); } class JSONRequest