]> git.puffer.fish Git - mirror/frr.git/commitdiff
build: improve backtrace support/detection
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 1 Aug 2013 07:43:36 +0000 (07:43 +0000)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 1 Apr 2014 15:20:44 +0000 (17:20 +0200)
libexecinfo is used to provide backtrace() on *BSD.  The API is
compatible with glibc's, so this is a "free" improvement.

To improve configure behaviour, the following configure options are
modified/introduced:

* --enable-gcc-rdynamic now defaults to "on" if the compiler is gcc.
  (I sadly wasn't able to find any documentation on the availability of
  this option for llvm, even though at least the version I have
  installed does support it)

* --enable-backtrace has been added.  This behaves as off/auto/on
  switch, i.e. giving either {dis,en}able will result in the requested
  behaviour (or an error if support wasn't found)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
INSTALL.quagga.txt
configure.ac
doc/install.texi

index 0d465879f5f34e269e78ad1ee1b05bb0557abcc3..11c85b1a31ce37395f028053149c43218dbaebad 100644 (file)
@@ -31,6 +31,9 @@ not a guarantee of support, merely "we agree that it is broken".)
   OpenBSD ? [info needed on what should work]
   Solaris (modern/supported versions, including OpenSolaris forks) 
 
+On BSD systems, installing libexecinfo is strongly recommended in order
+to get backtrace support.
+
 For further Quagga specific information on 'configure' and build-time
 configuration of the software, please read the Quagga info
 documentation, (doc/quagga.info).  To read the info page included with
index ff7a4d5478d5531ccd0a43dad72ddd47801cedaa..8964006a891e96dfaef20786b1d9064d739e72b1 100755 (executable)
@@ -273,7 +273,9 @@ AC_ARG_ENABLE(gcc_ultra_verbose,
 AC_ARG_ENABLE(linux24_tcp_md5,
 [  --enable-linux24-tcp-md5  enable support for old, Linux-2.4 RFC2385 patch])
 AC_ARG_ENABLE(gcc-rdynamic,
-[  --enable-gcc-rdynamic   enable gcc linking with -rdynamic for better backtraces])
+[  --enable-gcc-rdynamic         enable linking with -rdynamic for better backtraces (default if gcc)])
+AC_ARG_ENABLE(backtrace,
+[  --disable-backtrace,          disable crash backtraces (default autodetect)])
 AC_ARG_ENABLE(time-check,
 [  --disable-time-check          disable slow thread warning messages])
 AC_ARG_ENABLE(pcreposix,
@@ -288,8 +290,10 @@ if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then
   CFLAGS="${CFLAGS} -Wpacked -Wpadded"
 fi
 
-if test x"${enable_gcc_rdynamic}" = x"yes" ; then
-  LDFLAGS="${LDFLAGS} -rdynamic"
+if test x"${enable_gcc_rdynamic}" != x"no" ; then
+  if test x"${enable_gcc_rdynamic}" = x"yes" -o x"$COMPILER" = x"GCC"; then
+    LDFLAGS="${LDFLAGS} -rdynamic"
+  fi
 fi
 
 if test x"${enable_time_check}" != x"no" ; then
@@ -1566,12 +1570,21 @@ AX_SYS_WEAK_ALIAS
 dnl ---------------------------
 dnl check for glibc 'backtrace'
 dnl --------------------------- 
-AC_CHECK_HEADER([execinfo.h],
-  [AC_CHECK_FUNC([backtrace],
-    [AC_DEFINE(HAVE_GLIBC_BACKTRACE,,[Glibc backtrace])
-     AC_DEFINE(HAVE_STACK_TRACE,,[Stack symbol decoding])
+if test x"${enable_backtrace}" != x"no" ; then
+  backtrace_ok=no
+  AC_CHECK_HEADER([execinfo.h], [
+    AC_SEARCH_LIBS([backtrace], [execinfo], [
+      AC_DEFINE(HAVE_GLIBC_BACKTRACE,,[Glibc backtrace])
+      AC_DEFINE(HAVE_STACK_TRACE,,[Stack symbol decoding])
+      backtrace_ok=yes
+    ],, [-lm])
   ])
-])
+
+  if test x"${enable_backtrace}" = x"yes" -a x"${backtrace_ok}" = x"no"; then
+    dnl user explicitly requested backtrace but we failed to find support
+    AC_MSG_FAILURE([failed to find backtrace support])
+  fi
+fi
 
 dnl -----------------------------------------
 dnl check for malloc mallinfo struct and call
index 0f8f65fab89e7592b7aa13529aa70c6aa654e7d8..1e8d965bcf9a52b44261f7080fb391811182968c 100644 (file)
@@ -96,6 +96,16 @@ installed.  They can be excluded from build with this option, which will
 minimally decrease compile time and overhead.  They can always be built and
 executed at a later time by running @command{make check} in the @file{tests/}
 subdirectory, even if they're excluded from build.
+@item --enable-gcc-rdynamic
+Pass the @command{-rdynamic} option to the linker driver.  This is in most
+cases neccessary for getting usable backtraces.  This option defaults to on
+if the compiler is detected as gcc, but giving an explicit enable/disable is
+suggested.
+@item --enable-backtrace
+Controls backtrace support for the crash handlers. This is autodetected by
+default. Using the switch will enforce the requested behaviour, failing with
+an error if support is requested but not available.  On BSD systems, this
+needs libexecinfo, while on glibc support for this is part of libc itself.
 @end table
 
 You may specify any combination of the above options to the configure