mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
34d52cfe1a
Compute and propagate the library level (api/spi/ipi) of each module dependency through the dependency scanner so that the compiler can correctly enforce private module import diagnostics in CAS mode, where path-based SPI detection fails because CAS abstracts file paths to content IDs. Swift modules: - Detect library level from the module interface path using libraryLevelFromPath() during scanning, for both textual (.swiftinterface) and binary (.swiftmodule) Swift modules. Clang modules: - Expose ModuleMapIsPrivate from clang::Module in ModuleDeps via the dependency scanning infrastructure. - Set library level for clang modules in bridgeClangModuleDependency() using ModuleMapIsPrivate (catches module.private.modulemap in any SDK location) and libraryLevelFromPath() on the module map file (catches modules under PrivateFrameworks directories). The library level is: - Stored in ModuleDependencyInfo and serialized in the module dependency cache (format version bumped to v8). - Exposed through the swiftscan C API via a new swiftscan_module_info_get_library_level() function (API minor version bumped to 3). - Emitted in the dependency scanner JSON output as "libraryLevel" for all module kinds (Swift textual, Swift binary, Clang, and main module). - Parsed from the explicit module map JSON by ExplicitModuleMapParser for both Swift (ExplicitSwiftModuleInputInfo) and Clang (ExplicitClangModuleInputInfo) modules. - Looked up in ModuleLibraryLevelRequest via ASTContext::getExplicitModuleLibraryLevel(name, isClang), which consults the appropriate map (Swift or Clang) based on module kind. rdar://172693314 Assisted-By: Claude
50 lines
2.3 KiB
Swift
50 lines
2.3 KiB
Swift
// This test ensures that the parent invocation's '-validate-clang-modules-once' flag is inherited when building dependency modules
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: touch %t/Build.session
|
|
|
|
// RUN: %target-build-swift -module-name TestModule -module-link-name TestModule %S/Inputs/TestModule.swift -enable-library-evolution -emit-module-interface -o %t/TestModule.swiftmodule -swift-version 5 -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import
|
|
|
|
// RUN: %target-swift-frontend -scan-dependencies -no-scanner-module-validation %s -o %t/deps.json -I%t -validate-clang-modules-once -clang-build-session-file %t/Build.session -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import
|
|
// RUN: %validate-json %t/deps.json &>/dev/null
|
|
// RUN: %FileCheck %s < %t/deps.json
|
|
|
|
import TestModule
|
|
|
|
// CHECK: "directDependencies": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-DAG: "swift": "TestModule"
|
|
// CHECK-DAG: "swift": "Swift"
|
|
// CHECK-DAG: "swift": "SwiftOnoneSupport"
|
|
|
|
// Additional occurence in source-imported dependencies field
|
|
// CHECK: "swift": "TestModule"
|
|
|
|
// CHECK: "swift": "TestModule"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "modulePath": "{{.*}}TestModule-{{.*}}.swiftmodule",
|
|
// CHECK-NEXT: "libraryLevel":
|
|
// CHECK-NEXT: "sourceFiles": [
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "directDependencies": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "swift": "Swift"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "swift": "SwiftOnoneSupport"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "linkLibraries": [
|
|
// CHECK: "details": {
|
|
// CHECK-NEXT: "swift": {
|
|
// CHECK-NEXT: "moduleInterfacePath":
|
|
// CHECK-NEXT: "compiledModuleCandidates": [
|
|
// CHECK-NEXT: TestModule.swiftmodule
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "commandLine": [
|
|
// CHECK-NEXT: "-frontend",
|
|
// CHECK-NEXT: "-compile-module-from-interface",
|
|
// CHECK: "-validate-clang-modules-once",
|
|
// CHECK-NEXT: "-clang-build-session-file",
|
|
// CHECK-NEXT: "{{.*}}Build.session"
|