Bug 206580

Summary: www/spdylay does not compile with gcc49 on FreeBSD 9
Product: Ports & Packages Reporter: Olivier - interfaSys sàrl <software-freebsd>
Component: Individual Port(s)Assignee: Po-Chuan Hsieh <sunpoet>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: ph73nt, software-freebsd, w.schwarzenfeld
Priority: --- Flags: bugzilla: maintainer-feedback? (sunpoet)
Version: Latest   
Hardware: Any   
OS: Any   

Description Olivier - interfaSys sàrl 2016-01-24 16:16:24 UTC
There seems to be lots of problems with C++11 on FreeBSD9 when using gcc and this is just another example.

It seems I'm not the only one:
* https://unix.stackexchange.com/questions/153369/freebsd-spdylay-build-error
* https://forums.freebsd.org/threads/xorg-dependency-issues-on-ibook-g4.52497/

But the problem was never solved.

Reported upstream:
https://github.com/tatsuhiro-t/spdylay/issues/139

The logs of the failure


libtool: link: g++49 -O2 -pipe -fPIE -march=native -march=native -fstack-protector-strong --param ssp-buffer-size=4 -fno-strict-aliasing -std=c++11 -pthread -Wl,-rpath -Wl,/usr/local/lib -fstack-protector -o .libs/shrpx util.o timegm.o shrpx_config.o shrpx_listen_handler.o shrpx_client_handler.o shrpx_spdy_upstream.o shrpx_https_upstream.o shrpx_downstream_queue.o shrpx_downstream.o shrpx_downstream_connection.o shrpx_http_downstream_connection.o shrpx_spdy_downstream_connection.o shrpx_spdy_session.o shrpx_log.o shrpx_http.o shrpx_io_control.o shrpx_ssl.o shrpx_thread_event_receiver.o shrpx_worker.o shrpx_accesslog.o http-parser/http_parser.o shrpx.o  -L/usr/local/lib -lssl -lcrypto -lxml2 -liconv -lm -levent_openssl -levent ../lib/.libs/libspdylay.so -L/usr/lib -lz -pthread -Wl,-rpath -Wl,/usr/local/lib
spdylay_ssl.o: In function `spdylay::connect_to(std::string const&, unsigned short)':
spdylay_ssl.cc:(.text+0x365): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::make_listen_socket(std::string const&, unsigned short, int)':
spdylay_ssl.cc:(.text+0x5c5): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::ssl_handshake(ssl_st*, int)':
spdylay_ssl.cc:(.text+0xaf5): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.cc:(.text+0xb92): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::nonblock_connect_to(std::string const&, unsigned short, int)':
spdylay_ssl.cc:(.text+0x114e): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o:spdylay_ssl.cc:(.text+0x1376): more undefined references to `std::ctype<char>::_M_widen_init() const' follow
EventPoll_kqueue.o: In function `spdylay::EventPoll::EventPoll(unsigned long)':
EventPoll_kqueue.cc:(.text+0x5e): undefined reference to `__cxa_throw_bad_array_new_length'
SpdyServer.o: In function `spdylay::(anonymous namespace)::on_session_closed(spdylay::EventHandler*, long) [clone .part.19]':
SpdyServer.cc:(.text+0x324): undefined reference to `std::ctype<char>::_M_widen_init() const'
SpdyServer.o: In function `spdylay::SpdyEventHandler::submit_response(std::string const&, int, std::vector<std::pair<std::string, std::string>, std::allocator<std::pair<std::string, std::string> > > const&, spdylay_data_provider*)':
SpdyServer.cc:(.text+0xafc): undefined reference to `__cxa_throw_bad_array_new_length'
SpdyServer.o: In function `spdylay::SpdyServer::listen()':
SpdyServer.cc:(.text+0xd79): undefined reference to `std::ctype<char>::_M_widen_init() const'
SpdyServer.cc:(.text+0xe24): undefined reference to `std::ctype<char>::_M_widen_init() const'
SpdyServer.o: In function `spdylay::SpdyServer::run()':
SpdyServer.cc:(.text+0x1356): undefined reference to `std::ctype<char>::_M_widen_init() const'
SpdyServer.cc:(.text+0x1608): undefined reference to `std::ctype<char>::_M_widen_init() const'
SpdyServer.o: In function `spdylay::SSLAcceptEventHandler::execute(spdylay::Sessions*)':
SpdyServer.cc:(.text._ZN7spdylay21SSLAcceptEventHandler7executeEPNS_8SessionsE[_ZN7spdylay21SSLAcceptEventHandler7executeEPNS_8SessionsE]+0x134): undefined reference to `std::ctype<char>::_M_widen_init() const'
SpdyServer.o:SpdyServer.cc:(.text._ZN7spdylay21SSLAcceptEventHandler7executeEPNS_8SessionsE[_ZN7spdylay21SSLAcceptEventHandler7executeEPNS_8SessionsE]+0x4d8): more undefined references to `std::ctype<char>::_M_widen_init() const' follow
collect2: error: ld returned 1 exit status
*** [spdyd] Error code 1
spdylay_ssl.o: In function `spdylay::connect_to(std::string const&, unsigned short)':
spdylay_ssl.cc:(.text+0x365): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::make_listen_socket(std::string const&, unsigned short, int)':
spdylay_ssl.cc:(.text+0x5c5): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::ssl_handshake(ssl_st*, int)':
spdylay_ssl.cc:(.text+0xaf5): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.cc:(.text+0xb92): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::nonblock_connect_to(std::string const&, unsigned short, int)':
spdylay_ssl.cc:(.text+0x114e): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o:spdylay_ssl.cc:(.text+0x1376): more undefined references to `std::ctype<char>::_M_widen_init() const' follow
collect2: error: ld returned 1 exit status
*** [spdycat] Error code 1
shrpx_config.o: In function `shrpx::read_passwd_from_file(char const*)':
shrpx_config.cc:(.text+0x614): undefined reference to `std::ctype<char>::_M_widen_init() const'
shrpx_config.o: In function `shrpx::parse_config_str_list(unsigned long*, char const*)':
shrpx_config.cc:(.text+0x813): undefined reference to `__cxa_throw_bad_array_new_length'
shrpx_config.o: In function `shrpx::load_config(char const*)':
shrpx_config.cc:(.text+0x2566): undefined reference to `std::ctype<char>::_M_widen_init() const'
shrpx_listen_handler.o: In function `shrpx::ListenHandler::create_worker_thread(unsigned long)':
shrpx_listen_handler.cc:(.text+0x372): undefined reference to `__cxa_throw_bad_array_new_length'
shrpx_spdy_upstream.o: In function `shrpx::SpdyUpstream::on_downstream_header_complete(shrpx::Downstream*)':
shrpx_spdy_upstream.cc:(.text+0x512d): undefined reference to `__cxa_throw_bad_array_new_length'
shrpx_spdy_downstream_connection.o: In function `shrpx::SpdyDownstreamConnection::push_request_headers()':
shrpx_spdy_downstream_connection.cc:(.text+0x2331): undefined reference to `__cxa_throw_bad_array_new_length'
shrpx_ssl.o: In function `shrpx::ssl::setup_ssl_lock()':
shrpx_ssl.cc:(.text+0x1b7d): undefined reference to `__cxa_throw_bad_array_new_length'
collect2: error: ld returned 1 exit status
*** [shrpx] Error code 1
3 errors
*** [all-recursive] Error code 1
1 error
*** [all] Error code 2
1 error
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** [do-build] Error code 1

Stop in /usr/ports/www/spdylay.
Comment 1 Olivier - interfaSys sàrl 2016-01-24 16:22:13 UTC
A shorter log without parallel jobs:

libtool: link: g++49 -O2 -pipe -fPIE -march=native -march=native -fstack-protector-strong --param ssp-buffer-size=4 -fno-strict-aliasing -std=c++11 -pthread -Wl,-rpath -Wl,/usr/local/lib -fstack-protector -o .libs/spdycat util.o timegm.o spdylay_ssl.o spdycat.o HtmlParser.o http-parser/http_parser.o  -L/usr/local/lib -lssl -lcrypto -lxml2 -liconv -lm -levent_openssl -levent ../lib/.libs/libspdylay.so -L/usr/lib -lz -pthread -Wl,-rpath -Wl,/usr/local/lib
spdylay_ssl.o: In function `spdylay::connect_to(std::string const&, unsigned short)':
spdylay_ssl.cc:(.text+0x365): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::make_listen_socket(std::string const&, unsigned short, int)':
spdylay_ssl.cc:(.text+0x5c5): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::ssl_handshake(ssl_st*, int)':
spdylay_ssl.cc:(.text+0xaf5): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.cc:(.text+0xb92): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o: In function `spdylay::nonblock_connect_to(std::string const&, unsigned short, int)':
spdylay_ssl.cc:(.text+0x114e): undefined reference to `std::ctype<char>::_M_widen_init() const'
spdylay_ssl.o:spdylay_ssl.cc:(.text+0x1376): more undefined references to `std::ctype<char>::_M_widen_init() const' follow
collect2: error: ld returned 1 exit status
*** [spdycat] Error code 1

Stop in /usr/ports/www/spdylay/work/spdylay-1.3.2/src.
*** [all-recursive] Error code 1

Stop in /usr/ports/www/spdylay/work/spdylay-1.3.2.
*** [all] Error code 1

Stop in /usr/ports/www/spdylay/work/spdylay-1.3.2.
*** [do-build] Error code 1

Stop in /usr/ports/www/spdylay.
Comment 2 w.schwarzenfeld 2016-01-24 17:51:14 UTC
I got it to compile with:
CFLAGS+=-rpath=/usr/bin/gcc49
Comment 3 Olivier - interfaSys sàrl 2016-01-24 18:08:21 UTC
I've tried and it didn't change anything.

Since /usr/bin/gcc49 doesn't exist, did you create a symlink? Has it been there for a while? I suspect some of the dependencies would need to be compiled with that flag.

I use "LDFLAGS+= -Wl,-rpath=/usr/local/lib/gcc49" in my make.conf
Comment 4 w.schwarzenfeld 2016-01-24 18:54:05 UTC
Sorry, was too fast, above does not work (forgot I have something commented out).

But if I put:
.if ${OSVERSION} < 1000000 
USE_GCC=        4.9
LDFLAGS+=       -rpath=/usr/local/bin/
.endif

in the Makefile, it works.

(I know, it is need an other conditional - this one said work ever with gcc49 on 9.3).
Comment 5 Olivier - interfaSys sàrl 2016-01-24 19:03:21 UTC
Cool trick! :)

That even work with www/nghttp2 and I suspect many other ports giving me problems...

Many thanks!
Comment 6 Olivier - interfaSys sàrl 2016-01-24 19:04:02 UTC
BTW, I only needed
USE_GCC=        4.9
Comment 7 Neil 2016-06-06 19:03:40 UTC
I get what looks like the same error compiling www/spdylay with GCC 4.9 on the sparc64 build of FreeBSD 10.3.

I compile using:
> make USE_GCC=4.9 install

Config summary shows:
----
configure: summary of build options: 

 Version:  1.3.2 shared 9:0:2 
 Host type:  sparc64-portbld-freebsd10.3 
 Install prefix: /usr/local 
 C compiler:  gcc49 
 CFLAGS:  -O2 -pipe  -Wl,-rpath=/usr/local/lib/gcc49 -fno-strict-aliasing -I/usr/include 
 LDFLAGS:  -Wl,-rpath=/usr/local/lib/gcc49 -L/usr/local/lib/gcc49 
 LIBS:  -L/usr/lib -lz  
 CPPFLAGS:  
 C preprocessor: cpp49 
 C++ compiler:  g++49 
 CXXFLAGS:  -O2 -pipe  -Wl,-rpath=/usr/local/lib/gcc49 -fno-strict-aliasing  -Wl,-rpath=/usr/local/lib/gcc49 -std=c++11 
 CXXCPP:  g++49 -E 
 Library types:  Shared=yes, Static=yes 
 CUnit:  no 
 OpenSSL:  yes 
 Libxml2:  yes 
 Libevent(SSL):  yes 
 Src:  yes 
 Examples:  yes
----

Tail of the compile goes:
----
ibtool: link: g++49 -O2 -pipe -Wl,-rpath=/usr/local/lib/gcc49 -fno-strict-aliasing -Wl,-rpath=/usr/local/lib/gcc49 -std=c++11 -pthread -Wl,-rpath=/usr/local/lib/gcc49 -o .libs/spdycat util.o 
timegm.o spdylay_ssl.o spdycat.o HtmlParser.o http-parser/http_parser.o  -L/usr/lib -lcrypto -lssl -L/usr/local/lib -lxml2 -lm -levent_openssl -levent -L/usr/local/lib/gcc49 ../lib/.libs/libsp
dylay.so -lz -pthread -Wl,-rpath -Wl,/usr/local/lib 
spdylay_ssl.o: In function `spdylay::connect_to(std::string const&, unsigned short)': 
spdylay_ssl.cc:(.text+0x4b8): undefined reference to `std::ctype<char>::_M_widen_init() const' 
spdylay_ssl.o: In function `spdylay::make_listen_socket(std::string const&, unsigned short, int)': 
spdylay_ssl.cc:(.text+0x73c): undefined reference to `std::ctype<char>::_M_widen_init() const' 
spdylay_ssl.o: In function `spdylay::ssl_handshake(ssl_st*, int)': 
spdylay_ssl.cc:(.text+0xd24): undefined reference to `std::ctype<char>::_M_widen_init() const' 
spdylay_ssl.cc:(.text+0xdb8): undefined reference to `std::ctype<char>::_M_widen_init() const' 
spdylay_ssl.o: In function `spdylay::nonblock_connect_to(std::string const&, unsigned short, int)': 
spdylay_ssl.cc:(.text+0x1404): undefined reference to `std::ctype<char>::_M_widen_init() const' 
spdylay_ssl.o:spdylay_ssl.cc:(.text+0x1610): more undefined references to `std::ctype<char>::_M_widen_init() const' follow 
collect2: error: ld returned 1 exit status 
*** [spdycat] Error code 1 

make[3]: stopped in /usr/ports/www/spdylay/work/spdylay-1.3.2/src 
1 error 

make[3]: stopped in /usr/ports/www/spdylay/work/spdylay-1.3.2/src 
*** [all-recursive] Error code 1 

make[2]: stopped in /usr/ports/www/spdylay/work/spdylay-1.3.2 
1 error 

make[2]: stopped in /usr/ports/www/spdylay/work/spdylay-1.3.2 
*** [all] Error code 2 

make[1]: stopped in /usr/ports/www/spdylay/work/spdylay-1.3.2 
1 error 

make[1]: stopped in /usr/ports/www/spdylay/work/spdylay-1.3.2 
===> Compilation failed unexpectedly. 
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to 
the maintainer. 
*** Error code 1 

Stop. 
make: stopped in /usr/ports/www/spdylay
----

Also fails with MAKE_JOBS_UNSAFE=yes.
Comment 8 Po-Chuan Hsieh freebsd_committer freebsd_triage 2016-12-04 15:08:06 UTC
spdylay 1.4.0 builds fine in a FreeBSD 9.3-RELEASE-p50 jail with DEFAULT_VERSIONS=ssl=openssl.