uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
151
pkgs/development/compilers/yosys/default.nix
Normal file
151
pkgs/development/compilers/yosys/default.nix
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, abc-verifier
|
||||
, bash
|
||||
, bison
|
||||
, fetchFromGitHub
|
||||
, flex
|
||||
, libffi
|
||||
, makeWrapper
|
||||
, pkg-config
|
||||
, protobuf
|
||||
, python3
|
||||
, readline
|
||||
, symlinkJoin
|
||||
, tcl
|
||||
, verilog
|
||||
, zlib
|
||||
, yosys
|
||||
, yosys-bluespec
|
||||
, yosys-ghdl
|
||||
, yosys-symbiflow
|
||||
}:
|
||||
|
||||
# NOTE: as of late 2020, yosys has switched to an automation robot that
|
||||
# automatically tags their repository Makefile with a new build number every
|
||||
# day when changes are committed. please MAKE SURE that the version number in
|
||||
# the 'version' field exactly matches the YOSYS_VER field in the Yosys
|
||||
# makefile!
|
||||
#
|
||||
# if a change in yosys isn't yet available under a build number like this (i.e.
|
||||
# it was very recently merged, within an hour), wait a few hours for the
|
||||
# automation robot to tag the new version, like so:
|
||||
#
|
||||
# https://github.com/YosysHQ/yosys/commit/71ca9a825309635511b64b3ec40e5e5e9b6ad49b
|
||||
#
|
||||
# note that while most nix packages for "unstable versions" use a date-based
|
||||
# version scheme, synchronizing the nix package version here with the unstable
|
||||
# yosys version number helps users report better bugs upstream, and is
|
||||
# ultimately less confusing than using dates.
|
||||
|
||||
let
|
||||
|
||||
# Provides a wrapper for creating a yosys with the specifed plugins preloaded
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# my_yosys = yosys.withPlugins (with yosys.allPlugins; [
|
||||
# fasm
|
||||
# bluespec
|
||||
# ]);
|
||||
withPlugins = plugins:
|
||||
let
|
||||
paths = lib.closePropagation plugins;
|
||||
module_flags = with builtins; concatStringsSep " "
|
||||
(map (n: "--add-flags -m --add-flags ${n.plugin}") plugins);
|
||||
in lib.appendToName "with-plugins" ( symlinkJoin {
|
||||
inherit (yosys) name;
|
||||
paths = paths ++ [ yosys ] ;
|
||||
buildInputs = [ makeWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/yosys \
|
||||
--set NIX_YOSYS_PLUGIN_DIRS $out/share/yosys/plugins \
|
||||
${module_flags}
|
||||
'';
|
||||
});
|
||||
|
||||
allPlugins = {
|
||||
bluespec = yosys-bluespec;
|
||||
ghdl = yosys-ghdl;
|
||||
} // (yosys-symbiflow);
|
||||
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
pname = "yosys";
|
||||
version = "0.16";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "YosysHQ";
|
||||
repo = "yosys";
|
||||
rev = "${pname}-${version}";
|
||||
hash = "sha256-X1yygoat6ezJt9jLO+W528ryf381nKGDQ3cfrG1ZbIk=";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
nativeBuildInputs = [ pkg-config bison flex ];
|
||||
buildInputs = [ tcl readline libffi python3 protobuf zlib ];
|
||||
|
||||
makeFlags = [ "ENABLE_PROTOBUF=1" "PREFIX=${placeholder "out"}"];
|
||||
|
||||
patches = [
|
||||
./plugin-search-dirs.patch
|
||||
./fix-clang-build.patch # see https://github.com/YosysHQ/yosys/issues/2011
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace ./Makefile \
|
||||
--replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}'
|
||||
|
||||
chmod +x ./misc/yosys-config.in
|
||||
patchShebangs tests ./misc/yosys-config.in
|
||||
'';
|
||||
|
||||
preBuild = let
|
||||
shortAbcRev = builtins.substring 0 7 abc-verifier.rev;
|
||||
in ''
|
||||
chmod -R u+w .
|
||||
make config-${if stdenv.cc.isClang or false then "clang" else "gcc"}
|
||||
echo 'ABCEXTERNAL = ${abc-verifier}/bin/abc' >> Makefile.conf
|
||||
|
||||
# we have to do this ourselves for some reason...
|
||||
(cd misc && ${protobuf}/bin/protoc --cpp_out ../backends/protobuf/ ./yosys.proto)
|
||||
|
||||
if ! grep -q "ABCREV = ${shortAbcRev}" Makefile; then
|
||||
echo "ERROR: yosys isn't compatible with the provided abc (${shortAbcRev}), failing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "YOSYS_VER := $version" Makefile; then
|
||||
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package (allegedly ${version}), failing."
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
|
||||
checkTarget = "test";
|
||||
doCheck = true;
|
||||
checkInputs = [ verilog ];
|
||||
|
||||
# Internally, yosys knows to use the specified hardcoded ABCEXTERNAL binary.
|
||||
# But other tools (like mcy or symbiyosys) can't know how yosys was built, so
|
||||
# they just assume that 'yosys-abc' is available -- but it's not installed
|
||||
# when using ABCEXTERNAL
|
||||
#
|
||||
# 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";
|
||||
|
||||
setupHook = ./setup-hook.sh;
|
||||
|
||||
passthru = {
|
||||
inherit withPlugins allPlugins;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Open RTL synthesis framework and tools";
|
||||
homepage = "https://yosyshq.net/yosys/";
|
||||
license = licenses.isc;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ shell thoughtpolice emily ];
|
||||
};
|
||||
}
|
||||
13
pkgs/development/compilers/yosys/fix-clang-build.patch
Normal file
13
pkgs/development/compilers/yosys/fix-clang-build.patch
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/Makefile b/Makefile
|
||||
index 86abc6958..a72f7b792 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -187,7 +192,7 @@ endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG),clang)
|
||||
-CXX = clang
|
||||
+CXX = clang++
|
||||
LD = clang++
|
||||
CXXFLAGS += -std=$(CXXSTD) -Os
|
||||
ABCMKARGS += ARCHFLAGS="-DABC_USE_STDINT_H"
|
||||
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;
|
||||
33
pkgs/development/compilers/yosys/plugins/bluespec.nix
Normal file
33
pkgs/development/compilers/yosys/plugins/bluespec.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{ stdenv, lib, fetchFromGitHub, pkg-config
|
||||
, yosys, readline, zlib, bluespec
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "yosys-bluespec";
|
||||
version = "2021.09.08";
|
||||
plugin = "bluespec";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "thoughtpolice";
|
||||
repo = "yosys-bluespec";
|
||||
rev = "f6f4127a4e96e18080fd5362b6769fa3e24c76b1";
|
||||
sha256 = "sha256-3cNFP/k4JsgLyUQHWU10Htl2Rh0staAcA3R4piD6hDE=";
|
||||
};
|
||||
|
||||
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 ];
|
||||
};
|
||||
}
|
||||
32
pkgs/development/compilers/yosys/plugins/ghdl.nix
Normal file
32
pkgs/development/compilers/yosys/plugins/ghdl.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{ stdenv, lib, fetchFromGitHub, pkg-config
|
||||
, yosys, readline, zlib, ghdl
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "yosys-ghdl";
|
||||
version = "2021.01.25";
|
||||
plugin = "ghdl";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ghdl";
|
||||
repo = "ghdl-yosys-plugin";
|
||||
rev = "cba859cacf8c6631146dbdaa0f297c060b5a68cd";
|
||||
sha256 = "01d9wb7sqkmkf2y9bnn3pmhy08khzs5m1d06whxsiwgwnjzfk9mx";
|
||||
};
|
||||
|
||||
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 ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
diff --git a/yql-qlf-plugin/Makefile b/ql-qlf-plugin/Makefile
|
||||
index 2819055c9fe..0e391581012 100644
|
||||
--- a/ql-qlf-plugin/Makefile
|
||||
+++ b/ql-qlf-plugin/Makefile
|
||||
@@ -55,10 +55,6 @@ VERILOG_MODULES = $(COMMON)/cells_sim.v \
|
||||
$(PP3_DIR)/mult_sim.v \
|
||||
$(PP3_DIR)/qlal3_sim.v \
|
||||
|
||||
-retrieve-pmgen:=$(shell mkdir -p pmgen && wget -nc -O pmgen/pmgen.py https://raw.githubusercontent.com/SymbiFlow/yosys/master%2Bwip/passes/pmgen/pmgen.py)
|
||||
-
|
||||
-pre-build:=$(shell python3 pmgen/pmgen.py -o pmgen/ql-dsp-pm.h -p ql_dsp ql_dsp.pmg)
|
||||
-
|
||||
install_modules: $(VERILOG_MODULES)
|
||||
$(foreach f,$^,install -D $(f) $(DATA_DIR)/quicklogic/$(f);)
|
||||
|
||||
106
pkgs/development/compilers/yosys/plugins/symbiflow.nix
Normal file
106
pkgs/development/compilers/yosys/plugins/symbiflow.nix
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
{ fetchFromGitHub
|
||||
, gtest
|
||||
, lib
|
||||
, python3
|
||||
, readline
|
||||
, stdenv
|
||||
, which
|
||||
, yosys
|
||||
, zlib
|
||||
, yosys-symbiflow
|
||||
}: let
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "SymbiFlow";
|
||||
repo = "yosys-symbiflow-plugins";
|
||||
rev = "35c6c33811a8de7c80dff6a7bcf7aa6ec9b21233";
|
||||
hash = "sha256-g5dX9+R+gWt8e7Bhbbg60O9qa+Vi6Ar0M1sHhYlAre8=";
|
||||
};
|
||||
|
||||
version = "2022.01.06";
|
||||
|
||||
# Supported symbiflow plugins.
|
||||
#
|
||||
# The following are disabled:
|
||||
#
|
||||
# "ql-qlf" builds but fails to load the plugin, so is not currently supported.
|
||||
#
|
||||
# "UHDM" doesn't currently build, as the work to package UHDM and surelog has
|
||||
# not (yet) been undertaken.
|
||||
plugins = [
|
||||
"design_introspection"
|
||||
"fasm"
|
||||
"integrateinv"
|
||||
"params"
|
||||
"ql-iob"
|
||||
# "ql-qlf"
|
||||
"sdc"
|
||||
"xdc"
|
||||
# "UHDM"
|
||||
];
|
||||
|
||||
static_gtest = gtest.dev.overrideAttrs (old: {
|
||||
dontDisableStatic = true;
|
||||
disableHardening = [ "pie" ];
|
||||
cmakeFlags = old.cmakeFlags ++ ["-DBUILD_SHARED_LIBS=OFF"];
|
||||
});
|
||||
|
||||
in lib.genAttrs plugins (plugin: stdenv.mkDerivation (rec {
|
||||
pname = "yosys-symbiflow-${plugin}-plugin";
|
||||
inherit src version plugin;
|
||||
enableParallelBuilding = true;
|
||||
|
||||
nativeBuildInputs = [ which python3 ];
|
||||
buildInputs = [ yosys readline zlib ] ;
|
||||
|
||||
# xdc has an incorrect path to a test which has yet to be patched
|
||||
doCheck = plugin != "xdc";
|
||||
checkInputs = [ static_gtest ];
|
||||
|
||||
# ql-qlf tries to fetch a yosys script from github
|
||||
# Run the script in preBuild instead.
|
||||
patches = lib.optional ( plugin == "ql-qlf" ) ./symbiflow-pmgen.patch;
|
||||
|
||||
preBuild = ''
|
||||
mkdir -p ql-qlf-plugin/pmgen
|
||||
''
|
||||
+ lib.optionalString ( plugin == "ql-qlf" ) ''
|
||||
python3 ${yosys.src}/passes/pmgen/pmgen.py -o ql-qlf-plugin/pmgen/ql-dsp-pm.h -p ql_dsp ql-qlf-plugin/ql_dsp.pmg
|
||||
'';
|
||||
|
||||
# Providing a symlink avoids the need for patching the test makefile
|
||||
postUnpack = ''
|
||||
mkdir -p source/third_party/googletest/googletest/build/
|
||||
ln -s ${static_gtest}/lib source/third_party/googletest/googletest/build/lib
|
||||
'';
|
||||
|
||||
makeFlags = [
|
||||
"PLUGIN_LIST=${plugin}"
|
||||
];
|
||||
|
||||
buildFlags = [
|
||||
"PLUGINS_DIR=\${out}/share/yosys/plugins/"
|
||||
"DATA_DIR=\${out}/share/yosys/"
|
||||
];
|
||||
|
||||
checkFlags = [
|
||||
"PLUGINS_DIR=\${NIX_BUILD_TOP}/source/${plugin}-plugin"
|
||||
"DATA_DIR=\${NIX_BUILD_TOP}/source/${plugin}-plugin"
|
||||
( "NIX_YOSYS_PLUGIN_DIRS=\${NIX_BUILD_TOP}/source/${plugin}-plugin"
|
||||
# sdc and xdc plugins use design introspection for their tests
|
||||
+ (lib.optionalString ( plugin == "sdc" || plugin == "xdc" )
|
||||
":${yosys-symbiflow.design_introspection}/share/yosys/plugins/")
|
||||
)
|
||||
];
|
||||
|
||||
installFlags = buildFlags;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Symbiflow ${plugin} plugin for Yosys";
|
||||
license = licenses.isc;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ ollieB 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue