[compiler-rt] a3697dc - [compiler-rt] Give every installed file an install component (#227103)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 05:52:57 PDT 2026
Author: Joseph Huber
Date: 2026-09-29T07:52:49-05:00
New Revision: a3697dc8170d16e07bc4c507bb1d33b9d65a4c3c
URL: https://github.com/llvm/llvm-project/commit/a3697dc8170d16e07bc4c507bb1d33b9d65a4c3c
DIFF: https://github.com/llvm/llvm-project/commit/a3697dc8170d16e07bc4c507bb1d33b9d65a4c3c.diff
LOG: [compiler-rt] Give every installed file an install component (#227103)
Summary:
LLVM tries to expose install components to allow distributions to choose
the layers to build. Not all of the compiler-rt artifacts were installed
under this configuration. This PR makes this a consistent rule by
updating the existing helper function to require a parent target for the
component.
Adds things like
```
ninja install-dfsan
```
and ensures this installs everything
```
ninja install-compiler-rt-x86_64-unknown-linux-gnu
```
Added:
Modified:
compiler-rt/cmake/Modules/AddCompilerRT.cmake
compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
compiler-rt/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/cmake/Modules/SanitizerUtils.cmake
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/asan/scripts/CMakeLists.txt
compiler-rt/lib/copyprof/CMakeLists.txt
compiler-rt/lib/dfsan/CMakeLists.txt
compiler-rt/lib/hwasan/CMakeLists.txt
compiler-rt/lib/hwasan/scripts/CMakeLists.txt
compiler-rt/lib/memprof/CMakeLists.txt
compiler-rt/lib/msan/CMakeLists.txt
compiler-rt/lib/tsan/rtl/CMakeLists.txt
Removed:
################################################################################
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index cb23414b99f53..bd9aa3a52884f 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -345,13 +345,9 @@ function(add_compiler_rt_runtime name type)
endif()
foreach(libname ${libnames})
- # If you are using a multi-configuration generator we don't generate
- # per-library install rules, so we fall back to the parent target COMPONENT
- if(CMAKE_CONFIGURATION_TYPES AND LIB_PARENT_TARGET)
- set(COMPONENT_OPTION COMPONENT ${LIB_PARENT_TARGET})
- else()
- set(COMPONENT_OPTION COMPONENT ${libname})
- endif()
+ get_compiler_rt_install_component(${libname} "${LIB_PARENT_TARGET}"
+ component)
+ set(COMPONENT_OPTION COMPONENT ${component})
if(type STREQUAL "SHARED")
list(APPEND LIB_DEFS COMPILER_RT_SHARED_LIB)
@@ -612,7 +608,7 @@ function(add_compiler_rt_test test_suite test_name arch)
add_dependencies(${test_suite} T${test_name})
endfunction()
-macro(add_compiler_rt_script name)
+macro(add_compiler_rt_script name component)
set(dst ${COMPILER_RT_EXEC_OUTPUT_DIR}/${name})
set(src ${CMAKE_CURRENT_SOURCE_DIR}/${name})
add_custom_command(OUTPUT ${dst}
@@ -620,9 +616,11 @@ macro(add_compiler_rt_script name)
COMMAND ${CMAKE_COMMAND} -E copy_if_
diff erent ${src} ${dst}
COMMENT "Copying ${name}...")
add_custom_target(${name} DEPENDS ${dst})
+ add_dependencies(${component} ${name})
install(FILES ${dst}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
- DESTINATION ${COMPILER_RT_INSTALL_BINARY_DIR})
+ DESTINATION ${COMPILER_RT_INSTALL_BINARY_DIR}
+ COMPONENT ${component})
endmacro(add_compiler_rt_script src name)
diff --git a/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
index 20400014869e1..042137d76d0aa 100644
--- a/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
@@ -63,7 +63,8 @@ macro(archive_aix_libatomic name libname)
${objects_to_archive}
DEPENDS ${objects_to_archive})
install(FILES "${output_dir}/${libname}.a"
- DESTINATION ${install_dir})
+ DESTINATION ${install_dir}
+ COMPONENT ${LIB_PARENT_TARGET})
add_custom_target(aix-${libname}
DEPENDS "${output_dir}/${libname}.a")
add_dependencies(${LIB_PARENT_TARGET} aix-${libname})
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index e424c1b5ef87a..55f4a19b027d4 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -362,11 +362,8 @@ function(darwin_lipo_libs name)
set_target_properties(${name} PROPERTIES FOLDER "compiler-rt/Misc")
add_dependencies(${LIB_PARENT_TARGET} ${name})
- if(CMAKE_CONFIGURATION_TYPES)
- set(install_component ${LIB_PARENT_TARGET})
- else()
- set(install_component ${name})
- endif()
+ get_compiler_rt_install_component(${name} ${LIB_PARENT_TARGET}
+ install_component)
install(FILES ${LIB_OUTPUT_DIR}/lib${name}.a
DESTINATION ${LIB_INSTALL_DIR}
COMPONENT ${install_component})
diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index 402d14d928762..8e8e047559a2c 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -529,6 +529,16 @@ function(get_compiler_rt_install_dir arch install_dir)
endif()
endfunction()
+# Multi-configuration generators get no per-library install targets, so their
+# libraries are installed with the parent target's component instead.
+function(get_compiler_rt_install_component name parent_target component)
+ if(CMAKE_CONFIGURATION_TYPES AND parent_target)
+ set(${component} ${parent_target} PARENT_SCOPE)
+ else()
+ set(${component} ${name} PARENT_SCOPE)
+ endif()
+endfunction()
+
function(get_compiler_rt_output_dir arch output_dir)
# TODO: Use RUNTIMES_OUTPUT_RESOURCE_LIB_DIR instead
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
diff --git a/compiler-rt/cmake/Modules/SanitizerUtils.cmake b/compiler-rt/cmake/Modules/SanitizerUtils.cmake
index dea4d9a218d00..64a41b43f0b72 100644
--- a/compiler-rt/cmake/Modules/SanitizerUtils.cmake
+++ b/compiler-rt/cmake/Modules/SanitizerUtils.cmake
@@ -23,6 +23,9 @@ macro(add_sanitizer_rt_symbols name)
"PARENT_TARGET"
"ARCHS;EXTRA"
${ARGN})
+ if(NOT ARG_PARENT_TARGET)
+ message(FATAL_ERROR "add_sanitizer_rt_symbols(${name}) requires PARENT_TARGET")
+ endif()
foreach(arch ${ARG_ARCHS})
set(target_name ${name}-${arch})
set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.syms-stamp)
@@ -42,12 +45,15 @@ macro(add_sanitizer_rt_symbols name)
add_custom_target(${target_name}-symbols ALL
DEPENDS ${stamp}
SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA})
+ add_dependencies(${ARG_PARENT_TARGET} ${target_name}-symbols)
+ get_compiler_rt_install_component(${target_name} ${ARG_PARENT_TARGET}
+ component)
get_compiler_rt_install_dir(${arch} install_dir)
install(FILES $<TARGET_FILE:${target_name}>.syms
- DESTINATION ${install_dir})
- if(ARG_PARENT_TARGET)
- add_dependencies(${ARG_PARENT_TARGET} ${target_name}-symbols)
- endif()
+ DESTINATION ${install_dir}
+ COMPONENT ${component})
+ add_dependencies(install-${component} ${target_name}-symbols)
+ add_dependencies(install-${component}-stripped ${target_name}-symbols)
endforeach()
endmacro()
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index c5b1426812cfa..8ba0a38228601 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -417,12 +417,12 @@ else()
if (SANITIZER_USE_SYMBOLS AND NOT ${arch} STREQUAL "i386")
add_sanitizer_rt_symbols(clang_rt.asan_cxx
- ARCHS ${arch})
- add_dependencies(asan clang_rt.asan_cxx-${arch}-symbols)
+ ARCHS ${arch}
+ PARENT_TARGET asan)
add_sanitizer_rt_symbols(clang_rt.asan
ARCHS ${arch}
+ PARENT_TARGET asan
EXTRA asan.syms.extra)
- add_dependencies(asan clang_rt.asan-${arch}-symbols)
endif()
if (WIN32)
diff --git a/compiler-rt/lib/asan/scripts/CMakeLists.txt b/compiler-rt/lib/asan/scripts/CMakeLists.txt
index e5ab8ebed0242..67c9e6722114b 100644
--- a/compiler-rt/lib/asan/scripts/CMakeLists.txt
+++ b/compiler-rt/lib/asan/scripts/CMakeLists.txt
@@ -1,4 +1,3 @@
if(ANDROID)
- add_compiler_rt_script(asan_device_setup)
- add_dependencies(asan asan_device_setup)
+ add_compiler_rt_script(asan_device_setup asan)
endif()
diff --git a/compiler-rt/lib/copyprof/CMakeLists.txt b/compiler-rt/lib/copyprof/CMakeLists.txt
index 1de2d5f3682b2..727022db2114a 100644
--- a/compiler-rt/lib/copyprof/CMakeLists.txt
+++ b/compiler-rt/lib/copyprof/CMakeLists.txt
@@ -54,8 +54,8 @@ if(SANITIZER_USE_SYMBOLS)
foreach(arch ${COPYPROF_SUPPORTED_ARCH})
add_sanitizer_rt_symbols(clang_rt.copyprof
ARCHS ${arch}
+ PARENT_TARGET copyprof
EXTRA copyprof.syms.extra)
- add_dependencies(copyprof clang_rt.copyprof-${arch}-symbols)
endforeach()
endif()
diff --git a/compiler-rt/lib/dfsan/CMakeLists.txt b/compiler-rt/lib/dfsan/CMakeLists.txt
index 37c386d2de1f5..73f0351a5348a 100644
--- a/compiler-rt/lib/dfsan/CMakeLists.txt
+++ b/compiler-rt/lib/dfsan/CMakeLists.txt
@@ -49,9 +49,8 @@ foreach(arch ${DFSAN_SUPPORTED_ARCH})
PARENT_TARGET dfsan)
add_sanitizer_rt_symbols(clang_rt.dfsan
ARCHS ${arch}
+ PARENT_TARGET dfsan
EXTRA dfsan.syms.extra)
- add_dependencies(dfsan
- clang_rt.dfsan-${arch}-symbols)
endforeach()
set(dfsan_abilist_dir ${COMPILER_RT_OUTPUT_DIR}/share)
@@ -70,4 +69,5 @@ add_custom_command(OUTPUT ${dfsan_abilist_filename}
DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt)
add_dependencies(dfsan dfsan_abilist)
install(FILES ${dfsan_abilist_filename}
- DESTINATION ${COMPILER_RT_INSTALL_DATA_DIR})
+ DESTINATION ${COMPILER_RT_INSTALL_DATA_DIR}
+ COMPONENT dfsan)
diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt
index e7383d87c51d9..995c178cd74cb 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -236,12 +236,12 @@ function(add_hwasan_runtimes arch use_aliases)
if(SANITIZER_USE_SYMBOLS)
add_sanitizer_rt_symbols(${hwasan_runtime}
ARCHS ${arch}
+ PARENT_TARGET hwasan
EXTRA hwasan.syms.extra)
add_sanitizer_rt_symbols(${hwasan_runtime}_cxx
ARCHS ${arch}
+ PARENT_TARGET hwasan
EXTRA hwasan.syms.extra)
- add_dependencies(hwasan ${hwasan_runtime}-${arch}-symbols
- ${hwasan_runtime}_cxx-${arch}-symbols)
endif()
endfunction()
diff --git a/compiler-rt/lib/hwasan/scripts/CMakeLists.txt b/compiler-rt/lib/hwasan/scripts/CMakeLists.txt
index 68c8375c75ed3..083edb0bea9ad 100644
--- a/compiler-rt/lib/hwasan/scripts/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/scripts/CMakeLists.txt
@@ -1,2 +1 @@
-add_compiler_rt_script(hwasan_symbolize)
-add_dependencies(hwasan hwasan_symbolize)
+add_compiler_rt_script(hwasan_symbolize hwasan)
diff --git a/compiler-rt/lib/memprof/CMakeLists.txt b/compiler-rt/lib/memprof/CMakeLists.txt
index e6d99daca6ee7..764bdbc55079d 100644
--- a/compiler-rt/lib/memprof/CMakeLists.txt
+++ b/compiler-rt/lib/memprof/CMakeLists.txt
@@ -195,12 +195,12 @@ foreach(arch ${MEMPROF_SUPPORTED_ARCH})
if (SANITIZER_USE_SYMBOLS)
add_sanitizer_rt_symbols(clang_rt.memprof_cxx
- ARCHS ${arch})
- add_dependencies(memprof clang_rt.memprof_cxx-${arch}-symbols)
+ ARCHS ${arch}
+ PARENT_TARGET memprof)
add_sanitizer_rt_symbols(clang_rt.memprof
ARCHS ${arch}
+ PARENT_TARGET memprof
EXTRA memprof.syms.extra)
- add_dependencies(memprof clang_rt.memprof-${arch}-symbols)
endif()
endforeach()
diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt
index c5e6ab31ef5db..1cefee8ec2435 100644
--- a/compiler-rt/lib/msan/CMakeLists.txt
+++ b/compiler-rt/lib/msan/CMakeLists.txt
@@ -74,12 +74,12 @@ foreach(arch ${MSAN_SUPPORTED_ARCH})
if(SANITIZER_USE_SYMBOLS)
add_sanitizer_rt_symbols(clang_rt.msan
ARCHS ${arch}
+ PARENT_TARGET msan
EXTRA msan.syms.extra)
add_sanitizer_rt_symbols(clang_rt.msan_cxx
ARCHS ${arch}
+ PARENT_TARGET msan
EXTRA msan.syms.extra)
- add_dependencies(msan clang_rt.msan-${arch}-symbols
- clang_rt.msan_cxx-${arch}-symbols)
endif()
endforeach()
diff --git a/compiler-rt/lib/tsan/rtl/CMakeLists.txt b/compiler-rt/lib/tsan/rtl/CMakeLists.txt
index f93797754477a..35d0cf911671e 100644
--- a/compiler-rt/lib/tsan/rtl/CMakeLists.txt
+++ b/compiler-rt/lib/tsan/rtl/CMakeLists.txt
@@ -284,14 +284,14 @@ else()
PARENT_TARGET tsan)
add_sanitizer_rt_symbols(clang_rt.tsan
ARCHS ${arch}
+ PARENT_TARGET tsan
EXTRA tsan.syms.extra)
add_sanitizer_rt_symbols(clang_rt.tsan_cxx
ARCHS ${arch}
+ PARENT_TARGET tsan
EXTRA tsan.syms.extra)
add_dependencies(tsan clang_rt.tsan-${arch}
- clang_rt.tsan_cxx-${arch}
- clang_rt.tsan-${arch}-symbols
- clang_rt.tsan_cxx-${arch}-symbols)
+ clang_rt.tsan_cxx-${arch})
endforeach()
endif()
More information about the llvm-commits
mailing list