[ovs-dev] [PATCH] m4: Fix 32bit build with 64bit version of libunwind-dev installed.

Ilya Maximets i.maximets at ovn.org
Tue Oct 1 11:22:20 UTC 2019


32 and 64 bit versions of libunwind-dev package can not be installed
at the same time at least in Debian and Ubuntu.  AC_CHECK_LIB macro
doesn't know if we have '-m32' in OVS_CFLAGS, so we need to
additionally check for actual compiling possibility before enabling
the feature.  Otherwise 'make' will fail due to inability to
build with 64bit libunwind headers:

    https://travis-ci.org/openvswitch/ovs/jobs/590580374

    /usr/include/libunwind.h:23:28: fatal error:
        libunwind-x86.h: No such file or directory

CC: William Tu <u9012063 at gmail.com>
Fixes: e2ed6fbeb18c ("fatal-signal: Catch SIGSEGV and print backtrace.")
Signed-off-by: Ilya Maximets <i.maximets at ovn.org>
---
 m4/openvswitch.m4 | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 development)

diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 79e0be5a3..fa822eab7 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -640,7 +640,21 @@ 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_LIB(unwind, unw_backtrace,
+     [
+      dnl We need to additionally check if we can build with our CFLAGS
+      dnl because 32bit build could fail if 64bit library installed.
+      dnl 32 and 64 bit versions of libunwind development package could be
+      dnl mutually exclusive in distributions.
+      AC_MSG_CHECKING([whether building with libunwind works])
+      save_cflags="$CFLAGS"
+      CFLAGS="$CFLAGS $OVS_CFLAGS"
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <libunwind.h>])],
+                        [HAVE_UNWIND=yes], [HAVE_UNWIND=no])
+      CFLAGS="$save_cflags"
+      AC_MSG_RESULT([$HAVE_UNWIND])
+     ],
+     [HAVE_UNWIND=no])
    if test "$HAVE_UNWIND" = yes; then
      AC_DEFINE([HAVE_UNWIND], [1], [Define to 1 if unwind is detected.])
      LIBS="$LIBS -lunwind"
-- 
2.17.1



More information about the dev mailing list