Re: [PATCH] Don't link with -lrt on OpenBSD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 04, 2012 at 10:59:05AM -0600, Eric Blake wrote:
> On 09/04/2012 09:26 AM, Eric Blake wrote:
> > On 09/04/2012 09:04 AM, Jasper Lievisse Adriaanse wrote:
> >> >From bdf3bce37531ec346474bc5c4f37a5d2985d1d35 Mon Sep 17 00:00:00 2001
> >> From: Jasper Lievisse Adriaanse <jasper@xxxxxxxxx>
> >> Date: Tue, 4 Sep 2012 17:03:43 +0200
> >> Subject: [PATCH] Don't link with -lrt on OpenBSD
> >>
> >> ---
> >>  configure.ac |    8 +++++++-
> >>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> > 
> > I'd much rather write this as a probe to see if linking with -rt makes a
> > difference, and only add it when it matters, than trying to blindly add
> > it (the pre-patch version) or to blindly exclude it for some platforms
> > (the post-patch version).  I also wonder if gnulib has some help on this
> > front.  NACK to this version while I investigate.
> 
> In fact, gnulib already provides the LGPLv2+ clock-time module for
> clock_gettime and clock_settime, with an appropriate link library
> $(LIB_CLOCK_GETTIME) that is set to -lrt when necessary.  Does this
> patch work for you?
Yep, this seems to work just fine.
 
> From d74e5a4dfc434d3a1d01856d013a7f50d910fa95 Mon Sep 17 00:00:00 2001
> From: Eric Blake <eblake@xxxxxxxxxx>
> Date: Tue, 4 Sep 2012 10:57:25 -0600
> Subject: [PATCH] build: use correct libraries for clock_gettime
> 
> On OpenBSD, clock_gettime() exists in libc rather than librt, and
> blindly linking with -lrt made the build fail.  Gnulib already
> did the work for determining which libraries to use, so we should
> reuse that work rather than doing it ourselves.
> 
> * bootstrap.conf (gnulib_modules): Pull in clock-time.
> * configure.ac (RT_LIBS): Drop.
> * src/Makefile.am (libvirt_util_la_LIBADD): Use gnulib variable
> instead.
> * src/util/virtime.c (includes): Simplify.
> ---
>  bootstrap.conf     |  1 +
>  configure.ac       | 10 ----------
>  src/Makefile.am    |  2 +-
>  src/util/virtime.c |  6 ++----
>  4 files changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/bootstrap.conf b/bootstrap.conf
> index a6cfe24..7fefb69 100644
> --- a/bootstrap.conf
> +++ b/bootstrap.conf
> @@ -30,6 +30,7 @@ c-strcasestr
>  calloc-posix
>  canonicalize-lgpl
>  chown
> +clock-time
>  close
>  connect
>  configmake
> diff --git a/configure.ac b/configure.ac
> index e0d00d5..cb91e7d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -183,16 +183,6 @@ LIBS="$LIBS $LIB_PTHREAD $LIBMULTITHREAD"
>  AC_CHECK_FUNCS([pthread_mutexattr_init])
>  LIBS=$old_libs
> 
> -old_LIBS=$LIBS
> -RT_LIBS=
> -LIBS="$LIBS $LIB_PTHREAD -lrt"
> -AC_CHECK_FUNC([clock_gettime],[
> -     AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Defined if clock_gettime()
> exists in librt.so])
> -     RT_LIBS=-lrt
> -])
> -LIBS=$old_libs
> -AC_SUBST(RT_LIBS)
> -
>  dnl Availability of various common headers (non-fatal if missing).
>  AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \
>    sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 95e1bea..39adeac 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -668,7 +668,7 @@ libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS)
> $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
>  		$(DBUS_CFLAGS) $(LDEXP_LIBM)
>  libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
>  		$(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
> -		$(RT_LIBS) $(DBUS_LIBS) $(MSCOM_LIBS) $(LIBXML_LIBS)
> +		$(LIB_CLOCK_GETTIME) $(DBUS_LIBS) $(MSCOM_LIBS) $(LIBXML_LIBS)
> 
> 
>  noinst_LTLIBRARIES += libvirt_conf.la
> diff --git a/src/util/virtime.c b/src/util/virtime.c
> index 926bb50..d34e8ab 100644
> --- a/src/util/virtime.c
> +++ b/src/util/virtime.c
> @@ -1,7 +1,7 @@
>  /*
>   * virtime.c: Time handling functions
>   *
> - * Copyright (C) 2006-2011 Red Hat, Inc.
> + * Copyright (C) 2006-2012 Red Hat, Inc.
>   *
>   * This library is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU Lesser General Public
> @@ -34,9 +34,7 @@
>  #include <config.h>
> 
>  #include <stdio.h>
> -#ifndef HAVE_CLOCK_GETTIME
> -# include <sys/time.h>
> -#endif
> +#include <sys/time.h>
> 
>  #include "virtime.h"
>  #include "util.h"
> -- 
> 1.7.11.4
> 
> -- 
> Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
> 



-- 
Cheers,
Jasper

"Stay Hungry. Stay Foolish"

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]