Skip to content

Commit

Permalink
build: linux does not always have execinfo.h (neovim#7101)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmk authored Jul 30, 2017
1 parent 5cd68b3 commit a753837
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ if(CMAKE_EXE_LINKER_FLAGS MATCHES "--sort-common" OR
string(REGEX REPLACE "-Wl($| )" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
endif()

check_c_source_compiles("
#include <execinfo.h>
int main(void)
{
void *trace[1];
int trace_size = backtrace(trace, 1);
return 0;
}
" HAVE_EXECINFO_BACKTRACE)

if(MSVC)
# XXX: /W4 gives too many warnings. #3241
add_definitions(/W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
Expand Down Expand Up @@ -324,7 +334,6 @@ main(void)
return MSGPACK_OBJECT_FLOAT32;
}
" MSGPACK_HAS_FLOAT32)

if(MSGPACK_HAS_FLOAT32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_MSGPACK_HAS_FLOAT32")
endif()
Expand Down
2 changes: 2 additions & 0 deletions config/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@
#cmakedefine ORDER_BIG_ENDIAN
#define ENDIAN_INCLUDE_FILE <@ENDIAN_INCLUDE_FILE@>

#cmakedefine HAVE_EXECINFO_BACKTRACE

#endif // AUTO_CONFIG_H
7 changes: 5 additions & 2 deletions src/nvim/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ static uv_mutex_t mutex;
# include "log.c.generated.h"
#endif

#ifdef HAVE_EXECINFO_BACKTRACE
# include <execinfo.h>
#endif

static bool log_try_create(char *fname)
{
if (fname == NULL || fname[0] == '\0') {
Expand Down Expand Up @@ -173,8 +177,7 @@ FILE *open_log_file(void)
return stderr;
}

#if defined(__linux__)
# include <execinfo.h>
#ifdef HAVE_EXECINFO_BACKTRACE
void log_callstack(const char *const func_name, const int line_num)
{
void *trace[100];
Expand Down
2 changes: 1 addition & 1 deletion src/nvim/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
__VA_ARGS__)
#endif

#if defined(__linux__)
#ifdef HAVE_EXECINFO_BACKTRACE
# define LOG_CALLSTACK() log_callstack(__func__, __LINE__)
#endif

Expand Down

0 comments on commit a753837

Please sign in to comment.