Bug 207110 - net-p2p/bitcoin fails to build
Summary: net-p2p/bitcoin fails to build
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Tijl Coosemans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-11 16:00 UTC by olexander.v.melnyk
Modified: 2016-05-02 14:27 UTC (History)
8 users (show)

See Also:
bugzilla: maintainer-feedback? (robbak)


Attachments
bitcoin-hardening_off.log (620.38 KB, text/x-log)
2016-02-12 13:18 UTC, w.schwarzenfeld
no flags Details
bitcoin-hardening_on.log (255.62 KB, text/x-log)
2016-02-12 13:20 UTC, w.schwarzenfeld
no flags Details
log with HARDENING set (227.46 KB, text/x-log)
2016-02-12 14:11 UTC, olexander.v.melnyk
no flags Details
log with HARDENING unset (205.35 KB, text/x-log)
2016-02-12 14:17 UTC, olexander.v.melnyk
no flags Details
proposed patch for Makefile (523 bytes, patch)
2016-02-19 10:43 UTC, olexander.v.melnyk
no flags Details | Diff
log with changing compiler (228.76 KB, text/x-log)
2016-05-01 11:45 UTC, olexander.v.melnyk
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description olexander.v.melnyk 2016-02-11 16:00:32 UTC
net-p2p/bitcoin fails to build on amd64 10.1-RELEASE and 10.2-RELEASE
With option HARDENING set:

ar: warning: creating libleveldb.a
gmake[5]: Leaving directory '/usr/ports/net-p2p/bitcoin/work/bitcoin-0.11.2/src/leveldb'
gmake  -C secp256k1 libsecp256k1.la
gmake[5]: Entering directory '/usr/ports/net-p2p/bitcoin/work/bitcoin-0.11.2/src/secp256k1'
/bin/sh ./libtool  --tag=CC   --mode=compile cc -DHAVE_CONFIG_H -I. -I./src  -I./include    -O2 -pipe  -fstack-protector -fno-strict-aliasing -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -MT src/libsecp256k1_la-secp256k1.lo -MD -MP -MF src/.deps/libsecp256k1_la-secp256k1.Tpo -c -o src/libsecp256k1_la-secp256k1.lo `test -f 'src/secp256k1.c' || echo './'`src/secp256k1.c
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I./src -I./include -O2 -pipe -fstack-protector -fno-strict-aliasing -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -MT src/libsecp256k1_la-secp256k1.lo -MD -MP -MF src/.deps/libsecp256k1_la-secp256k1.Tpo -c src/secp256k1.c  -fPIC -DPIC -o src/libsecp256k1_la-secp256k1.o
mv -f src/.deps/libsecp256k1_la-secp256k1.Tpo src/.deps/libsecp256k1_la-secp256k1.Plo
/bin/sh ./libtool  --tag=CC   --mode=link cc  -O2 -pipe  -fstack-protector -fno-strict-aliasing -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings  -fstack-protector -o libsecp256k1.la -rpath /usr/local/lib src/libsecp256k1_la-secp256k1.lo  -L/usr/local/lib/db48
libtool: link: /usr/bin/ar cru .libs/libsecp256k1.a  src/libsecp256k1_la-secp256k1.o
libtool: link: /usr/bin/ranlib .libs/libsecp256k1.a
libtool: link: ( cd ".libs" && rm -f "libsecp256k1.la" && ln -s "../libsecp256k1.la" "libsecp256k1.la" )
gmake[5]: Leaving directory '/usr/ports/net-p2p/bitcoin/work/bitcoin-0.11.2/src/secp256k1'
/bin/sh ../libtool  --tag CXX  --mode=link g++  -O2 -pipe -fstack-protector -fno-strict-aliasing  -I/usr/local/include/db48  -Wstack-protector -fstack-protector-all -fPIE  -D_THREAD_SAFE -pthread    -fstack-protector  -Wl,-z,relro -Wl,-z,now -pie -o qt/bitcoin-qt qt/qt_bitcoin_qt-bitcoin.o   qt/libbitcoinqt.a libbitcoin_server.a libbitcoin_wallet.a libbitcoin_cli.a libbitcoin_common.a libbitcoin_util.a crypto/libbitcoin_crypto.a univalue/libbitcoin_univalue.a ./leveldb/libleveldb.a ./leveldb/libmemenv.a -pthread -L/usr/local/lib -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lboost_chrono -L/usr/local/lib/qt4 -lQtGui -lQtNetwork -lQtCore    -L/usr/local/lib -lqrencode -lpthread   -L/usr/local/lib -lprotobuf -D_THREAD_SAFE -pthread  -lpthread   -ldb_cxx-4.8 -L/usr/lib -lssl -L/usr/lib -lcrypto  secp256k1/libsecp256k1.la -lcrypto -L/usr/local/lib/db48
libtool: link: g++ -O2 -pipe -fstack-protector -fno-strict-aliasing -I/usr/local/include/db48 -Wstack-protector -fstack-protector-all -fPIE -D_THREAD_SAFE -pthread -fstack-protector -Wl,-z -Wl,relro -Wl,-z -Wl,now -pie -o qt/bitcoin-qt qt/qt_bitcoin_qt-bitcoin.o -pthread -D_THREAD_SAFE -pthread  qt/libbitcoinqt.a libbitcoin_server.a libbitcoin_wallet.a libbitcoin_cli.a libbitcoin_common.a libbitcoin_util.a crypto/libbitcoin_crypto.a univalue/libbitcoin_univalue.a ./leveldb/libleveldb.a ./leveldb/libmemenv.a -L/usr/local/lib -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lboost_chrono -L/usr/local/lib/qt4 -lQtGui -lQtNetwork -lQtCore -lqrencode -lprotobuf -lpthread -ldb_cxx-4.8 -L/usr/lib -lssl secp256k1/.libs/libsecp256k1.a -L/usr/local/lib/db48 -lcrypto -pthread
/usr/local/bin/ld: /usr/lib/crt1.o: relocation R_X86_64_32 against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC
/usr/lib/crt1.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:2628: recipe for target 'qt/bitcoin-qt' failed
gmake[4]: *** [qt/bitcoin-qt] Error 1
gmake[4]: Leaving directory '/usr/ports/net-p2p/bitcoin/work/bitcoin-0.11.2/src'
Makefile:6470: recipe for target 'all-recursive' failed


With option HARDENING unset:

ar: warning: creating libleveldb.a
gmake[5]: Leaving directory '/usr/ports/net-p2p/bitcoin/work/bitcoin-0.11.2/src/leveldb'
gmake  -C secp256k1 libsecp256k1.la
gmake[5]: Entering directory '/usr/ports/net-p2p/bitcoin/work/bitcoin-0.11.2/src/secp256k1'
/bin/sh ./libtool  --tag=CC   --mode=compile cc -DHAVE_CONFIG_H -I. -I./src  -I./include    -O2 -pipe  -fstack-protector -fno-strict-aliasing -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -MT src/libsecp256k1_la-secp256k1.lo -MD -MP -MF src/.deps/libsecp256k1_la-secp256k1.Tpo -c -o src/libsecp256k1_la-secp256k1.lo `test -f 'src/secp256k1.c' || echo './'`src/secp256k1.c
libtool: compile:  cc -DHAVE_CONFIG_H -I. -I./src -I./include -O2 -pipe -fstack-protector -fno-strict-aliasing -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -MT src/libsecp256k1_la-secp256k1.lo -MD -MP -MF src/.deps/libsecp256k1_la-secp256k1.Tpo -c src/secp256k1.c  -fPIC -DPIC -o src/libsecp256k1_la-secp256k1.o
mv -f src/.deps/libsecp256k1_la-secp256k1.Tpo src/.deps/libsecp256k1_la-secp256k1.Plo
/bin/sh ./libtool  --tag=CC   --mode=link cc  -O2 -pipe  -fstack-protector -fno-strict-aliasing -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings  -fstack-protector -o libsecp256k1.la -rpath /usr/local/lib src/libsecp256k1_la-secp256k1.lo  -L/usr/local/lib/db48
libtool: link: /usr/bin/ar cru .libs/libsecp256k1.a  src/libsecp256k1_la-secp256k1.o
libtool: link: /usr/bin/ranlib .libs/libsecp256k1.a
libtool: link: ( cd ".libs" && rm -f "libsecp256k1.la" && ln -s "../libsecp256k1.la" "libsecp256k1.la" )
gmake[5]: Leaving directory '/usr/ports/net-p2p/bitcoin/work/bitcoin-0.11.2/src/secp256k1'
/bin/sh ../libtool  --tag CXX  --mode=link g++    -D_THREAD_SAFE -pthread    -fstack-protector -o qt/bitcoin-qt qt/qt_bitcoin_qt-bitcoin.o   qt/libbitcoinqt.a libbitcoin_server.a libbitcoin_wallet.a libbitcoin_cli.a libbitcoin_common.a libbitcoin_util.a crypto/libbitcoin_crypto.a univalue/libbitcoin_univalue.a ./leveldb/libleveldb.a ./leveldb/libmemenv.a -pthread -L/usr/local/lib -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lboost_chrono -L/usr/local/lib/qt4 -lQtGui -lQtNetwork -lQtCore    -L/usr/local/lib -lqrencode -lpthread   -L/usr/local/lib -lprotobuf -D_THREAD_SAFE -pthread  -lpthread   -ldb_cxx-4.8 -L/usr/lib -lssl -L/usr/lib -lcrypto  secp256k1/libsecp256k1.la -lcrypto -L/usr/local/lib/db48
libtool: link: g++ -D_THREAD_SAFE -pthread -fstack-protector -o qt/bitcoin-qt qt/qt_bitcoin_qt-bitcoin.o -pthread -D_THREAD_SAFE -pthread  qt/libbitcoinqt.a libbitcoin_server.a libbitcoin_wallet.a libbitcoin_cli.a libbitcoin_common.a libbitcoin_util.a crypto/libbitcoin_crypto.a univalue/libbitcoin_univalue.a ./leveldb/libleveldb.a ./leveldb/libmemenv.a -L/usr/local/lib -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lboost_chrono -L/usr/local/lib/qt4 -lQtGui -lQtNetwork -lQtCore -lqrencode -lprotobuf -lpthread -ldb_cxx-4.8 -L/usr/lib -lssl secp256k1/.libs/libsecp256k1.a -L/usr/local/lib/db48 -lcrypto -pthread
/usr/local/bin/ld: qt/qt_bitcoin_qt-bitcoin.o: undefined reference to symbol '_ZNSt3__18ios_base5clearEj'
//usr/lib/libc++.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:2628: recipe for target 'qt/bitcoin-qt' failed
gmake[4]: *** [qt/bitcoin-qt] Error 1
gmake[4]: Leaving directory '/usr/ports/net-p2p/bitcoin/work/bitcoin-0.11.2/src'

The other options do not affect the result
Comment 1 robbak 2016-02-12 08:51:52 UTC
I cannot confirm this error. The port builds fine for me on 10.1, both with and without hardening set.

Note that, in both of your build snippets, with and without HARDENING, the build fails, all be it with different errors.

As far as I can see, this is a problem with your local configuration, although nothing in either of your partial build outputs tells me what. I'll have to leave this issue here until someone else has the same problem, or you find what is the local cause of your issue.

I suggest rebuilding all required ports and trying again, making sure to run 'make clean', in case there is a missing or corrupted file.
Comment 2 Mark Evenson 2016-02-12 08:56:53 UTC
(In reply to robbak from comment #1)

I can confirm this error as occurring on 10.2.

I will try rebuilding all dependent ports as robbak suggests.
Comment 3 olexander.v.melnyk 2016-02-12 09:58:03 UTC
(In reply to robbak from comment #1)
Before commit bug report, i was trying to rebuild the dependency and checked build on a second system with a clean installation all ports ( sorry for my bad english, this is not my native language )
Comment 4 w.schwarzenfeld 2016-02-12 12:48:43 UTC
Trying it also failes (on 10-2 amd64) in the port, but builds with poudriere.
Comment 5 robbak 2016-02-12 12:58:35 UTC
(In reply to w.schwarzenfeld from comment #4)
OK, thanks. I don't at the moment have a 10.x system to build on, so I can't see the error. I'll have to fix that, or course. This is probably it pulling in a library etc. from your system instead of the bundled one.

Could you confirm - is yours the failure with HARDENING, or the failure without? Or is it both? A full log of a failed build would help. Use script(1) to create a log file, and attach it to this bug report.
Comment 6 w.schwarzenfeld 2016-02-12 13:10:57 UTC
It failes with both. It is exactly the same as olexander.v.melnyk described.
Comment 7 w.schwarzenfeld 2016-02-12 13:18:56 UTC
Created attachment 166895 [details]
bitcoin-hardening_off.log
Comment 8 w.schwarzenfeld 2016-02-12 13:20:29 UTC
Created attachment 166896 [details]
bitcoin-hardening_on.log
Comment 9 w.schwarzenfeld 2016-02-12 13:30:28 UTC
Poudriere builds both, with HARDENING on or off.
Comment 10 robbak 2016-02-12 13:46:54 UTC
(In reply to w.schwarzenfeld from comment #8)
One thing I have noticed - you are using ccache. Any difference if you disable ccache? That is a clear difference between poudriere and other builds.

Other reportees - are you using ccache? Can you try the build without it?
Comment 11 olexander.v.melnyk 2016-02-12 13:57:02 UTC
(In reply to robbak from comment #10)
I do not use ccache.
Comment 12 w.schwarzenfeld 2016-02-12 14:06:53 UTC
(In reply to robbak from comment #10)


On my system poudriere also uses ccache. Same error without ccache in the port.
Comment 13 olexander.v.melnyk 2016-02-12 14:11:21 UTC
Created attachment 166899 [details]
log with HARDENING set
Comment 14 olexander.v.melnyk 2016-02-12 14:17:30 UTC
Created attachment 166900 [details]
log with HARDENING unset
Comment 15 olexander.v.melnyk 2016-02-19 10:43:40 UTC
Created attachment 167171 [details]
proposed patch for Makefile

Not sure it's entirely correct patch, but it works for me.
Comment 16 Thierry Thomas freebsd_committer 2016-03-05 16:16:36 UTC
It fails also for me, but with another error, related to libboost and the latest openssl:

c++ -DHAVE_CONFIG_H -I. -I../src/config  -I. -I./obj -pthread -I/usr/local/include -I./leveldb/include -I./leveldb/helpers/memenv -I/usr/local/include -I/usr/local/include -I./secp256k1/include   -Qunused-arguments  -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2  -O2 -pipe -march=corei7 -fstack-protector -fno-strict-aliasing  -I/usr/local/include/db48  -Wstack-protector -fstack-protector-all -fPIE -MT libbitcoin_server_a-net.o -MD -MP -MF .deps/libbitcoin_server_a-net.Tpo -c -o libbitcoin_server_a-net.o `test -f 'net.cpp' || echo './'`net.cpp
In file included from init.cpp:21:
In file included from ./rpcserver.h:10:
In file included from ./rpcprotocol.h:16:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:786:
/usr/local/include/boost/asio/ssl/impl/context.ipp:91:31: error: no member named 'SSLv3_method' in the global namespace; did you mean 'SSLv23_method'?
    handle_ = ::SSL_CTX_new(::SSLv3_method());
                            ~~^~~~~~~~~~~~
                              SSLv23_method                                                                                                                  
/usr/local/include/openssl/ssl.h:2360:19: note: 'SSLv23_method' declared here
const SSL_METHOD *SSLv23_method(void); /* Negotiate highest available SSL/TLS
Comment 17 Thierry Thomas freebsd_committer 2016-03-14 21:40:45 UTC
Since r411050, the previous error with SSLv23_method has been fixed, and but now it fails at linking:

/bin/sh ../libtool  --tag CXX  --mode=link g++  -O2 -pipe -march=corei7 -fstack-protector -fno-strict-aliasing  -I/usr/local/include/db48  -Wstack-protector -fstack-protector-all -fPIE  -D_THREAD_SAFE -pthread    -Wl,-rpath,/usr/local/lib -fstack-protector  -Wl,-z,relro -Wl,-z,now -pie -o qt/bitcoin-qt qt/qt_bitcoin_qt-bitcoin.o   qt/libbitcoinqt.a libbitcoin_server.a libbitcoin_wallet.a libbitcoin_cli.a libbitcoin_common.a libbitcoin_util.a crypto/libbitcoin_crypto.a univalue/libbitcoin_univalue.a ./leveldb/libleveldb.a ./leveldb/libmemenv.a -pthread -L/usr/local/lib -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lboost_chrono -L/usr/local/lib/qt4 -lQtGui -lQtNetwork -lQtCore    -L/usr/local/lib -lqrencode -pthread   -L/usr/local/lib -lprotobuf -D_THREAD_SAFE -pthread  -lpthread   -ldb_cxx-4.8 -L/usr/local/lib -lssl -L/usr/local/lib -lcrypto  secp256k1/libsecp256k1.la -lcrypto -L/usr/local/lib/db48
libtool: link: g++ -O2 -pipe -march=corei7 -fstack-protector -fno-strict-aliasing -I/usr/local/include/db48 -Wstack-protector -fstack-protector-all -fPIE -D_THREAD_SAFE -pthread -Wl,-rpath -Wl,/usr/local/lib -fstack-protector -Wl,-z -Wl,relro -Wl,-z -Wl,now -pie -o qt/bitcoin-qt qt/qt_bitcoin_qt-bitcoin.o -pthread -pthread -D_THREAD_SAFE -pthread  qt/libbitcoinqt.a libbitcoin_server.a libbitcoin_wallet.a libbitcoin_cli.a libbitcoin_common.a libbitcoin_util.a crypto/libbitcoin_crypto.a univalue/libbitcoin_univalue.a ./leveldb/libleveldb.a ./leveldb/libmemenv.a -L/usr/local/lib -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lboost_chrono -L/usr/local/lib/qt4 -lQtGui -lQtNetwork -lQtCore -lqrencode -lprotobuf -lpthread -ldb_cxx-4.8 -lssl secp256k1/.libs/libsecp256k1.a -L/usr/local/lib/db48 -lcrypto -pthread
/usr/local/bin/ld: /usr/lib/crt1.o: relocation R_X86_64_32 against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC
/usr/lib/crt1.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

I have not yet tried to recompile with -fPIC
Comment 18 Andriy Voskoboinyk freebsd_committer 2016-04-11 15:05:46 UTC
> /usr/local/bin/ld: /usr/lib/crt1.o: relocation R_X86_64_32 against `_DYNAMIC'
> can not be used when making a shared object; recompile with -fPIC

Linker should use Scrt1.o for PIE binary (not crt1.o)

> /bin/sh ../libtool  --tag CXX  --mode=link g++
> ...
> /usr/local/bin/ld: qt/qt_bitcoin_qt-bitcoin.o: undefined reference to symbol 
> '_ZNSt3__18ios_base5clearEj'
> //usr/lib/libc++.so.1: error adding symbols: DSO missing from command line

Looks like you are trying to mix g++ compiled binary (bitcoin) with clang++ compiled one (boost-libs).
Comment 19 Andriy Voskoboinyk freebsd_committer 2016-04-11 15:16:37 UTC
> qt/qt_bitcoin_qt-bitcoin.o
not boost-libs. just one (at least?) object file
Comment 20 Tijl Coosemans freebsd_committer 2016-05-01 10:16:31 UTC
Try changing compiler:c++0x into compiler:c++11-lang in net-p2p/bitcoin/Makefile:

-USES= autoreconf compiler:c++0x gmake libtool pkgconfig shebangfix
+USES= autoreconf compiler:c++11-lang gmake libtool pkgconfig shebangfix
Comment 21 olexander.v.melnyk 2016-05-01 11:45:57 UTC
Created attachment 169846 [details]
log with changing compiler

builds fail without changes
Comment 22 Tijl Coosemans freebsd_committer 2016-05-01 12:41:41 UTC
(In reply to olexander.v.melnyk from comment #21)
So configure does indeed look for an ObjC++ compiler and on your system it uses g++ for that.  This is only used on Darwin to compile some files, but because automake detects that it can be used to compile files it generates a Makefile.in that also uses it to link the executable.  Your original patch is correct, but I think it can be reduced to just this:

+CONFIGURE_ENV+= OBJCXX="${CXX}" OBJCXXFLAGS="${CXXFLAGS}"

Can you test this?
Comment 23 olexander.v.melnyk 2016-05-01 14:02:18 UTC
(In reply to Tijl Coosemans from comment #22)
I checked and you're right, the patch may be reduced (without changing the compiler)
Comment 24 commit-hook freebsd_committer 2016-05-02 14:21:09 UTC
A commit references this bug:

Author: tijl
Date: Mon May  2 14:20:32 UTC 2016
New revision: 414450
URL: https://svnweb.freebsd.org/changeset/ports/414450

Log:
  Add OBJCXX and OBJCXXFLAGS to CONFIGURE_ENV.

  When compiled on Darwin bitcoin-qt needs two extra files that are written
  in ObjC++.  These aren't needed on FreeBSD but because of this the ObjC++
  compiler is used as linker instead of the C++ compiler.  Without defining
  OBJCXX clang may be used as C++ compiler while g++ is used as ObjC++
  compiler.  This may cause link problems.

  PR:		207110
  Submitted by:	olexander.v.melnyk@gmail.com
  Approved by:	robbak@robbak.com (maintainer, via email)

Changes:
  head/net-p2p/bitcoin/Makefile