Skip to content
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

Allow opting out of the default umbrella header, to support strict imports #348

Merged
merged 3 commits into from
Nov 12, 2021

Conversation

acecilia
Copy link
Contributor

@acecilia acecilia commented Nov 9, 2021

👋

This PR better supports strict imports, meaning files only import what they use, and they import everything they use.

See documentation in code for the full context 🙏

@acecilia acecilia changed the title Allow opting out of the legacy umbrella header, to support strict imports Allow opting out of the default umbrella header, to support strict imports Nov 11, 2021
@gyfelton
Copy link
Contributor

@acecilia Hi curious if you folks ever get any performance gain by turning it off?

gyfelton added a commit that referenced this pull request Aug 21, 2024
…lt umbrella header generated (#897)

### What changed:
1. When generate_default_umbrella_header is set to False, still add
statements around `extern double {module_name}VersionNumber;` to
umbrella header so that clang can resolve the situation when module_name
is the same for two different modules (where their path is diff).
2. When generate_default_umbrella_header is set to False, use `extern`
instead of `FOUNDATION_EXPORT` since `FOUNDATION_EXPORT` is `extern` and
trying to define it in `else` clause will cause `warning: ambiguous
expansion of macro 'FOUNDATION_EXPORT'` error.

### Why this change:
[The original PR](#348) that
introduced the flag `generate_default_umbrella_header` essentially wants
to not import UIKit/Foundation to restrict on what to import by default,
which is a good thing. However, it kinda overkill by also not including
the statements around version number and version string. Which
apparently affects how clang resolves module mapping (from a module name
to a path) and in our set up, leading to error similar to:
```
path/to/alice.modulemap:2:21: error: umbrella for module 'bob' already covers this directory

   umbrella header "foo-umbrella.h"
                    ^
```
For reference, this is originated from `diag::err_mmap_umbrella_clash`
error in https://github.com/llvm/llvm-project

For our case, the umbrella header name for both alice and bob modules
are `foo`, which is totally fine since their path is different. But for
some reason when trying to compile the code in a remote execution
service such as buildfarm, above error shows up. I cannot reproduce it
with `local` or `sandboxed` mode.

Now looking back, the theory is that when there is clash on umbrealla
header name, it will use the module's version string/number to figure
out which is which? I don't really have any other theory for now. I
cannot find such reference to `VersionNumber`/`VersionString` that is
meaningful. Nor can I setup a test case here since it only break remote
execution.

This does not revert the original PR in anyway, I still get to
implicitly import Foundation/UIKit with this change.

### Tests
No change on testing since this flag was not tested anywhere for now. I
can add this flag to some random testing targets in this PR though but
tests so far are still all passing with this turned off.
@acecilia
Copy link
Contributor Author

👋 Mmm it has been a long time, but I do not recall observing any major benefit on app size nor build time

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