Failed compile 1.8.x with undefined symbol `trace' on latest cygwin64(gcc6.4)


#1

Tested with make TARGET=cygwin

gcc  -g -o haproxy src/ev_poll.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/filter
s.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
src/mux_h2.o: In function `h2s_frt_make_resp_data':
/home/***/haproxy-1.8.3/src/mux_h2.c:3278: undefined reference to `trace'
/home/***/haproxy-1.8.3/src/mux_h2.c:3278:(.text+0x39d0): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `trace'
collect2: error: ld returned 1 exit status
make: *** [Makefile:898: haproxy] Error 1

Comment the trace in mux_h2.c works, but is there something wrong with the src or compiler?

nm src/standard.o | grep trace Show

0000000000006300 T .weak.trace.ulltoa
                 w trace


#2

This is the trace functionality introduced in commit 1296382d0b (“CONTRIB: trace: add the possibility to place trace calls in the code”), and called since commit c652dbde9d (“MEDIUM: h2: send the H1 response body as DATA frames”).

Not sure why cygwin would not find trace() in standard.c. @willy ?


#3

Probably because of header inclusion ordering or something like this. I’m seeing that mux_h2.c doesn’t directly include standard.h so it only works by chance.

@yyjdelete, care to try the following patch ?

diff --git a/src/mux_h2.c b/src/mux_h2.c
index 7bb51ea…63e896b 100644
— a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -17,6 +17,7 @@
#include <common/hpack-enc.h>
#include <common/hpack-tbl.h>
#include <common/net_helper.h>
+#include <common/standard.h>
#include <proto/applet.h>
#include <proto/connection.h>
#include <proto/h1.h>


#4

Still the same result.


#5

I really don’t understand how this is possible, as the “trace()” prototype is in standard.h, and the function is declared in src/standard.c which is loaded with everything.

Well, the only thing specific to this function is that it’s declared with a “weak” attribute. Maybe it causes your compiler to drop it. Would you want to try to remove “weak” from the attribute statement in standard.c, around line 3968 ?


#6

Remove the weak works.

And I see the below cmd, move src/standard.o before src/mux_h2.o also works.

gcc -g -o haproxy src/ev_poll.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

#7

This is useful, though I fear it’ll break again multiple times, especially if we generalise these traces. I need to think about it a bit more. Thanks for your tests.


#8

I use make with TRACE=1 option to pass this error.

make TARGET=cygwin TRACE=1