Skip to content

Don't emit @main into SIL #40767

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 2 commits into from
Jan 9, 2022

Conversation

etcwilde
Copy link
Member

@etcwilde etcwilde commented Jan 7, 2022

Cherry-picking #40601

We emit all the necessary entry point bits directly into SIL. Specifically, Entrypoint.$main.
When re-injesting SIL files, @main handling would re-trigger, attempting to add another Entrypoint.$main resulting in the following error message: error: invalid redeclaration of synthesized static method '$main()'.
We don't need to keep the attribute after we've generated the main function, so drop it.

https://bugs.swift.org/browse/SR-14957
rdar://80971052

We want to control when the attribute gets emitted so we need to make
the attribute non-simple.
We've already generated the parts necessary to handle `@main` during
SILGen. Keeping the attribute on the struct means that re-ingesting the
SIL will fail because it tries to re-create the implicit `$main`
function resulting in the following error message:

error: invalid redeclaration of synthesized static method '$main()'
  static func $main()
@etcwilde etcwilde added the r5.6 label Jan 7, 2022
@etcwilde
Copy link
Member Author

etcwilde commented Jan 7, 2022

@swift-ci please test

@etcwilde etcwilde requested a review from nate-chandler January 7, 2022 19:54
@etcwilde etcwilde merged commit 544c47c into swiftlang:release/5.6 Jan 9, 2022
@etcwilde etcwilde deleted the ewilde/no-main-in-sil branch January 10, 2022 16:33
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.6 labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants