Bug 4562 - need to link against libtirpc with FEATURE_MOUNT_NFS and glibc-2.14+
Summary: need to link against libtirpc with FEATURE_MOUNT_NFS and glibc-2.14+
Status: REOPENED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.19.x
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL: http://lists.busybox.net/pipermail/bu...
Keywords:
: 6242 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-11-29 11:47 UTC by Bart Kus
Modified: 2023-01-07 13:55 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bart Kus 2011-11-29 11:47:09 UTC
Compiling from latest git.  The regular (dynamically linked) version compiled OK, then I tried this static version:


eo@jo ~/busybox $ CONFIG_STATIC=y make
  LINK    busybox_unstripped
Trying libraries: crypt m
Failed: -Wl,--start-group -lcrypt -lm -Wl,--end-group
Output of:
gcc -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement -Wold-style-definition -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -Os -static -o busybox_unstripped -Wl,--sort-common -Wl,--sort-section,alignment -Wl,--start-group applets/built-in.o archival/lib.a archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a printutils/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a archival/built-in.o archival/libarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o printutils/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group -Wl,--start-group -lcrypt -lm -Wl,--end-group
==========
networking/lib.a(nslookup.o): In function `print_host':
nslookup.c:(.text.print_host+0x3d): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(ipcalc.o): In function `ipcalc_main':
ipcalc.c:(.text.ipcalc_main+0x211): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/lib.a(inet_common.o): In function `INET_resolve':
inet_common.c:(.text.INET_resolve+0x47): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(inetd.o): In function `reread_config_file':
inetd.c:(.text.reread_config_file+0x79e): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(netstat.o): In function `ip_port_str':
netstat.c:(.text.ip_port_str+0x3e): warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(inetd.o): In function `reread_config_file':
inetd.c:(.text.reread_config_file+0x724): warning: Using 'getrpcbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(inetd.o): In function `unregister_rpc':
inetd.c:(.text.unregister_rpc+0x17): undefined reference to `pmap_unset'
networking/lib.a(inetd.o): In function `register_rpc':
inetd.c:(.text.register_rpc+0x46): undefined reference to `pmap_unset'
inetd.c:(.text.register_rpc+0x62): undefined reference to `pmap_set'
networking/lib.a(inetd.o): In function `prepare_socket_fd':
inetd.c:(.text.prepare_socket_fd+0x82): undefined reference to `bindresvport'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
eo@jo ~/busybox $


Please see my more in-depth comments at:

https://bugs.gentoo.org/show_bug.cgi?id=391817#c5

My glibc version is:


eo@jo ~/busybox $ equery l glibc
 * Searching for glibc ...
[IP-] [  ] sys-libs/glibc-2.14.1:2.2


In short, it looks like the latest glibc (master branch commit 7b57bfe5988e476ea40934457dfd1c8a231e2391) removed RPC support from the static version of the lib.

Or I'm totally screwing up something trivial.
Comment 1 Mike Frysinger 2011-11-29 20:21:48 UTC
semi-known issue
Comment 2 Bart Kus 2011-11-29 21:18:22 UTC
Unlike the linked email thread where -ltirpc and -lpthread fixed the issue, I still have missing symbols when linking against the latest glibc:


eo@jo ~/busybox $ export CONFIG_STATIC=y
eo@jo ~/busybox $ gcc -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement -Wold-style-definition -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -Os -static -o busybox_unstripped -Wl,--sort-common -Wl,--sort-section,alignment -Wl,--start-group applets/built-in.o archival/lib.a archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a printutils/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a archival/built-in.o archival/libarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o printutils/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group -Wl,--start-group -lcrypt -lm -ltirpc -lpthread -Wl,--end-group
networking/lib.a(nslookup.o): In function `print_host':
nslookup.c:(.text.print_host+0x3d): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(ipcalc.o): In function `ipcalc_main':
ipcalc.c:(.text.ipcalc_main+0x211): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/lib.a(inet_common.o): In function `INET_resolve':
inet_common.c:(.text.INET_resolve+0x47): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(inetd.o): In function `reread_config_file':
inetd.c:(.text.reread_config_file+0x79e): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(netstat.o): In function `ip_port_str':
netstat.c:(.text.ip_port_str+0x3e): warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(inetd.o): In function `reread_config_file':
inetd.c:(.text.reread_config_file+0x724): warning: Using 'getrpcbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libtirpc.a(libtirpc_la-auth_des.o): In function `authdes_validate':
(.text+0xee): undefined reference to `ecb_crypt'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libtirpc.a(libtirpc_la-auth_des.o): In function `authdes_marshal':
(.text+0x252): undefined reference to `cbc_crypt'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libtirpc.a(libtirpc_la-auth_des.o): In function `authdes_marshal':
(.text+0x320): undefined reference to `ecb_crypt'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libtirpc.a(libtirpc_la-auth_des.o): In function `authdes_refresh':
(.text+0x446): undefined reference to `key_encryptsession_pk'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libtirpc.a(libtirpc_la-auth_des.o): In function `authdes_pk_seccreate':
(.text+0x5c9): undefined reference to `getnetname'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libtirpc.a(libtirpc_la-auth_des.o): In function `authdes_pk_seccreate':
(.text+0x775): undefined reference to `key_gendes'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/libtirpc.a(libtirpc_la-auth_des.o): In function `authdes_seccreate':
(.text+0x91e): undefined reference to `getpublickey'
collect2: ld returned 1 exit status
eo@jo ~/busybox $


Any tips on how to get a static version built at all?  I marked it as major originally since static doesn't wanna build no matter what I've tried.  The missing symbols listed in this modified command line also look to have been dropped from the latest glibc static version:


eo@jo ~/busybox $ nm /usr/lib64/libc.a 2>/dev/null | grep _crypt
eo@jo ~/busybox $ nm /usr/lib64/libc.a 2>/dev/null | wc -l
15029
Comment 3 Denys Vlasenko 2011-12-05 03:03:30 UTC
glibc does not "fully" support static linking. It's a known decision of glibc developers.

Having said that, in current git FEATURE_MOUNT_NFS is changed so that it can be disabled and NFS mounts will still work, but will require somewhat recent 2.6 kernels. Maybe you can disable it. Also, consider enabling local crypt routines (CONFIG_USE_BB_CRYPT=y, CONFIG_USE_BB_CRYPT_SHA=y)


> Any tips on how to get a static version built at all? 

I suggest switching to uclibc for static build. uclibc project DOES support static build, and this build will be MUCH smaller (~300k) than one against glibc.
Comment 4 Mike Frysinger 2013-12-06 02:13:39 UTC
to clarify for people, there's two ways to fix this:
- disable the rpc settings in your busybox config.  there's only like two ... one for inetd, and one for mount for supporting nfs.  the latter isn't even really needed to mount nfs if you don't mind disabling some nfs mount features.
- manually link against libtirpc yourself

the issue is that newer glibc has been removing rpc functionality (which is good because this stuff is old and doesn't support things like IPv6).  but busybox needs to support linking against the libtirpc package (via pkg-config) so that it gets the newer maintained library, and one that works :).
Comment 5 Denys Vlasenko 2016-04-03 13:25:40 UTC
Add libraries you need to CONFIG_EXTRA_LDLIBS.
Comment 6 Mike Frysinger 2016-04-10 14:37:45 UTC
i don't think that resolution makes sense.  if everyone who wants to use rpc features has to know to set up their lib/cppflags settings correctly, then maybe we should be automating it.  otherwise, why do also probe selinux libs in the makefiles ?  by that logic, that code should be deleted and force people to manually add -lselinux too.

i was planning on implementing this already, so i'll take the bug.
Comment 7 Mike Frysinger 2018-01-24 04:38:41 UTC
*** Bug 6242 has been marked as a duplicate of this bug. ***
Comment 8 306595428@qq.com 2023-01-07 13:55:13 UTC
(In reply to Denys Vlasenko from comment #5)
how to do it? i had add CONFIG_EXTRA_LDLIBS: libtirpc and tirpc, the result also is failed.