Re: HAProxy compilation issue
Hi Olivier, On Fri, Jan 18, 2019 at 04:17:30PM +0100, Olivier D wrote: > > It's been a while since we've got such linking issues. Usually they come > > from libpthread or libdl, which are most always shared. Can you please > > try the attached patch ? > > > > Tested and approved :) compilation is working correctly \o/ Thank you. However I can't merge it as-is as it will definitely break some configurations since some CFLAGS are lost when placed there. I think we'll switch to new variables like NEED_DL, NEED_PTHREAD, NEED_RT etc and add them at the end. Thanks, Willy
Re: HAProxy compilation issue
Hello, Le sam. 12 janv. 2019 à 13:19, Willy Tarreau a écrit : > Hi Olivier, > > On Wed, Jan 09, 2019 at 07:23:42PM +0100, Olivier D wrote: > > 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 : > (...) > > /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 > > It's been a while since we've got such linking issues. Usually they come > from libpthread or libdl, which are most always shared. Can you please > try the attached patch ? > Tested and approved :) compilation is working correctly \o/ Olivier > > Thanks, > Willy >
Re: HAProxy compilation issue
Hi Olivier, On Wed, Jan 09, 2019 at 07:23:42PM +0100, Olivier D wrote: > 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 : (...) > /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 It's been a while since we've got such linking issues. Usually they come from libpthread or libdl, which are most always shared. Can you please try the attached patch ? Thanks, Willy diff --git a/Makefile b/Makefile index 94e0473..24bd87a 100644 --- a/Makefile +++ b/Makefile @@ -574,17 +574,6 @@ OPTIONS_CFLAGS += -DCONFIG_REGPARM=3 BUILD_OPTIONS += $(call ignore_implicit,USE_REGPARM) endif -ifneq ($(USE_DL),) -BUILD_OPTIONS += $(call ignore_implicit,USE_DL) -OPTIONS_LDFLAGS += -ldl -endif - -ifneq ($(USE_THREAD),) -BUILD_OPTIONS += $(call ignore_implicit,USE_THREAD) -OPTIONS_CFLAGS += -DUSE_THREAD -OPTIONS_LDFLAGS += -lpthread -endif - # report DLMALLOC_SRC only if explicitly specified ifneq ($(DLMALLOC_SRC),) BUILD_OPTIONS += DLMALLOC_SRC=$(DLMALLOC_SRC) @@ -618,20 +607,6 @@ endif OPTIONS_OBJS += src/ssl_sock.o endif -# The private cache option affect the way the shctx is built -ifneq ($(USE_PRIVATE_CACHE),) -OPTIONS_CFLAGS += -DUSE_PRIVATE_CACHE -else -ifneq ($(USE_PTHREAD_PSHARED),) -OPTIONS_CFLAGS += -DUSE_PTHREAD_PSHARED -OPTIONS_LDFLAGS += -lpthread -else -ifneq ($(USE_FUTEX),) -OPTIONS_CFLAGS += -DUSE_SYSCALL_FUTEX -endif -endif -endif - ifneq ($(USE_LUA),) check_lua_lib = $(shell echo "int main(){}" | $(CC) -o /dev/null -x c - $(2) -l$(1) 2>/dev/null && echo $(1)) check_lua_inc = $(shell if [ -d $(2)$(1) ]; then echo $(2)$(1); fi;) @@ -838,6 +813,33 @@ OPTIONS_CFLAGS += -DCONFIG_HAP_NS BUILD_OPTIONS += $(call ignore_implicit,USE_NS) endif +# -ldl and -lpthread should appear last otherwise some systems may face +# some build issues. +ifneq ($(USE_DL),) +BUILD_OPTIONS += $(call ignore_implicit,USE_DL) +OPTIONS_LDFLAGS += -ldl +endif + +ifneq ($(USE_THREAD),) +BUILD_OPTIONS += $(call ignore_implicit,USE_THREAD) +OPTIONS_CFLAGS += -DUSE_THREAD +OPTIONS_LDFLAGS += -lpthread +endif + +# The private cache option affect the way the shctx is built +ifneq ($(USE_PRIVATE_CACHE),) +OPTIONS_CFLAGS += -DUSE_PRIVATE_CACHE +else +ifneq ($(USE_PTHREAD_PSHARED),) +OPTIONS_CFLAGS += -DUSE_PTHREAD_PSHARED +OPTIONS_LDFLAGS += -lpthread +else +ifneq ($(USE_FUTEX),) +OPTIONS_CFLAGS += -DUSE_SYSCALL_FUTEX +endif +endif +endif + Global link options # These options are added at the end of the "ld" command line. Use LDFLAGS to # add options at the beginning of the "ld" command line if needed.
HAProxy compilation issue
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