diff mbox series

[ovs-dev] configure: Properly handle case where libunwind.h is not available.

Message ID 1571175048-48730-1-git-send-email-yihung.wei@gmail.com
State Superseded
Headers show
Series [ovs-dev] configure: Properly handle case where libunwind.h is not available. | expand

Commit Message

Yi-Hung Wei Oct. 15, 2019, 9:30 p.m. UTC
It is possible that user install libunwind but not libunwind-devel,
and it will run into a compilation error.  So check the existence
of the header file instead of the library.

Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
---
 m4/openvswitch.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Pfaff Oct. 15, 2019, 6:53 p.m. UTC | #1
On Tue, Oct 15, 2019 at 02:30:48PM -0700, Yi-Hung Wei wrote:
> It is possible that user install libunwind but not libunwind-devel,
> and it will run into a compilation error.  So check the existence
> of the header file instead of the library.
> 
> Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
> ---
>  m4/openvswitch.m4 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> index 79e0be5a33dd..da7119951484 100644
> --- a/m4/openvswitch.m4
> +++ b/m4/openvswitch.m4
> @@ -640,7 +640,7 @@ AC_DEFUN([OVS_CHECK_UNBOUND],
>  
>  dnl Checks for libunwind.
>  AC_DEFUN([OVS_CHECK_UNWIND],
> -  [AC_CHECK_LIB(unwind, unw_backtrace, [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
> +  [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])

It might be wise to check for both, e.g.:

AC_CHECK_LIB([unwind], [unw_backtrace],
  [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])],
  [HAVE_UNWIND=no])
Yi-Hung Wei Oct. 15, 2019, 11:49 p.m. UTC | #2
On Tue, Oct 15, 2019 at 3:25 PM Ben Pfaff <blp@ovn.org> wrote:
>
> On Tue, Oct 15, 2019 at 02:30:48PM -0700, Yi-Hung Wei wrote:
> > It is possible that user install libunwind but not libunwind-devel,
> > and it will run into a compilation error.  So check the existence
> > of the header file instead of the library.
> >
> > Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
> > Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
> > ---
> >  m4/openvswitch.m4 | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> > index 79e0be5a33dd..da7119951484 100644
> > --- a/m4/openvswitch.m4
> > +++ b/m4/openvswitch.m4
> > @@ -640,7 +640,7 @@ AC_DEFUN([OVS_CHECK_UNBOUND],
> >
> >  dnl Checks for libunwind.
> >  AC_DEFUN([OVS_CHECK_UNWIND],
> > -  [AC_CHECK_LIB(unwind, unw_backtrace, [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
> > +  [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
>
> It might be wise to check for both, e.g.:
>
> AC_CHECK_LIB([unwind], [unw_backtrace],
>   [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])],
>   [HAVE_UNWIND=no])
>

Hi Ben,

In most distros, libunwind-devel (or libunwind-dev) depends on
libunwind.  Is it necessary for us to check both?

Thanks,

-Yi-Hung
Ben Pfaff Oct. 16, 2019, 10:16 p.m. UTC | #3
On Tue, Oct 15, 2019 at 04:49:33PM -0700, Yi-Hung Wei wrote:
> On Tue, Oct 15, 2019 at 3:25 PM Ben Pfaff <blp@ovn.org> wrote:
> >
> > On Tue, Oct 15, 2019 at 02:30:48PM -0700, Yi-Hung Wei wrote:
> > > It is possible that user install libunwind but not libunwind-devel,
> > > and it will run into a compilation error.  So check the existence
> > > of the header file instead of the library.
> > >
> > > Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
> > > Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
> > > ---
> > >  m4/openvswitch.m4 | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> > > index 79e0be5a33dd..da7119951484 100644
> > > --- a/m4/openvswitch.m4
> > > +++ b/m4/openvswitch.m4
> > > @@ -640,7 +640,7 @@ AC_DEFUN([OVS_CHECK_UNBOUND],
> > >
> > >  dnl Checks for libunwind.
> > >  AC_DEFUN([OVS_CHECK_UNWIND],
> > > -  [AC_CHECK_LIB(unwind, unw_backtrace, [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
> > > +  [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
> >
> > It might be wise to check for both, e.g.:
> >
> > AC_CHECK_LIB([unwind], [unw_backtrace],
> >   [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])],
> >   [HAVE_UNWIND=no])
> >
> 
> Hi Ben,
> 
> In most distros, libunwind-devel (or libunwind-dev) depends on
> libunwind.  Is it necessary for us to check both?

Not if everyone installs from a distro package.  If you install from a
tarball, it's easy to provide configure options that make the header
available but not the library, or vice versa.  It's better to catch that
at configure time.
Yi-Hung Wei Oct. 17, 2019, 4:45 a.m. UTC | #4
On Wed, Oct 16, 2019 at 6:50 PM Ben Pfaff <blp@ovn.org> wrote:
>
> On Tue, Oct 15, 2019 at 04:49:33PM -0700, Yi-Hung Wei wrote:
> > On Tue, Oct 15, 2019 at 3:25 PM Ben Pfaff <blp@ovn.org> wrote:
> > >
> > > On Tue, Oct 15, 2019 at 02:30:48PM -0700, Yi-Hung Wei wrote:
> > > > It is possible that user install libunwind but not libunwind-devel,
> > > > and it will run into a compilation error.  So check the existence
> > > > of the header file instead of the library.
> > > >
> > > > Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
> > > > Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
> > > > ---
> > > >  m4/openvswitch.m4 | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> > > > index 79e0be5a33dd..da7119951484 100644
> > > > --- a/m4/openvswitch.m4
> > > > +++ b/m4/openvswitch.m4
> > > > @@ -640,7 +640,7 @@ AC_DEFUN([OVS_CHECK_UNBOUND],
> > > >
> > > >  dnl Checks for libunwind.
> > > >  AC_DEFUN([OVS_CHECK_UNWIND],
> > > > -  [AC_CHECK_LIB(unwind, unw_backtrace, [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
> > > > +  [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
> > >
> > > It might be wise to check for both, e.g.:
> > >
> > > AC_CHECK_LIB([unwind], [unw_backtrace],
> > >   [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])],
> > >   [HAVE_UNWIND=no])
> > >
> >
> > Hi Ben,
> >
> > In most distros, libunwind-devel (or libunwind-dev) depends on
> > libunwind.  Is it necessary for us to check both?
>
> Not if everyone installs from a distro package.  If you install from a
> tarball, it's easy to provide configure options that make the header
> available but not the library, or vice versa.  It's better to catch that
> at configure time.

Thanks for explanation.   It's better to check both.  I will send out v2 soon.

Thanks,

-Yi-Hung
diff mbox series

Patch

diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 79e0be5a33dd..da7119951484 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -640,7 +640,7 @@  AC_DEFUN([OVS_CHECK_UNBOUND],
 
 dnl Checks for libunwind.
 AC_DEFUN([OVS_CHECK_UNWIND],
-  [AC_CHECK_LIB(unwind, unw_backtrace, [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
+  [AC_CHECK_HEADERS([libunwind.h], [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
    if test "$HAVE_UNWIND" = yes; then
      AC_DEFINE([HAVE_UNWIND], [1], [Define to 1 if unwind is detected.])
      LIBS="$LIBS -lunwind"