Skip to content

[windows] fix flaky linker error when building LLDB #10613

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

Open
wants to merge 3 commits into
base: stable/20240723
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 0 additions & 3 deletions lldb/source/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ add_lldb_library(liblldb SHARED ${option_framework}
lldbValueObject
lldbVersion
${LLDB_ALL_PLUGINS}
## BEGIN SWIFT
${SWIFT_ALL_LIBS}
## END SWIFT
LINK_COMPONENTS
Support

Expand Down
7 changes: 7 additions & 0 deletions lldb/source/Plugins/Language/Swift/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
set(LLVM_NO_RTTI 1)

set(SWIFT_CORE_LIB)

if(WIN32)
list(APPEND SWIFT_CORE_LIB swiftCore)
endif()

add_lldb_library(lldbPluginSwiftLanguage PLUGIN
FoundationValueTypes.cpp
LogChannelSwift.cpp
Expand Down Expand Up @@ -27,6 +33,7 @@ add_lldb_library(lldbPluginSwiftLanguage PLUGIN
lldbPluginTypeSystemSwift
swiftAST
swiftClangImporter
${SWIFT_CORE_LIB} # fixes a linker issue when building on Windows.

Choose a reason for hiding this comment

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

It wouldn't hurt to be more verbose and mention which symbol is missing, and that we don't actually think this is the correct solution, but merely a workaround.

Copy link
Author

Choose a reason for hiding this comment

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

Made the comment more explicit 👍

Copy link
Member

Choose a reason for hiding this comment

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

This really is the right solution - if you have Swift code in the image, you need to have swiftrt.obj linked in to register the metadata with the runtime, and thus you need to register the runtime.

If this is truly a workaround, then we should probably indicate what dependency we are pulling in that we should not be which is resulting in Swift code being pulled into the module.

Copy link
Author

Choose a reason for hiding this comment

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

If this is truly a workaround, then we should probably indicate what dependency we are pulling in that we should not be which is resulting in Swift code being pulled into the module.

Could it be linked to these commits? swiftlang/swift@8cb86ac - swiftlang/swift@0c42b57?

I'm not sure how to determine if it's a workaround or the right solution.

Copy link
Member

@compnerd compnerd May 9, 2025

Choose a reason for hiding this comment

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

No, neither of those are related. The first is a change to the stubs, and the second is limited to ELF. The way to determine if this is a workaround or the right solution is to understand why there is any Swift code in the module. If you are supposed to have Swift code, then this is the right fix - Swift code generally requires that you are linking to swiftCore as that is what provides the implementation for the basic types.

clangAST

LINK_COMPONENTS
Expand Down