Skip to content

[embedded] Skip EagerSpecializer on embedded Swift #74480

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 1 commit into from
Jun 18, 2024

Conversation

kubamracek
Copy link
Contributor

EagerSpecializer SIL pass processes @_specialize-annotated functions and creates a "type check" in them that compares metadata. This is (1) incompatible with Embedded Swift, because metadata are not available there, and (2) unnecessary in Embedded Swift because all functions are fully specialized already. Let's disable EagerSpecializer when compiling in Embedded Swift mode.

This fixes a compilation error when using anything that's @_specialize-annotated. Before this fix, using e.g. the Substring.init<S: Sequence>(_ elements: S) where S.Element == Character function from the stdlib (which has the annotation) results in:

in function specialized Substring.init<A>(_:)
<unknown>:0: error: cannot use metatype of type 'Array<Character>' in embedded Swift

See the attached testcase.

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek kubamracek added the embedded Embedded Swift label Jun 17, 2024
@kubamracek kubamracek merged commit 4d52b58 into swiftlang:main Jun 18, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedded Embedded Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants