Skip to content

[TBDGen] Fix check for global accessors #18883

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
Aug 22, 2018

Conversation

harlanhaskins
Copy link
Contributor

Previously, TBDGen skipped emitting lazy initializers for globals that
appeared in any file with an entry point. This breaks, however on files
that have an NSApplicationMain/UIApplicationMain class in them, where
the entry point is synthesized but top-level globals are not locally
scoped. This change re-uses SILGen's check and only skips variable
declarations that appear at top level in a script mode file.

Resolves rdar://43549749

Previously, TBDGen skipped emitting lazy initializers for globals that
appeared in any file with an entry point. This breaks, however on files
that have an NSApplicationMain/UIApplicationMain class in them, where
the entry point is synthesized but top-level globals are not locally
scoped. This change re-uses SILGen's check and only skips variable
declarations that appear at top level in a script mode file.

Resolves rdar://43549749
@harlanhaskins
Copy link
Contributor Author

@swift-ci please smoke test

@slavapestov
Copy link
Contributor

Does it ever make sense for script mode declarations to have public symbols? Maybe we should fix the linkage computation for the initializer instead

@slavapestov
Copy link
Contributor

Also why would you want to generate a TBD for something with a main() function? Isn’t TBD only for dynamic libraries?

@harlanhaskins
Copy link
Contributor Author

harlanhaskins commented Aug 22, 2018

If -enable-testing is passed, global lazy inits get public symbols, but that's a useless flag if you're compiling in script mode, but we could detect that and keep them private.

Currently, in Debug on Apple platforms, we validate the TBD file symbol generation against generated IR unless explicitly told not to via -validate-tbd-against-ir=none, so even if we're not going to emit a TBD file directly, we still support the symbol validation logic. Maybe we could revisit that policy for modules with a main.

@jrose-apple
Copy link
Contributor

It's still sensible to try to parallelize building test targets with building the app target.

@harlanhaskins
Copy link
Contributor Author

It would probably be a good idea to revisit visibility for top-level symbols in script files, but for now I'm gonna merge this to unblock the bots.

@harlanhaskins harlanhaskins merged commit 096e6ad into swiftlang:master Aug 22, 2018
@harlanhaskins harlanhaskins deleted the traumatic-irony branch August 22, 2018 01:23
harlanhaskins pushed a commit to harlanhaskins/swift that referenced this pull request Sep 12, 2018
Previously, TBDGen skipped emitting lazy initializers for globals that
appeared in any file with an entry point. This breaks, however on files
that have an NSApplicationMain/UIApplicationMain class in them, where
the entry point is synthesized but top-level globals are not locally
scoped. This change re-uses SILGen's check and only skips variable
declarations that appear at top level in a script mode file.

Resolves rdar://43549749
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