Skip to content

[cmake/AddSwift] When support is passed for LLVM_LINK_COMPONENTS also implicitly include demangle #38913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,13 @@ function(add_swift_host_library name)
message(FATAL_ERROR "One of SHARED/STATIC/OBJECT must be specified")
endif()

# Using `support` llvm component ends up adding `-Xlinker /path/to/lib/libLLVMDemangle.a`
# to `LINK_FLAGS` but `libLLVMDemangle.a` is not added as an input to the linking ninja statement.
# As a workaround, include `demangle` component whenever `support` is mentioned.
if("support" IN_LIST ASHL_LLVM_LINK_COMPONENTS)
list(APPEND ASHL_LLVM_LINK_COMPONENTS "demangle")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike this solution since it is a bit of a hack. But I think it is fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing!

endif()

if(XCODE)
get_filename_component(base_dir ${CMAKE_CURRENT_SOURCE_DIR} NAME)

Expand Down Expand Up @@ -794,6 +801,12 @@ function(add_swift_host_tool executable)
precondition(ASHT_SWIFT_COMPONENT
MESSAGE "Swift Component is required to add a host tool")

# Using `support` llvm component ends up adding `-Xlinker /path/to/lib/libLLVMDemangle.a`
# to `LINK_FLAGS` but `libLLVMDemangle.a` is not added as an input to the linking ninja statement.
# As a workaround, include `demangle` component whenever `support` is mentioned.
if("support" IN_LIST ASHT_LLVM_LINK_COMPONENTS)
list(APPEND ASHT_LLVM_LINK_COMPONENTS "demangle")
endif()

add_executable(${executable} ${ASHT_UNPARSED_ARGUMENTS})
_add_host_variant_c_compile_flags(${executable})
Expand Down