2023-07-15 17:15:38 +00:00
|
|
|
diff --git i/passes/cmds/plugin.cc w/passes/cmds/plugin.cc
|
|
|
|
index 08b4aa8c4..f00f540e9 100644
|
|
|
|
--- i/passes/cmds/plugin.cc
|
|
|
|
+++ w/passes/cmds/plugin.cc
|
|
|
|
@@ -87,15 +87,33 @@ void load_plugin(std::string filename, std::vector<std::string> aliases)
|
2021-01-17 00:15:33 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
// We were unable to open the file, try to do so from the plugin directory
|
|
|
|
if (hdl == NULL && orig_filename.find('/') == std::string::npos) {
|
|
|
|
- hdl = dlopen([orig_filename]() {
|
|
|
|
- std::string new_path = proc_share_dirname() + "plugins/" + orig_filename;
|
|
|
|
+ std::string install_dir = proc_share_dirname() + "plugins";
|
|
|
|
|
|
|
|
- // Check if we need to append .so
|
|
|
|
- if (new_path.find(".so") == std::string::npos)
|
|
|
|
- new_path.append(".so");
|
|
|
|
+ vector<string> all_dirs;
|
|
|
|
+ all_dirs.push_back(install_dir);
|
|
|
|
|
|
|
|
- return new_path;
|
|
|
|
- }().c_str(), RTLD_LAZY|RTLD_LOCAL);
|
|
|
|
+ char* plugin_dirs = getenv("NIX_YOSYS_PLUGIN_DIRS");
|
|
|
|
+ if (plugin_dirs != NULL) {
|
|
|
|
+ std::string p(plugin_dirs), t;
|
|
|
|
+ std::stringstream ss(p);
|
2021-01-17 00:15:33 +00:00
|
|
|
+
|
2023-07-15 17:15:38 +00:00
|
|
|
+ while(std::getline(ss, t, ':')) {
|
|
|
|
+ all_dirs.push_back(t);
|
|
|
|
+ }
|
|
|
|
+ }
|
2021-01-17 00:15:33 +00:00
|
|
|
+
|
2023-07-15 17:15:38 +00:00
|
|
|
+ for (auto dir : all_dirs) {
|
|
|
|
+ hdl = dlopen([dir, orig_filename]() {
|
|
|
|
+ std::string new_path = dir + "/" + orig_filename;
|
2021-01-17 00:15:33 +00:00
|
|
|
+
|
2023-07-15 17:15:38 +00:00
|
|
|
+ // Check if we need to append .so
|
|
|
|
+ if (new_path.find(".so") == std::string::npos)
|
|
|
|
+ new_path.append(".so");
|
2021-01-17 00:15:33 +00:00
|
|
|
+
|
2023-07-15 17:15:38 +00:00
|
|
|
+ return new_path;
|
|
|
|
+ }().c_str(), RTLD_LAZY|RTLD_LOCAL);
|
|
|
|
+ if (hdl != NULL) break;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdl == NULL)
|