Merge pull request #109461 from thoughtpolice/nixpkgs/yosys-plugins
yosys: add support for loading plugins, revert symbiflow changes
This commit is contained in:
@@ -5,13 +5,15 @@ assert backend == "mcode" || backend == "llvm";
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "ghdl-${backend}";
|
||||
version = "0.37";
|
||||
# NOTE(aseipp): move to 0.38 when it comes out, since it should support a stable
|
||||
# version of the yosys plugin
|
||||
version = "unstable-2021.01.14";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ghdl";
|
||||
repo = "ghdl";
|
||||
rev = "v${version}";
|
||||
sha256 = "0b53yl4im33c1cd4mdyc4ks9cmrpixym17gzchfmplrl22w3l17y";
|
||||
owner = "ghdl";
|
||||
repo = "ghdl";
|
||||
rev = "4868294436574660552ccef50a5b0849559393de";
|
||||
sha256 = "1wqjf0qc66dam1n2mskmlvj53bcsdwwk5rq9gimq6ah1vcwi222p";
|
||||
};
|
||||
|
||||
LIBRARY_PATH = "${stdenv.cc.libc}/lib";
|
||||
@@ -23,7 +25,7 @@ stdenv.mkDerivation rec {
|
||||
sed -i 's/check_version 7.0/check_version 7/g' configure
|
||||
'';
|
||||
|
||||
configureFlags = lib.optional (backend == "llvm")
|
||||
configureFlags = [ "--enable-synth" ] ++ lib.optional (backend == "llvm")
|
||||
"--with-llvm-config=${llvm}/bin/llvm-config";
|
||||
|
||||
hardeningDisable = [ "format" ];
|
||||
@@ -33,7 +35,7 @@ stdenv.mkDerivation rec {
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/ghdl/ghdl";
|
||||
description = "VHDL 2008/93/87 simulator";
|
||||
maintainers = with maintainers; [ lucus16 ];
|
||||
maintainers = with maintainers; [ lucus16 thoughtpolice ];
|
||||
platforms = platforms.linux;
|
||||
license = licenses.gpl2;
|
||||
};
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
{ stdenv
|
||||
, fetchFromGitHub
|
||||
, cmake
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "prjxray-tools";
|
||||
version = "0.1-2676-gac8d30e3";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "SymbiFlow";
|
||||
repo = "prjxray";
|
||||
fetchSubmodules = true;
|
||||
rev = "ac8d30e3fe2029122408888d2313844b3e0c265b";
|
||||
sha256 = "1ag7dk12hdhip821crwinncp8vgyzs0r85l1h2vbgn61lnxc7f4h";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "Documenting the Xilinx 7-series bit-stream format";
|
||||
homepage = "https://github.com/SymbiFlow/prjxray";
|
||||
license = licenses.isc;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ mcaju ];
|
||||
};
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
{ stdenv
|
||||
, fetchFromGitHub
|
||||
, bison
|
||||
, cmake
|
||||
, flex
|
||||
, pkg-config
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "symbiflow-vtr";
|
||||
version = "8.0.0.rc2-4003-g8980e4621";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "SymbiFlow";
|
||||
repo = "vtr-verilog-to-routing";
|
||||
rev = "8980e46218542888fac879961b13aa7b0fba8432";
|
||||
sha256 = "1sq7f1f3dzfm48a9vq5nvp0zllby0nasm3pvqab70f4jaq0m1aaa";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
bison
|
||||
cmake
|
||||
flex
|
||||
pkg-config
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DWITH_ODIN=OFF"
|
||||
"-DWITH_ABC=OFF"
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "SymbiFlow WIP changes for Verilog to Routing (VTR)";
|
||||
homepage = "https://github.com/SymbiFlow/vtr-verilog-to-routing";
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ mcaju ];
|
||||
};
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{ stdenv
|
||||
, fetchFromGitHub
|
||||
, symbiflow-yosys
|
||||
, zlib
|
||||
, readline
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "symbiflow-yosys-plugins";
|
||||
version = "1.0.0.7-0060-g7454cd6b";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "SymbiFlow";
|
||||
repo = "yosys-symbiflow-plugins";
|
||||
rev = "7454cd6b5e4fd22854e2ada219a5e3c3a06e0717";
|
||||
sha256 = "0r9r31p7fy4ylfrwvwlbivq5a03xrph34blxbxzx2c8bc02mbv0s";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
nativeBuildInputs = [ symbiflow-yosys ];
|
||||
|
||||
buildInputs = [
|
||||
readline
|
||||
zlib
|
||||
];
|
||||
|
||||
makeFlags = [ "PLUGINS_DIR=${placeholder "out"}/share/yosys/plugins" ];
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "Yosys SymbiFlow Plugins";
|
||||
homepage = "https://github.com/SymbiFlow/yosys-symbiflow-plugins";
|
||||
license = licenses.isc;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ mcaju ];
|
||||
};
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{ stdenv
|
||||
, abc-verifier
|
||||
, fetchFromGitHub
|
||||
, yosys
|
||||
, plugins ? []
|
||||
}:
|
||||
|
||||
let
|
||||
localAbc-verifier = abc-verifier.overrideAttrs (_: rec {
|
||||
pname = "abc-verifier";
|
||||
version = "2020.06.22";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "YosysHQ";
|
||||
repo = "abc";
|
||||
rev = "341db25668f3054c87aa3372c794e180f629af5d";
|
||||
sha256 = "14cgv34vz5ljkcms6nrv19vqws2hs8bgjgffk5q03cbxnm2jxv5s";
|
||||
};
|
||||
|
||||
passthru.rev = src.rev;
|
||||
});
|
||||
in
|
||||
|
||||
(yosys.overrideAttrs (oldAttrs: rec {
|
||||
pname = "symbiflow-yosys";
|
||||
version = "0.9+2406";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "SymbiFlow";
|
||||
repo = "yosys";
|
||||
rev = "d8b2d1a2b1a93057678cf49bb8f0329f191faba1";
|
||||
sha256 = "1w8jnqzabvzixjllhb6ak2n2gmjvsn6qd996i7z70bsq5rgdkq9g";
|
||||
};
|
||||
})).override {
|
||||
abc-verifier = localAbc-verifier;
|
||||
plugins = plugins;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{ stdenv
|
||||
{ stdenv, lib
|
||||
, abc-verifier
|
||||
, bash
|
||||
, bison
|
||||
@@ -12,7 +12,6 @@
|
||||
, tcl
|
||||
, verilog
|
||||
, zlib
|
||||
, plugins ? []
|
||||
}:
|
||||
|
||||
# NOTE: as of late 2020, yosys has switched to an automation robot that
|
||||
@@ -33,8 +32,6 @@
|
||||
# ultimately less confusing than using dates.
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
inherit plugins;
|
||||
|
||||
pname = "yosys";
|
||||
version = "0.9+3830";
|
||||
|
||||
@@ -46,17 +43,21 @@ stdenv.mkDerivation rec {
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
nativeBuildInputs = [ pkg-config protobuf flex bison python3 ];
|
||||
nativeBuildInputs = [ pkg-config bison flex ];
|
||||
buildInputs = [ tcl readline libffi python3 protobuf zlib ];
|
||||
|
||||
makeFlags = [ "ENABLE_PROTOBUF=1" "PREFIX=${placeholder "out"}"];
|
||||
|
||||
patchPhase = ''
|
||||
patches = [
|
||||
./plugin-search-dirs.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace ./Makefile \
|
||||
--replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}'
|
||||
|
||||
chmod +x ./misc/yosys-config.in
|
||||
patchShebangs ./misc/yosys-config.in
|
||||
patchShebangs tests
|
||||
patchShebangs tests ./misc/yosys-config.in
|
||||
'';
|
||||
|
||||
preBuild = let
|
||||
@@ -75,7 +76,7 @@ stdenv.mkDerivation rec {
|
||||
fi
|
||||
|
||||
if ! grep -q "YOSYS_VER := $version" Makefile; then
|
||||
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package ($version), failing."
|
||||
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package (${version}), failing."
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
@@ -92,16 +93,11 @@ stdenv.mkDerivation rec {
|
||||
# add a symlink to fake things so that both variants work the same way. this
|
||||
# is also needed at build time for the test suite.
|
||||
postBuild = "ln -sfv ${abc-verifier}/bin/abc ./yosys-abc";
|
||||
postInstall = ''
|
||||
ln -sfv ${abc-verifier}/bin/abc $out/bin/yosys-abc
|
||||
postInstall = "ln -sfv ${abc-verifier}/bin/abc $out/bin/yosys-abc";
|
||||
|
||||
mkdir -p $out/share/yosys/plugins
|
||||
for plugin in $plugins; do
|
||||
ln -sfv $plugin/share/yosys/plugins/* $out/share/yosys/plugins/
|
||||
done
|
||||
'';
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
meta = with lib; {
|
||||
description = "Open RTL synthesis framework and tools";
|
||||
homepage = "http://www.clifford.at/yosys/";
|
||||
license = licenses.isc;
|
||||
|
||||
34
pkgs/development/compilers/yosys/plugin-search-dirs.patch
Normal file
34
pkgs/development/compilers/yosys/plugin-search-dirs.patch
Normal file
@@ -0,0 +1,34 @@
|
||||
diff --git a/passes/cmds/plugin.cc b/passes/cmds/plugin.cc
|
||||
index 3ed19497..f9534bd0 100644
|
||||
--- a/passes/cmds/plugin.cc
|
||||
+++ b/passes/cmds/plugin.cc
|
||||
@@ -75,8 +75,27 @@ void load_plugin(std::string filename, std::vector<std::string> aliases)
|
||||
#endif
|
||||
|
||||
void *hdl = dlopen(filename.c_str(), RTLD_LAZY|RTLD_LOCAL);
|
||||
- if (hdl == NULL && orig_filename.find('/') == std::string::npos)
|
||||
- hdl = dlopen((proc_share_dirname() + "plugins/" + orig_filename + ".so").c_str(), RTLD_LAZY|RTLD_LOCAL);
|
||||
+ if (hdl == NULL && orig_filename.find('/') == std::string::npos) {
|
||||
+ std::string install_dir = proc_share_dirname() + "plugins";
|
||||
+
|
||||
+ vector<string> all_dirs;
|
||||
+ all_dirs.push_back(install_dir);
|
||||
+
|
||||
+ 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 + ".so").c_str(), RTLD_LAZY|RTLD_LOCAL);
|
||||
+ if (hdl != NULL) break;
|
||||
+ }
|
||||
+ }
|
||||
if (hdl == NULL)
|
||||
log_cmd_error("Can't load module `%s': %s\n", filename.c_str(), dlerror());
|
||||
loaded_plugins[orig_filename] = hdl;
|
||||
32
pkgs/development/compilers/yosys/plugins/bluespec.nix
Normal file
32
pkgs/development/compilers/yosys/plugins/bluespec.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
{ stdenv, lib, fetchFromGitHub, pkg-config
|
||||
, yosys, readline, zlib, bluespec
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "yosys-bluespec";
|
||||
version = "2021.01.14";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "thoughtpolice";
|
||||
repo = "yosys-bluespec";
|
||||
rev = "7a0c609e9b601560067c34b8ce41e89ea4a397d4";
|
||||
sha256 = "0xj9j5dwvq0dwqzfjd4ikmxkd28amj6d9m6ava7pwcrpjhyjnd0c";
|
||||
};
|
||||
|
||||
buildInputs = [ yosys readline zlib bluespec ];
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
|
||||
doCheck = true;
|
||||
makeFlags = [
|
||||
"PREFIX=$(out)/share/yosys/plugins"
|
||||
"STATIC_BSC_PATH=${bluespec}/bin/bsc"
|
||||
"STATIC_BSC_LIBDIR=${bluespec}/lib"
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Bluespec plugin for Yosys";
|
||||
license = licenses.isc;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ thoughtpolice ];
|
||||
};
|
||||
}
|
||||
31
pkgs/development/compilers/yosys/plugins/ghdl.nix
Normal file
31
pkgs/development/compilers/yosys/plugins/ghdl.nix
Normal file
@@ -0,0 +1,31 @@
|
||||
{ stdenv, lib, fetchFromGitHub, pkg-config
|
||||
, yosys, readline, zlib, ghdl
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "yosys-ghdl";
|
||||
version = "2021.01.01";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ghdl";
|
||||
repo = "ghdl-yosys-plugin";
|
||||
rev = "8b3e740fef9a653a20a838f1ade475960e1d379b";
|
||||
sha256 = "13kpcp37r11xgqd8aksddi40a5vpzqi7p8qgyjbs99lyscyli75x";
|
||||
};
|
||||
|
||||
buildInputs = [ yosys readline zlib ghdl ];
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
|
||||
doCheck = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/yosys/plugins
|
||||
cp ghdl.so $out/share/yosys/plugins/ghdl.so
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "GHDL plugin for Yosys";
|
||||
license = licenses.isc;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ thoughtpolice ];
|
||||
};
|
||||
}
|
||||
5
pkgs/development/compilers/yosys/setup-hook.sh
Normal file
5
pkgs/development/compilers/yosys/setup-hook.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
addYosysPluginPath() {
|
||||
addToSearchPath NIX_YOSYS_PLUGIN_DIRS "$1/share/yosys/plugins"
|
||||
}
|
||||
|
||||
addEnvHooks "$targetOffset" addYosysPluginPath
|
||||
Reference in New Issue
Block a user