[libunwind] Haiku: Initial support
Adds build support for Haiku. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157866
This commit is contained in:
@@ -11,7 +11,11 @@ include(CheckCSourceCompiles)
|
||||
# --unwindlib=none is supported, and use that if possible.
|
||||
llvm_check_compiler_linker_flag(C "--unwindlib=none" CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
|
||||
|
||||
check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
|
||||
if (HAIKU)
|
||||
check_library_exists(root fopen "" LIBUNWIND_HAS_ROOT_LIB)
|
||||
else()
|
||||
check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
|
||||
endif()
|
||||
|
||||
if (NOT LIBUNWIND_USE_COMPILER_RT)
|
||||
if (ANDROID)
|
||||
@@ -45,6 +49,9 @@ if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
|
||||
if (LIBUNWIND_HAS_C_LIB)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
|
||||
endif ()
|
||||
if (LIBUNWIND_HAS_ROOT_LIB)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES root)
|
||||
endif ()
|
||||
if (LIBUNWIND_USE_COMPILER_RT)
|
||||
include(HandleCompilerRT)
|
||||
find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY
|
||||
@@ -111,3 +118,7 @@ else()
|
||||
check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB)
|
||||
check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB)
|
||||
endif()
|
||||
|
||||
if(HAIKU)
|
||||
check_library_exists(bsd dl_iterate_phdr "" LIBUNWIND_HAS_BSD_LIB)
|
||||
endif()
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
# if defined(__linux__)
|
||||
# define _LIBUNWIND_TARGET_LINUX 1
|
||||
# endif
|
||||
# if defined(__HAIKU__)
|
||||
# define _LIBUNWIND_TARGET_HAIKU 1
|
||||
# endif
|
||||
# if defined(__i386__)
|
||||
# define _LIBUNWIND_TARGET_I386
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 8
|
||||
|
||||
@@ -102,6 +102,16 @@ if (APPLE)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (HAIKU)
|
||||
add_library_flags_if(LIBUNWIND_HAS_ROOT_LIB root)
|
||||
|
||||
add_library_flags_if(LIBUNWIND_HAS_BSD_LIB bsd)
|
||||
add_compile_flags_if(LIBUNWIND_HAS_BSD_LIB -D_LIBUNWIND_USE_HAIKU_BSD_LIB=1)
|
||||
|
||||
add_compile_flags("-D_DEFAULT_SOURCE")
|
||||
add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME")
|
||||
endif ()
|
||||
|
||||
string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")
|
||||
string(REPLACE ";" " " LIBUNWIND_CXX_FLAGS "${LIBUNWIND_CXX_FLAGS}")
|
||||
string(REPLACE ";" " " LIBUNWIND_C_FLAGS "${LIBUNWIND_C_FLAGS}")
|
||||
|
||||
@@ -46,6 +46,12 @@
|
||||
#elif defined(_AIX)
|
||||
// The traceback table at the end of each function is used for unwinding.
|
||||
#define _LIBUNWIND_SUPPORT_TBTAB_UNWIND 1
|
||||
#elif defined(__HAIKU__)
|
||||
#if defined(_LIBUNWIND_USE_HAIKU_BSD_LIB)
|
||||
#define _LIBUNWIND_USE_DL_ITERATE_PHDR 1
|
||||
#endif
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_INDEX 1
|
||||
#else
|
||||
// Assume an ELF system with a dl_iterate_phdr function.
|
||||
#define _LIBUNWIND_USE_DL_ITERATE_PHDR 1
|
||||
|
||||
@@ -14,6 +14,9 @@ if @LIBUNWIND_ENABLE_CET@:
|
||||
if '@CMAKE_SYSTEM_NAME@' == 'Linux':
|
||||
link_flags.append('-Wl,--export-dynamic')
|
||||
|
||||
if '@CMAKE_DL_LIBS@':
|
||||
link_flags.append('-l@CMAKE_DL_LIBS@')
|
||||
|
||||
# Stack unwinding tests need unwinding tables and these are not generated by default on all targets.
|
||||
compile_flags.append('-funwind-tables')
|
||||
|
||||
@@ -25,7 +28,7 @@ config.substitutions.append(('%{compile_flags}',
|
||||
'-nostdinc++ -I %{{include}} {}'.format(' '.join(compile_flags))
|
||||
))
|
||||
config.substitutions.append(('%{link_flags}',
|
||||
'-L %{{lib}} -Wl,-rpath,%{{lib}} -lc++ -ldl {}'.format(' '.join(link_flags))
|
||||
'-L %{{lib}} -Wl,-rpath,%{{lib}} -lc++ {}'.format(' '.join(link_flags))
|
||||
))
|
||||
config.substitutions.append(('%{exec}',
|
||||
'%{executor} --execdir %T -- '
|
||||
|
||||
@@ -13,6 +13,9 @@ if @LIBUNWIND_ENABLE_CET@:
|
||||
if '@CMAKE_SYSTEM_NAME@' == 'Linux':
|
||||
link_flags.append('-Wl,--export-dynamic')
|
||||
|
||||
if '@CMAKE_DL_LIBS@':
|
||||
link_flags.append('-l@CMAKE_DL_LIBS@')
|
||||
|
||||
# Stack unwinding tests need unwinding tables and these are not generated by default on all targets.
|
||||
compile_flags.append('-funwind-tables')
|
||||
|
||||
@@ -24,7 +27,7 @@ config.substitutions.append(('%{compile_flags}',
|
||||
'-nostdinc++ -I %{{include}} {}'.format(' '.join(compile_flags))
|
||||
))
|
||||
config.substitutions.append(('%{link_flags}',
|
||||
'-L %{{lib}} -Wl,-rpath,%{{lib}} -lunwind -ldl {}'.format(' '.join(link_flags))
|
||||
'-L %{{lib}} -Wl,-rpath,%{{lib}} -lunwind {}'.format(' '.join(link_flags))
|
||||
))
|
||||
config.substitutions.append(('%{exec}',
|
||||
'%{executor} --execdir %T -- '
|
||||
|
||||
@@ -16,6 +16,9 @@ if @LIBUNWIND_ENABLE_CET@:
|
||||
if '@CMAKE_SYSTEM_NAME@' == 'Linux':
|
||||
link_flags.append('-Wl,--export-dynamic')
|
||||
|
||||
if '@CMAKE_DL_LIBS@':
|
||||
link_flags.append('-l@CMAKE_DL_LIBS@')
|
||||
|
||||
# Stack unwinding tests need unwinding tables and these are not generated by default on all targets.
|
||||
compile_flags.append('-funwind-tables')
|
||||
|
||||
@@ -27,7 +30,7 @@ config.substitutions.append(('%{compile_flags}',
|
||||
'-nostdinc++ -I %{{include}} {}'.format(' '.join(compile_flags))
|
||||
))
|
||||
config.substitutions.append(('%{link_flags}',
|
||||
'%{{lib}}/libunwind.a -ldl {}'.format(' '.join(link_flags))
|
||||
'%{{lib}}/libunwind.a {}'.format(' '.join(link_flags))
|
||||
))
|
||||
config.substitutions.append(('%{exec}',
|
||||
'%{executor} --execdir %T -- '
|
||||
|
||||
Reference in New Issue
Block a user