2022-08-12 12:06:08 +00:00
|
|
|
{ stdenv, fetchFromGitHub, fetchpatch, callPackage, gnat11, zlib, llvm, lib
|
2020-04-24 23:36:52 +00:00
|
|
|
, backend ? "mcode" }:
|
|
|
|
|
|
|
|
assert backend == "mcode" || backend == "llvm";
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "ghdl-${backend}";
|
2021-02-13 14:23:35 +00:00
|
|
|
version = "1.0.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-01-17 00:15:33 +00:00
|
|
|
owner = "ghdl";
|
|
|
|
repo = "ghdl";
|
2021-02-13 14:23:35 +00:00
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "1gyh0xckwbzgslbpw9yrpj4gqs9fm1a2qpbzl0sh143fk1kwjlly";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
patches = [
|
|
|
|
# Allow compilation with GNAT 11, picked from master
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-gnat-11-compilation.patch";
|
|
|
|
url = "https://github.com/ghdl/ghdl/commit/8356ea3bb4e8d0e5ad8638c3d50914b64fc360ec.patch";
|
|
|
|
sha256 = "04pzn8g7xha8000wbjjmry6h1grfqyn3bjvj47hi4qwgl21wfjra";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
LIBRARY_PATH = "${stdenv.cc.libc}/lib";
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
buildInputs = [ gnat11 zlib ] ++ lib.optional (backend == "llvm") [ llvm ];
|
2021-04-18 02:13:31 +00:00
|
|
|
propagatedBuildInputs = lib.optionals (backend == "llvm") [ zlib ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
# If llvm 7.0 works, 7.x releases should work too.
|
2021-02-13 14:23:35 +00:00
|
|
|
sed -i 's/check_version 7.0/check_version 7/g' configure
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
configureFlags = [ "--enable-synth" ] ++ lib.optional (backend == "llvm")
|
2021-05-20 23:08:51 +00:00
|
|
|
"--with-llvm-config=${llvm.dev}/bin/llvm-config";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-04-18 02:13:31 +00:00
|
|
|
passthru = {
|
|
|
|
# run with either of
|
|
|
|
# nix-build -A ghdl-mcode.passthru.tests
|
|
|
|
# nix-build -A ghdl-llvm.passthru.tests
|
|
|
|
tests = {
|
|
|
|
simple = callPackage ./test-simple.nix { inherit backend; };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/ghdl/ghdl";
|
|
|
|
description = "VHDL 2008/93/87 simulator";
|
2021-01-17 00:15:33 +00:00
|
|
|
maintainers = with maintainers; [ lucus16 thoughtpolice ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
license = licenses.gpl2;
|
|
|
|
};
|
|
|
|
}
|