Skip to content

[Frontend] Add option to explicitly import Builtin #63734

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
Feb 21, 2023

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Feb 16, 2023

This PR adds a new frontend option, -enable-builtin-module, that enables a module to explicitly import Builtin when needed. As part of this, the explicit import gets emitted into interface files so that we no longer implicitly import this module.

Motivation for this new flag includes the fact that standard library modules who are not the core sometimes need to access these builtins, but can only do so via -parse-stdlib who in itself bring along lots of other quirks that don't apply to these modules. The biggest is that the standard library is unconditionally built with -assert-config Debug even in release modes of the standard library. Modules using this flag and using stdlib APIs who have _debugPreconditions must incur the code size and branch of these preconditions even though they may not want them in opaque parts of their libraries. With this new flag, those modules can explicitly import Builtin and remove their dependence on -parse-stdlib allowing them to 1. implicitly get import Swift like normal Swift code and 2. be built as normal Swift code. It would be nice if one day we sunsetted -parse-stdlib and all of the unique flags that come along with it were explicit in the stdlib's build settings.

@Azoy
Copy link
Contributor Author

Azoy commented Feb 16, 2023

@swift-ci please test

@xedin xedin removed their request for review February 17, 2023 18:01
@Azoy
Copy link
Contributor Author

Azoy commented Feb 17, 2023

@swift-ci please test macOS

@Azoy Azoy merged commit 10f85db into swiftlang:main Feb 21, 2023
@Azoy Azoy deleted the builtin-flag branch February 21, 2023 06:08
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.

2 participants