Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 135529 - net-misc/quagga-0.99.4: link order with libcap
Summary: net-misc/quagga-0.99.4: link order with libcap
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High normal
Assignee: Amir Guindehi (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-04 09:05 UTC by solar (RETIRED)
Modified: 2006-06-04 21:35 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
quagga-0.99.4-libcap-linkorder.patch (quagga-0.99.4-libcap-linkorder.patch,597 bytes, patch)
2006-06-04 09:06 UTC, solar (RETIRED)
Details | Diff
quagga-0.99.4-zebra-linkorder.patch (quagga-0.99.4-zebra-linkorder.patch,557 bytes, patch)
2006-06-04 13:40 UTC, Alin Năstac (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description solar (RETIRED) gentoo-dev 2006-06-04 09:05:56 UTC
[ebuild     U ] net-misc/quagga-0.99.4 [0.98.6-r1] USE="-bgpclassless -ipv6 -multipath -ospfapi -pam -realms -snmp -tcp-zebra -tcpmd5" 0 kB 

mkdir .libs
i386-gentoo-linux-uclibc-gcc -Os -pipe -Wstack-protector -Wformat=2 -o .libs/zebra zserv.o main.o interface.o connected.o zebra_rib.o redistribute.o debug.o rtadv.o zebra_snmp.o zebra_vty.o irdp_main.o irdp_interface.o irdp_packet.o router-id.o ioctl.o ipforward_proc.o if_netlink.o if_proc.o rt_netlink.o rtread_netlink.o  -lcap ../lib/.libs/libzebra.so -lm -lcrypt
../lib/.libs/libzebra.so: undefined reference to `cap_init'
../lib/.libs/libzebra.so: undefined reference to `cap_get_flag'
../lib/.libs/libzebra.so: undefined reference to `cap_clear'
../lib/.libs/libzebra.so: undefined reference to `cap_set_flag'
../lib/.libs/libzebra.so: undefined reference to `cap_set_proc'
../lib/.libs/libzebra.so: undefined reference to `cap_free'
collect2: ld returned 1 exit status
------------------------------------------------------------------------
This is another strange case.

We can see -lcap is in the cmdline like it should be but the ordering of it 
seems to have some direct effect. If we move the -lcap anywhere after the 
libzebra.so bit it will correctly link.

tinderbox zebra # i386-gentoo-linux-uclibc-gcc -Os -pipe -Wstack-protector -Wformat=2 -o .libs/zebra zserv.o main.o interface.o connected.o zebra_rib.o redistribute.o debug.o rtadv.o zebra_snmp.o zebra_vty.o irdp_main.o irdp_interface.o irdp_packet.o router-id.o ioctl.o ipforward_proc.o if_netlink.o if_proc.o rt_netlink.o rtread_netlink.o  -lcap ../lib/.libs/libzebra.so -lm -lcrypt


However the libcap DT_NEEDED entry is disreguarded.

tinderbox zebra # scanelf -n  .libs/zebra
 TYPE   NEEDED FILE 
ET_DYN libzebra.so.0,libm.so.0,libcrypt.so.0,libc.so.0 .libs/zebra 


So this tells us it had to use the .a file for symbols. My guess is that
no symbols for cap* are needed by the linker so it ignored the libcap.
But then something in the -lzebra needs it and this later causes the
error.

------------------------------------------------------------------------
tinderbox zebra # qlist -dosevvv libcap
sys-libs/libcap-1.10-r6
CONTENTS:
/sbin/
/sbin/sucap
/sbin/execcap
/sbin/setpcaps
/sbin/getpcaps
/lib/
/lib/libcap.so.1.10
/usr/
/usr/lib/
/usr/lib/libcap.so.1.10
/usr/lib/libcap.a
/usr/include/
/usr/include/sys/
/usr/include/sys/capability.h


------------------------------------------------------------------------

Portage 2.1_rc1-r4 (uclibc/x86/2005.1, gcc-3.4.6, uclibc-0.9.28-r0, 2.6.11-hardened-r15 i686)
=================================================================
System uname: 2.6.11-hardened-r15 i686 Intel(R) Pentium(R) 4 CPU 2.60GHz
Gentoo Base System version 1.12.0
dev-lang/python:     2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  0.4.2-r1
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r2
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r5
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i386-gentoo-linux-uclibc"
CFLAGS="-Os -pipe -Wstack-protector -Wformat=2"
CHOST="i386-gentoo-linux-uclibc"
CONFIG_PROTECT="/etc /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/bind"
CONFIG_PROTECT_MASK="/etc/gconf /etc/revdep-rebuild /etc/terminfo /etc/env.d"
CXXFLAGS="-Os -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig buildpkg distclean distlocks genpkgindex metadata-transfer nodoc noinfo noman sandbox sfperms strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
MAKEOPTS="-j4"
PKGDIR="/usr/portage/packages/i386-gentoo-linux-uclibc/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local/local"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="bindist bitmap-fonts cli dri hardened minimal multicall ncurses pcre pic readline reflection session spl truetype-fonts type1-fonts uclibc x86 xorg zlib elibc_uclibc kernel_linux userland_GNU"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 solar (RETIRED) gentoo-dev 2006-06-04 09:06:39 UTC
Created attachment 88355 [details, diff]
quagga-0.99.4-libcap-linkorder.patch

Patch corrects link order.
Comment 2 Alin Năstac (RETIRED) gentoo-dev 2006-06-04 13:40:55 UTC
Created attachment 88378 [details, diff]
quagga-0.99.4-zebra-linkorder.patch

I think you patch the wrong file because Makefile.in will be rewritten by eautoreconf.

This new patch modifies Makefile.am instead and also moves LIB_IPV6 at the end of zebra_LDADD. Please test it.
Comment 3 solar (RETIRED) gentoo-dev 2006-06-04 14:00:18 UTC
My attached patch was for an autopatching system I use. But you are correct 
in thinking it would not be suitable for tree usage. Sorry about any confusion.

I've retested quagga with your patch and it solves the problem also with 
the unresolved symbols.

Please apply to the tree.
Comment 4 Alin Năstac (RETIRED) gentoo-dev 2006-06-04 21:35:32 UTC
Fixed without revision bumping.