[libcxxabi][libunwind] Support for using LLVM libc (#134893)
This generalizes the support added in #99287 renaming the option to
RUNTIMES_USE_LIBC and integrating the module into libc++abi and
libunwind as well.
GitOrigin-RevId: 9d3b60dea7ad81f6cb0d9f2e51bb6c80c03fa2d4
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e27f3c2..5f4b090 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -182,6 +182,8 @@
# Configure compiler.
include(config-ix)
+include(HandleLibC) # Setup the C library flags
+
if (LIBUNWIND_USE_COMPILER_RT AND NOT LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
list(APPEND LIBUNWIND_LINK_FLAGS "-rtlib=compiler-rt")
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 03818b1..71663a2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -132,9 +132,10 @@
else()
target_compile_options(unwind_shared_objects PRIVATE -fno-rtti)
endif()
-target_link_libraries(unwind_shared_objects PRIVATE unwind-headers ${LIBUNWIND_LIBRARIES})
target_compile_options(unwind_shared_objects PUBLIC "${LIBUNWIND_ADDITIONAL_COMPILE_FLAGS}")
-target_link_libraries(unwind_shared_objects PUBLIC "${LIBUNWIND_ADDITIONAL_LIBRARIES}")
+target_link_libraries(unwind_shared_objects
+ PUBLIC "${LIBUNWIND_ADDITIONAL_LIBRARIES}"
+ PRIVATE unwind-headers runtimes-libc-headers ${LIBUNWIND_LIBRARIES})
set_target_properties(unwind_shared_objects
PROPERTIES
CXX_EXTENSIONS OFF
@@ -147,7 +148,7 @@
endif()
add_library(unwind_shared SHARED)
-target_link_libraries(unwind_shared PUBLIC unwind_shared_objects)
+target_link_libraries(unwind_shared PUBLIC unwind_shared_objects runtimes-libc-shared)
set_target_properties(unwind_shared
PROPERTIES
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBUNWIND_ENABLE_SHARED}>,FALSE,TRUE>"
@@ -173,9 +174,10 @@
else()
target_compile_options(unwind_static_objects PRIVATE -fno-rtti)
endif()
-target_link_libraries(unwind_static_objects PRIVATE unwind-headers ${LIBUNWIND_LIBRARIES})
target_compile_options(unwind_static_objects PUBLIC "${LIBUNWIND_ADDITIONAL_COMPILE_FLAGS}")
-target_link_libraries(unwind_static_objects PUBLIC "${LIBUNWIND_ADDITIONAL_LIBRARIES}")
+target_link_libraries(unwind_static_objects
+ PUBLIC "${LIBUNWIND_ADDITIONAL_LIBRARIES}"
+ PRIVATE unwind-headers runtimes-libc-headers ${LIBUNWIND_LIBRARIES})
set_target_properties(unwind_static_objects
PROPERTIES
CXX_EXTENSIONS OFF
@@ -194,7 +196,7 @@
endif()
add_library(unwind_static STATIC)
-target_link_libraries(unwind_static PUBLIC unwind_static_objects)
+target_link_libraries(unwind_static PUBLIC unwind_static_objects runtimes-libc-static)
set_target_properties(unwind_static
PROPERTIES
EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBUNWIND_ENABLE_STATIC}>,FALSE,TRUE>"