Skip to content

Commit

Permalink
[runtimes] Handle interface targets in runtimes distribution components
Browse files Browse the repository at this point in the history
As reported in [1], cxx-headers is not a valid distribution target
because it is an interface target in CMake. This breaks the most
basic MultiDistributionExample of the runtimes build.

This patch handles interface targets by getting rid of the assumption
that all distribution components have a target associated to them. It
is valid for a distribution component to only have a `install-FOO`
target.

In the case where only `cxx-headers` is provided as a distribution
component, `ninja toolchain-distribution` will not build anything
after this patch, since there is effectively nothing to build for
the `cxx-headers` target. However, running `ninja install-toolchain-distribution`
will build everything, as expected.

[1]: https://discord.com/channels/636084430946959380/636732894974312448/1010013287464828968

Differential Revision: https://reviews.llvm.org/D132387

(cherry picked from commit 5905e69)
  • Loading branch information
ldionne authored and tru committed Aug 25, 2022
1 parent d761fe6 commit 0cc033e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions llvm/cmake/modules/LLVMDistributionSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ function(llvm_distribution_add_targets)
add_custom_target(install-${distribution_target}-stripped)

foreach(target ${distribution_components})
# Note that some distribution components may not have an actual target, but only an install-FOO target.
# This happens for example if a target is an INTERFACE target.
if(TARGET ${target})
add_dependencies(${distribution_target} ${target})
else()
message(SEND_ERROR "Specified distribution component '${target}' doesn't have a target")
endif()

if(TARGET install-${target})
Expand Down
2 changes: 1 addition & 1 deletion llvm/runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function(runtime_default_target)
endforeach()
foreach(component ${LLVM_RUNTIME_DISTRIBUTION_COMPONENTS})
if(NOT ${component} IN_LIST SUB_COMPONENTS)
list(APPEND extra_targets ${component} install-${component} install-${component}-stripped)
list(APPEND extra_targets install-${component} install-${component}-stripped)
endif()
endforeach()

Expand Down

0 comments on commit 0cc033e

Please sign in to comment.