Skip to content

[Macros] Plugin search options group #66650

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
Jun 15, 2023

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jun 14, 2023

load-plugin-library, load-plugin-executable, -plugin-path and -external-plugin-path should be searched in the order they are specified in the arguments.

Previously, for example -plugin-path used to precede -external-plugin-path regardless of the position in the arguments.

@rintaro rintaro force-pushed the macros-plugins-searchopts branch from f18d241 to 090fcda Compare June 14, 2023 22:35
@@ -34,7 +35,6 @@ enum class ModuleSearchPathKind {
Framework,
DarwinImplicitFramework,
RuntimeLibrary,
CompilerPlugin,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModuleSearchPathKind::CompilePlugin was incomplete (only set for -load-plugin-library), and was not actually used.

enum class SearchPathKind : uint8_t {
Import = 1 << 0,
Framework = 1 << 1,
CompilerPlugin = 1 << 2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto: SearchPathKind::CompilerPlugin wasn't actually used.

void setCompilerPluginLibraryPaths(
std::vector<std::string> NewCompilerPluginLibraryPaths) {
CompilerPluginLibraryPaths = NewCompilerPluginLibraryPaths;
Lookup.searchPathsDidChange();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugin search doesn't use Lookup, and adding plugin search path won't affect import module search path. So we don't need to call Lookup.searchPathsDidChange() when updating PluginSearchOpts.

pluginLibBasename.append(moduleName.str());
pluginLibBasename.append(LTDL_SHLIB_EXT);

// FIXME: Should we create a lookup table keyed by module name?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we create a lookup table for -load-plugin-executable only. But we could lazily create a lookup table for all keyed by module names. But that's need to scan (iterate directory entries) all search paths, so I'm not sure it worth it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to do the one scan rather than the continual exists checks, but not doing that in this PR is fine IMO.

@@ -15,7 +15,6 @@
// CHECK: -plugin-path: {{.*}}plugins
// CHECK: -plugin-path: {{.*}}plugins
// CHECK: -plugin-path: {{.*}}plugins
// CHECK: -plugin-path: {{.*}}plugins
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously manually specified -plugin-path was duplicated in libDriver.

'load-plugin-library', 'load-plugin-executable', '-plugin-path' and
'-external-plugin-path' should be searched in the order they are
specified in the arguments.

Previously, for example '-plugin-path' used to precede
'-external-plugin-path' regardless of the position in the arguments.
@rintaro rintaro force-pushed the macros-plugins-searchopts branch from 090fcda to 5791a2c Compare June 14, 2023 22:46
pair.ModuleNames, [&](auto &name) { optStr += name; },
[&]() { optStr += ","; });
serializationOpts.CompilerPluginExecutablePaths.push_back(optStr);
// FIXME: Preserve the order of these options.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you intentionally trying to avoid changing the module serialization format here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my intension is doing it in a followup.

@rintaro
Copy link
Member Author

rintaro commented Jun 14, 2023

@swift-ci Please smoke test

pluginLibBasename.append(moduleName.str());
pluginLibBasename.append(LTDL_SHLIB_EXT);

// FIXME: Should we create a lookup table keyed by module name?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better to do the one scan rather than the continual exists checks, but not doing that in this PR is fine IMO.

case OPT_external_plugin_path: {
// '<plugin directory>#<plugin server executable path>'.
// FIXME: '#' can be used in the paths.
StringRef dylibPath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily a dylib

// RUN: -module-name test \
// RUN: -load-plugin-executable %t/libexec/MacroDefinitionPlugin#MacroDefinition \
// RUN: -plugin-path %t/lib/plugins \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add -load-plugin-library here too?

// RUN: -external-plugin-path %t/external#%swift-plugin-server \
// RUN: -plugin-path %t/lib/plugins \
// RUN: -load-plugin-executable %t/libexec/MacroDefinitionPlugin#MacroDefinition \
// RUN: -o %t/main4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

@rintaro
Copy link
Member Author

rintaro commented Jun 15, 2023

swiftlang/llvm-project#6998
@swift-ci Please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants