aboutsummaryrefslogtreecommitdiff
path: root/libunwind/src
diff options
context:
space:
mode:
authorLouis Dionne <ldionne.2@gmail.com>2022-05-11 11:06:28 -0400
committerLouis Dionne <ldionne.2@gmail.com>2022-05-16 08:41:16 -0400
commitaa656f6c2dec73faceeed21e15401d8f0c743c8b (patch)
tree920998d4553607e3a36861d8a53daf8e8ae8b3cd /libunwind/src
parent80bebbc7cb77979ef9d229450b7ea84e3e9c6a5a (diff)
downloadllvm-aa656f6c2dec73faceeed21e15401d8f0c743c8b.zip
llvm-aa656f6c2dec73faceeed21e15401d8f0c743c8b.tar.gz
llvm-aa656f6c2dec73faceeed21e15401d8f0c743c8b.tar.bz2
[runtimes] Introduce object libraries
This is a variant of D116689 rebased on top of the new (proposed) ABI refactoring in D120727. It should conserve the basic properties of the original patch by @phosek, except it also allows cleaning up the merging of libc++abi into libc++ from the libc++ side. Differential Revision: https://reviews.llvm.org/D125393
Diffstat (limited to 'libunwind/src')
-rw-r--r--libunwind/src/CMakeLists.txt75
1 files changed, 44 insertions, 31 deletions
diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index faef6a8..61df273 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -136,27 +136,36 @@ set_property(SOURCE ${LIBUNWIND_C_SOURCES}
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
# Build the shared library.
+add_library(unwind_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
+if(CMAKE_C_COMPILER_ID STREQUAL MSVC)
+ target_compile_options(unwind_shared_objects PRIVATE /GR-)
+else()
+ target_compile_options(unwind_shared_objects PRIVATE -fno-rtti)
+endif()
+target_link_libraries(unwind_shared_objects PRIVATE unwind-headers ${LIBUNWIND_LIBRARIES})
+set_target_properties(unwind_shared_objects
+ PROPERTIES
+ CXX_EXTENSIONS OFF
+ CXX_STANDARD 11
+ CXX_STANDARD_REQUIRED ON
+ COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
+)
+if (CMAKE_POSITION_INDEPENDENT_CODE OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
+ set_target_properties(unwind_shared_objects PROPERTIES POSITION_INDEPENDENT_CODE ON) # must set manually because it's an object library
+endif()
+
if (LIBUNWIND_ENABLE_SHARED)
- add_library(unwind_shared SHARED ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
- if(CMAKE_C_COMPILER_ID STREQUAL MSVC)
- target_compile_options(unwind_shared PRIVATE /GR-)
- else()
- target_compile_options(unwind_shared PRIVATE -fno-rtti)
- endif()
- target_link_libraries(unwind_shared PRIVATE ${LIBUNWIND_LIBRARIES}
- PRIVATE unwind-headers)
+ add_library(unwind_shared SHARED)
+ target_link_libraries(unwind_shared PUBLIC unwind_shared_objects)
set_target_properties(unwind_shared
PROPERTIES
- CXX_EXTENSIONS OFF
- CXX_STANDARD 11
- CXX_STANDARD_REQUIRED ON
- COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
LINKER_LANGUAGE C
OUTPUT_NAME "unwind"
VERSION "1.0"
SOVERSION "1"
)
+
list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_shared")
if (LIBUNWIND_INSTALL_SHARED_LIBRARY)
list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_shared")
@@ -164,33 +173,37 @@ if (LIBUNWIND_ENABLE_SHARED)
endif()
# Build the static library.
+add_library(unwind_static_objects OBJECT EXCLUDE_FROM_ALL ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
+if(CMAKE_C_COMPILER_ID STREQUAL MSVC)
+ target_compile_options(unwind_static_objects PRIVATE /GR-)
+else()
+ target_compile_options(unwind_static_objects PRIVATE -fno-rtti)
+endif()
+target_link_libraries(unwind_static_objects PRIVATE unwind-headers ${LIBUNWIND_LIBRARIES})
+set_target_properties(unwind_static_objects
+ PROPERTIES
+ CXX_EXTENSIONS OFF
+ CXX_STANDARD 11
+ CXX_STANDARD_REQUIRED ON
+ COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
+)
+
+if(LIBUNWIND_HIDE_SYMBOLS)
+ target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility=hidden)
+ target_add_compile_flags_if_supported(unwind_static_objects PRIVATE -fvisibility-global-new-delete-hidden)
+ target_compile_definitions(unwind_static_objects PRIVATE _LIBUNWIND_HIDE_SYMBOLS)
+endif()
+
if (LIBUNWIND_ENABLE_STATIC)
- add_library(unwind_static STATIC ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
- if(CMAKE_C_COMPILER_ID STREQUAL MSVC)
- target_compile_options(unwind_static PRIVATE /GR-)
- else()
- target_compile_options(unwind_static PRIVATE -fno-rtti)
- endif()
- target_link_libraries(unwind_static PRIVATE ${LIBUNWIND_LIBRARIES}
- PRIVATE unwind-headers)
+ add_library(unwind_static STATIC)
+ target_link_libraries(unwind_static PUBLIC unwind_static_objects)
set_target_properties(unwind_static
PROPERTIES
- CXX_EXTENSIONS OFF
- CXX_STANDARD 11
- CXX_STANDARD_REQUIRED ON
- COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
LINKER_LANGUAGE C
OUTPUT_NAME "unwind"
)
- if(LIBUNWIND_HIDE_SYMBOLS)
- append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility=hidden)
- append_flags_if_supported(UNWIND_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden)
- target_compile_options(unwind_static PRIVATE ${UNWIND_STATIC_LIBRARY_FLAGS})
- target_compile_definitions(unwind_static PRIVATE _LIBUNWIND_HIDE_SYMBOLS)
- endif()
-
list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_static")
if (LIBUNWIND_INSTALL_STATIC_LIBRARY)
list(APPEND LIBUNWIND_INSTALL_TARGETS "unwind_static")