Skip to content

Front-end: pass down main executable path to the sub-ASTContext for building module interfaces. NFC #33212

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
Jul 31, 2020
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
3 changes: 3 additions & 0 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> BridgingHeaderDirForPrint;
Expand Down
4 changes: 3 additions & 1 deletion include/swift/Frontend/ModuleInterfaceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
1 change: 1 addition & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions lib/Frontend/ModuleInterfaceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down