[libvirt] [PATCH] Check for link_addr more thoroughly

Some versions of kFreeBSD (like 9.0) declare link_addr in a header but lack an implementation. This makes ./configure pass but breaks compilation later with a undefined reference to `link_addr' Althought that's a bug in the OS header we can detect it easily by also trying to link. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=715320 --- configure.ac | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index b5af0d3..4e8b9b8 100644 --- a/configure.ac +++ b/configure.ac @@ -2391,13 +2391,15 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_newname, [#include <sys/socket.h> #include <net/if.h> ]) + # Check for BSD approach for setting MAC addr -AC_CHECK_DECLS([link_addr], - [], [], - [#include <sys/types.h> - #include <sys/socket.h> - #include <net/if_dl.h> - ]) +AC_TRY_LINK([#include <sys/types.h> + #include <sys/socket.h> + #include <net/if_dl.h>], + [link_addr(NULL, NULL)], + [AC_DEFINE([HAVE_DECL_LINK_ADDR], + [1], + [whether link_addr is available])]) # Check for BSD approach for bridge management AC_CHECK_DECLS([BRDGSFD, BRDGADD, BRDGDEL], -- 1.8.3.2

On 07/17/2013 01:05 PM, Guido Günther wrote:
Some versions of kFreeBSD (like 9.0) declare link_addr in a header but lack an implementation. This makes ./configure pass but breaks compilation later with a
undefined reference to `link_addr'
Althought that's a bug in the OS header we can detect it easily by also trying to link.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=715320 --- configure.ac | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
+ # Check for BSD approach for setting MAC addr -AC_CHECK_DECLS([link_addr], - [], [], - [#include <sys/types.h> - #include <sys/socket.h> - #include <net/if_dl.h> - ]) +AC_TRY_LINK([#include <sys/types.h>
I'd prefer we use AC_LINK_IFELSE here (upstream autoconf has deprecated AC_TRY_LINK on the grounds that AC_LINK_IFELSE has saner quoting rules in relation to the rest of the configure.ac file).
+ #include <sys/socket.h> + #include <net/if_dl.h>], + [link_addr(NULL, NULL)], + [AC_DEFINE([HAVE_DECL_LINK_ADDR], + [1], + [whether link_addr is available])])
The concept makes sense, but it's probably worth seeing a v2 just to make sure the modernized autoconf magic is correct. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Some versions of kFreeBSD (like 9.0) declare link_addr in a header but lack an implementation. This makes ./configure pass but breaks compilation later with a undefined reference to `link_addr' Althought that's a bug in the OS header we can detect it easily by also trying to link. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=715320 --- Changes from v1: Use AC_LINK_IFELSE instead of AC_TRY_LINK I used AC_TRY_LINK since it's used in other places in configure.ac. Should these be converted too? Cheers, -- Guido configure.ac | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index b5af0d3..5d5c8de 100644 --- a/configure.ac +++ b/configure.ac @@ -2391,13 +2391,19 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_newname, [#include <sys/socket.h> #include <net/if.h> ]) + # Check for BSD approach for setting MAC addr -AC_CHECK_DECLS([link_addr], - [], [], - [#include <sys/types.h> - #include <sys/socket.h> - #include <net/if_dl.h> - ]) +AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[ + #include <sys/types.h> + #include <sys/socket.h> + #include <net/if_dl.h> + ]], + [[ + link_addr(NULL, NULL)]])], + [AC_DEFINE([HAVE_DECL_LINK_ADDR], + [1], + [whether link_addr is available])]) # Check for BSD approach for bridge management AC_CHECK_DECLS([BRDGSFD, BRDGADD, BRDGDEL], -- 1.8.3.2

On 07/18/2013 03:11 AM, Guido Günther wrote:
Some versions of kFreeBSD (like 9.0) declare link_addr in a header but lack an implementation. This makes ./configure pass but breaks compilation later with a
undefined reference to `link_addr'
Althought that's a bug in the OS header we can detect it easily by also trying to link.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=715320 --- Changes from v1:
Use AC_LINK_IFELSE instead of AC_TRY_LINK
Thanks; ACK.
I used AC_TRY_LINK since it's used in other places in configure.ac. Should these be converted too?
Sure, that's a reasonable cleanup, but as a separate patch. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Thu, Jul 18, 2013 at 07:04:13AM -0600, Eric Blake wrote:
On 07/18/2013 03:11 AM, Guido Günther wrote:
Some versions of kFreeBSD (like 9.0) declare link_addr in a header but lack an implementation. This makes ./configure pass but breaks compilation later with a
undefined reference to `link_addr'
Althought that's a bug in the OS header we can detect it easily by also trying to link.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=715320 --- Changes from v1:
Use AC_LINK_IFELSE instead of AC_TRY_LINK
Thanks; ACK. Pushed. Thanks.
I used AC_TRY_LINK since it's used in other places in configure.ac. Should these be converted too?
Sure, that's a reasonable cleanup, but as a separate patch.
I'll add that to my backlog. Cheers, -- Guido
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Guido Günther