Skip to content

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Oct 9, 2025

We now have several new runtime libraries in the toolchain but they are not listed in the autolink deduplication list. This can lead to an excessive memory footprint when linking on platforms that use autolink-extract.

See #58380
As a data point, this change reduced the memory footprint of our wasm-ld process from 33.34 GiB → 2.22 GiB and link time from 46.4 s → 1.4 s.

…ing, and WASI platform We now have several new runtime libraries in the toolchain but they are not listed in the autolink deduplication list. This can lead to an excessive memory footprint when linking on platforms that use autolink-extract. See swiftlang#58380
@kateinoigakukun
Copy link
Member Author

@swift-ci smoke test

@kateinoigakukun kateinoigakukun marked this pull request as ready for review October 9, 2025 11:48
@kateinoigakukun kateinoigakukun requested review from finagolfin and artemcm and removed request for MaxDesiatov and etcwilde October 9, 2025 11:48
@MaxDesiatov MaxDesiatov added autolinking swift-autolink-extract Area → compiler → legacy driver: the 'swift-autolink-extract' mode labels Oct 9, 2025
Copy link
Member

@finagolfin finagolfin left a comment

Choose a reason for hiding this comment

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

All for half of these, not sure about the others.

"-lFoundationInternationalization",
"-lFoundationNetworking",
"-lFoundationXML",
"-l_CFXMLInterface",
Copy link
Member

Choose a reason for hiding this comment

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

This is a static-only CoreFoundation library: I thought we weren't supposed to publicly link these?

Copy link
Member Author

@kateinoigakukun kateinoigakukun Oct 9, 2025

Choose a reason for hiding this comment

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

Good point, yes. They are static-only libraries and we static-link everything. They are not supposed to be imported at code, so they don't have their corresponding .swiftmodule but we still ship their archives. So those link options are embedded in the client of those private modules (in this case, FoundationXML.swiftmodule) through -public-autolink-library
https://github.com/swiftlang/swift-corelibs-foundation/blob/ec675206c8cd939fbd4783421ea07954dcb5e175/Sources/FoundationXML/CMakeLists.txt#L33-L47

"-lFoundationNetworking",
"-lFoundationXML",
"-l_CFXMLInterface",
"-l_FoundationCShims",
Copy link
Member

Choose a reason for hiding this comment

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

Another static-only library, bit taken aback since the first time I'm seeing these listed here, sure you need this?

"-lFoundationXML",
"-l_CFXMLInterface",
"-l_FoundationCShims",
"-l_FoundationCollections",
Copy link
Member

Choose a reason for hiding this comment

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

Same here, static-only, I guess you're static linking the runtime libraries much more for Wasm binaries?

"-lXCTest",
// swift-testing libraries
"-l_TestingInternals",
"-l_TestDiscovery",
Copy link
Member

Choose a reason for hiding this comment

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

I don't see either of these in the linux SDK, Wasm only?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are also static-only libraries, installed only when building swift-testing with BUILD_SHARED_LIBS=OFF.
https://github.com/swiftlang/swift-testing/blob/fa1e095b316b9925dd5cc7fafc5d67825a07cd52/Sources/_TestingInternals/CMakeLists.txt#L31

Other platform toolchains/SDKs don't have it because they always build it as shared libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autolinking swift-autolink-extract Area → compiler → legacy driver: the 'swift-autolink-extract' mode
3 participants