20 assert backend == "mcode" || backend == "llvm" || backend == "gcc";
22 stdenv.mkDerivation (finalAttrs: {
23 pname = "ghdl-${backend}";
26 src = fetchFromGitHub {
29 rev = "v${finalAttrs.version}";
30 hash = "sha256-tPSHer3qdtEZoPh9BsEyuTOrXgyENFUyJqnUS3UYAvM=";
33 LIBRARY_PATH = "${stdenv.cc.libc}/lib";
39 ++ lib.optionals (backend == "gcc") [
47 ++ lib.optionals (backend == "llvm") [
50 ++ lib.optionals (backend == "gcc") [
55 propagatedBuildInputs =
58 ++ lib.optionals (backend == "llvm" || backend == "gcc") [
64 # If llvm 7.0 works, 7.x releases should work too.
65 sed -i 's/check_version 7.0/check_version 7/g' configure
67 + lib.optionalString (backend == "gcc") ''
68 ${gnutar}/bin/tar -xf ${gcc-unwrapped.src}
73 # See https://github.com/ghdl/ghdl/pull/2058
77 ++ lib.optionals (backend == "llvm") [
78 "--with-llvm-config=${llvm.dev}/bin/llvm-config"
80 ++ lib.optionals (backend == "gcc") [
81 "--with-gcc=gcc-${gcc-unwrapped.version}"
84 buildPhase = lib.optionalString (backend == "gcc") ''
88 ../gcc-${gcc-unwrapped.version}/configure \
89 --with-native-system-header-dir=/include \
90 --with-build-sysroot=${lib.getDev glibc} \
92 --enable-languages=c,vhdl \
99 make -j $NIX_BUILD_CORES
102 make -j $NIX_BUILD_CORES ghdllib
105 postFixup = lib.optionalString (backend == "gcc") ''
106 wrapProgram $out/bin/ghdl \
107 --set LIBRARY_PATH ${
108 lib.makeLibraryPath [
117 ++ lib.optionals (backend == "gcc") [
118 # GCC compilation fails with format errors
122 enableParallelBuilding = true;
126 # nix-build -A ghdl-mcode.passthru.tests
127 # nix-build -A ghdl-llvm.passthru.tests
128 # nix-build -A ghdl-gcc.passthru.tests
130 simple = callPackage ./test-simple.nix { inherit backend; };
135 homepage = "https://github.com/ghdl/ghdl";
136 description = "VHDL 2008/93/87 simulator";
137 license = lib.licenses.gpl2Plus;
138 mainProgram = "ghdl";
139 maintainers = with lib.maintainers; [
145 ++ lib.optionals (backend == "mcode" || backend == "llvm") [ "x86_64-darwin" ];