Merge pull request #73725 from rintaro/macros-inproc-plugin

[Macros] In-process plugin server
This commit is contained in:
Rintaro Ishizaki
2024-06-26 06:33:38 -07:00
committed by GitHub
43 changed files with 729 additions and 893 deletions

View File

@@ -188,6 +188,37 @@ void CompilerInvocation::setDefaultBlocklistsIfNecessary() {
}
}
void CompilerInvocation::setDefaultInProcessPluginServerPathIfNecessary() {
if (!SearchPathOpts.InProcessPluginServerPath.empty())
return;
if (FrontendOpts.MainExecutablePath.empty())
return;
// '/usr/bin/swift'
SmallString<64> serverLibPath{FrontendOpts.MainExecutablePath};
llvm::sys::path::remove_filename(serverLibPath); // remove 'swift'
#if defined(_WIN32)
// Windows: usr\bin\SwiftInProcPluginServer.dll
llvm::sys::path::append(serverLibPath, "SwiftInProcPluginServer.dll");
#elif defined(__APPLE__)
// Darwin: usr/lib/swift/host/libSwiftInProcPluginServer.dylib
llvm::sys::path::remove_filename(serverLibPath); // remove 'bin'
llvm::sys::path::append(serverLibPath, "lib", "swift", "host");
llvm::sys::path::append(serverLibPath, "libSwiftInProcPluginServer.dylib");
#else
// Other: usr/lib/swift/host/libSwiftInProcPluginServer.so
llvm::sys::path::remove_filename(serverLibPath); // remove 'bin'
llvm::sys::path::append(serverLibPath, "lib", "swift", "host");
llvm::sys::path::append(serverLibPath, "libSwiftInProcPluginServer.so");
#endif
SearchPathOpts.InProcessPluginServerPath = serverLibPath.str();
}
static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
const FrontendOptions &FrontendOpts,
const LangOptions &LangOpts) {
@@ -1975,6 +2006,9 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
}
Opts.setFrameworkSearchPaths(FrameworkSearchPaths);
if (const Arg *A = Args.getLastArg(OPT_in_process_plugin_server_path))
Opts.InProcessPluginServerPath = A->getValue();
// All plugin search options, i.e. '-load-plugin-library',
// '-load-plugin-executable', '-plugin-path', and '-external-plugin-path'
// are grouped, and plugins are searched by the order of these options.
@@ -3521,6 +3555,7 @@ bool CompilerInvocation::parseArgs(
updateRuntimeLibraryPaths(SearchPathOpts, FrontendOpts, LangOpts);
setDefaultPrebuiltCacheIfNecessary();
setDefaultBlocklistsIfNecessary();
setDefaultInProcessPluginServerPathIfNecessary();
// Now that we've parsed everything, setup some inter-option-dependent state.
setIRGenOutputOptsFromFrontendOptions(IRGenOpts, FrontendOpts);