Le 25/02/2019 à 17:55, Jean-Marc Lasgouttes a écrit :
commit 4028eefe6190551c8be96cd451337dea2808742b
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Mon Feb 25 17:37:06 2019 +0100

     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.

Now the callstacks make sense, at least on my linux box. I'd appreciate feedback on other gcc/clang builds (mac, windows).

Something similar should be done for cmake. It would also be possible to add an lfun to toggle this state.

As can be seen below, there is a price to pay: the text section of the lyx binary goes from 18M to 21M.

This could easily be backported to 2.3.x.

JMarc

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
---
  config/lyxinclude.m4 |   33 ++++++++++++++++++++-------------
  src/Makefile.am      |    5 +++--
  2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index cf49495..8e1d279 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -609,22 +609,29 @@ 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        necessary APIs are available to print callstacks.
  AC_DEFUN([LYX_CHECK_CALLSTACK_PRINTING],
-[AC_CACHE_CHECK([whether printing callstack is possible],
-               [lyx_cv_callstack_printing],
-[AC_TRY_COMPILE([
-#include <execinfo.h>
-#include <cxxabi.h>
-], [
-       void* array[200];
-       size_t size = backtrace(array, 200);
-       backtrace_symbols(array, size);
-       int status = 0;
-       abi::__cxa_demangle("abcd", 0, 0, &status);
-],
-[lyx_cv_callstack_printing=yes], [lyx_cv_callstack_printing=no])])
+[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],
+  [AC_TRY_COMPILE([
+  #include <execinfo.h>
+  #include <cxxabi.h>
+  ], [
+         void* array[200];
+         size_t size = backtrace(array, 200);
+         backtrace_symbols(array, size);
+         int status = 0;
+         abi::__cxa_demangle("abcd", 0, 0, &status);
+  ],, [lyx_cv_callstack_printing=no])])
+fi
  if test x"$lyx_cv_callstack_printing" = xyes; then
    AC_DEFINE([LYX_CALLSTACK_PRINTING], 1,
              [Define if callstack can be printed])
+  lyx_flags="$lyx_flags callback-printing"
+  AM_LDFLAGS="${AM_LDFLAGS} -rdynamic"
  fi
  ])
diff --git a/src/Makefile.am b/src/Makefile.am
index d924a5e..ef18959 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,8 @@ OTHERLIBS = $(BOOST_LIBS) $(MYTHES_LIBS) $(ENCHANT_LIBS) 
$(HUNSPELL_LIBS) \
  noinst_LIBRARIES = liblyxcore.a
  bin_PROGRAMS = lyx
+lyx_LDFLAGS = $(AM_LDFLAGS) $(QT_LDFLAGS)
+
  lyx_LDADD = \
        liblyxcore.a \
        liblyxmathed.a \
@@ -36,7 +38,6 @@ lyx_LDADD = \
        liblyxgraphics.a \
        support/liblyxsupport.a \
        $(OTHERLIBS) \
-       $(QT_LDFLAGS) \
        $(QT_LIB)
if LYX_WIN_RESOURCE
@@ -46,7 +47,7 @@ if LYX_WIN_RESOURCE
  endif
if INSTALL_MACOSX
-lyx_LDFLAGS = -framework AppKit -framework ApplicationServices \
+lyx_LDFLAGS += -framework AppKit -framework ApplicationServices \
        -Wl,-rpath,@loader_path/../Frameworks \
        -Wl,-rpath,@executable_path/../Frameworks \
        -Wl,-headerpad_max_install_names


Reply via email to