Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 494940 - net-libs/gnutls-3.2.8 - ../../lib/.libs/libgnutls.so: undefined reference to `clock_gettime'
Summary: net-libs/gnutls-3.2.8 - ../../lib/.libs/libgnutls.so: undefined reference to ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Crypto team [DISABLED]
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-21 11:24 UTC by Evgeny Bobkin
Modified: 2013-12-22 14:39 UTC (History)
5 users (show)

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


Attachments
proposed patch for -lrt correct linkage (gnutls-3.2.8-librt-linkage.patch,548 bytes, patch)
2013-12-21 19:47 UTC, Evgeny Bobkin
Details | Diff
0001-build-detect-clock_gettime-out-of-librt.patch (0001-build-detect-clock_gettime-out-of-librt.patch,879 bytes, patch)
2013-12-21 21:18 UTC, Alon Bar-Lev (RETIRED)
Details | Diff
buildlog (gnutls.buldlog,244.63 KB, application/octet-stream)
2013-12-21 22:45 UTC, Evgeny Bobkin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Evgeny Bobkin 2013-12-21 11:24:52 UTC
using gcc 4.8.2
...
Making all in crywrap
make[4]: Entering directory `/var/tmp/portage/net-libs/gnutls-3.2.8/work/gnutls-3.2.8/src/crywrap'
x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../..  -I./../../lib/includes -I./../../lib/includes -DSYSCONFDIR=\"/etc\" -DCRYWRAP_PATCHLEVEL=\"3\"    -march=core-avx-i -O2 -pipe -c -o crywrap.o crywrap.c
crywrap.c: In function '_crywrap_do_one':
crywrap.c:859:7: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       (gnutls_transport_ptr_t) insock,
       ^
crywrap.c:860:7: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       (gnutls_transport_ptr_t) outsock);
       ^
crywrap.c: In function '_crywrap_setup_pidfile':
crywrap.c:812:8: warning: ignoring return value of 'fchown', declared with attribute warn_unused_result [-Wunused-result]
  fchown(pidfilefd, config->uid, (gid_t) - 1);
        ^
crywrap.c:816:7: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
  write(pidfilefd, mypid, strlen(mypid));
       ^
/bin/sh ../../libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc   -march=core-avx-i -O2 -pipe  -Wl,-O1 -Wl,--as-needed -o crywrap crywrap.o ../../lib/libgnutls.la -lidn   
libtool: link: x86_64-pc-linux-gnu-gcc -march=core-avx-i -O2 -pipe -Wl,-O1 -o .libs/crywrap crywrap.o  -Wl,--as-needed ../../lib/.libs/libgnutls.so -L/usr/lib64 -lz -lnettle -lhogweed -lgmp -lidn
../../lib/.libs/libgnutls.so: undefined reference to `clock_gettime'
collect2: error: ld returned 1 exit status
make[4]: *** [crywrap] Error 1
make[4]: Leaving directory `/var/tmp/portage/net-libs/gnutls-3.2.8/work/gnutls-3.2.8/src/crywrap'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/var/tmp/portage/net-libs/gnutls-3.2.8/work/gnutls-3.2.8/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/var/tmp/portage/net-libs/gnutls-3.2.8/work/gnutls-3.2.8/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/portage/net-libs/gnutls-3.2.8/work/gnutls-3.2.8'
make: *** [all] Error 2
 * ERROR: net-libs/gnutls-3.2.8::gentoo failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=net-libs/gnutls-3.2.8::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=net-libs/gnutls-3.2.8::gentoo'`.
 * The complete build log is located at '/var/log/portage/net-libs:gnutls-3.2.8:20131221-111826.log'.
 * For convenience, a symlink to the build log is located at '/var/tmp/portage/net-libs/gnutls-3.2.8/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/net-libs/gnutls-3.2.8/temp/environment'.
 * Working directory: '/var/tmp/portage/net-libs/gnutls-3.2.8/work/gnutls-3.2.8'
 * S: '/var/tmp/portage/net-libs/gnutls-3.2.8/work/gnutls-3.2.8'

>>> Failed to emerge net-libs/gnutls-3.2.8, Log file:
...

Reproducible: Always
Comment 1 Evgeny Bobkin 2013-12-21 11:27:05 UTC
just a guess: probably a -lrt linkage is required
Comment 2 walt 2013-12-21 16:09:49 UTC
configure.ac introduces the new variables gnutls_needs_librt and NEEDS_LIBRT.

NEEDS_LIBRT is incorrectly set to FALSE, so I think gnutls_needs_librt never
gets set (or tested?).
Comment 3 Evgeny Bobkin 2013-12-21 19:46:07 UTC
well, I have investigated this the issue a little bit and after reading this post 

http://gnu-autoconf.7623.n7.nabble.com/Correct-way-to-check-for-clock-gettime-td12276.html

I suggest the following patch, which I have tested successfully :

>>> Preparing source in /var/tmp/portage/net-libs/gnutls-3.2.8/work/gnutls-3.2.8 ...
 * Applying user patches from /etc/portage/patches//net-libs/gnutls ...
 *   gnutls-3.2.8-librt-linkage.patch ...                                [ ok ]
 * Done with patching


here is the patch:

diff -urN gnutls-3.2.8/configure.ac gnutls-3.2.8-a/configure.ac
--- gnutls-3.2.8/configure.ac	2013-12-16 18:33:56.000000000 +0100
+++ gnutls-3.2.8-a/configure.ac	2013-12-21 20:35:09.032596590 +0100
@@ -233,6 +233,12 @@
 #include <signal.h>
 ], [timer_create (0,0,0);])
 
+AC_SEARCH_LIBS([clock_gettime], [rt],) 
+ 
+if test "$ac_cv_search_clock_gettime" = "-lrt"; then 
+     LIBS="$LIBS -lrt" 
+fi 
+
 if test "$ac_cv_func_pthread_mutex_lock" != "yes";then
   AC_LIB_HAVE_LINKFLAGS(pthread,, [#include <pthread.h>], [pthread_mutex_lock (0);])
 fi
Comment 4 Evgeny Bobkin 2013-12-21 19:47:03 UTC
Created attachment 365840 [details, diff]
proposed patch for -lrt correct linkage
Comment 5 Alon Bar-Lev (RETIRED) gentoo-dev 2013-12-21 20:16:23 UTC
(In reply to Evgeny Bobkin from comment #4)
> Created attachment 365840 [details, diff] [details, diff]
> proposed patch for -lrt correct linkage

Thanks!

But I think the following should also do the trick without any conditional, can you please check it out? if not, can you please attach config.log?

AC_SEARCH_LIBS([clock_gettime], [rt])
Comment 6 Evgeny Bobkin 2013-12-21 21:04:10 UTC
(In reply to Alon Bar-Lev from comment #5)
> (In reply to Evgeny Bobkin from comment #4)
> > Created attachment 365840 [details, diff] [details, diff] [details, diff]
> > proposed patch for -lrt correct linkage
> 
> Thanks!
> 
> But I think the following should also do the trick without any conditional,
> can you please check it out? if not, can you please attach config.log?
> 
> AC_SEARCH_LIBS([clock_gettime], [rt])

yep, indeed, it's enough.
Comment 7 Alon Bar-Lev (RETIRED) gentoo-dev 2013-12-21 21:18:43 UTC
Created attachment 365842 [details, diff]
0001-build-detect-clock_gettime-out-of-librt.patch

Hmm... while looking at code, it seems that gnutls has its own way of doing so, can you please checkout this patch?
Comment 8 Evgeny Bobkin 2013-12-21 22:42:45 UTC
(In reply to Alon Bar-Lev from comment #7)
> Created attachment 365842 [details, diff] [details, diff]
> 0001-build-detect-clock_gettime-out-of-librt.patch
> 
> Hmm... while looking at code, it seems that gnutls has its own way of doing
> so, can you please checkout this patch?

the second patch proposal fails with the same error message as in the first comment.

...
checking for library containing clock_gettime... -lrt
checking for clock_gettime... yes
checking for clock_settime... yes
checking for error_at_line... yes
...

however -lrt does not seem to be appended to CLIBS
Comment 9 Evgeny Bobkin 2013-12-21 22:45:23 UTC
Created attachment 365856 [details]
buildlog
Comment 10 walt 2013-12-21 23:00:49 UTC
My ebuild skills are a bit rusty :(

I saved your patch as gnutls-3.2.8-build.patch and put it in
/usr/portage/net-libs/gnutls/files/

I regenerated the Manifest file and then emerged gnutls again, which failed with the same error because configure.ac was not, in fact, patched.

Shouldn't build.log contain messages about patches being applied right near the beginning of the log?  There are no such messages, even about the already existing patches.


(BTW, this package emerged with no errors on a ~amd64 machine I run in virtualbox, and the installed libgnutls.so.28.29.0 is *not* linked to librt.)
Comment 11 Evgeny Bobkin 2013-12-21 23:08:22 UTC
(In reply to walt from comment #10)
> My ebuild skills are a bit rusty :(
> 
> I saved your patch as gnutls-3.2.8-build.patch and put it in
> /usr/portage/net-libs/gnutls/files/
user patches for this ebuild should be placed in /etc/portage/patches/net-libs/gnutls.

for more details please consider the official wiki pages http://wiki.gentoo.org/wiki//etc/portage/patches
> 
> I regenerated the Manifest file and then emerged gnutls again, which failed
> with the same error because configure.ac was not, in fact, patched.
> 
> Shouldn't build.log contain messages about patches being applied right near
> the beginning of the log?  There are no such messages, even about the
> already existing patches.
yep, then you should observe something like:
...
 * Applying user patches from /etc/portage/patches//net-libs/gnutls ...
 *   gnutls-3.2.8-librt-linkage.patch ...                                [ ok ]
 * Done with patching
> 
> 
> (BTW, this package emerged with no errors on a ~amd64 machine I run in
> virtualbox, and the installed libgnutls.so.28.29.0 is *not* linked to librt.)
Comment 12 walt 2013-12-21 23:45:33 UTC
(In reply to Evgeny Bobkin from comment #11)

> user patches for this ebuild should be placed in
> /etc/portage/patches/net-libs/gnutls.

Did that. And it worked :)  Thanks Evgeny.

Unfortunately I reproduced your failure in Comment 8, even though Alon's patch was definitely applied this time (I double-checked).
Comment 13 Alon Bar-Lev (RETIRED) gentoo-dev 2013-12-22 05:43:45 UTC
Hi,

I need config.log of a run that reproduce this issue and this patch applied.

Thanks!
Comment 14 Alon Bar-Lev (RETIRED) gentoo-dev 2013-12-22 06:04:29 UTC
No need, reproduced.
Comment 15 Evgeny Bobkin 2013-12-22 13:12:25 UTC
So, what is the way to proceed here?
Has anyone forwarded it to upstream?

the solution 

AC_SEARCH_LIBS([clock_gettime], [rt], [], [
  AC_MSG_ERROR([unable to find the clock_gettime() function])
])

is the only working at the moment!!
Comment 16 Alon Bar-Lev (RETIRED) gentoo-dev 2013-12-22 14:39:01 UTC
(In reply to Evgeny Bobkin from comment #15)
> So, what is the way to proceed here?
> Has anyone forwarded it to upstream?
> 
> the solution 
> 
> AC_SEARCH_LIBS([clock_gettime], [rt], [], [
>   AC_MSG_ERROR([unable to find the clock_gettime() function])
> ])
> 
> is the only working at the moment!!

patience.