From 3086338f9dabb17d6c209606d661991d9a98f4a0 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 7 Jan 2020 16:06:23 +0100 Subject: [PATCH 1/7] yosys: user placeholder --- pkgs/development/compilers/yosys/default.nix | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix index 8948af17145..cd34f95c691 100644 --- a/pkgs/development/compilers/yosys/default.nix +++ b/pkgs/development/compilers/yosys/default.nix @@ -1,8 +1,15 @@ -{ stdenv, fetchFromGitHub -, pkgconfig, bison, flex -, tcl, readline, libffi, python3 -, protobuf, zlib +{ stdenv +, bison +, fetchFromGitHub +, flex +, libffi +, pkgconfig +, protobuf +, python3 +, readline +, tcl , verilog +, zlib }: with builtins; @@ -37,7 +44,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkgconfig ]; buildInputs = [ tcl readline libffi python3 bison flex protobuf zlib ]; - makeFlags = [ "ENABLE_PROTOBUF=1" ]; + makeFlags = [ "ENABLE_PROTOBUF=1" "PREFIX=${placeholder "out"}"]; patchPhase = '' substituteInPlace ../yosys-abc/Makefile \ @@ -58,7 +65,6 @@ stdenv.mkDerivation rec { ln -s ../yosys-abc abc make config-${if stdenv.cc.isClang or false then "clang" else "gcc"} echo 'ABCREV := default' >> Makefile.conf - makeFlags="PREFIX=$out $makeFlags" # we have to do this ourselves for some reason... (cd misc && ${protobuf}/bin/protoc --cpp_out ../backends/protobuf/ ./yosys.proto) From e0b28fb806ff748c3c12aa33e82eb6a63ea0da11 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 7 Jan 2020 16:09:08 +0100 Subject: [PATCH 2/7] yosys: don't use srcs array, but single src --- pkgs/development/compilers/yosys/default.nix | 52 +++++++++----------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix index cd34f95c691..c6684c631e4 100644 --- a/pkgs/development/compilers/yosys/default.nix +++ b/pkgs/development/compilers/yosys/default.nix @@ -14,31 +14,27 @@ with builtins; -stdenv.mkDerivation rec { +let + # NOTE: the version of abc used here is synchronized with + # the one in the yosys Makefile of the version above; + # keep them the same for quality purposes. + abc = fetchFromGitHub { + owner = "berkeley-abc"; + repo = "abc"; + rev = "623b5e82513d076a19f864c01930ad1838498894"; + sha256 = "1mrfqwsivflqdzc3531r6mzp33dfyl6dnqjdwfcq137arqh36m67"; + }; +in stdenv.mkDerivation rec { pname = "yosys"; version = "2019.10.18"; - srcs = [ - (fetchFromGitHub { - owner = "yosyshq"; - repo = "yosys"; - rev = "3c41599ee1f62e4d77ba630fa1a245ef3fe236fa"; - sha256 = "0jg2g8v08ax1q6qlvn8c1h147m03adzrgf21043xwbh4c7s5k137"; - name = "yosys"; - }) - - # NOTE: the version of abc used here is synchronized with - # the one in the yosys Makefile of the version above; - # keep them the same for quality purposes. - (fetchFromGitHub { - owner = "berkeley-abc"; - repo = "abc"; - rev = "623b5e82513d076a19f864c01930ad1838498894"; - sha256 = "1mrfqwsivflqdzc3531r6mzp33dfyl6dnqjdwfcq137arqh36m67"; - name = "yosys-abc"; - }) - ]; - sourceRoot = "yosys"; + src = fetchFromGitHub { + owner = "yosyshq"; + repo = "yosys"; + rev = "3c41599ee1f62e4d77ba630fa1a245ef3fe236fa"; + sha256 = "0jg2g8v08ax1q6qlvn8c1h147m03adzrgf21043xwbh4c7s5k137"; + name = "yosys"; + }; enableParallelBuilding = true; nativeBuildInputs = [ pkgconfig ]; @@ -47,22 +43,22 @@ stdenv.mkDerivation rec { makeFlags = [ "ENABLE_PROTOBUF=1" "PREFIX=${placeholder "out"}"]; patchPhase = '' - substituteInPlace ../yosys-abc/Makefile \ - --replace 'CC := gcc' "" \ - --replace 'CXX := g++' "" substituteInPlace ./Makefile \ --replace 'CXX = clang' "" \ --replace 'LD = clang++' 'LD = $(CXX)' \ --replace 'CXX = gcc' "" \ --replace 'LD = gcc' 'LD = $(CXX)' \ --replace 'ABCMKARGS = CC="$(CXX)" CXX="$(CXX)"' 'ABCMKARGS =' \ - --replace 'echo UNKNOWN' 'echo ${substring 0 10 (elemAt srcs 0).rev}' + --replace 'echo UNKNOWN' 'echo ${substring 0 10 src.rev}' patchShebangs tests ''; preBuild = '' - chmod -R u+w ../yosys-abc - ln -s ../yosys-abc abc + cp -R ${abc} abc + chmod -R u+w . + substituteInPlace abc/Makefile \ + --replace 'CC := gcc' "" \ + --replace 'CXX := g++' "" make config-${if stdenv.cc.isClang or false then "clang" else "gcc"} echo 'ABCREV := default' >> Makefile.conf From 48085826fa1cd014a9dd97365fe63fbff7ea40f4 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 1 Feb 2020 12:11:30 +0100 Subject: [PATCH 3/7] yosys: use external abc --- pkgs/development/compilers/yosys/default.nix | 27 +++----------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix index c6684c631e4..f034d88b0dc 100644 --- a/pkgs/development/compilers/yosys/default.nix +++ b/pkgs/development/compilers/yosys/default.nix @@ -1,4 +1,5 @@ { stdenv +, abc-verifier , bison , fetchFromGitHub , flex @@ -12,19 +13,7 @@ , zlib }: -with builtins; - -let - # NOTE: the version of abc used here is synchronized with - # the one in the yosys Makefile of the version above; - # keep them the same for quality purposes. - abc = fetchFromGitHub { - owner = "berkeley-abc"; - repo = "abc"; - rev = "623b5e82513d076a19f864c01930ad1838498894"; - sha256 = "1mrfqwsivflqdzc3531r6mzp33dfyl6dnqjdwfcq137arqh36m67"; - }; -in stdenv.mkDerivation rec { +stdenv.mkDerivation rec { pname = "yosys"; version = "2019.10.18"; @@ -49,18 +38,14 @@ in stdenv.mkDerivation rec { --replace 'CXX = gcc' "" \ --replace 'LD = gcc' 'LD = $(CXX)' \ --replace 'ABCMKARGS = CC="$(CXX)" CXX="$(CXX)"' 'ABCMKARGS =' \ - --replace 'echo UNKNOWN' 'echo ${substring 0 10 src.rev}' + --replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}' patchShebangs tests ''; preBuild = '' - cp -R ${abc} abc chmod -R u+w . - substituteInPlace abc/Makefile \ - --replace 'CC := gcc' "" \ - --replace 'CXX := g++' "" make config-${if stdenv.cc.isClang or false then "clang" else "gcc"} - echo 'ABCREV := default' >> Makefile.conf + 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) @@ -68,10 +53,6 @@ in stdenv.mkDerivation rec { doCheck = true; checkInputs = [ verilog ]; - # checkPhase defaults to VERBOSE=y, which gets passed down to abc, - # which then does $(VERBOSE)gcc, which then complains about not - # being able to find ygcc. Life is pain. - checkFlags = [ " " ]; meta = { description = "Framework for RTL synthesis tools"; From 214cac8b26d69b8841e5042e3f0bc2720a75f9f3 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 1 Feb 2020 12:15:45 +0100 Subject: [PATCH 4/7] yosys: 2019.10.18 -> 2020.02.01 --- pkgs/development/compilers/yosys/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix index f034d88b0dc..b34125bcacd 100644 --- a/pkgs/development/compilers/yosys/default.nix +++ b/pkgs/development/compilers/yosys/default.nix @@ -15,13 +15,13 @@ stdenv.mkDerivation rec { pname = "yosys"; - version = "2019.10.18"; + version = "2020.02.01"; src = fetchFromGitHub { owner = "yosyshq"; repo = "yosys"; - rev = "3c41599ee1f62e4d77ba630fa1a245ef3fe236fa"; - sha256 = "0jg2g8v08ax1q6qlvn8c1h147m03adzrgf21043xwbh4c7s5k137"; + rev = "a1c840ca5d6e8b580e21ae48550570aa9665741a"; + sha256 = "1vna04dh6l68nifssgs3hxqwn4k529krmm4crj94a8wwhwra52mh"; name = "yosys"; }; From 351f47da57f5fdae14877147ca8b0898273256d9 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 1 Feb 2020 12:16:45 +0100 Subject: [PATCH 5/7] abc-verifier: 2018-07-08 -> 2020-01-11 --- pkgs/applications/science/logic/abc/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/science/logic/abc/default.nix b/pkgs/applications/science/logic/abc/default.nix index c832d12627a..0252273efd0 100644 --- a/pkgs/applications/science/logic/abc/default.nix +++ b/pkgs/applications/science/logic/abc/default.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation { pname = "abc-verifier"; - version = "2018-07-08"; + version = "2020-01-11"; src = fetchFromGitHub { owner = "berkeley-abc"; repo = "abc"; - rev = "24407e13db4b8ca16c3996049b2d33ec3722de39"; - sha256 = "1rckji7nk81n6v1yajz7daqwipxacv7zlafknvmbiwji30j47sq5"; + rev = "71f2b40320127561175ad60f6f2428f3438e5243"; + sha256 = "15sn146ajxql7l1h8rsag5lhn4spwvgjhwzqawfr78snzadw8by3"; }; nativeBuildInputs = [ cmake ]; From 570afbcb5bec1585f01eeefa48afe57410e84914 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 1 Feb 2020 12:33:46 +0100 Subject: [PATCH 6/7] abc-verifier: passthru rev Some consumers of abc-verifier require certain abc versions. For that reason, expose the exact rev via a passtrhru. --- pkgs/applications/science/logic/abc/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/science/logic/abc/default.nix b/pkgs/applications/science/logic/abc/default.nix index 0252273efd0..8551a3ee4ca 100644 --- a/pkgs/applications/science/logic/abc/default.nix +++ b/pkgs/applications/science/logic/abc/default.nix @@ -1,16 +1,20 @@ { fetchFromGitHub, stdenv, readline, cmake }: -stdenv.mkDerivation { +let + rev = "71f2b40320127561175ad60f6f2428f3438e5243"; +in stdenv.mkDerivation { pname = "abc-verifier"; version = "2020-01-11"; src = fetchFromGitHub { + inherit rev; owner = "berkeley-abc"; repo = "abc"; - rev = "71f2b40320127561175ad60f6f2428f3438e5243"; sha256 = "15sn146ajxql7l1h8rsag5lhn4spwvgjhwzqawfr78snzadw8by3"; }; + passthru.rev = rev; + nativeBuildInputs = [ cmake ]; buildInputs = [ readline ]; From b437fa4c523e80b74307bf602ebd0a30d18efc63 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 1 Feb 2020 12:34:30 +0100 Subject: [PATCH 7/7] yosys: check abc-verifier rev to ensure compatibility --- pkgs/development/compilers/yosys/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix index b34125bcacd..7027c5a0523 100644 --- a/pkgs/development/compilers/yosys/default.nix +++ b/pkgs/development/compilers/yosys/default.nix @@ -42,13 +42,20 @@ stdenv.mkDerivation rec { patchShebangs tests ''; - preBuild = '' + 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 "yosys isn't compatible with the provided abc (${shortAbcRev}), failing." + exit 1 + fi ''; doCheck = true;