Support gcc 4.8.5, resolves #220
This commit is contained in:
parent
c37b5ed736
commit
b18e9a1eb9
@ -34,12 +34,20 @@ endif()
|
|||||||
if(PROJECT_IS_TOP_LEVEL)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
check_cxx_compiler_flag(-fdiagnostics-color=always HAS_CXX_FDIAGNOSTICS_COLOR)
|
||||||
|
if(HAS_CXX_FDIAGNOSTICS_COLOR)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
||||||
|
endif()
|
||||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
|
||||||
endif()
|
endif()
|
||||||
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
check_c_compiler_flag(-fdiagnostics-color=always HAS_C_FDIAGNOSTICS_COLOR)
|
||||||
|
if(HAS_C_FDIAGNOSTICS_COLOR)
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
|
||||||
|
endif()
|
||||||
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics")
|
||||||
endif()
|
endif()
|
||||||
@ -176,6 +184,11 @@ target_compile_options(
|
|||||||
${warning_options}
|
${warning_options}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
|
||||||
|
# https://godbolt.org/z/qYh89E6rq
|
||||||
|
target_compile_options(${target_name} PRIVATE -Wno-missing-field-initializers)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CPPTRACE_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR})
|
set(CPPTRACE_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR})
|
||||||
set(CPPTRACE_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR})
|
set(CPPTRACE_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR})
|
||||||
set(CPPTRACE_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH})
|
set(CPPTRACE_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH})
|
||||||
|
|||||||
@ -424,7 +424,7 @@ namespace detail {
|
|||||||
static std::unordered_map<std::string, Result<elf, internal_error>> cache;
|
static std::unordered_map<std::string, Result<elf, internal_error>> cache;
|
||||||
auto it = cache.find(object_path);
|
auto it = cache.find(object_path);
|
||||||
if(it == cache.end()) {
|
if(it == cache.end()) {
|
||||||
auto res = cache.insert({ object_path, elf::open_elf(object_path) });
|
auto res = cache.emplace(object_path, elf::open_elf(object_path));
|
||||||
VERIFY(res.second);
|
VERIFY(res.second);
|
||||||
it = res.first;
|
it = res.first;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -272,7 +272,8 @@ namespace cpptrace {
|
|||||||
memcpy(new_vtable_page, type_info_vtable_pointer, vtable_size * sizeof(void*));
|
memcpy(new_vtable_page, type_info_vtable_pointer, vtable_size * sizeof(void*));
|
||||||
// ninja in the custom __do_catch interceptor
|
// ninja in the custom __do_catch interceptor
|
||||||
auto new_vtable = static_cast<void**>(new_vtable_page);
|
auto new_vtable = static_cast<void**>(new_vtable_page);
|
||||||
new_vtable[6] = reinterpret_cast<void*>(do_catch_function);
|
// double cast is done here because older (and some newer gcc versions) warned about it under -Wpedantic
|
||||||
|
new_vtable[6] = reinterpret_cast<void*>(reinterpret_cast<std::uintptr_t>(do_catch_function));
|
||||||
// make the page read-only
|
// make the page read-only
|
||||||
mprotect_page(new_vtable_page, page_size, memory_readonly);
|
mprotect_page(new_vtable_page, page_size, memory_readonly);
|
||||||
|
|
||||||
|
|||||||
@ -324,7 +324,7 @@ namespace libdwarf {
|
|||||||
char** dw_srcfiles;
|
char** dw_srcfiles;
|
||||||
Dwarf_Signed dw_filecount;
|
Dwarf_Signed dw_filecount;
|
||||||
VERIFY(wrap(dwarf_srcfiles, cu_die.get(), &dw_srcfiles, &dw_filecount) == DW_DLV_OK);
|
VERIFY(wrap(dwarf_srcfiles, cu_die.get(), &dw_srcfiles, &dw_filecount) == DW_DLV_OK);
|
||||||
it = srcfiles_cache.insert(it, {off, srcfiles{cu_die.dbg, dw_srcfiles, dw_filecount}});
|
it = srcfiles_cache.emplace_hint(it, off, srcfiles{cu_die.dbg, dw_srcfiles, dw_filecount});
|
||||||
}
|
}
|
||||||
if(file_i < it->second.count()) {
|
if(file_i < it->second.count()) {
|
||||||
// dwarf is using 1-indexing
|
// dwarf is using 1-indexing
|
||||||
|
|||||||
@ -67,7 +67,14 @@ namespace libdwarf {
|
|||||||
// sorted range entries for dies
|
// sorted range entries for dies
|
||||||
template<
|
template<
|
||||||
typename T,
|
typename T,
|
||||||
typename std::enable_if<std::is_trivially_copyable<T>::value && sizeof(T) <= 16, int>::type = 0
|
typename std::enable_if<
|
||||||
|
// old gcc doesn't support this trait https://godbolt.org/z/fKWT9jTK7
|
||||||
|
#if !(defined(__GNUC__) && (__GNUC__ < 5))
|
||||||
|
std::is_trivially_copyable<T>::value &&
|
||||||
|
#endif
|
||||||
|
sizeof(T) <= 16,
|
||||||
|
int
|
||||||
|
>::type = 0
|
||||||
>
|
>
|
||||||
class die_cache {
|
class die_cache {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -24,6 +24,13 @@
|
|||||||
#define NODISCARD
|
#define NODISCARD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// workaround a bizarre gcc bug https://godbolt.org/z/s78vnf7jv
|
||||||
|
// https://github.com/jeremy-rifkin/cpptrace/issues/220
|
||||||
|
#if defined(__GNUC__) && (__GNUC__ < 7)
|
||||||
|
#undef NODISCARD
|
||||||
|
#define NODISCARD
|
||||||
|
#endif
|
||||||
|
|
||||||
#if IS_MSVC
|
#if IS_MSVC
|
||||||
#define MSVC_CDECL __cdecl
|
#define MSVC_CDECL __cdecl
|
||||||
#else
|
#else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user