From ecbf44485b3a6b72ba260d20c82881cf10e86b09 Mon Sep 17 00:00:00 2001 From: timor Date: Wed, 10 Aug 2016 16:00:12 +0200 Subject: [PATCH 1/2] ghdl: add support for llvm backend Make the existing ghdl recipe more flexible, and introduce "ghdl_llvm" as a package in addition to "ghdl_mcode". This seems to specifically require llvm 3.5, though. The flavour is also encoded in the package name. cc @viric --- pkgs/development/compilers/ghdl/default.nix | 23 ++++++++++++++------- pkgs/top-level/all-packages.nix | 8 ++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/ghdl/default.nix b/pkgs/development/compilers/ghdl/default.nix index d8b0598e2783..56d778f4f1c6 100644 --- a/pkgs/development/compilers/ghdl/default.nix +++ b/pkgs/development/compilers/ghdl/default.nix @@ -1,16 +1,26 @@ -{ stdenv, fetchurl, gnat, zlib }: +{ stdenv, fetchurl, gnat, zlib, llvm_35, ncurses, clang, flavour ? "mcode" }: + +# mcode only works on x86, while the llvm flavour works on both x86 and x86_64. + + +assert flavour == "llvm" || flavour == "mcode"; + let + inherit (stdenv.lib) optional; + inherit (stdenv.lib) optionals; version = "0.33"; in stdenv.mkDerivation rec { - name = "ghdl-mcode-${version}"; + name = "ghdl-${flavour}-${version}"; src = fetchurl { url = "https://github.com/tgingold/ghdl/archive/v${version}.tar.gz"; sha256 = "09yvgqyglbakd74v2dgr470clzm744i232nixyffcds55vkij5da"; }; - buildInputs = [ gnat zlib ]; + buildInputs = [ gnat zlib ] ++ optionals (flavour == "llvm") [ clang ncurses ]; + + configureFlags = optional (flavour == "llvm") "--with-llvm=${llvm_35}"; patchPhase = '' # Disable warnings-as-errors, because there are warnings (unused things) @@ -23,11 +33,10 @@ stdenv.mkDerivation rec { meta = { homepage = "http://sourceforge.net/p/ghdl-updates/wiki/Home/"; - description = "Free VHDL simulator, mcode flavour"; + description = "Free VHDL simulator"; maintainers = with stdenv.lib.maintainers; [viric]; - # I think that mcode can only generate x86 code, - # so it fails to link pieces on x86_64. - platforms = with stdenv.lib.platforms; [ "i686-linux" ]; + platforms = with stdenv.lib.platforms; (if flavour == "llvm" then [ "i686-linux" "x86_64-linux" ] + else [ "i686-linux" ]); license = stdenv.lib.licenses.gpl2Plus; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 06b89397c249..125eea936602 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4710,7 +4710,13 @@ in profiledCompiler = false; }); - ghdl_mcode = callPackage_i686 ../development/compilers/ghdl { }; + ghdl_mcode = callPackage_i686 ../development/compilers/ghdl { + flavour = "mcode"; + }; + + ghdl_llvm = callPackage ../development/compilers/ghdl { + flavour = "llvm"; + }; gcl = callPackage ../development/compilers/gcl { gmp = gmp4; From d5ffca88295c9f10be37b8719546b1b486860039 Mon Sep 17 00:00:00 2001 From: timor Date: Tue, 13 Sep 2016 19:25:08 +0200 Subject: [PATCH 2/2] ghdl: use fetchFromGitHub for some reason the sha256 changed... --- pkgs/development/compilers/ghdl/default.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ghdl/default.nix b/pkgs/development/compilers/ghdl/default.nix index 56d778f4f1c6..ff772864e625 100644 --- a/pkgs/development/compilers/ghdl/default.nix +++ b/pkgs/development/compilers/ghdl/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, gnat, zlib, llvm_35, ncurses, clang, flavour ? "mcode" }: +{ stdenv, fetchFromGitHub, gnat, zlib, llvm_35, ncurses, clang, flavour ? "mcode" }: # mcode only works on x86, while the llvm flavour works on both x86 and x86_64. @@ -13,9 +13,11 @@ in stdenv.mkDerivation rec { name = "ghdl-${flavour}-${version}"; - src = fetchurl { - url = "https://github.com/tgingold/ghdl/archive/v${version}.tar.gz"; - sha256 = "09yvgqyglbakd74v2dgr470clzm744i232nixyffcds55vkij5da"; + src = fetchFromGitHub { + owner = "tgingold"; + repo = "ghdl"; + rev = "v${version}"; + sha256 = "0g72rk2yzr0lrpncq2c1qcv71w3mi2hjq84r1yzgjr6d0qm87r2a"; }; buildInputs = [ gnat zlib ] ++ optionals (flavour == "llvm") [ clang ncurses ];