Skip to content

Remove Stubs.cpp and reimplement what it has in Swift.#929

Merged
grynspan merged 2 commits into
mainfrom
jgrynspan-remove-stubs-cpp
Jan 27, 2025
Merged

Remove Stubs.cpp and reimplement what it has in Swift.#929
grynspan merged 2 commits into
mainfrom
jgrynspan-remove-stubs-cpp

Conversation

@grynspan

@grynspan grynspan commented Jan 27, 2025

Copy link
Copy Markdown
Contributor

This PR removes Stubs.cpp, which currently houses some thunks for functions that are conditionally unavailable in glibc, and replaces it with runtime function lookups in Swift. Is there potentially a one-time non-zero performance cost? Yes. Is that performance cost prohibitive given that the functions are only looked up once and then cached? No.

These functions won't get called on Linux if SWT_NO_DYNAMIC_LINKING is defined but we don't currently support that combination anyway. Even if you're using a statically-linked Swift standard library, we'd expect Linux to still support calling dlsym().

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR removes Stubs.cpp, which currently houses some thunks for functions that
are conditionally unavailable in glibc, and replaces it with runtime function
lookups in Swift. Is there potentially a one-time non-zero performance cost?
Yes. Is that performance cost prohibitive given that the functions are only
looked up once and then cached? No.

These functions won't get called on Linux if `SWT_NO_DYNAMIC_LINKING` is defined
but we don't currently support that combination anyway. Even if you're using a
statically-linked Swift standard library, we'd expect Linux to still support
calling `dlsym()`.
@grynspan grynspan added linux 🐧 Linux support (all distros) less-c++ 🐀 Work to reduce the size of our C++ codebase and/or dependencies labels Jan 27, 2025
@grynspan grynspan added this to the Swift 6.x milestone Jan 27, 2025
@grynspan grynspan self-assigned this Jan 27, 2025
@grynspan

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@grynspan

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@grynspan grynspan merged commit 95b97a6 into main Jan 27, 2025
@grynspan grynspan deleted the jgrynspan-remove-stubs-cpp branch January 27, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

less-c++ 🐀 Work to reduce the size of our C++ codebase and/or dependencies linux 🐧 Linux support (all distros)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants