On Fri, Feb 26, 2016 at 03:02:56AM -0800, Martin Winter wrote:
> > Building Stage: Failed
> > ----------------
> > CentOS6 amd64 build: Successful
> > Ubuntu1204 amd64 build: Successful
> > NetBSD7 amd64 build: Successful
> > FreeBSD10 amd64 build: Successful
> > OmniOS amd64 build: Successful
> > NetBSD6 amd64 build: Successful
> > FreeBSD8 amd64 build: Successful
> > Debian8 amd64 build: Successful
> > Openbsd58 amd64 build: Successful
> > FreeBSD9 amd64 build: Successful
> > CentOS7 amd64 build: Successful
> >
> > Package building failed for Ubuntu1404 amd64 build:    (see full log 
> > in attachment ubuntu1404_amd64_pkgbuild.log)
[...]
> […]
>    CC       pim_static.o
>    AR       libpim.a
>    CC       test_igmpv3_join.o
>    CCLD     test_igmpv3_join
> test_igmpv3_join.o:(.data.rel.ro+0x0): undefined reference to `_mt_TMP'
> test_igmpv3_join.o:(.data.rel.ro+0x8): undefined reference to `_mt_IF'
> test_igmpv3_join.o:(.data.rel.ro+0x10): undefined reference to 
> `_mt_CONNECTED_LABEL'
> pim_igmp_join.o:(.data.rel.ro+0x0): undefined reference to `_mt_TMP'
> pim_igmp_join.o:(.data.rel.ro+0x8): undefined reference to `_mt_IF'
> pim_igmp_join.o:(.data.rel.ro+0x10): undefined reference to 
> `_mt_CONNECTED_LABEL'
> collect2: error: ld returned 1 exit status
> make[4]: *** [test_igmpv3_join] Error 1
> make[4]: Leaving directory
> `/home/ci/cibuild.247/debpkg/quagga-test/pimd'

That's a very interesting failure... it actually depends on -O0 in the
CFLAGS.  It's a long chain:  since the change
  "*: use an ifindex_t type, defined in lib/if.h, for ifindex values"
- pim_igmp_join.h includes lib/if.h (to get the typedef for ifindex_t)
- lib/if.h declares two MTYPEs with compile-time constants as in
  static const MTYPE_TMP = &_mt_TMP;
- test_igmpv3_join doesn't link libzebra
- with -O0, "static const" emission is unconditional; -O1, -Os or -Og
  "fix" this, so should -fno-keep-static-consts but it doesn't do
  anything

=> undefined reference on a constant that isn't used anywhere.

Interestingly, the same behaviour would also trigger if lib/if.h
contained any "static inline" function that has any reference to
libzebra symbols.  Ultimately, using the header without linking the
library doesn't seem the best thing to do, though arguably it's also
fallout from this patch.

There are multiple ways to fix this:
(a) link test_igmpv3_join with libzebra (with --as-needed)
(b) move ifindex_t to zebra.h
(c) use int on pim_igmp_join_source
(d) copy-paste (or #include) pim_igmp_join.c into test_igmpv3_join.c

I would probably do (d) and remove references to if.h and zebra.h from
test_igmpv3_join.c.  The file doesn't use anything from either of those
two headers aside from ifindex_t.


-David


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to