Skip to content

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

Merged

Conversation

nkcsgexi
Copy link
Contributor

@nkcsgexi nkcsgexi commented Aug 28, 2019

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

@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@jrose-apple jrose-apple left a 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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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
@nkcsgexi nkcsgexi force-pushed the frontend-opts-load-interface-for-module branch from 87c548c to 1e65666 Compare August 28, 2019 02:41
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi changed the title Frontend: add a front-end option to specify module names for which we prefer to loading via interfaces Frontend: add a front-end option to specify module names for which we prefer loading via interfaces Aug 28, 2019
@nkcsgexi nkcsgexi merged commit e29dc4e into swiftlang:master Aug 28, 2019
@nkcsgexi nkcsgexi deleted the frontend-opts-load-interface-for-module branch August 28, 2019 04:11
CacheDir, PrebuiltCacheDir, ModuleID.second,
RemarkOnRebuildFromInterface, dependencyTracker,
LoadMode);
llvm::is_contained(PreferInterfaceForModules,
ModuleName)?
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

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.

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