diff --git a/SConstruct b/SConstruct index edb57778..a6d37a30 100644 --- a/SConstruct +++ b/SConstruct @@ -27,7 +27,7 @@ opts.AddVariables( BoolVariable('SYSTEM_LUA','Use system lua instead of static lua provided with fceux', 1), BoolVariable('SYSTEM_MINIZIP', 'Use system minizip instead of static minizip provided with fceux', 0), BoolVariable('LSB_FIRST', 'Least signficant byte first (non-PPC)', 1), - BoolVariable('CLANG', 'Compile with llvm-clang instead of gcc', 1), + BoolVariable('CLANG', 'Compile with llvm-clang instead of gcc', 0), BoolVariable('SDL2', 'Compile using SDL2 instead of SDL 1.2 (experimental/non-functional)', 0) ) AddOption('--prefix', dest='prefix', type='string', nargs=1, action='store', metavar='DIR', help='installation prefix') @@ -83,6 +83,13 @@ if env['PLATFORM'] == 'win32': env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"]) else: conf = Configure(env) + # If libdw is available, compile in backward-cpp support + if conf.CheckLib('dw'): + conf.env.Append(CCFLAGS = "-DBACKWARD_HAS_DW=1") + conf.env.Append(LINKFLAGS = "-ldw") + # workaround for upstream backward-cpp issue (https://github.com/bombela/backward-cpp/issues/2) + if env['CLANG']: + conf.env.Append(CCFLAGS = "-DBACKWARD_HAS_BACKTRACE=1") if conf.CheckFunc('asprintf'): conf.env.Append(CCFLAGS = "-DHAVE_ASPRINTF") if env['SYSTEM_MINIZIP']: diff --git a/src/utils/SConscript b/src/utils/SConscript index 8a3569b5..bc9d9dab 100644 --- a/src/utils/SConscript +++ b/src/utils/SConscript @@ -2,6 +2,7 @@ import glob #source_list = glob.glob('*.cpp') source_list = Split( """ +backward.cpp ConvertUTF.c xstring.cpp crc32.cpp @@ -14,6 +15,7 @@ memory.cpp Import('env') + if env['SYSTEM_MINIZIP'] == 0: source_list.append('unzip.cpp') source_list.append('ioapi.cpp') diff --git a/src/utils/backward.cpp b/src/utils/backward.cpp new file mode 100644 index 00000000..7f8e776c --- /dev/null +++ b/src/utils/backward.cpp @@ -0,0 +1,33 @@ +// Pick your poison. +// +// On GNU/Linux, you have few choices to get the most out of your stack trace. +// +// By default you get: +// - object filename +// - function name +// +// In order to add: +// - source filename +// - line and column numbers +// - source code snippet (assuming the file is accessible) + +// Install one of the following library then uncomment one of the macro (or +// better, add the detection of the lib and the macro definition in your build +// system) + +// - apt-get install libdw-dev ... +// - g++/clang++ -ldw ... +// #define BACKWARD_HAS_DW 1 + +// - apt-get install binutils-dev ... +// - g++/clang++ -lbfd ... +// #define BACKWARD_HAS_BFD 1 +#if BACKWARD_HAS_DW==1 +#include "backward.hpp" + +namespace backward { + +backward::SignalHandling sh; + +} // namespace backward +#endif