Skip to content

Commit 1085746

Browse files
authored
Merge pull request #33212 from nkcsgexi/pass-down-main-path
Front-end: pass down main executable path to the sub-ASTContext for building module interfaces. NFC
2 parents 1420a38 + bfacad6 commit 1085746

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

include/swift/Frontend/FrontendOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ class FrontendOptions {
250250
/// Should we enable the dependency verifier for all primary files known to this frontend?
251251
bool EnableIncrementalDependencyVerifier = false;
252252

253+
/// The path of the swift-frontend executable.
254+
std::string MainExecutablePath;
255+
253256
/// The directory path we should use when print #include for the bridging header.
254257
/// By default, we include ImplicitObjCHeaderPath directly.
255258
llvm::Optional<std::string> BridgingHeaderDirForPrint;

include/swift/Frontend/ModuleInterfaceLoader.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,12 @@ struct ModuleInterfaceLoaderOptions {
266266
bool remarkOnRebuildFromInterface = false;
267267
bool disableInterfaceLock = false;
268268
bool disableImplicitSwiftModule = false;
269+
std::string mainExecutablePath;
269270
ModuleInterfaceLoaderOptions(const FrontendOptions &Opts):
270271
remarkOnRebuildFromInterface(Opts.RemarkOnRebuildFromModuleInterface),
271272
disableInterfaceLock(Opts.DisableInterfaceFileLock),
272-
disableImplicitSwiftModule(Opts.DisableImplicitModules) {}
273+
disableImplicitSwiftModule(Opts.DisableImplicitModules),
274+
mainExecutablePath(Opts.MainExecutablePath) {}
273275
ModuleInterfaceLoaderOptions() = default;
274276
};
275277

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
5252
}
5353

5454
void CompilerInvocation::setMainExecutablePath(StringRef Path) {
55+
FrontendOpts.MainExecutablePath = Path.str();
5556
llvm::SmallString<128> LibPath;
5657
computeRuntimeResourcePathFromExecutablePath(Path, LibPath);
5758
setRuntimeResourcePath(LibPath.str());

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
12681268
StringRef prebuiltCachePath,
12691269
bool serializeDependencyHashes,
12701270
bool trackSystemDependencies): SM(SM), Diags(Diags), ArgSaver(Allocator) {
1271+
subInvocation.setMainExecutablePath(LoaderOpts.mainExecutablePath);
12711272
inheritOptionsForBuildingInterface(searchPathOpts, langOpts);
12721273
// Configure front-end input.
12731274
auto &SubFEOpts = subInvocation.getFrontendOptions();

0 commit comments

Comments
 (0)