Skip to content

Commit 72e5919

Browse files
authored
Merge pull request #64528 from DougGregor/old-driver-plugin-path
[Driver] Implement inference of `-plugin-path` arguments.
2 parents cc43326 + 928c821 commit 72e5919

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/Driver/ToolChains.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,32 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
376376
inputArgs.AddAllArgs(arguments, options::OPT_file_compilation_dir);
377377
}
378378

379+
// Add plugin path options.
380+
inputArgs.AddAllArgs(arguments, options::OPT_plugin_path);
381+
382+
{
383+
SmallString<64> pluginPath;
384+
auto programPath = getDriver().getSwiftProgramPath();
385+
CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
386+
programPath, /*shared=*/true, pluginPath);
387+
388+
auto defaultPluginPath = pluginPath;
389+
llvm::sys::path::append(defaultPluginPath, "host", "plugins");
390+
391+
// Default plugin path.
392+
arguments.push_back("-plugin-path");
393+
arguments.push_back(inputArgs.MakeArgString(defaultPluginPath));
394+
395+
// Local plugin path.
396+
llvm::sys::path::remove_filename(pluginPath); // Remove "swift"
397+
llvm::sys::path::remove_filename(pluginPath); // Remove "lib"
398+
llvm::sys::path::append(pluginPath, "local", "lib");
399+
llvm::sys::path::append(pluginPath, "swift");
400+
llvm::sys::path::append(pluginPath, "host", "plugins");
401+
arguments.push_back("-plugin-path");
402+
arguments.push_back(inputArgs.MakeArgString(pluginPath));
403+
}
404+
379405
// Pass through any subsystem flags.
380406
inputArgs.AddAllArgs(arguments, options::OPT_Xllvm);
381407
inputArgs.AddAllArgs(arguments, options::OPT_Xcc);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 %s 2>^1 | %FileCheck %s
2+
3+
// CHECK: -plugin-path
4+
// CHECK-SAME: {{(/|\\\\)}}lib{{(/|\\\\)}}swift{{(/|\\\\)}}host{{(/|\\\\)}}plugins
5+
6+
// CHECK-SAME: -plugin-path
7+
// CHECK-SAME: {{(/|\\\\)}}local{{(/|\\\\)}}lib{{(/|\\\\)}}swift{{(/|\\\\)}}host{{(/|\\\\)}}plugins

0 commit comments

Comments
 (0)