Skip to content

Commit aee4579

Browse files
committed
Invoke Explicit Interface Build when '-explicit-interface-module-build' is specified on a '-compile-module-from-interface' frontend action, using the CompilerInstance instantiated directly from the command-line in order to build the module.
1 parent a90d3e2 commit aee4579

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ WARNING(warning_cannot_find_locale_file,none,
9999
"cannot find translations for '%0' at '%1': no such file", (StringRef, StringRef))
100100
WARNING(warning_cannot_multithread_batch_mode,none,
101101
"ignoring -num-threads argument; cannot multithread batch mode", ())
102-
ERROR(error_cannot_ignore_interface_options_in_mode,none,
103-
"'-ignore-interface-provided-options' only supported when building a module from interface ('-compile-module-from-interface')'", ())
102+
ERROR(error_cannot_explicit_interface_build_in_mode,none,
103+
"'-explicit-interface-module-build' only supported when building a module from interface ('-compile-module-from-interface')'", ())
104104
ERROR(error_unsupported_option_argument,none,
105105
"unsupported argument '%1' to option '%0'", (StringRef, StringRef))
106106
ERROR(error_immediate_mode_missing_stdlib,none,

lib/FrontendTool/FrontendTool.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,26 @@ static bool buildModuleFromInterface(CompilerInstance &Instance) {
422422
StringRef PrebuiltCachePath = FEOpts.PrebuiltModuleCachePath;
423423
ModuleInterfaceLoaderOptions LoaderOpts(FEOpts);
424424
StringRef ABIPath = Instance.getPrimarySpecificPathsForAtMostOnePrimary()
425-
.SupplementaryOutputs.ABIDescriptorOutputPath;
426-
427-
428-
429-
return ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
425+
.SupplementaryOutputs.ABIDescriptorOutputPath;
426+
427+
// If an explicit interface build was requested, bypass the creation of a new
428+
// sub-instance from the interface which will build it in a separate thread,
429+
// and isntead directly use the current \c Instance for compilation.
430+
if (FEOpts.ExplicitInterfaceBuild)
431+
return ModuleInterfaceLoader::buildExplicitSwiftModuleFromSwiftInterface(
432+
Instance, Invocation.getClangModuleCachePath(),
433+
FEOpts.BackupModuleInterfaceDir, PrebuiltCachePath, ABIPath, InputPath,
434+
Invocation.getOutputFilename(),
435+
FEOpts.SerializeModuleInterfaceDependencyHashes,
436+
Invocation.getSearchPathOptions().CandidateCompiledModules);
437+
else
438+
return ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
430439
Instance.getSourceMgr(), Instance.getDiags(),
431440
Invocation.getSearchPathOptions(), Invocation.getLangOptions(),
432441
Invocation.getClangImporterOptions(),
433442
Invocation.getClangModuleCachePath(), PrebuiltCachePath,
434-
FEOpts.BackupModuleInterfaceDir,
435-
Invocation.getModuleName(), InputPath, Invocation.getOutputFilename(), ABIPath,
443+
FEOpts.BackupModuleInterfaceDir, Invocation.getModuleName(), InputPath,
444+
Invocation.getOutputFilename(), ABIPath,
436445
FEOpts.SerializeModuleInterfaceDependencyHashes,
437446
FEOpts.shouldTrackSystemDependencies(), LoaderOpts,
438447
RequireOSSAModules_t(Invocation.getSILOptions()));

test/ModuleInterface/IgnoreInterfaceFlags.swiftinterface renamed to test/ModuleInterface/ExplicitInterfaceBuild.swiftinterface

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
// REQUIRES: OS=macosx
55
// RUN: %empty-directory(%t)
6-
// Without '-ignore-interface-provided-options' this job fails because of the mismatch in 'module-name'
7-
// RUN: %target-swift-frontend -compile-module-from-interface -module-name IgnoresFlags -ignore-interface-provided-options -o %/t/IgnoresFlags.swiftmodule %s -verify
6+
// Without '-explicit-interface-module-build' this job fails because of the mismatch in 'module-name'
7+
// RUN: %target-swift-frontend -compile-module-from-interface -module-name IgnoresFlags -explicit-interface-module-build -o %/t/IgnoresFlags.swiftmodule %s -verify
88

99
import Swift
1010
extension Int {
1111
public static var fortytwo: Int = 42
12-
}
12+
}

0 commit comments

Comments
 (0)