19 assert backend == "mcode" || backend == "llvm" || backend == "gcc";
21 stdenv.mkDerivation (finalAttrs: {
22 pname = "ghdl-${backend}";
25 src = fetchFromGitHub {
28 rev = "v${finalAttrs.version}";
29 hash = "sha256-tPSHer3qdtEZoPh9BsEyuTOrXgyENFUyJqnUS3UYAvM=";
32 LIBRARY_PATH = "${stdenv.cc.libc}/lib";
36 ] ++ lib.optionals (backend == "gcc") [
42 ] ++ lib.optionals (backend == "llvm") [
44 ] ++ lib.optionals (backend == "gcc") [
49 propagatedBuildInputs = [
50 ] ++ lib.optionals (backend == "llvm" || backend == "gcc") [
55 # If llvm 7.0 works, 7.x releases should work too.
56 sed -i 's/check_version 7.0/check_version 7/g' configure
57 '' + lib.optionalString (backend == "gcc") ''
58 ${gnutar}/bin/tar -xf ${gcc-unwrapped.src}
62 # See https://github.com/ghdl/ghdl/pull/2058
65 ] ++ lib.optionals (backend == "llvm") [
66 "--with-llvm-config=${llvm.dev}/bin/llvm-config"
67 ] ++ lib.optionals (backend == "gcc") [
68 "--with-gcc=gcc-${gcc-unwrapped.version}"
71 buildPhase = lib.optionalString (backend == "gcc") ''
75 ../gcc-${gcc-unwrapped.version}/configure \
76 --with-native-system-header-dir=/include \
77 --with-build-sysroot=${lib.getDev glibc} \
79 --enable-languages=c,vhdl \
86 make -j $NIX_BUILD_CORES
89 make -j $NIX_BUILD_CORES ghdllib
92 postFixup = lib.optionalString (backend == "gcc") ''
93 wrapProgram $out/bin/ghdl \
94 --set LIBRARY_PATH ${lib.makeLibraryPath [
100 ] ++ lib.optionals (backend == "gcc") [
101 # GCC compilation fails with format errors
105 enableParallelBuilding = true;
109 # nix-build -A ghdl-mcode.passthru.tests
110 # nix-build -A ghdl-llvm.passthru.tests
111 # nix-build -A ghdl-gcc.passthru.tests
113 simple = callPackage ./test-simple.nix { inherit backend; };
118 homepage = "https://github.com/ghdl/ghdl";
119 description = "VHDL 2008/93/87 simulator";
120 license = lib.licenses.gpl2Plus;
121 mainProgram = "ghdl";
122 maintainers = with lib.maintainers; [ lucus16 thoughtpolice ];
125 ++ lib.optionals (backend == "mcode" || backend == "llvm") [ "x86_64-darwin" ];