[systemd-devel] [PATCH] Add -lresolv to libudev LIBADD

Łukasz Stelmach l.stelmach at samsung.com
Fri Feb 21 09:06:01 PST 2014


It was <2014-02-21 pią 17:06>, when Kay Sievers wrote:
> On Fri, Feb 21, 2014 at 4:58 PM, Łukasz Stelmach <l.stelmach at samsung.com> wrote:
>> It was <2014-02-21 pią 16:22>, when Lennart Poettering wrote:
>>> On Fri, 21.02.14 15:54, Łukasz Stelmach (l.stelmach at samsung.com) wrote:
>>>
>>>> Fix problems with unresolved symbols when building on Ubuntu 12.04 x86_64.
>>>>
>>>> --8<---------------cut here---------------start------------->8---
>>>> ./.libs/libudev.so: undefined reference to `__res_search'
>>>> ./.libs/libudev.so: undefined reference to `__res_query'
>>>> collect2: ld returned 1 exit status
>>>> --8<---------------cut here---------------end--------------->8---
>>>
>>> This doesn't look right. libudev really shouldn't need libresolv. We
>>> should figure out how these calls got pulled in...
>>
>> Let me go step-by-step:
>>
>> --8<---------------cut here---------------start------------->8---
>> $ strings ./.libs/libudev.so | grep __res_'\(query\|search\)'
>>
>> __res_query
>> __res_search
>>
>> # libudev needs libsystemd-internal
>> $ strings ./.libs/libsystemd-internal.a | grep __res_'\(query\|search\)'
>
> This does not seem to happen here. Are you sure that "as-needed" is
> working in your setup?

Stracing gcc linking libudev.so shows --as-needed interleaved with
--no-as-needed. This is how libudev.so.1.4.0 is created

--8<---------------cut here---------------start------------->8---
"/usr/bin/ld.bfd.real" "--sysroot=/" "--build-id" "--no-add-needed"
"--as-needed" "--eh-frame-hdr" "-m" "elf_x86_64" "--hash-style=gnu"
"-shared" "-z" "relro" "-o" ".libs/libudev.so.1.4.0"
"/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o"
"/usr/lib/gcc/x86_64-linux-gnu/4.6/crtbeginS.o"
"-L/usr/lib/gcc/x86_64-linux-gnu/4.6"
"-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu"
"-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib"
"-L/lib/x86_64-linux-gnu" "-L/lib/../lib" "-L/usr/lib/x86_64-linux-gnu"
"-L/usr/lib/../lib" "-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.."
"src/libudev/.libs/libudev_la-libudev.o"
"src/libudev/.libs/libudev_la-libudev-list.o"
"src/libudev/.libs/libudev_la-libudev-util.o"
"src/libudev/.libs/libudev_la-libudev-device.o"
"src/libudev/.libs/libudev_la-libudev-enumerate.o"
"src/libudev/.libs/libudev_la-libudev-monitor.o"
"src/libudev/.libs/libudev_la-libudev-queue.o"
"src/libudev/.libs/libudev_la-libudev-hwdb.o" "--whole-archive"
"./.libs/libsystemd-internal.a" "./.libs/libsystemd-shared.a"
"--no-whole-archive" "-lrt" "-ldl" "--as-needed" "--no-undefined"
"--gc-sections" "-z" "relro" "-z" "now"
"--version-script=./src/libudev/libudev.sym" "-soname" "libudev.so.1"
"-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lpthread" "-lc"
"-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
"/usr/lib/gcc/x86_64-linux-gnu/4.6/crtendS.o"
"/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crtn.o"
--8<---------------cut here---------------end--------------->8---

Got it! --whole-archive before libsystemd-*.a that is!

--8<---------------cut here---------------start------------->8---
$ git grep whole.archive 
$ grep -rl whole.archive .
./autom4te.cache/output.2
./autom4te.cache/output.1
./autom4te.cache/output.0
./config.status
./build-aux/ltmain.sh
./configure
./m4/libtool.m4
./libtool
--8<---------------cut here---------------end--------------->8---

-- 
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20140221/3b0befa4/attachment.pgp>


More information about the systemd-devel mailing list