Make callstack printing useful and optional

When callback printing is enabled, link lyx with -rdynamic, so that
stacks have LyX symbols available.

Add option --disable-callstack-printing to configure.

Running "size" on binary:
 * with callstack printing support
   text	   data	    bss	    dec	    hex	filename
20891684	  34680	 107796	21034160	140f4b0	src/lyx

 * without callstack printing support
    text	   data	    bss	    dec	    hex	filename
17953640	  34648	 107796	18096084	1141fd4	src/lyx
This commit is contained in:
Jean-Marc Lasgouttes 2019-02-25 17:37:06 +01:00
parent e78a5bd1a8
commit 4028eefe61
2 changed files with 23 additions and 15 deletions

View File

@ -609,7 +609,12 @@ dnl prevent clash with system zlib that might be dragged in by other libs
dnl Usage: LYX_CHECK_CALLSTACK_PRINTING: define LYX_CALLSTACK_PRINTING if the dnl Usage: LYX_CHECK_CALLSTACK_PRINTING: define LYX_CALLSTACK_PRINTING if the
dnl necessary APIs are available to print callstacks. dnl necessary APIs are available to print callstacks.
AC_DEFUN([LYX_CHECK_CALLSTACK_PRINTING], AC_DEFUN([LYX_CHECK_CALLSTACK_PRINTING],
[AC_CACHE_CHECK([whether printing callstack is possible], [AC_ARG_ENABLE([callstack-printing],
[AC_HELP_STRING([--disable-callstack-printing],[do not print a callstack when crashing])],
lyx_cv_callstack_printing=$enableval, lyx_cv_callstack_printing=yes)
if test x"$lyx_cv_callstack_printing" = xyes; then
AC_CACHE_CHECK([whether printing callstack is possible],
[lyx_cv_callstack_printing], [lyx_cv_callstack_printing],
[AC_TRY_COMPILE([ [AC_TRY_COMPILE([
#include <execinfo.h> #include <execinfo.h>
@ -620,11 +625,13 @@ AC_DEFUN([LYX_CHECK_CALLSTACK_PRINTING],
backtrace_symbols(array, size); backtrace_symbols(array, size);
int status = 0; int status = 0;
abi::__cxa_demangle("abcd", 0, 0, &status); abi::__cxa_demangle("abcd", 0, 0, &status);
], ],, [lyx_cv_callstack_printing=no])])
[lyx_cv_callstack_printing=yes], [lyx_cv_callstack_printing=no])]) fi
if test x"$lyx_cv_callstack_printing" = xyes; then if test x"$lyx_cv_callstack_printing" = xyes; then
AC_DEFINE([LYX_CALLSTACK_PRINTING], 1, AC_DEFINE([LYX_CALLSTACK_PRINTING], 1,
[Define if callstack can be printed]) [Define if callstack can be printed])
lyx_flags="$lyx_flags callback-printing"
AM_LDFLAGS="${AM_LDFLAGS} -rdynamic"
fi fi
]) ])

View File

@ -27,6 +27,8 @@ OTHERLIBS = $(BOOST_LIBS) $(MYTHES_LIBS) $(ENCHANT_LIBS) $(HUNSPELL_LIBS) \
noinst_LIBRARIES = liblyxcore.a noinst_LIBRARIES = liblyxcore.a
bin_PROGRAMS = lyx bin_PROGRAMS = lyx
lyx_LDFLAGS = $(AM_LDFLAGS) $(QT_LDFLAGS)
lyx_LDADD = \ lyx_LDADD = \
liblyxcore.a \ liblyxcore.a \
liblyxmathed.a \ liblyxmathed.a \
@ -36,7 +38,6 @@ lyx_LDADD = \
liblyxgraphics.a \ liblyxgraphics.a \
support/liblyxsupport.a \ support/liblyxsupport.a \
$(OTHERLIBS) \ $(OTHERLIBS) \
$(QT_LDFLAGS) \
$(QT_LIB) $(QT_LIB)
if LYX_WIN_RESOURCE if LYX_WIN_RESOURCE
@ -46,7 +47,7 @@ if LYX_WIN_RESOURCE
endif endif
if INSTALL_MACOSX if INSTALL_MACOSX
lyx_LDFLAGS = -framework AppKit -framework ApplicationServices \ lyx_LDFLAGS += -framework AppKit -framework ApplicationServices \
-Wl,-rpath,@loader_path/../Frameworks \ -Wl,-rpath,@loader_path/../Frameworks \
-Wl,-rpath,@executable_path/../Frameworks \ -Wl,-rpath,@executable_path/../Frameworks \
-Wl,-headerpad_max_install_names -Wl,-headerpad_max_install_names