Bitcoin stable (v0.5.x) on FreeBSD [patch]
grarpamp
grarpamp at gmail.com
Mon Jan 30 02:42:42 UTC 2012
FreeBSD's port of bitcoin is lagging behind. Here is a patch.
Though it should go well, a QT build has not been tried yet.
Surely others can do a better job with the makefile than me.
The rest is backport from bitcoind master + includes.
test_bitcoin works.
Please consider/review for inclusion. Thanks :)
platform:
FreeBSD RELENG_8 i386, gcc 4.2.2, gmake 3.81
boost 1.48.0, db 4.8.30
Patch made and build tested against:
bitcoind-stable a0db9a79e5b6b7226b7c3a3f61df30106eac304c
Also works with:
bitcoind-stable v0.5.2 7de7913abdbaa30f0ef6ad1b63508d3a8441d08f
Set the BOOST and BDB paths, then (static is optional):
USE_UPNP=- STATIC=y BOXTYPE=bsd gmake -f makefile.unix
-------------- next part --------------
diff -u -r bitcoind-stable.orig/src/makefile.unix bitcoind-stable/src/makefile.unix
--- bitcoind-stable.orig/src/makefile.unix 2012-01-29 14:12:20.000000000 -0500
+++ bitcoind-stable/src/makefile.unix 2012-01-29 20:29:30.093693000 -0500
@@ -2,25 +2,26 @@
# Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php.
-USE_UPNP:=0
+USE_UPNP?=0
DEFS=-DNOPCH
DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
-LIBS += $(addprefix -l,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
+LIBS += $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
-LMODE = dynamic
-LMODE2 = dynamic
ifdef STATIC
- LMODE = static
- ifeq (${STATIC}, all)
- LMODE2 = static
+ ifeq (${BOXTYPE}, bsd)
+ # fixes this
+ # /usr/bin/ld: cannot find -lgcc_s
+ LIBS+= -static
+ else
+ # just do them all at once here, default dynamic
+ LIBS+= -Wl,-Bstatic
endif
endif
# for boost 1.37, add -mt to the boost libraries
-LIBS= \
- -Wl,-B$(LMODE) \
+LIBS+= \
-l boost_system$(BOOST_LIB_SUFFIX) \
-l boost_filesystem$(BOOST_LIB_SUFFIX) \
-l boost_program_options$(BOOST_LIB_SUFFIX) \
@@ -41,12 +42,14 @@
DEFS += -DUSE_SSL
endif
-LIBS+= \
- -Wl,-B$(LMODE2) \
- -l z \
- -l dl \
- -l pthread
-
+ifeq (${BOXTYPE}, bsd)
+ # unused? : z
+ # covered by -pthread : pthread
+ # not present, part of -lc : dl
+ LIBS+= -l z -l pthread
+else
+ LIBS+= -l z -l pthread -l dl
+endif
# Hardening
# Make some classes of vulnerabilities unexploitable in case one is discovered.
@@ -66,7 +69,15 @@
# Make some important things such as the global offset table read only as soon as
# the dynamic linker is finished building it. This will prevent overwriting of addresses
# which would later be jumped to.
+ifeq (${BOXTYPE}, bsd)
+ # quiets these - only linking, not objects
+ # g++: -z: linker input file unused because linking not done
+ # g++: relro: linker input file unused because linking not done
+ # g++: now: linker input file unused because linking not done
+ LIBS+= -Wl,-z,relro -Wl,-z,now
+else
HARDENING+=-Wl,-z,relro -Wl,-z,now
+endif
# Build position independent code to take advantage of Address Space Layout Randomization
# offered by some kernels.
@@ -147,7 +158,7 @@
rm -f $(@:%.o=%.d)
test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
- $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
+ $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
clean:
-rm -f bitcoind test_bitcoin
diff -u -r bitcoind-stable.orig/src/net.cpp bitcoind-stable/src/net.cpp
--- bitcoind-stable.orig/src/net.cpp 2012-01-29 14:12:20.000000000 -0500
+++ bitcoind-stable/src/net.cpp 2012-01-29 20:29:30.093693000 -0500
@@ -1490,7 +1490,7 @@
// Choose an address to connect to based on most recently seen
//
CAddress addrConnect;
- int64 nBest = INT64_MIN;
+ int64 nBest = std::numeric_limits<int64>::min();
// Only connect to one address per a.b.?.? range.
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
diff -u -r bitcoind-stable.orig/src/protocol.cpp bitcoind-stable/src/protocol.cpp
--- bitcoind-stable.orig/src/protocol.cpp 2012-01-29 14:12:20.000000000 -0500
+++ bitcoind-stable/src/protocol.cpp 2012-01-29 20:29:30.093693000 -0500
@@ -5,6 +5,8 @@
#include "protocol.h"
#include "util.h"
+#include <netinet/in.h>
+#include <sys/socket.h>
#ifndef WIN32
# include <arpa/inet.h>
diff -u -r bitcoind-stable.orig/src/util.cpp bitcoind-stable/src/util.cpp
--- bitcoind-stable.orig/src/util.cpp 2012-01-29 14:12:21.000000000 -0500
+++ bitcoind-stable/src/util.cpp 2012-01-29 20:29:30.093693000 -0500
@@ -132,7 +132,7 @@
// The range of the random source must be a multiple of the modulus
// to give every possible output value an equal possibility
- uint64 nRange = (UINT64_MAX / nMax) * nMax;
+ uint64 nRange = (std::numeric_limits<uint64>::max() / nMax) * nMax;
uint64 nRand = 0;
do
RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
diff -u -r bitcoind-stable.orig/src/wallet.cpp bitcoind-stable/src/wallet.cpp
--- bitcoind-stable.orig/src/wallet.cpp 2012-01-29 14:12:21.000000000 -0500
+++ bitcoind-stable/src/wallet.cpp 2012-01-29 20:29:30.093693000 -0500
@@ -764,7 +764,7 @@
// List of values less than target
pair<int64, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
- coinLowestLarger.first = INT64_MAX;
+ coinLowestLarger.first = std::numeric_limits<int64>::max();
coinLowestLarger.second.first = NULL;
vector<pair<int64, pair<const CWalletTx*,unsigned int> > > vValue;
int64 nTotalLower = 0;
More information about the freebsd-ports
mailing list