Skip to content

[ModuleInterface] Determine package-only resolution need based on input mode #78867

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
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2306,9 +2306,10 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
Opts.ScannerModuleValidation |= Args.hasFlag(OPT_scanner_module_validation,
OPT_no_scanner_module_validation,
CASOpts.EnableCaching);

bool buildingFromInterface =
FrontendOptions::doesActionBuildModuleFromInterface(
FrontendOpts.RequestedAction);
FrontendOpts.InputMode ==
FrontendOptions::ParseInputMode::SwiftModuleInterface;
auto firstInputPath =
FrontendOpts.InputsAndOutputs.hasInputs()
? FrontendOpts.InputsAndOutputs.getFilenameOfFirstInput()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/module-cache)
// RUN: %empty-directory(%t/Swift)
// RUN: %empty-directory(%t/OtherSwift)
// RUN: split-file %s %t

// Build in-package ModuleC
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/OtherSwift/ModuleC.swiftmodule -module-name ModuleC -package-name TestPak %t/C.swift

// Build in-package ModuleB
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Swift/ModuleB.swiftmodule -enable-library-evolution -emit-module-interface-path %t/Swift/ModuleB.swiftinterface -module-name ModuleB -package-name TestPak %t/B.swift -I%t/OtherSwift

// Build in-package ModuleA
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Swift/ModuleA.swiftmodule -enable-library-evolution -emit-module-interface-path %t/Swift/ModuleA.swiftinterface -module-name ModuleA -package-name TestPak %t/A.swift -I%t/Swift -I%t/OtherSwift

// Remove binary module for A to make sure an implicit interface compile gets triggered
// RUN: rm %t/Swift/ModuleA.swiftmodule
// Remove in-package-only dependency of B to ensure that if the compiler looks for it, compilation will fail
// RUN: rm %t/OtherSwift/ModuleC.swiftmodule

// Build out-of-package client source
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Swift/Client.swiftmodule -module-name Client %t/Client.swift -I%t/Swift

//--- C.swift
public func c() {}

//--- B.swift
package import ModuleC

//--- A.swift
@_exported public import ModuleB

//--- Client.swift
import ModuleA