Skip to content

Don't emit @main into SIL #40601

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
Dec 17, 2021
Merged

Conversation

etcwilde
Copy link
Member

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

@etcwilde
Copy link
Member Author

@swift-ci please test

Copy link
Contributor

@nate-chandler nate-chandler left a comment

Choose a reason for hiding this comment

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

Thanks! Looks like SWIFTMODULE_VERSION_MINOR needs to be updated.

@etcwilde
Copy link
Member Author

Thanks! Looks like SWIFTMODULE_VERSION_MINOR needs to be updated.

That would probably be the safest option, yes. I think it's technically safe because I haven't changed anything in the module file though.

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 force-pushed the ewilde/no-main-in-sil branch from 604ddae to 2760016 Compare December 17, 2021 00:31
@etcwilde
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2760016

@etcwilde
Copy link
Member Author

@swift-ci please clean test Linux

@etcwilde etcwilde merged commit b15adea into swiftlang:main Dec 17, 2021
@etcwilde etcwilde deleted the ewilde/no-main-in-sil branch December 17, 2021 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants