depot/pkgs/development/compilers/yosys/plugin-search-dirs.patch
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

45 lines
1.5 KiB
Diff

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)
// 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);
+
+ while(std::getline(ss, t, ':')) {
+ all_dirs.push_back(t);
+ }
+ }
+
+ for (auto dir : all_dirs) {
+ hdl = dlopen([dir, orig_filename]() {
+ std::string new_path = dir + "/" + orig_filename;
+
+ // Check if we need to append .so
+ if (new_path.find(".so") == std::string::npos)
+ new_path.append(".so");
+
+ return new_path;
+ }().c_str(), RTLD_LAZY|RTLD_LOCAL);
+ if (hdl != NULL) break;
+ }
}
if (hdl == NULL)