[libcxx-commits] [libcxx] fa7ce8e - [runtimes] Fix the build of merged ABI/unwinder libraries
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 19 07:49:44 PDT 2022
Author: Louis Dionne
Date: 2022-05-19T10:49:36-04:00
New Revision: fa7ce8e685faa63f7ad1d0c7a640217286ec291b
URL: https://github.com/llvm/llvm-project/commit/fa7ce8e685faa63f7ad1d0c7a640217286ec291b
DIFF: https://github.com/llvm/llvm-project/commit/fa7ce8e685faa63f7ad1d0c7a640217286ec291b.diff
LOG: [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
Added:
libcxx/cmake/caches/Generic-merged.cmake
libcxxabi/test/configs/llvm-libc++abi-merged.cfg.in
libunwind/test/configs/llvm-libunwind-merged.cfg.in
Modified:
libcxx/CMakeLists.txt
libcxx/src/CMakeLists.txt
libcxx/utils/ci/buildkite-pipeline.yml
libcxx/utils/ci/run-buildbot
libcxxabi/CMakeLists.txt
libcxxabi/src/CMakeLists.txt
Removed:
################################################################################
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index ec4c2e408ca90..e06f3ec559ec6 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -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
diff --git a/libcxx/cmake/caches/Generic-merged.cmake b/libcxx/cmake/caches/Generic-merged.cmake
new file mode 100644
index 0000000000000..b2e02f7310555
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-merged.cmake
@@ -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 "")
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 42f41719eec23..570464f08c9ee 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -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()
diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml
index c6496b2510d58..cf011d123fe6f 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -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:
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 4ff71500465e7..bc57927e4aef1 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -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
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 791ff6c75df72..76d54f8d32a7b 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -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
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index afaed4fea326c..a8c79aa6f380a 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -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})
diff --git a/libcxxabi/test/configs/llvm-libc++abi-merged.cfg.in b/libcxxabi/test/configs/llvm-libc++abi-merged.cfg.in
new file mode 100644
index 0000000000000..c17cb0801dfa7
--- /dev/null
+++ b/libcxxabi/test/configs/llvm-libc++abi-merged.cfg.in
@@ -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
+)
diff --git a/libunwind/test/configs/llvm-libunwind-merged.cfg.in b/libunwind/test/configs/llvm-libunwind-merged.cfg.in
new file mode 100644
index 0000000000000..19808a173ad8c
--- /dev/null
+++ b/libunwind/test/configs/llvm-libunwind-merged.cfg.in
@@ -0,0 +1,65 @@
+ at AUTO_GEN_COMMENT@
+
+ at 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
+)
More information about the libcxx-commits
mailing list