-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Frontend: add a front-end option to specify module names for which we prefer loading via interfaces #26894
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
Frontend: add a front-end option to specify module names for which we prefer loading via interfaces #26894
Conversation
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, only small comments. The test confuses me quite a bit, though!
// Dump Json file for cake ABI via .swiftinteface file | ||
// RUN: %api-digester -dump-sdk -module cake -o - -module-cache-path %t.module-cache %clang-importer-sdk-nosource -I %t.mod1 -I %S/Inputs/APINotesLeft -abi -use-interface-for-module cake > %t.dump2.json | ||
|
||
// Compare two Json files and we should see some differences. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we seeing differences here? It looks like you're building the swiftmodule and the swiftinterface from the same build settings, so they should have identical public contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice here we are comparing two Json files: the first Json file is a dump from loading the interface; the second Json file is a dump from loading the binary format generated directly from the source code. The difference is due to that source-generated swiftmodule files can diverge from the swiftmodule files generated from interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they do, that's a bug. How are these differences coming up?
… prefer to loading via interfaces ABI checker imports Swift frameworks by using Swift interfaces for various reasons. The existing way of controlling preferred importing mechanism is by setting an environment variable (SWIFT_FORCE_MODULE_LOADING), which may lead to performance issues because the stdlib could also be loaded in this way. This patch adds a new front-end option to specify module names for which we prefer to importing via Swift interface. The option currently is only accessible via swift-api-digester. rdar://54559888
87c548c
to
1e65666
Compare
@swift-ci please smoke test |
CacheDir, PrebuiltCacheDir, ModuleID.second, | ||
RemarkOnRebuildFromInterface, dependencyTracker, | ||
LoadMode); | ||
llvm::is_contained(PreferInterfaceForModules, | ||
ModuleName)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a space again.
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t.mod1/cake.swiftinterface %S/Inputs/cake_baseline/cake.swift -I %S/Inputs/APINotesLeft %clang-importer-sdk-nosource -parse-as-library -enable-library-evolution -disable-objc-attr-requires-foundation-module -module-cache-path %t.module-cache | ||
|
||
// Generate .swiftmodule file for module cake | ||
// RUN: %target-swift-frontend -emit-module -o %t.mod1/cake.swiftmodule %S/Inputs/cake_baseline/cake.swift -I %S/Inputs/APINotesLeft %clang-importer-sdk-nosource -parse-as-library -disable-objc-attr-requires-foundation-module -module-cache-path %t.module-cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. You forgot -enable-library-evolution
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the other changes should not happen, and if they do that's a problem.
@@ -42,8 +42,10 @@ class SerializedModuleLoaderBase : public ModuleLoader { | |||
protected: | |||
ASTContext &Ctx; | |||
ModuleLoadingMode LoadMode; | |||
ArrayRef<std::string> PreferInterfaceForModules; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed this the first time around. This doesn't belong in SerializedModuleLoaderBase; please move it up to ParseableInterfaceModuleLoader.
ABI checker imports Swift frameworks by using Swift interfaces for various
reasons. The existing way of controlling preferred importing mechanism is by
setting an environment variable (SWIFT_FORCE_MODULE_LOADING), which may lead
to performance issues because the stdlib could also be loaded in this way.
This patch adds a new front-end option to specify module names for
which we prefer importing via Swift interface. The option currently is only
accessible via swift-api-digester.
rdar://54559888