Files
patches/llvm/llvm-project-22.1.6-llvm-libgcc-runtimes.patch
SFG545 accdf3d3fb Add runtime compatibility patch set
Add an LLVM 22.1.6 runtimes patch for building libc++, libc++abi, and llvm-libgcc together. The patch lets libc++abi accept llvm-libgcc as the provider of the LLVM unwinder, keeps the libgcc_s version script private to libunwind so it does not leak into libc++abi links, and adds an opt-out for building compiler-rt inside llvm-libgcc when an exported external builtins archive is available.

Add libxcrypt patches for current Clang/glibc builds: avoid treating Clang as old GCC in yescrypt assembly selection and adjust yescrypt strchr call sites for the newer glibc const-correct prototype behavior.

Add a mandoc 1.14.6 patch for zstd-compressed manual pages, including configure checks, linker flags, documentation, section matching, and decompression handling.

Remove the obsolete Perl 5.42.2 LBI patch from the patch set.
2026-05-29 22:23:57 -05:00

170 lines
8.3 KiB
Diff

diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 2b67c59..02124de 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -53,8 +53,10 @@ option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode.
option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." ON)
-if (LIBCXXABI_USE_LLVM_UNWINDER AND NOT "libunwind" IN_LIST LLVM_ENABLE_RUNTIMES)
- message(FATAL_ERROR "LIBCXXABI_USE_LLVM_UNWINDER is set to ON, but libunwind is not specified in LLVM_ENABLE_RUNTIMES.")
+if (LIBCXXABI_USE_LLVM_UNWINDER AND
+ NOT "libunwind" IN_LIST LLVM_ENABLE_RUNTIMES AND
+ NOT "llvm-libgcc" IN_LIST LLVM_ENABLE_RUNTIMES)
+ message(FATAL_ERROR "LIBCXXABI_USE_LLVM_UNWINDER is set to ON, but neither libunwind nor llvm-libgcc is specified in LLVM_ENABLE_RUNTIMES.")
endif()
option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF)
option(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
diff --git a/llvm-libgcc/CMakeLists.txt b/llvm-libgcc/CMakeLists.txt
index 47208fc..9f31762 100644
--- a/llvm-libgcc/CMakeLists.txt
+++ b/llvm-libgcc/CMakeLists.txt
@@ -32,8 +32,13 @@ set(LLVM_LIBGCC_LIBUNWIND_PATH "${CMAKE_CURRENT_LIST_DIR}/../libunwind"
CACHE PATH "Specify path to libunwind source.")
set(LLVM_LIBGCC_COMPILER_RT_PATH "${CMAKE_CURRENT_LIST_DIR}/../compiler-rt"
CACHE PATH "Specify path to compiler-rt source.")
+option(LLVM_LIBGCC_BUILD_COMPILER_RT
+ "Build compiler-rt builtins as part of llvm-libgcc." ON)
include(GNUInstallDirs)
+list(APPEND CMAKE_MODULE_PATH "${LLVM_LIBGCC_COMPILER_RT_PATH}/cmake/Modules")
+include(CompilerRTUtils)
+include(HandleCompilerRT)
if(NOT LLVM_LIBGCC_EXPLICIT_OPT_IN)
message(FATAL_ERROR
@@ -88,9 +93,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_LIBGCC_LIBRARY_DIR})
# Build libraries
#===============================================================================
-set(COMPILER_RT_BUILD_BUILTINS ON)
-set(COMPILER_RT_BUILTINS_HIDE_SYMBOLS OFF)
-add_subdirectory(${LLVM_LIBGCC_COMPILER_RT_PATH} ${LLVM_LIBGCC_COMPILER_RT_BINARY_DIR})
+if(LLVM_LIBGCC_BUILD_COMPILER_RT)
+ set(COMPILER_RT_BUILD_BUILTINS ON)
+ set(COMPILER_RT_BUILTINS_HIDE_SYMBOLS OFF)
+ add_subdirectory(${LLVM_LIBGCC_COMPILER_RT_PATH} ${LLVM_LIBGCC_COMPILER_RT_BINARY_DIR})
+endif()
set(LIBUNWIND_ENABLE_STATIC ON)
set(LIBUNWIND_ENABLE_SHARED ON)
@@ -108,33 +115,65 @@ add_custom_target(gcc_s.ver
add_dependencies(unwind_shared gcc_s.ver)
+if(NOT LLVM_TARGET_TRIPLE)
+ set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
+endif()
construct_compiler_rt_default_triple()
-target_link_options(unwind_shared PUBLIC
+target_link_options(unwind_shared PRIVATE
-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/gcc_s.ver
)
-target_link_libraries(unwind_shared PUBLIC
- $<TARGET_OBJECTS:clang_rt.builtins-${COMPILER_RT_DEFAULT_TARGET_ARCH}>
- m
-)
+if(LLVM_LIBGCC_BUILD_COMPILER_RT)
+ set(LLVM_LIBGCC_COMPILER_RT_DEPS clang_rt.builtins-${COMPILER_RT_DEFAULT_TARGET_ARCH})
+ set(LLVM_LIBGCC_COMPILER_RT_OBJECTS
+ $<TARGET_OBJECTS:clang_rt.builtins-${COMPILER_RT_DEFAULT_TARGET_ARCH}>)
+else()
+ set(LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY "" CACHE FILEPATH
+ "Path to an existing compiler-rt builtins archive when LLVM_LIBGCC_BUILD_COMPILER_RT is OFF.")
+ if(NOT LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY)
+ find_compiler_rt_library(builtins LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY
+ TARGET ${COMPILER_RT_DEFAULT_TARGET_TRIPLE})
+ endif()
+ if(NOT LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY OR
+ LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY STREQUAL "NOTFOUND")
+ message(FATAL_ERROR
+ "LLVM_LIBGCC_BUILD_COMPILER_RT is OFF, but compiler-rt builtins could not "
+ "be found. Set LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY to an existing "
+ "libclang_rt.builtins archive.")
+ endif()
+ set(LLVM_LIBGCC_COMPILER_RT_LINK_TARGET
+ "${LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY}" CACHE STRING
+ "Install-tree target used by the libgcc.a symlink when LLVM_LIBGCC_BUILD_COMPILER_RT is OFF.")
+ set(LLVM_LIBGCC_COMPILER_RT_OBJECTS
+ -Wl,--whole-archive
+ ${LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY}
+ -Wl,--no-whole-archive)
+endif()
+
+target_link_libraries(unwind_shared PRIVATE ${LLVM_LIBGCC_COMPILER_RT_OBJECTS})
+target_link_libraries(unwind_shared PUBLIC m)
#===============================================================================
# Install Symlinks
#===============================================================================
-get_compiler_rt_install_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} install_dir_builtins)
-string(REGEX REPLACE "^lib/" "" install_dir_builtins "${install_dir_builtins}")
-string(FIND "${install_dir_builtins}" "clang" install_path_contains_triple)
-if(install_path_contains_triple EQUAL -1)
- set(builtins_suffix "-${COMPILER_RT_DEFAULT_TARGET_ARCH}")
+if(LLVM_LIBGCC_BUILD_COMPILER_RT)
+ get_compiler_rt_install_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} install_dir_builtins)
+ string(REGEX REPLACE "^lib/" "" install_dir_builtins "${install_dir_builtins}")
+ string(FIND "${install_dir_builtins}" "clang" install_path_contains_triple)
+ if(install_path_contains_triple EQUAL -1)
+ set(builtins_suffix "-${COMPILER_RT_DEFAULT_TARGET_ARCH}")
+ else()
+ string(PREPEND install_dir_builtins "../")
+ endif()
+ set(LLVM_LIBGCC_COMPILER_RT ${install_dir_builtins}/libclang_rt.builtins${builtins_suffix}.a)
else()
- string(PREPEND install_dir_builtins "../")
+ set(LLVM_LIBGCC_COMPILER_RT "${LLVM_LIBGCC_COMPILER_RT_LINK_TARGET}")
endif()
-set(LLVM_LIBGCC_COMPILER_RT ${install_dir_builtins}/libclang_rt.builtins${builtins_suffix}.a)
add_custom_target(llvm-libgcc ALL
- DEPENDS unwind_shared unwind_static clang_rt.builtins-${COMPILER_RT_DEFAULT_TARGET_ARCH}
+ DEPENDS unwind_shared unwind_static ${LLVM_LIBGCC_COMPILER_RT_DEPS}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLVM_LIBGCC_COMPILER_RT} libgcc.a
COMMAND ${CMAKE_COMMAND} -E create_symlink libunwind.a libgcc_eh.a
COMMAND ${CMAKE_COMMAND} -E create_symlink libunwind.so libgcc_s.so.1.0
@@ -147,10 +186,12 @@ install(TARGETS unwind_shared unwind_static
ARCHIVE DESTINATION ${LLVM_LIBGCC_INSTALL_LIBRARY_DIR} COMPONENT llvm-libgcc
RUNTIME DESTINATION ${LLVM_LIBGCC_INSTALL_RUNTIME_DIR} COMPONENT llvm-libgcc)
-install(TARGETS clang_rt.builtins-${COMPILER_RT_DEFAULT_TARGET_ARCH}
- LIBRARY DESTINATION ${LLVM_LIBGCC_INSTALL_LIBRARY_DIR}/${install_dir_builtins} COMPONENT llvm-libgcc
- ARCHIVE DESTINATION ${LLVM_LIBGCC_INSTALL_LIBRARY_DIR}/${install_dir_builtins} COMPONENT llvm-libgcc
- RUNTIME DESTINATION ${LLVM_LIBGCC_INSTALL_RUNTIME_DIR}/${install_dir_builtins} COMPONENT llvm-libgcc)
+if(LLVM_LIBGCC_BUILD_COMPILER_RT)
+ install(TARGETS clang_rt.builtins-${COMPILER_RT_DEFAULT_TARGET_ARCH}
+ LIBRARY DESTINATION ${LLVM_LIBGCC_INSTALL_LIBRARY_DIR}/${install_dir_builtins} COMPONENT llvm-libgcc
+ ARCHIVE DESTINATION ${LLVM_LIBGCC_INSTALL_LIBRARY_DIR}/${install_dir_builtins} COMPONENT llvm-libgcc
+ RUNTIME DESTINATION ${LLVM_LIBGCC_INSTALL_RUNTIME_DIR}/${install_dir_builtins} COMPONENT llvm-libgcc)
+endif()
foreach(VAR libgcc.a libgcc_eh.a libgcc_s.so.1.0 libgcc_s.so.1 libgcc_s.so)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${VAR}
diff --git a/llvm-libgcc/docs/LLVMLibgcc.rst b/llvm-libgcc/docs/LLVMLibgcc.rst
index 22dae7a..88e3fa2 100644
--- a/llvm-libgcc/docs/LLVMLibgcc.rst
+++ b/llvm-libgcc/docs/LLVMLibgcc.rst
@@ -72,6 +72,18 @@ CMake options
Since llvm-libgcc is such a fundamental, low-level component, we have made it
difficult to accidentally build, by requiring you to set an opt-in flag.
+.. option:: `LLVM_LIBGCC_BUILD_COMPILER_RT`
+
+ **Default**: ``ON``
+
+ Build the compiler-rt builtins archive as part of llvm-libgcc. When set to
+ ``OFF``, llvm-libgcc finds an existing compiler-rt builtins archive with the
+ compiler driver, links it into ``libunwind.so``, and only creates the
+ compatibility symlinks instead of installing compiler-rt. Set
+ ``LLVM_LIBGCC_COMPILER_RT_BUILTINS_LIBRARY`` if the compiler driver cannot
+ find the archive, and set ``LLVM_LIBGCC_COMPILER_RT_LINK_TARGET`` if the
+ installed symlink should point at a different path.
+
.. _Building llvm-libgcc
Building llvm-libgcc