Skip to content

Commit 55cc29f

Browse files
committed
[Explicit Module Build] Execute module interface verification in a sub-invocation context
Otherwise, with `-explicit-interface-module-build` they do not read out/inherit compiler flags written in the interface itself. Resolves rdar://122418125
1 parent 906d261 commit 55cc29f

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

Diff for: lib/Frontend/ModuleInterfaceLoader.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,10 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
17681768
if (LoaderOpts.disableImplicitSwiftModule) {
17691769
genericSubInvocation.getFrontendOptions().DisableImplicitModules = true;
17701770
GenericArgs.push_back("-disable-implicit-swift-modules");
1771+
GenericArgs.push_back("-Xcc");
1772+
GenericArgs.push_back("-fno-implicit-modules");
1773+
GenericArgs.push_back("-Xcc");
1774+
GenericArgs.push_back("-fno-implicit-module-maps");
17711775
}
17721776
// If building an application extension, make sure API use
17731777
// is restricted accordingly in downstream dependnecies.
@@ -1780,7 +1784,6 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
17801784
ParentInvocationTarget = langOpts.Target;
17811785

17821786
// Pass down -explicit-swift-module-map-file
1783-
// FIXME: we shouldn't need this. Remove it?
17841787
StringRef explicitSwiftModuleMap = searchPathOpts.ExplicitSwiftModuleMap;
17851788
genericSubInvocation.getSearchPathOptions().ExplicitSwiftModuleMap =
17861789
explicitSwiftModuleMap.str();

Diff for: lib/FrontendTool/FrontendTool.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,13 @@ static bool buildModuleFromInterface(CompilerInstance &Instance) {
413413
// If an explicit interface build was requested, bypass the creation of a new
414414
// sub-instance from the interface which will build it in a separate thread,
415415
// and isntead directly use the current \c Instance for compilation.
416-
if (FEOpts.ExplicitInterfaceBuild)
416+
//
417+
// FIXME: -typecheck-module-from-interface is the exception here because
418+
// currently we need to ensure it still reads the flags written out
419+
// in the .swiftinterface file itself. Instead, creation of that
420+
// job should incorporate those flags.
421+
if (FEOpts.ExplicitInterfaceBuild &&
422+
!(FEOpts.isTypeCheckAction() && !FEOpts.EnableCaching))
417423
return ModuleInterfaceLoader::buildExplicitSwiftModuleFromSwiftInterface(
418424
Instance, Invocation.getClangModuleCachePath(),
419425
FEOpts.BackupModuleInterfaceDir, PrebuiltCachePath, ABIPath, InputPath,

Diff for: test/ScanDependencies/explicit-module-map-typecheck-module-from-interface.swift renamed to test/ScanDependencies/explicit-typecheck-from-interface.swift

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
// REQUIRES: objc_interop, OS=macosx
12
// RUN: %empty-directory(%t)
23
// RUN: mkdir -p %t/clang-module-cache
34
// RUN: mkdir -p %t/inputs
45
// RUN: echo "/// Some cool comments" > %t/foo.swift
56
// RUN: echo "public func foo() {}" >> %t/foo.swift
6-
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/inputs/Foo.swiftmodule -emit-module-interface-path %t/Foo.swiftinterface \
7+
// RUN: %target-swift-emit-pcm -module-name SwiftShims %swift-lib-dir/swift/shims/module.modulemap -o %t/inputs/SwiftShims.pcm
8+
// RUN: %target-swift-emit-pcm -module-name _SwiftConcurrencyShims %swift-lib-dir/swift/shims/module.modulemap -o %t/inputs/_SwiftConcurrencyShims.pcm
9+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/inputs/Foo.swiftmodule -emit-module-interface-path %t/Foo.swiftinterface -alias-module-names-in-module-interface \
710
// RUN: -swift-version 5 -enable-library-evolution -module-cache-path %t.module-cache %t/foo.swift -module-name Foo
811

912
// RUN: echo "[{" > %/t/inputs/map.json
@@ -29,14 +32,22 @@
2932
// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json
3033
// RUN: echo "}," >> %/t/inputs/map.json
3134
// RUN: echo "{" >> %/t/inputs/map.json
35+
// RUN: echo "\"moduleName\": \"SwiftShims\"," >> %/t/inputs/map.json
36+
// RUN: echo "\"isFramework\": false," >> %/t/inputs/map.json
37+
// RUN: echo "\"clangModuleMapPath\": \"%swift-lib-dir/swift/shims/module.modulemap\"," >> %/t/inputs/map.json
38+
// RUN: echo "\"clangModulePath\": \"%t/inputs/SwiftShims.pcm\"" >> %/t/inputs/map.json
39+
// RUN: echo "}," >> %/t/inputs/map.json
40+
// RUN: echo "{" >> %/t/inputs/map.json
41+
// RUN: echo "\"moduleName\": \"_SwiftConcurrencyShims\"," >> %/t/inputs/map.json
42+
// RUN: echo "\"isFramework\": false," >> %/t/inputs/map.json
43+
// RUN: echo "\"clangModuleMapPath\": \"%swift-lib-dir/swift/shims/module.modulemap\"," >> %/t/inputs/map.json
44+
// RUN: echo "\"clangModulePath\": \"%t/inputs/_SwiftConcurrencyShims.pcm\"" >> %/t/inputs/map.json
45+
// RUN: echo "}," >> %/t/inputs/map.json
46+
// RUN: echo "{" >> %/t/inputs/map.json
3247
// RUN: echo "\"moduleName\": \"_StringProcessing\"," >> %/t/inputs/map.json
3348
// RUN: echo "\"modulePath\": \"%/string_processing_module\"," >> %/t/inputs/map.json
3449
// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json
3550
// RUN: echo "}]" >> %/t/inputs/map.json
3651

3752
// RUN: %target-swift-frontend -typecheck-module-from-interface %t/Foo.swiftinterface -module-cache-path %t.module-cache \
38-
// RUN: -explicit-interface-module-build -explicit-swift-module-map-file %t/inputs/map.json -Rmodule-loading -Xcc -Rmodule-import 2>&1 | %FileCheck %s
39-
40-
// CHECK-DAG: loaded module 'Swift'
41-
// CHECK-DAG: loaded module '_StringProcessing'
42-
// CHECK-DAG: loaded module '_Concurrency'
53+
// RUN: -explicit-interface-module-build -explicit-swift-module-map-file %t/inputs/map.json -disable-implicit-swift-modules -verify

0 commit comments

Comments
 (0)