Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Optionally support using the system-installed libunwind #17164

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 51 additions & 8 deletions src/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
cmake_minimum_required(VERSION 2.8.12.2)

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
# On OSX, we use the libunwind that's part of the OS
set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1)
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)

include_directories(SYSTEM /usr/local/include)
include_directories(libunwind/include)

add_compile_options(-fPIC)

if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
include_directories(libunwind/include)
add_subdirectory(libunwind)
endif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)

include(configure.cmake)

Expand Down Expand Up @@ -240,10 +245,9 @@ set(SOURCES
thread/tls.cpp
)

if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
# On OSX, we use the libunwind that's part of the OS
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
set(LIBUNWIND_OBJECTS $<TARGET_OBJECTS:libunwind>)
endif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)

add_library(coreclrpal
STATIC
Expand All @@ -267,10 +271,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)

if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
find_library(UNWIND unwind)
endif()
find_library(INTL intl)
target_link_libraries(coreclrpal
pthread
rt
${UNWIND}
${INTL}
)
endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
Expand Down Expand Up @@ -303,7 +311,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
${LZMA})
endif()


if(CLR_MAKE_PLATFORM_ANDROID)
find_library(ANDROID_SUPPORT NAMES android-support)
find_library(ANDROID_GLOB NAMES android-glob)
Expand All @@ -326,20 +333,56 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
dl
)


if(NOT INTL STREQUAL INTL-NOTFOUND)
target_link_libraries(coreclrpal ${INTL})
endif(NOT INTL STREQUAL INTL-NOTFOUND)

if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
if(PAL_CMAKE_PLATFORM_ARCH_ARM)
find_library(UNWIND_ARCH NAMES unwind-arm)
endif()

if(PAL_CMAKE_PLATFORM_ARCH_ARM64)
find_library(UNWIND_ARCH NAMES unwind-aarch64)
endif()

if(PAL_CMAKE_PLATFORM_ARCH_AMD64)
find_library(UNWIND_ARCH NAMES unwind-x86_64)
endif()

if(NOT UNWIND_ARCH STREQUAL UNWIND_ARCH-NOTFOUND)
target_link_libraries(coreclrpal ${UNWIND_ARCH})
endif()

find_library(UNWIND_GENERIC NAMES unwind-generic)

if(NOT UNWIND_GENERIC STREQUAL UNWIND_GENERIC-NOTFOUND)
target_link_libraries(coreclrpal ${UNWIND_GENERIC})
endif()

find_library(UNWIND NAMES unwind)

if(UNWIND STREQUAL UNWIND-NOTFOUND)
message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8-dev or libunwind-devel.")
endif()

target_link_libraries(coreclrpal ${UNWIND})

endif(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)

endif(CMAKE_SYSTEM_NAME STREQUAL Linux)

if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
if (CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
find_library(UNWIND unwind)
endif()
add_definitions(-D_KMEMUSER)
find_library(INTL intl)
find_library(KVM kvm)
target_link_libraries(coreclrpal
pthread
rt
${UNWIND}
${INTL}
${KVM}
)
Expand Down
8 changes: 6 additions & 2 deletions src/pal/src/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,9 @@ int main()
set(SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING 1)
set(ERROR_FUNC_FOR_GLOB_HAS_FIXED_PARAMS 1)

list(INSERT CMAKE_REQUIRED_INCLUDES 0 ${CMAKE_CURRENT_SOURCE_DIR}/libunwind/include ${CMAKE_CURRENT_BINARY_DIR}/libunwind/include)
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
list(INSERT CMAKE_REQUIRED_INCLUDES 0 ${CMAKE_CURRENT_SOURCE_DIR}/libunwind/include ${CMAKE_CURRENT_BINARY_DIR}/libunwind/include)
endif()

check_c_source_compiles("
#include <libunwind.h>
Expand All @@ -991,7 +993,9 @@ int main(int argc, char **argv)
return 0;
}" UNWIND_CONTEXT_IS_UCONTEXT_T)

list(REMOVE_AT CMAKE_REQUIRED_INCLUDES 0 1)
if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
list(REMOVE_AT CMAKE_REQUIRED_INCLUDES 0 1)
endif()

check_cxx_source_compiles("
#include <sys/param.h>
Expand Down