-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libcxxabi][libunwind] Support for using LLVM libc #134893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#=============================================================================== | ||
# Define targets for linking against the selected C library | ||
# | ||
# After including this file, the following targets are defined: | ||
# - libcxxabi-libc-headers: An interface target that allows getting access to the | ||
# headers of the selected C library. | ||
# - libcxxabi-libc-shared: A target representing the selected shared C library. | ||
# - libcxxabi-libc-static: A target representing the selected static C library. | ||
#=============================================================================== | ||
|
||
# Link against a system-provided libc | ||
if (LIBCXXABI_LIBC STREQUAL "system") | ||
add_library(libcxxabi-libc-headers INTERFACE) | ||
|
||
add_library(libcxxabi-libc-static INTERFACE) | ||
add_library(libcxxabi-libc-shared INTERFACE) | ||
|
||
# Link against the in-tree LLVM libc | ||
elseif (LIBCXXABI_LIBC STREQUAL "llvm-libc") | ||
add_library(libcxxabi-libc-headers INTERFACE) | ||
target_link_libraries(libcxxabi-libc-headers INTERFACE libc-headers) | ||
if(CXX_SUPPORTS_NOSTDLIBINC_FLAG) | ||
target_compile_options(libcxxabi-libc-headers INTERFACE "-nostdlibinc") | ||
endif() | ||
|
||
add_library(libcxxabi-libc-static INTERFACE) | ||
if (TARGET libc) | ||
target_link_libraries(libcxxabi-libc-static INTERFACE libc) | ||
endif() | ||
if (TARGET libm) | ||
target_link_libraries(libcxxabi-libc-static INTERFACE libm) | ||
endif() | ||
if (CXX_SUPPORTS_NOLIBC_FLAG) | ||
target_link_options(libcxxabi-libc-static INTERFACE "-nolibc") | ||
endif() | ||
|
||
# TODO: There's no support for building LLVM libc as a shared library yet. | ||
add_library(libcxxabi-libc-shared INTERFACE) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,11 +172,12 @@ if (LIBCXXABI_USE_LLVM_UNWINDER) | |
target_link_libraries(cxxabi_shared_objects PUBLIC unwind_shared) | ||
endif() | ||
endif() | ||
target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_LIBRARIES}) | ||
target_link_libraries(cxxabi_shared_objects | ||
PUBLIC cxxabi-headers | ||
PRIVATE cxx-headers runtimes-libc-headers ${LIBCXXABI_LIBRARIES}) | ||
if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG) | ||
target_link_libraries(cxxabi_shared_objects PRIVATE ${LIBCXXABI_BUILTINS_LIBRARY}) | ||
endif() | ||
target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers) | ||
set_target_properties(cxxabi_shared_objects | ||
PROPERTIES | ||
CXX_EXTENSIONS OFF | ||
|
@@ -215,7 +216,7 @@ if (ZOS) | |
endif () | ||
|
||
target_link_libraries(cxxabi_shared | ||
PUBLIC cxxabi_shared_objects | ||
PUBLIC cxxabi_shared_objects runtimes-libc-shared | ||
PRIVATE ${LIBCXXABI_LIBRARIES}) | ||
|
||
if (LIBCXXABI_ENABLE_SHARED) | ||
|
@@ -274,8 +275,9 @@ if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC | |
target_link_libraries(cxxabi_static_objects PUBLIC unwind_static_objects) # propagate usage requirements | ||
target_sources(cxxabi_static_objects PUBLIC $<TARGET_OBJECTS:unwind_static_objects>) | ||
endif() | ||
target_link_libraries(cxxabi_static_objects PRIVATE cxx-headers ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) | ||
target_link_libraries(cxxabi_static_objects PUBLIC cxxabi-headers) | ||
target_link_libraries(cxxabi_static_objects | ||
PUBLIC cxxabi-headers | ||
PRIVATE cxx-headers runtimes-libc-headers ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) | ||
set_target_properties(cxxabi_static_objects | ||
PROPERTIES | ||
CXX_EXTENSIONS OFF | ||
|
@@ -311,7 +313,7 @@ endif() | |
|
||
add_library(cxxabi_static STATIC) | ||
if (LIBCXXABI_USE_LLVM_UNWINDER AND NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY) | ||
target_link_libraries(cxxabi_static PUBLIC unwind_static) | ||
target_link_libraries(cxxabi_static PUBLIC unwind_static runtimes-libc-static) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This raises an interesting question: right now, we link a static libc (let's call it However, it would in theory make sense to allow e.g. I'm not saying this patch has to fix that shortcoming since it's a pre-existing condition in libc++, but that should be on our radar. |
||
endif() | ||
set_target_properties(cxxabi_static | ||
PROPERTIES | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#=============================================================================== | ||
# Define targets for linking against the selected C library | ||
# | ||
# After including this file, the following targets are defined: | ||
# - libunwind-libc-headers: An interface target that allows getting access to the | ||
# headers of the selected C library. | ||
# - libunwind-libc-shared: A target representing the selected shared C library. | ||
# - libunwind-libc-static: A target representing the selected static C library. | ||
#=============================================================================== | ||
|
||
# Link against a system-provided libc | ||
if (LIBUNWIND_LIBC STREQUAL "system") | ||
add_library(libunwind-libc-headers INTERFACE) | ||
|
||
add_library(libunwind-libc-static INTERFACE) | ||
add_library(libunwind-libc-shared INTERFACE) | ||
|
||
# Link against the in-tree LLVM libc | ||
elseif (LIBUNWIND_LIBC STREQUAL "llvm-libc") | ||
add_library(libunwind-libc-headers INTERFACE) | ||
target_link_libraries(libunwind-libc-headers INTERFACE libc-headers) | ||
if(CXX_SUPPORTS_NOSTDLIBINC_FLAG) | ||
target_compile_options(libunwind-libc-headers INTERFACE "-nostdlibinc") | ||
endif() | ||
|
||
add_library(libunwind-libc-static INTERFACE) | ||
if (TARGET libc) | ||
target_link_libraries(libunwind-libc-static INTERFACE libc) | ||
endif() | ||
if (TARGET libm) | ||
target_link_libraries(libunwind-libc-static INTERFACE libm) | ||
endif() | ||
if (CXX_SUPPORTS_NOLIBC_FLAG) | ||
target_link_options(libunwind-libc-static INTERFACE "-nolibc") | ||
endif() | ||
|
||
# TODO: There's no support for building LLVM libc as a shared library yet. | ||
add_library(libunwind-libc-shared INTERFACE) | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#=============================================================================== | ||
# Define targets for linking against the selected C library | ||
# | ||
# After including this file, the following targets are defined: | ||
# - runtimes-libc-headers: An interface target that allows getting access to the | ||
# headers of the selected C library. | ||
# - runtimes-libc-shared: A target representing the selected shared C library. | ||
# - runtimes-libc-static: A target representing the selected static C library. | ||
#=============================================================================== | ||
|
||
set(RUNTIMES_SUPPORTED_C_LIBRARIES system llvm-libc) | ||
set(RUNTIMES_USE_LIBC "system" CACHE STRING "Specify C library to use. Supported values are ${RUNTIMES_SUPPORTED_C_LIBRARIES}.") | ||
if (NOT "${RUNTIMES_USE_LIBC}" IN_LIST RUNTIMES_SUPPORTED_C_LIBRARIES) | ||
message(FATAL_ERROR "Unsupported C library: '${RUNTIMES_CXX_ABI}'. Supported values are ${RUNTIMES_SUPPORTED_C_LIBRARIES}.") | ||
endif() | ||
|
||
# Link against a system-provided libc | ||
if (RUNTIMES_USE_LIBC STREQUAL "system") | ||
add_library(runtimes-libc-headers INTERFACE) | ||
|
||
add_library(runtimes-libc-static INTERFACE) | ||
add_library(runtimes-libc-shared INTERFACE) | ||
|
||
# Link against the in-tree LLVM libc | ||
elseif (RUNTIMES_USE_LIBC STREQUAL "llvm-libc") | ||
add_library(runtimes-libc-headers INTERFACE) | ||
target_link_libraries(runtimes-libc-headers INTERFACE libc-headers) | ||
check_cxx_compiler_flag(-nostdlibinc CXX_SUPPORTS_NOSTDLIBINC_FLAG) | ||
if(CXX_SUPPORTS_NOSTDLIBINC_FLAG) | ||
target_compile_options(runtimes-libc-headers INTERFACE "-nostdlibinc") | ||
endif() | ||
|
||
add_library(runtimes-libc-static INTERFACE) | ||
if (TARGET libc) | ||
target_link_libraries(runtimes-libc-static INTERFACE libc) | ||
endif() | ||
if (TARGET libm) | ||
target_link_libraries(runtimes-libc-static INTERFACE libm) | ||
endif() | ||
if (CXX_SUPPORTS_NOLIBC_FLAG) | ||
target_link_options(runtimes-libc-static INTERFACE "-nolibc") | ||
endif() | ||
|
||
# TODO: There's no support for building LLVM libc as a shared library yet. | ||
add_library(runtimes-libc-shared INTERFACE) | ||
endif() |
Uh oh!
There was an error while loading. Please reload this page.