Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1diff --git i/passes/cmds/plugin.cc w/passes/cmds/plugin.cc 2index 08b4aa8c4..f00f540e9 100644 3--- i/passes/cmds/plugin.cc 4+++ w/passes/cmds/plugin.cc 5@@ -87,15 +87,33 @@ void load_plugin(std::string filename, std::vector<std::string> aliases) 6 7 // We were unable to open the file, try to do so from the plugin directory 8 if (hdl == NULL && orig_filename.find('/') == std::string::npos) { 9- hdl = dlopen([orig_filename]() { 10- std::string new_path = proc_share_dirname() + "plugins/" + orig_filename; 11+ std::string install_dir = proc_share_dirname() + "plugins"; 12 13- // Check if we need to append .so 14- if (new_path.find(".so") == std::string::npos) 15- new_path.append(".so"); 16+ vector<string> all_dirs; 17+ all_dirs.push_back(install_dir); 18 19- return new_path; 20- }().c_str(), RTLD_LAZY|RTLD_LOCAL); 21+ char* plugin_dirs = getenv("NIX_YOSYS_PLUGIN_DIRS"); 22+ if (plugin_dirs != NULL) { 23+ std::string p(plugin_dirs), t; 24+ std::stringstream ss(p); 25+ 26+ while(std::getline(ss, t, ':')) { 27+ all_dirs.push_back(t); 28+ } 29+ } 30+ 31+ for (auto dir : all_dirs) { 32+ hdl = dlopen([dir, orig_filename]() { 33+ std::string new_path = dir + "/" + orig_filename; 34+ 35+ // Check if we need to append .so 36+ if (new_path.find(".so") == std::string::npos) 37+ new_path.append(".so"); 38+ 39+ return new_path; 40+ }().c_str(), RTLD_LAZY|RTLD_LOCAL); 41+ if (hdl != NULL) break; 42+ } 43 } 44 45 if (hdl == NULL)