2022-10-21 18:38:19 +00:00
|
|
|
{ stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, callPackage
|
|
|
|
, gnat
|
|
|
|
, zlib
|
|
|
|
, llvm
|
|
|
|
, lib
|
|
|
|
, backend ? "mcode"
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
assert backend == "mcode" || backend == "llvm";
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "ghdl-${backend}";
|
2022-10-21 18:38:19 +00:00
|
|
|
version = "2.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}";
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-B/G3FGRzYy4Y9VNNB8yM3FohiIjPJhYSVbqsTN3cL5k=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
patches = [
|
2022-10-21 18:38:19 +00:00
|
|
|
# https://github.com/ghdl/ghdl/issues/2056
|
2021-12-06 16:07:01 +00:00
|
|
|
(fetchpatch {
|
2022-10-21 18:38:19 +00:00
|
|
|
name = "fix-build-gcc-12.patch";
|
|
|
|
url = "https://github.com/ghdl/ghdl/commit/f8b87697e8b893b6293ebbfc34670c32bfb49397.patch";
|
|
|
|
hash = "sha256-tVbMm8veFkNPs6WFBHvaic5Jkp1niyg0LfFufa+hT/E=";
|
2021-12-06 16:07:01 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
LIBRARY_PATH = "${stdenv.cc.libc}/lib";
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
gnat
|
|
|
|
];
|
|
|
|
buildInputs = [
|
|
|
|
zlib
|
|
|
|
] ++ lib.optional (backend == "llvm") [
|
|
|
|
llvm
|
|
|
|
];
|
|
|
|
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
|
|
|
'';
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
configureFlags = [
|
|
|
|
# See https://github.com/ghdl/ghdl/pull/2058
|
|
|
|
"--disable-werror"
|
|
|
|
"--enable-synth"
|
|
|
|
] ++ lib.optionals (backend == "llvm") [
|
|
|
|
"--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;
|
|
|
|
};
|
|
|
|
}
|