Skip to content

ModuleInterface: Setup logic to load distributed swiftinterfaces over swiftmodules by default #71617

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
Mar 12, 2024

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Feb 14, 2024

The Swift compiler can load either the binary swiftmodule file or the textual swiftinterface file when importing a module. It currently picks the swiftmodule over the swiftinterface, unless there’s an exception. We should flip the default for distributed modules, prefer the swiftinterface over the swiftmodule unless there’s an exception.

This PR only puts the logic in place, turning the new logic on by default will be done separately by adding the special blocklist item Swift_UseSwiftinterfaceByDefault.

rdar://122955640

@xymus
Copy link
Contributor Author

xymus commented Feb 14, 2024

@swift-ci Please smoke test

@@ -444,11 +444,19 @@ NOTE(compiled_module_ignored_reason,none,
"|it belongs to a framework in the SDK"
"|loading from module interfaces is preferred"
"|it's a compiler host module"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not new in this PR, but what does "host" mean in this context? When I see the diagnostic in the test, I find it a bit confusing since when I read "host" in a compilation context my impression is that it usually refers to a particular role in cross compilation. Here it just means it's in the resource dir, aka the toolchain, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it's for macros and refers to a cross-compilation concern, or at least bootstrapping.

@bnbarham Could you remind us why we ignore swiftmodules when isInResourceHostDir?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is really just an issue in our build/test infrastructure, as the modules won't even be there in the toolchain (or at least, they shouldn't be if they are 😅). The issue is that these libraries are built by the "host" (builder/) compiler, but are then read by the just-built compiler when eg. building libraries/executables in the tests. An alternative to this would be building the swiftmodule itself elsewhere during the build, I'd be open to that rather than this hack if you'd prefer as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll need an option in build systems to not install swiftmodules at some point. For this PR we could improve the proposed diagnostic, it sounds like it will be mostly us seeing it.

The Swift compiler can load either the binary swiftmodule file or the
textual swiftinterface file when importing a module. It currently picks
the swiftmodule over the swiftinterface, unless there’s an exception. We
should flip the default for distributed modules, prefer the
swiftinterface over the swiftmodule unless there’s an exception.

rdar://122955640
@xymus xymus force-pushed the swiftinterface-by-default-mode branch from d663696 to 4945cfc Compare February 27, 2024 18:27
@xymus
Copy link
Contributor Author

xymus commented Feb 27, 2024

@swift-ci Please smoke test

@cachemeifyoucan
Copy link
Contributor

What does this mean for explicit module build?

@xymus
Copy link
Contributor Author

xymus commented Feb 27, 2024

@cachemeifyoucan This change should affect explicit builds in the same way as implicit builds. Explicit module builds schedules the job to populate the module cache which relies on this logic to chose between rebuilding the swiftinterface or writing down a forwarding module.

@cachemeifyoucan
Copy link
Contributor

@cachemeifyoucan This change should affect explicit builds in the same way as implicit builds. Explicit module builds schedules the job to populate the module cache which relies on this logic to chose between rebuilding the swiftinterface or writing down a forwarding module.

Would be good to see a test for that case.

@xymus
Copy link
Contributor Author

xymus commented Mar 7, 2024

@swift-ci Please smoke test

1 similar comment
@xymus
Copy link
Contributor Author

xymus commented Mar 12, 2024

@swift-ci Please smoke test

@xymus xymus merged commit c13a4c5 into swiftlang:main Mar 12, 2024
@xymus xymus deleted the swiftinterface-by-default-mode branch March 12, 2024 14:52
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.

4 participants