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

2014-02-21 Thread Łukasz Stelmach
It was <2014-02-21 pią 17:06>, when Kay Sievers wrote:
> On Fri, Feb 21, 2014 at 4:58 PM, Łukasz Stelmach  
> wrote:
>> It was <2014-02-21 pią 16:22>, when Lennart Poettering wrote:
>>> On Fri, 21.02.14 15:54, Łukasz Stelmach (l.stelm...@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


pgpdU73u0Ig1s.pgp
Description: PGP signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-02-21 Thread Kay Sievers
On Fri, Feb 21, 2014 at 4:58 PM, Łukasz Stelmach  wrote:
> It was <2014-02-21 pią 16:22>, when Lennart Poettering wrote:
>> On Fri, 21.02.14 15:54, Łukasz Stelmach (l.stelm...@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?

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-02-21 Thread Łukasz Stelmach
It was <2014-02-21 pią 16:22>, when Lennart Poettering wrote:
> On Fri, 21.02.14 15:54, Łukasz Stelmach (l.stelm...@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\)'

__res_query
__res_search

$ grep __res_query [list of objects used to build l-i.a]

Binary file src/libsystemd/sd-resolve/.libs/libsystemd_internal_la-sd-resolve.o 
matches

$ rm -f src/libsystemd/sd-resolve/libsystemd_internal_la-sd-resolve.lo \
  && strace make src/libsystemd/sd-resolve/libsystemd_internal_la-sd-resolve.lo

$ grep __res_'\(query\|search\)' /usr/include/resolv.h

#define res_query   __res_query
#define res_querydomain __res_querydomain
#define res_search  __res_search

$ gcc -std=gnu99 [...]-E src/libsystemd/sd-resolve/sd-resolve.c  -fPIC \
-DPIC | grep __res_'\(query\|search\)'

void __res_close (void) __attribute__ ((__nothrow__ , __leaf__));
int __res_init (void) __attribute__ ((__nothrow__ , __leaf__));
int __res_isourserver (const struct sockaddr_in *) __attribute__ ((__nothrow__ 
, __leaf__));
int __res_mkquery (int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int) __attribute__ ((__nothrow__ , 
__leaf__));
int __res_query (const char *, int, int, u_char *, int) __attribute__ 
((__nothrow__ , __leaf__));
int __res_querydomain (const char *, const char *, int, int,
 u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
int __res_search (const char *, int, int, u_char *, int) __attribute__ 
((__nothrow__ , __leaf__));
int __res_send (const u_char *, int, u_char *, int) __attribute__ ((__nothrow__ 
, __leaf__));

# 327 "/usr/include/resolv.h" 3 4

int __res_hnok (const char *) __attribute__ ((__nothrow__ , __leaf__));
--
 do { if ((__builtin_expect(!!(!(length == sizeof(ResRequest) + 
res_req->dname_len)),0))) log_assert_failed("length == sizeof(ResRequest) + 
res_req->dname_len", "src/libsystemd/sd-resolve/sd-resolve.c", 425, 
__PRETTY_FUNCTION__); } while (0);

 dname = (const char *) req + sizeof(ResRequest);

 if (req->type == REQUEST_RES_QUERY)
 ret = __res_query(dname, res_req->class, 
res_req->type, (unsigned char *) &answer, 10240);
 else
 ret = __res_search(dname, res_req->class, 
res_req->type, (unsigned char *) &answer, 10240);

 return send_res_reply(out_fd, req->id, (unsigned char *) 
&answer, ret, (*__errno_location ()), (*__h_errno_location ()));
}

case REQUEST_TERMINATE:
--8<---cut here---end--->8---

There are defines in resolv.h which make res_query() and res_search() be
substituted with __res_.* versions. These does not look like Ubuntu
specific stuff[1].

[1] 
https://sourceware.org/git/?p=glibc.git;a=blob;f=resolv/resolv.h;h=53c3bba182be49ba0a2372ffba7920c016029ecd;hb=HEAD#l262

-- 
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics


pgp3lwnDs_tBP.pgp
Description: PGP signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-02-21 Thread Lennart Poettering
On Fri, 21.02.14 15:54, Łukasz Stelmach (l.stelm...@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...

> 
> ---
>  Makefile.am |3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index f6c22bd..682266b 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -2416,7 +2416,8 @@ libudev_la_LDFLAGS = \
>  
>  libudev_la_LIBADD = \
>   libsystemd-internal.la \
> - libsystemd-shared.la
> + libsystemd-shared.la \
> + -lresolv
>  
>  pkgconfiglib_DATA += \
>   src/libudev/libudev.pc


Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-02-21 Thread Łukasz Stelmach
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---

---
 Makefile.am |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index f6c22bd..682266b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2416,7 +2416,8 @@ libudev_la_LDFLAGS = \
 
 libudev_la_LIBADD = \
libsystemd-internal.la \
-   libsystemd-shared.la
+   libsystemd-shared.la \
+   -lresolv
 
 pkgconfiglib_DATA += \
src/libudev/libudev.pc
-- 
1.7.9.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel