mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Do now write out bridging header dependencies of binary modules unless in CAS mode
We only record these dependencies in CAS mode, because we require explicit PCH tasks to be produced for imported header of binary module dependencies. In the meantime, in non-CAS mode loading clients will consume the `.h` files encoded in the `.swiftmodules` directly. Followup changes to SwiftDriver will enable explicit PCH compilation of such dependenceis, but for the time being restore prior behavior for non-CAS explicit module builds. Resolves rdar://116006619
This commit is contained in:
@@ -158,6 +158,7 @@ namespace swift {
|
|||||||
bool EmbeddedSwiftModule = false;
|
bool EmbeddedSwiftModule = false;
|
||||||
bool IsOSSA = false;
|
bool IsOSSA = false;
|
||||||
bool SkipNonExportableDecls = false;
|
bool SkipNonExportableDecls = false;
|
||||||
|
bool ExplicitModuleBuild = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace swift
|
} // end namespace swift
|
||||||
|
|||||||
@@ -240,6 +240,8 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
|
|||||||
|
|
||||||
serializationOpts.SkipNonExportableDecls = opts.SkipNonExportableDecls;
|
serializationOpts.SkipNonExportableDecls = opts.SkipNonExportableDecls;
|
||||||
|
|
||||||
|
serializationOpts.ExplicitModuleBuild = FrontendOpts.DisableImplicitModules;
|
||||||
|
|
||||||
return serializationOpts;
|
return serializationOpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1303,7 +1303,8 @@ void Serializer::writeInputBlock() {
|
|||||||
// We do not want to serialize the explicitly-specified .pch path if one was
|
// We do not want to serialize the explicitly-specified .pch path if one was
|
||||||
// provided. Instead we write out the path to the original header source so
|
// provided. Instead we write out the path to the original header source so
|
||||||
// that clients can consume it.
|
// that clients can consume it.
|
||||||
if (llvm::sys::path::extension(importedHeaderPath)
|
if (Options.ExplicitModuleBuild &&
|
||||||
|
llvm::sys::path::extension(importedHeaderPath)
|
||||||
.endswith(file_types::getExtension(file_types::TY_PCH)))
|
.endswith(file_types::getExtension(file_types::TY_PCH)))
|
||||||
importedHeaderPath = clangImporter->getClangInstance()
|
importedHeaderPath = clangImporter->getClangInstance()
|
||||||
.getASTReader()
|
.getASTReader()
|
||||||
|
|||||||
@@ -477,12 +477,19 @@ SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework) {
|
|||||||
|
|
||||||
auto importedHeaderSet = binaryModuleImports.get().headerImports;
|
auto importedHeaderSet = binaryModuleImports.get().headerImports;
|
||||||
std::vector<std::string> importedHeaders;
|
std::vector<std::string> importedHeaders;
|
||||||
importedHeaders.reserve(importedHeaderSet.size());
|
// FIXME: We only record these dependencies in CAS mode, because
|
||||||
llvm::transform(importedHeaderSet.keys(),
|
// we require explicit PCH tasks to be produced for imported header
|
||||||
std::back_inserter(importedHeaders),
|
// of binary module dependencies. In the meantime, in non-CAS mode
|
||||||
[](llvm::StringRef N) {
|
// loading clients will consume the `.h` files encoded in the `.swiftmodules`
|
||||||
return N.str();
|
// directly.
|
||||||
});
|
if (Ctx.ClangImporterOpts.CASOpts) {
|
||||||
|
importedHeaders.reserve(importedHeaderSet.size());
|
||||||
|
llvm::transform(importedHeaderSet.keys(),
|
||||||
|
std::back_inserter(importedHeaders),
|
||||||
|
[](llvm::StringRef N) {
|
||||||
|
return N.str();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
auto &importedOptionalModuleSet = binaryModuleOptionalImports.get().moduleImports;
|
auto &importedOptionalModuleSet = binaryModuleOptionalImports.get().moduleImports;
|
||||||
std::vector<std::string> importedOptionalModuleNames;
|
std::vector<std::string> importedOptionalModuleNames;
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
// RUN: %empty-directory(%t/clang-module-cache)
|
// RUN: %empty-directory(%t/clang-module-cache)
|
||||||
// RUN: %empty-directory(%t/PCH)
|
// RUN: %empty-directory(%t/PCH)
|
||||||
|
// RUN: %empty-directory(%t/HEADER)
|
||||||
// RUN: %empty-directory(%t/SwiftModules)
|
// RUN: %empty-directory(%t/SwiftModules)
|
||||||
|
// RUN: %empty-directory(%t/CAS)
|
||||||
|
|
||||||
// - Set up Foo Swift dependency
|
// - Set up Foo Swift dependency
|
||||||
// RUN: echo "extension Profiler {" >> %t/foo.swift
|
// RUN: echo "extension Profiler {" >> %t/foo.swift
|
||||||
@@ -10,10 +12,10 @@
|
|||||||
// RUN: echo "}" >> %t/foo.swift
|
// RUN: echo "}" >> %t/foo.swift
|
||||||
|
|
||||||
// - Set up Foo bridging header
|
// - Set up Foo bridging header
|
||||||
// RUN: echo "struct Profiler { void* ptr; };" >> %t/foo.h
|
// RUN: echo "struct Profiler { void* ptr; };" >> %t/HEADER/foo.h
|
||||||
|
|
||||||
// - Compile bridging header
|
// - Compile bridging header
|
||||||
// RUN: %target-swift-frontend -enable-objc-interop -emit-pch %t/foo.h -o %t/PCH/foo.pch -disable-implicit-swift-modules
|
// RUN: %target-swift-frontend -enable-objc-interop -emit-pch %t/HEADER/foo.h -o %t/PCH/foo.pch -disable-implicit-swift-modules
|
||||||
|
|
||||||
// - Set up explicit dependencies for Foo
|
// - Set up explicit dependencies for Foo
|
||||||
// RUN: %target-swift-emit-pcm -module-name SwiftShims %swift-lib-dir/swift/shims/module.modulemap -o %t/inputs/SwiftShims.pcm
|
// RUN: %target-swift-emit-pcm -module-name SwiftShims %swift-lib-dir/swift/shims/module.modulemap -o %t/inputs/SwiftShims.pcm
|
||||||
@@ -50,21 +52,27 @@
|
|||||||
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/SwiftModules/Foo.swiftmodule %t/foo.swift -module-name Foo -import-objc-header %t/PCH/foo.pch -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -disable-implicit-swift-modules -explicit-swift-module-map-file %t/foo_inputs_map.json
|
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/SwiftModules/Foo.swiftmodule %t/foo.swift -module-name Foo -import-objc-header %t/PCH/foo.pch -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -disable-implicit-swift-modules -explicit-swift-module-map-file %t/foo_inputs_map.json
|
||||||
|
|
||||||
// - Scan main module
|
// - Scan main module
|
||||||
// RUN: %target-swift-frontend -scan-dependencies %s -I %t/SwiftModules -I %S/Inputs/Swift -o %t/deps.json
|
// RUN: %target-swift-frontend -scan-dependencies %s -I %t/SwiftModules -I %S/Inputs/Swift -o %t/deps.json -cache-compile-job -cas-path %t/cas
|
||||||
// RUN: %validate-json %t/deps.json | %FileCheck %s
|
// RUN: %validate-json %t/deps.json | %FileCheck %s
|
||||||
|
|
||||||
|
// - Scan main module without a CAS and ensure no headerDependencies are emitted
|
||||||
|
// RUN: %target-swift-frontend -scan-dependencies %s -I %t/SwiftModules -I %S/Inputs/Swift -o %t/deps_nocas.json
|
||||||
|
// RUN: %validate-json %t/deps_nocas.json | %FileCheck %s --check-prefix=CHECK-NO-HEADERS
|
||||||
|
|
||||||
// CHECK: "swift": "FooClient"
|
// CHECK: "swift": "FooClient"
|
||||||
// CHECK: "swift": "FooClient"
|
// CHECK: "swift": "FooClient"
|
||||||
// CHECK: "swiftPrebuiltExternal": "Foo"
|
// CHECK: "swiftPrebuiltExternal": "Foo"
|
||||||
// CHECK: "commandLine": [
|
// CHECK: "commandLine": [
|
||||||
// CHECK: "-include-pch",
|
// CHECK: "-include-pch",
|
||||||
// CHECK-NEXT: "-Xcc",
|
// CHECK-NEXT: "-Xcc",
|
||||||
// CHECK-NEXT: "{{.*}}{{/|\\}}PCH{{/|\\}}foo.pch"
|
// CHECK-NEXT: "{{.*}}{{/|\\}}HEADER{{/|\\}}foo.h"
|
||||||
|
|
||||||
|
|
||||||
// CHECK: "swiftPrebuiltExternal": "Foo"
|
// CHECK: "swiftPrebuiltExternal": "Foo"
|
||||||
// CHECK: "headerDependencies": [
|
// CHECK: "headerDependencies": [
|
||||||
// CHECK: "{{.*}}{{/|\\}}PCH{{/|\\}}foo.pch"
|
// CHECK: "{{.*}}{{/|\\}}HEADER{{/|\\}}foo.h"
|
||||||
// CHECK: ],
|
// CHECK: ],
|
||||||
|
|
||||||
|
// CHECK-NO-HEADERS-NOT: "headerDependencies"
|
||||||
|
|
||||||
import FooClient
|
import FooClient
|
||||||
|
|||||||
Reference in New Issue
Block a user