diff --git a/include/swift/Frontend/FrontendOptions.h b/include/swift/Frontend/FrontendOptions.h index 34473a06be232..4c9afa649e6b5 100644 --- a/include/swift/Frontend/FrontendOptions.h +++ b/include/swift/Frontend/FrontendOptions.h @@ -250,6 +250,9 @@ class FrontendOptions { /// Should we enable the dependency verifier for all primary files known to this frontend? bool EnableIncrementalDependencyVerifier = false; + /// The path of the swift-frontend executable. + std::string MainExecutablePath; + /// The directory path we should use when print #include for the bridging header. /// By default, we include ImplicitObjCHeaderPath directly. llvm::Optional BridgingHeaderDirForPrint; diff --git a/include/swift/Frontend/ModuleInterfaceLoader.h b/include/swift/Frontend/ModuleInterfaceLoader.h index 6d80cd8b8b99e..997cd2b49ac2a 100644 --- a/include/swift/Frontend/ModuleInterfaceLoader.h +++ b/include/swift/Frontend/ModuleInterfaceLoader.h @@ -266,10 +266,12 @@ struct ModuleInterfaceLoaderOptions { bool remarkOnRebuildFromInterface = false; bool disableInterfaceLock = false; bool disableImplicitSwiftModule = false; + std::string mainExecutablePath; ModuleInterfaceLoaderOptions(const FrontendOptions &Opts): remarkOnRebuildFromInterface(Opts.RemarkOnRebuildFromModuleInterface), disableInterfaceLock(Opts.DisableInterfaceFileLock), - disableImplicitSwiftModule(Opts.DisableImplicitModules) {} + disableImplicitSwiftModule(Opts.DisableImplicitModules), + mainExecutablePath(Opts.MainExecutablePath) {} ModuleInterfaceLoaderOptions() = default; }; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 837d536df6103..785c9e22303eb 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -52,6 +52,7 @@ void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath( } void CompilerInvocation::setMainExecutablePath(StringRef Path) { + FrontendOpts.MainExecutablePath = Path.str(); llvm::SmallString<128> LibPath; computeRuntimeResourcePathFromExecutablePath(Path, LibPath); setRuntimeResourcePath(LibPath.str()); diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index a8e0451722ec7..dd12f0734e365 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -1268,6 +1268,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl( StringRef prebuiltCachePath, bool serializeDependencyHashes, bool trackSystemDependencies): SM(SM), Diags(Diags), ArgSaver(Allocator) { + subInvocation.setMainExecutablePath(LoaderOpts.mainExecutablePath); inheritOptionsForBuildingInterface(searchPathOpts, langOpts); // Configure front-end input. auto &SubFEOpts = subInvocation.getFrontendOptions();