Hello folks,

Just wanted to raise an issue with a compilation error on HAProxy that I
was able to solve by myself. Just wanted to know if this issue is
haproxy-related or compiler-related (and if a fix should be provided in the
future)

Compiling haproxy (1.8.17) failed with this error :

make TARGET=linux2628 USE_STATIC_PCRE=1 USE_ZLIB=1 USE_OPENSSL=1
ZLIB_LIB=/usr/src/haproxy/zlibbin/lib
ZLIB_INC=/usr/src/haproxy/zlibbin/include
SSL_INC=/usr/src/haproxy/opensslbin/include
SSL_LIB=/usr/src/haproxy/opensslbin/lib ADDLIB=-ldl -lzlib
PCREDIR=/usr/src/haproxy/pcrebin USE_LUA=1 LUA_LIB=/usr/src/haproxy/lua/lib
LUA_INC=/usr/src/haproxy/lua/include
[...]
gcc  -g -o haproxy src/ev_poll.o src/ev_epoll.o src/ssl_sock.o src/hlua.o
src/hlua_fcn.o ebtree/ebtree.o ebtree/eb32sctree.o ebtree/eb32tree.o
ebtree/eb64tree.o ebtree/ebmbtree.o ebtree/ebsttree.o ebtree/ebimtree.o
ebtree/ebistree.o src/proto_http.o src/cfgparse.o src/server.o src/stream.o
src/flt_spoe.o src/stick_table.o src/stats.o src/mux_h2.o src/checks.o
src/haproxy.o src/log.o src/dns.o src/peers.o src/standard.o src/sample.o
src/cli.o src/stream_interface.o src/proto_tcp.o src/backend.o src/proxy.o
src/tcp_rules.o src/listener.o src/flt_http_comp.o src/pattern.o
src/cache.o src/filters.o src/vars.o src/acl.o src/payload.o
src/connection.o src/raw_sock.o src/proto_uxst.o src/flt_trace.o
src/session.o src/ev_select.o src/channel.o src/task.o src/queue.o
src/applet.o src/map.o src/frontend.o src/freq_ctr.o src/lb_fwlc.o
src/mux_pt.o src/auth.o src/fd.o src/hpack-dec.o src/memory.o src/lb_fwrr.o
src/lb_chash.o src/lb_fas.o src/hathreads.o src/chunk.o src/lb_map.o
src/xxhash.o src/regex.o src/shctx.o src/buffer.o src/action.o src/h1.o
src/compression.o src/pipe.o src/namespace.o src/sha1.o src/hpack-tbl.o
src/hpack-enc.o src/uri_auth.o src/time.o src/proto_udp.o src/arg.o
src/signal.o src/protocol.o src/lru.o src/hdr_idx.o src/hpack-huff.o
src/mailers.o src/h2.o src/base64.o src/hash.o   -lcrypt
-L/usr/src/haproxy/zlibbin/lib -lz -ldl -lpthread
-L/usr/src/haproxy/opensslbin/lib -lssl -lcrypto -ldl -Wl,--export-dynamic
-L/usr/src/haproxy/lua/lib -llua -lm -ldl -L/usr/src/haproxy/pcrebin/lib
-Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic -ldl
/usr/src/haproxy/opensslbin/lib/libcrypto.a(threads_pthread.o): In function
`fork_once_func':
threads_pthread.c:(.text+0x16): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status


Seems this error already happened to someone here :
https://github.com/openssl/openssl/issues/3884

So I modified by hand gcc line to move -lpthread at the end of the line
like this :
gcc  -g -o haproxy src/ev_poll.o src/ev_epoll.o src/ssl_sock.o src/hlua.o
src/hlua_fcn.o ebtree/ebtree.o ebtree/eb32sctree.o ebtree/eb32tree.o
ebtree/eb64tree.o ebtree/ebmbtree.o ebtree/ebsttree.o ebtree/ebimtree.o
ebtree/ebistree.o src/proto_http.o src/cfgparse.o src/server.o src/stream.o
src/flt_spoe.o src/stick_table.o src/stats.o src/mux_h2.o src/checks.o
src/haproxy.o src/log.o src/dns.o src/peers.o src/standard.o src/sample.o
src/cli.o src/stream_interface.o src/proto_tcp.o src/backend.o src/proxy.o
src/tcp_rules.o src/listener.o src/flt_http_comp.o src/pattern.o
src/cache.o src/filters.o src/vars.o src/acl.o src/payload.o
src/connection.o src/raw_sock.o src/proto_uxst.o src/flt_trace.o
src/session.o src/ev_select.o src/channel.o src/task.o src/queue.o
src/applet.o src/map.o src/frontend.o src/freq_ctr.o src/lb_fwlc.o
src/mux_pt.o src/auth.o src/fd.o src/hpack-dec.o src/memory.o src/lb_fwrr.o
src/lb_chash.o src/lb_fas.o src/hathreads.o src/chunk.o src/lb_map.o
src/xxhash.o src/regex.o src/shctx.o src/buffer.o src/action.o src/h1.o
src/compression.o src/pipe.o src/namespace.o src/sha1.o src/hpack-tbl.o
src/hpack-enc.o src/uri_auth.o src/time.o src/proto_udp.o src/arg.o
src/signal.o src/protocol.o src/lru.o src/hdr_idx.o src/hpack-huff.o
src/mailers.o src/h2.o src/base64.o src/hash.o   -lcrypt
-L/usr/src/haproxy/zlibbin/lib -lz -ldl -L/usr/src/haproxy/opensslbin/lib
-lssl -lcrypto -ldl -Wl,--export-dynamic -L/usr/src/haproxy/lua/lib -llua
-lm -ldl -L/usr/src/haproxy/pcrebin/lib -Wl,-Bstatic -lpcreposix -lpcre
-Wl,-Bdynamic -ldl -lpthread
... and compilation was OK !

I tried with gcc 4.8.2 (centos6) and gcc 7.2.1 with exactly the same
behaviour.

Additional softwares used :
OpenSSL 1.1.1a
Lua 5.3.5
PCRE version : 8.41
zlib version : 1.2.11

Olivier

Reply via email to