[runtimes] Fix the build of merged ABI/unwinder libraries
Also, add a CI job that tests this configuration. The exact configuration is that we build a shared libc++ and merge objects for the ABI library and the unwinder library into it. Differential Revision: https://reviews.llvm.org/D125903
This commit is contained in:
parent
e601b2a154
commit
fa7ce8e685
|
@ -237,11 +237,11 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY
|
|||
|
||||
cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY
|
||||
"Statically link the ABI library to static library" ON
|
||||
"LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF)
|
||||
"LIBCXX_ENABLE_STATIC_ABI_LIBRARY" OFF)
|
||||
|
||||
cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY
|
||||
"Statically link the ABI library to shared library" ON
|
||||
"LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_SHARED" OFF)
|
||||
"LIBCXX_ENABLE_STATIC_ABI_LIBRARY" OFF)
|
||||
|
||||
# Generate and install a linker script inplace of libc++.so. The linker script
|
||||
# will link libc++ to the correct ABI library. This option is on by default
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
# Build a libc++ shared library, but merge libc++abi and libunwind into it.
|
||||
set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "")
|
||||
set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
|
||||
set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
|
||||
set(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY ON CACHE BOOL "")
|
||||
|
||||
set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
|
||||
set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
|
||||
set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
|
||||
set(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY ON CACHE BOOL "")
|
||||
|
||||
set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
|
|
@ -223,10 +223,10 @@ if (LIBCXX_ENABLE_SHARED)
|
|||
# dependencies are recorded when creating a linker script.
|
||||
# TODO: Look into modifying the linker script creation to recursively consider interface libraries
|
||||
if (LIBCXXABI_USE_LLVM_UNWINDER)
|
||||
if (NOT LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_shared OR HAVE_LIBUNWIND))
|
||||
target_link_libraries(cxx_shared PUBLIC unwind_shared)
|
||||
elseif (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY AND (TARGET unwind_static OR HAVE_LIBUNWIND))
|
||||
if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
|
||||
# libunwind is already included in libc++abi
|
||||
elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
|
||||
target_link_libraries(cxx_shared PUBLIC unwind_shared)
|
||||
else()
|
||||
target_link_libraries(cxx_shared PUBLIC unwind)
|
||||
endif()
|
||||
|
|
|
@ -351,6 +351,20 @@ steps:
|
|||
limit: 2
|
||||
timeout_in_minutes: 120
|
||||
|
||||
- label: "Shared library with merged ABI and unwinder libraries"
|
||||
command: "libcxx/utils/ci/run-buildbot generic-merged"
|
||||
artifact_paths:
|
||||
- "**/test-results.xml"
|
||||
- "**/*.abilist"
|
||||
agents:
|
||||
queue: "libcxx-builders"
|
||||
os: "linux"
|
||||
retry:
|
||||
automatic:
|
||||
- exit_status: -1 # Agent was lost
|
||||
limit: 2
|
||||
timeout_in_minutes: 120
|
||||
|
||||
- label: "Assertions enabled"
|
||||
command: "libcxx/utils/ci/run-buildbot generic-assertions"
|
||||
artifact_paths:
|
||||
|
|
|
@ -267,6 +267,14 @@ generic-static)
|
|||
-DLIBUNWIND_TEST_CONFIG="llvm-libunwind-static.cfg.in"
|
||||
check-runtimes
|
||||
;;
|
||||
generic-merged)
|
||||
clean
|
||||
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-merged.cmake" \
|
||||
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in" \
|
||||
-DLIBCXXABI_TEST_CONFIG="llvm-libc++abi-merged.cfg.in" \
|
||||
-DLIBUNWIND_TEST_CONFIG="llvm-libunwind-merged.cfg.in"
|
||||
check-runtimes
|
||||
;;
|
||||
generic-clang-13)
|
||||
export CC=clang-13
|
||||
export CXX=clang++-13
|
||||
|
|
|
@ -115,10 +115,10 @@ cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY
|
|||
|
||||
cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY
|
||||
"Statically link the LLVM unwinder to static library" ON
|
||||
"LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF)
|
||||
"LIBCXXABI_ENABLE_STATIC_UNWINDER" OFF)
|
||||
cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY
|
||||
"Statically link the LLVM unwinder to shared library" ON
|
||||
"LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF)
|
||||
"LIBCXXABI_ENABLE_STATIC_UNWINDER" OFF)
|
||||
|
||||
option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
|
||||
# The default terminate handler attempts to demangle uncaught exceptions, which
|
||||
|
|
|
@ -155,6 +155,7 @@ endif()
|
|||
add_library(cxxabi_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
|
||||
if (LIBCXXABI_USE_LLVM_UNWINDER)
|
||||
if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
|
||||
target_link_libraries(cxxabi_shared_objects PUBLIC unwind_shared_objects) # propagate usage requirements
|
||||
target_sources(cxxabi_shared_objects PUBLIC $<TARGET_OBJECTS:unwind_shared_objects>)
|
||||
else()
|
||||
target_link_libraries(cxxabi_shared_objects PUBLIC unwind_shared)
|
||||
|
@ -228,6 +229,7 @@ endif()
|
|||
# Build the static library.
|
||||
add_library(cxxabi_static_objects OBJECT EXCLUDE_FROM_ALL ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
|
||||
if (LIBCXXABI_USE_LLVM_UNWINDER AND LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY)
|
||||
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})
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# Testing configuration for libc++abi when merged into a libc++ shared library.
|
||||
|
||||
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
|
||||
|
||||
config.substitutions.append(('%{flags}',
|
||||
'-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
|
||||
))
|
||||
config.substitutions.append(('%{compile_flags}',
|
||||
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} -DLIBCXXABI_NO_TIMER -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS ' +
|
||||
'-I %{libcxx}/test/support -I %{libcxx}/src'
|
||||
))
|
||||
config.substitutions.append(('%{link_flags}',
|
||||
'-nostdlib++ -L %{lib} -Wl,-rpath,%{lib} -lc++ -pthread'
|
||||
))
|
||||
config.substitutions.append(('%{exec}',
|
||||
'%{executor} --execdir %T -- '
|
||||
))
|
||||
|
||||
import os, site
|
||||
site.addsitedir(os.path.join('@LIBCXXABI_LIBCXX_PATH@', 'utils'))
|
||||
import libcxx.test.params, libcxx.test.newconfig, libcxx.test.newconfig
|
||||
libcxx.test.newconfig.configure(
|
||||
libcxx.test.params.DEFAULT_PARAMETERS,
|
||||
libcxx.test.features.DEFAULT_FEATURES,
|
||||
config,
|
||||
lit_config
|
||||
)
|
|
@ -0,0 +1,65 @@
|
|||
@AUTO_GEN_COMMENT@
|
||||
|
||||
@SERIALIZED_LIT_PARAMS@
|
||||
|
||||
#
|
||||
# Configuration file for running the libunwind tests against a libc++ shared library
|
||||
# into which the unwinder was merged.
|
||||
#
|
||||
|
||||
import os, site
|
||||
site.addsitedir(os.path.join('@LIBUNWIND_LIBCXX_PATH@', 'utils'))
|
||||
import libcxx.test.format
|
||||
|
||||
# Basic configuration of the test suite
|
||||
config.name = os.path.basename('@LIBUNWIND_TEST_CONFIG@')
|
||||
config.test_source_root = os.path.join('@LIBUNWIND_SOURCE_DIR@', 'test')
|
||||
config.test_format = libcxx.test.format.CxxStandardLibraryTest()
|
||||
config.recursiveExpansionLimit = 10
|
||||
config.test_exec_root = '@CMAKE_BINARY_DIR@'
|
||||
config.target_info = "@LIBUNWIND_TARGET_INFO@"
|
||||
|
||||
compile_flags = []
|
||||
link_flags = []
|
||||
if @LIBUNWIND_USES_ARM_EHABI@:
|
||||
config.available_features.add('libunwind-arm-ehabi')
|
||||
|
||||
if not @LIBUNWIND_ENABLE_THREADS@:
|
||||
compile_flags.append('-D_LIBUNWIND_HAS_NO_THREADS')
|
||||
config.available_features.add('libunwind-no-threads')
|
||||
|
||||
if @LIBUNWIND_ENABLE_CET@:
|
||||
compile_flags.append('-fcf-protection=full')
|
||||
|
||||
if '@CMAKE_SYSTEM_NAME@' == 'Linux':
|
||||
link_flags.append('-Wl,--export-dynamic')
|
||||
|
||||
# Stack unwinding tests need unwinding tables and these are not generated by default on all targets.
|
||||
compile_flags.append('-funwind-tables')
|
||||
|
||||
config.substitutions.append(('%{executor}', '@LIBUNWIND_EXECUTOR@'))
|
||||
|
||||
config.substitutions.append(('%{cxx}', '@CMAKE_CXX_COMPILER@'))
|
||||
local_sysroot = '@CMAKE_OSX_SYSROOT@' or '@CMAKE_SYSROOT@'
|
||||
config.substitutions.append(('%{flags}',
|
||||
'-isysroot {}'.format(local_sysroot) if local_sysroot else ''
|
||||
))
|
||||
config.substitutions.append(('%{compile_flags}',
|
||||
'-nostdinc++ -I {}/include {}'.format('@LIBUNWIND_SOURCE_DIR@', ' '.join(compile_flags))
|
||||
))
|
||||
config.substitutions.append(('%{link_flags}',
|
||||
'-L {0} -Wl,-rpath,{0} -lc++ -ldl {1}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags))
|
||||
))
|
||||
config.substitutions.append(('%{exec}',
|
||||
'%{executor} --execdir %T -- ' if '@LIBUNWIND_EXECUTOR@' else ''
|
||||
))
|
||||
|
||||
import os, site
|
||||
site.addsitedir(os.path.join('@LIBUNWIND_LIBCXX_PATH@', 'utils'))
|
||||
import libcxx.test.params, libcxx.test.newconfig, libcxx.test.newconfig
|
||||
libcxx.test.newconfig.configure(
|
||||
libcxx.test.params.DEFAULT_PARAMETERS,
|
||||
libcxx.test.features.DEFAULT_FEATURES,
|
||||
config,
|
||||
lit_config
|
||||
)
|
Loading…
Reference in New Issue