From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pjotr Prins Subject: Re: [PATCH] Add LDC. Date: Sat, 27 Feb 2016 07:20:36 +0100 Message-ID: <20160227062036.GA24845@thebird.nl> References: <87ziwtec5x.fsf@gnu.org> <87si2dfmpl.fsf@gnu.org> <87mvskaxq6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZYGD-0000w6-CL for guix-devel@gnu.org; Sat, 27 Feb 2016 01:21:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZYG9-0000mw-F0 for guix-devel@gnu.org; Sat, 27 Feb 2016 01:21:49 -0500 Content-Disposition: inline In-Reply-To: <87mvskaxq6.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Roel Janssen Cc: guix-devel@gnu.org Announcement: The ldc D compiler has been added to GNU Guix http://forum.dlang.org/thread/zeeytgxkdkjdeebqozfz@forum.dlang.org =20 Right before ldc 1.0 going into alpha. Great timing :) LDC 1.0.0-alpha1 has been released! http://forum.dlang.org/thread/ndafedsqoqxkhqpbkfja@forum.dlang.org Pj. On Tue, Jan 05, 2016 at 03:48:33PM +0100, Roel Janssen wrote: > From 2a07b6ca221a6466d05fcc434331748b80dc3809 Mon Sep 17 00:00:00 2001 > From: Roel Janssen > Date: Tue, 5 Jan 2016 15:43:50 +0100 > Subject: [PATCH] gnu: Add LDC. >=20 > * gnu/packages/ldc.scm: New file. > * gnu/packages/patches/ldc-disable-tests.patch: New file. > * gnu-system.am (GNU_SYSTEM_MODULES): Add ldc.scm. > (dist_patch_DATA): Add patch file. > --- > gnu-system.am | 2 + > gnu/packages/ldc.scm | 118 +++++++++++++++++++= ++++++++ > gnu/packages/patches/ldc-disable-tests.patch | 90 +++++++++++++++++++= + > 3 files changed, 210 insertions(+) > create mode 100644 gnu/packages/ldc.scm > create mode 100644 gnu/packages/patches/ldc-disable-tests.patch >=20 > diff --git a/gnu-system.am b/gnu-system.am > index 4788bc7..3dd49fe 100644 > --- a/gnu-system.am > +++ b/gnu-system.am > @@ -174,6 +174,7 @@ GNU_SYSTEM_MODULES =3D \ > gnu/packages/key-mon.scm \ > gnu/packages/kodi.scm \ > gnu/packages/language.scm \ > + gnu/packages/ldc.scm \ > gnu/packages/less.scm \ > gnu/packages/lesstif.scm \ > gnu/packages/libcanberra.scm \ > @@ -522,6 +523,7 @@ dist_patch_DATA =3D \ > gnu/packages/patches/jasper-CVE-2008-3522.patch \ > gnu/packages/patches/jbig2dec-ignore-testtest.patch \ > gnu/packages/patches/kmod-module-directory.patch \ > + gnu/packages/patches/ldc-disable-tests.patch \ > gnu/packages/patches/lftp-dont-save-unknown-host-fingerprint.patch \ > gnu/packages/patches/liba52-enable-pic.patch \ > gnu/packages/patches/liba52-link-with-libm.patch \ > diff --git a/gnu/packages/ldc.scm b/gnu/packages/ldc.scm > new file mode 100644 > index 0000000..0bafad0 > --- /dev/null > +++ b/gnu/packages/ldc.scm > @@ -0,0 +1,118 @@ > +;;; GNU Guix --- Functional package management for GNU > +;;; Copyright =C2=A9 2015 Roel Janssen > +;;; Copyright =C2=A9 2015 Pjotr Prins > +;;; > +;;; This file is part of GNU Guix. > +;;; > +;;; GNU Guix is free software; you can redistribute it and/or modify i= t > +;;; under the terms of the GNU General Public License as published by > +;;; the Free Software Foundation; either version 3 of the License, or = (at > +;;; your option) any later version. > +;;; > +;;; GNU Guix is distributed in the hope that it will be useful, but > +;;; WITHOUT ANY WARRANTY; without even the implied warranty of > +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +;;; GNU General Public License for more details. > +;;; > +;;; You should have received a copy of the GNU General Public License > +;;; along with GNU Guix. If not, see . > + > +(define-module (gnu packages ldc) > + #:use-module ((guix licenses) #:prefix license:) > + #:use-module (guix packages) > + #:use-module (guix download) > + #:use-module (guix build-system cmake) > + #:use-module (gnu packages) > + #:use-module (gnu packages base) > + #:use-module (gnu packages libedit) > + #:use-module (gnu packages llvm) > + #:use-module (gnu packages textutils) > + #:use-module (gnu packages zip)) > + > +(define-public ldc > + (package > + (name "ldc") > + (version "0.16.1") > + (source (origin > + (method url-fetch) > + (uri (string-append > + "https://github.com/ldc-developers/ldc/archive/v" > + version ".tar.gz")) > + (file-name (string-append name "-" version ".tar.gz")) > + (sha256 > + (base32 > + "1jvilxx0rpqmkbja4m69fhd5g09697xq7vyqp2hz4hvxmmmv4j40"= )))) > + (build-system cmake-build-system) > + ;; LDC currently only supports the x86_64 and i686 architectures. > + (supported-systems '("x86_64-linux" "i686-linux")) > + (arguments > + `(#:phases > + (modify-phases %standard-phases > + (add-after 'unpack 'unpack-submodule-sources > + (lambda* (#:key inputs #:allow-other-keys) > + (let ((unpack (lambda (source target) > + (with-directory-excursion target > + (zero? (system* "tar" "xvf" > + (assoc-ref inputs sourc= e) > + "--strip-components=3D1= ")))))) > + (and (unpack "phobos-src" "runtime/phobos") > + (unpack "druntime-src" "runtime/druntime") > + (unpack "dmd-testsuite-src" "tests/d2/dmd-testsuit= e"))))) > + (add-after 'unpack-submodule-sources 'patch-phobos > + (lambda* (#:key inputs #:allow-other-keys) > + (substitute* "runtime/phobos/std/process.d" > + (("/bin/sh") (which "sh")) > + (("echo") (which "echo"))) > + (substitute* "runtime/phobos/std/datetime.d" > + (("/usr/share/zoneinfo/") > + (string-append (assoc-ref inputs "tzdata") "/share/zon= einfo"))) > + (substitute* "tests/d2/dmd-testsuite/Makefile" > + (("/bin/bash") (which "bash"))) > + #t))))) > + (inputs > + `(("libconfig" ,libconfig) > + ("libedit" ,libedit) > + ("tzdata" ,tzdata))) > + (native-inputs > + `(("llvm" ,llvm) > + ("clang" ,clang) > + ("unzip" ,unzip) > + ("phobos-src" > + ,(origin > + (method url-fetch) > + (uri (string-append > + "https://github.com/ldc-developers/phobos/archive/ldc-= v" > + version ".tar.gz")) > + (sha256 > + (base32 > + "0sgdj0536c4nb118yiw1f8lqy5d3g3lpg9l99l165lk9xy45l9z4")) > + (patches (list (search-patch "ldc-disable-tests.patch"))))) > + ("druntime-src" > + ,(origin > + (method url-fetch) > + (uri (string-append > + "https://github.com/ldc-developers/druntime/archive/ld= c-v" > + version ".tar.gz")) > + (sha256 > + (base32 > + "0z4mkyddx6c4sy1vqgqvavz55083dsxws681qkh93jh1rpby9yg6")))) > + ("dmd-testsuite-src" > + ,(origin > + (method url-fetch) > + (uri (string-append > + "https://github.com/ldc-developers/dmd-testsuite/archi= ve/ldc-v" > + version ".tar.gz")) > + (sha256 > + (base32 > + "0yc6miidzgl9k33ygk7xcppmfd6kivqj02cvv4fmkbs3qz4yy3z1"))))= )) > + (home-page "http://wiki.dlang.org/LDC") > + (synopsis "LLVM compiler for the D programming language") > + (description > + "LDC is a compiler for the D programming language. It is based o= n the > +latest DMD frontend and uses LLVM as backend.") > + ;; Most of the code is released under BSD-3, except for code origi= nally > + ;; written for GDC, which is released under GPLv2+, and the DMD fr= ontend, > + ;; which is released under the =E2=80=9CBoost Software License ver= sion 1.0". > + (license (list license:bsd-3 > + license:gpl2+ > + license:x11-style "http://www.boost.org/LICENSE_1_0= .txt")))) > diff --git a/gnu/packages/patches/ldc-disable-tests.patch b/gnu/package= s/patches/ldc-disable-tests.patch > new file mode 100644 > index 0000000..3f5e6c2 > --- /dev/null > +++ b/gnu/packages/patches/ldc-disable-tests.patch > @@ -0,0 +1,90 @@ > +This patch fixes a failing unit test by feeding buildNormalizedPath to= the > +tzdata properly. Three other tests are disabled, one assumes /root an= d the > +two others use networking. Not bad out of almost 700 tests! > + > +by Pjotr Prins > + > +diff --git a/std/datetime.d b/std/datetime.d > +index 8e4ed3b..6c15bc5 100644 > +--- a/std/datetime.d > ++++ b/std/datetime.d > +@@ -28018,6 +28018,7 @@ public: > + The default directory where the TZ Database files are. It= 's empty > + for Windows, since Windows doesn't have them. > + +/ > ++ =20 > + enum defaultTZDatabaseDir =3D "/usr/share/zoneinfo/"; > + } > + else version(Windows) > +@@ -28069,14 +28070,13 @@ assert(tz.dstName =3D=3D "PDT"); > + import std.range : retro; > + import std.format : format; > +=20 > +- name =3D strip(name); > +- > + enforce(tzDatabaseDir.exists(), new DateTimeException(format(= "Directory %s does not exist.", tzDatabaseDir))); > + enforce(tzDatabaseDir.isDir, new DateTimeException(format("%s= is not a directory.", tzDatabaseDir))); > +=20 > +- immutable file =3D buildNormalizedPath(tzDatabaseDir, name); > ++ auto filename =3D "./" ~ strip(name); // make sure the prefix= is not stripped > ++ immutable file =3D buildNormalizedPath(tzDatabaseDir, filenam= e); > +=20 > +- enforce(file.exists(), new DateTimeException(format("File %s = does not exist.", file))); > ++ enforce(file.exists(), new DateTimeException(format("File %s = does not exist in %s.", file, tzDatabaseDir))); > + enforce(file.isFile, new DateTimeException(format("%s is not = a file.", file))); > +=20 > + auto tzFile =3D File(file); > +diff --git a/std/path.d b/std/path.d > +index 254d8f0..b0fc04d 100644 > +--- a/std/path.d > ++++ b/std/path.d > +@@ -3080,8 +3080,11 @@ unittest > + } > + else > + { > ++ pragma(msg, "test disabled on GNU Guix"); > ++/* > + assert(expandTilde("~root") =3D=3D "/root", expandTilde("= ~root")); > + assert(expandTilde("~root/") =3D=3D "/root/", expandTilde= ("~root/")); > ++*/ > + } > + assert(expandTilde("~Idontexist/hey") =3D=3D "~Idontexist/hey= "); > + } > +diff --git a/std/socket.d b/std/socket.d > +index b85d1c9..7fbf346 100644 > +--- a/std/socket.d > ++++ b/std/socket.d > +@@ -517,6 +517,8 @@ class Protocol > +=20 > + unittest > + { > ++ pragma(msg, "test disabled on GNU Guix"); > ++/* > + // getprotobyname,number are unimplemented on Android > + softUnittest({ > + Protocol proto =3D new Protocol; > +@@ -530,6 +532,7 @@ unittest > + assert(proto.name =3D=3D "tcp"); > + assert(proto.aliases.length =3D=3D 1 && proto.aliases[0] =3D=3D= "TCP"); > + }); > ++*/ > + } > +=20 > +=20 > +@@ -859,6 +862,8 @@ class InternetHost > +=20 > + unittest > + { > ++ pragma(msg, "test disabled on GNU Guix"); > ++ /* > + InternetHost ih =3D new InternetHost; > +=20 > + ih.getHostByAddr(0x7F_00_00_01); > +@@ -889,6 +894,7 @@ unittest > + // writefln("aliases[%d] =3D %s", i, s); > + // } > + }); > ++ */ > + } > +=20 > +=20 > --=20 > 2.5.0 >=20 > Hello Ricardo, >=20 > Thanks again for your time and helpful response. I hope this version o= f > the patch is fine. >=20 > Ricardo Wurmus writes: >=20 > > Roel Janssen writes: > > > >> +(define-module (gnu packages ldc) > >> + #:use-module ((guix licenses) #:prefix license:) > >> + #:use-module (guix packages) > >> + #:use-module (guix download) > >> + #:use-module (guix build-system cmake) > >> + #:use-module (gnu packages) > >> + #:use-module (gnu packages base) > >> + #:use-module (gnu packages libedit) > >> + #:use-module (gnu packages llvm) > >> + #:use-module (gnu packages textutils) > >> + #:use-module (gnu packages zip)) > >> + > >> +(define-public ldc > >> + (package > >> + (name "ldc") > >> + (version "0.16.1") > >> + (source (origin > >> + (method url-fetch) > >> + (uri (string-append > >> + "https://github.com/ldc-developers/ldc/archive/= v" > >> + version ".tar.gz")) > >> + (file-name (string-append name "-" version ".tar.gz")= ) > >> + (sha256 > >> + (base32 > >> + "1jvilxx0rpqmkbja4m69fhd5g09697xq7vyqp2hz4hvxmmmv4j= 40")))) > >> + (build-system cmake-build-system) > >> + (supported-systems '("x86_64-linux" "i686-linux")) ; other arch= itectures are > >> + (arguments ; not suppor= ted (yet). > > > > This comment would better be placed above the =E2=80=98(supported-sys= tems...)=E2=80=99 > > line. Having it be part of the =E2=80=98(arguments=E2=80=99 line as = well is not nice. > > As a line comment it would then start with a double-semicolon. >=20 > Ok. >=20 > >> + `(#:phases > >> + (modify-phases %standard-phases > >> + (add-after 'unpack 'unpack-phobos-source > >> + (lambda* (#:key inputs #:allow-other-keys) > >> + (with-directory-excursion "runtime/phobos" > >> + (zero? (system* "tar" "xvf" (assoc-ref inputs "pho= bos-src") > >> + "--strip-components=3D1"))))) > >> + (add-after 'unpack 'unpack-druntime-source > >> + (lambda* (#:key inputs #:allow-other-keys) > >> + (with-directory-excursion "runtime/druntime" > >> + (zero? (system* "tar" "xvzf" (assoc-ref inputs "dr= untime-src") > >> + "--strip-components=3D1"))))) > >> + (add-after 'unpack 'unpack-dmd-testsuite-source > >> + (lambda* (#:key inputs #:allow-other-keys) > >> + (with-directory-excursion "tests/d2/dmd-testsuite" > >> + (zero? (system* "tar" "xvzf" > >> + (assoc-ref inputs "dmd-testsuite-s= rc") > >> + "--strip-components=3D1"))))) > > > > I still think that using one phase for unpacking additional tarballs > > would totally suffice. Something like this, maybe: > > > > (add-after 'unpack 'unpack-phobos-source > > (lambda* (#:key inputs #:allow-other-keys) > > (let ((unpack (lambda (source target) > > (with-directory-excursion target > > (zero? (system* "tar" "xvf" > > (assoc-ref inputs sourc= e) > > "--strip-components=3D1= ")))))) > > (and (unpack "phobos-src" "runtime/phobos") > > (unpack "druntime-src" "runtime/druntime") > > (unpack "dmd-testsuite-src" "tests/d2/dmd-testsuit= e"))))) > > > > It=E2=80=99s just a matter of taste, but I really find that your prop= osed three > > phases look rather noisy with lots of boilerplate, which I don=E2=80=99= t think > > needs repeating. >=20 > After seeing how you would go about this I totally agree. I envisioned > three times the (with-directory-excursion) part, which wasn't much > better than what I had. >=20 > This looks really good. Thanks for your guidance! >=20 > >> + (add-after > >> + 'unpack-phobos-source 'patch-phobos > > > > Please pull the symbols onto the same line as =E2=80=9Cadd-after=E2=80= =9D. >=20 > Ok. >=20 > >> + (lambda* (#:key inputs #:allow-other-keys) > >> + (begin > > > > =E2=80=9Cbegin=E2=80=9D is not needed in =E2=80=9Clambda=E2=80=9D. >=20 > Cool. I didn't know that, thanks! >=20 > >> + (substitute* "runtime/phobos/std/process.d" > >> + (("/bin/sh") (which "sh")) > >> + (("echo") (which "echo"))) > >> + (substitute* "runtime/phobos/std/datetime.d" > >> + (("/usr/share/zoneinfo/") > >> + (string-append (assoc-ref inputs "tzdata") "/share= /zoneinfo"))) > >> + (substitute* "tests/d2/dmd-testsuite/Makefile" > >> + (("/bin/bash") (which "bash")))) > >> + #t)) > > > > > >> + (add-after 'unpack-dmd-testsuite-source 'patch-dmd-testsui= te > >> + (lambda _ > >> + #t))))) > > > > I don=E2=80=99t think this phase is needed. >=20 > You're right. >=20 > >> + (inputs > >> + `(("libconfig" ,libconfig) > >> + ("libedit" ,libedit) > >> + ("tzdata" ,tzdata))) > >> + (native-inputs > >> + `(("llvm" ,llvm) > >> + ("clang" ,clang) > >> + ("unzip" ,unzip) > >> + ("phobos-src" > >> + ,(origin > >> + (method url-fetch) > >> + (uri (string-append > >> + "https://github.com/ldc-developers/phobos/archive/l= dc-v" > >> + version ".tar.gz")) > >> + (sha256 > >> + (base32 > >> + "0sgdj0536c4nb118yiw1f8lqy5d3g3lpg9l99l165lk9xy45l9z4")= ) > >> + (patches (list (search-patch "ldc-disable-tests.patch")))= )) > >> + ("druntime-src" > >> + ,(origin > >> + (method url-fetch) > >> + (uri (string-append > >> + "https://github.com/ldc-developers/druntime/archive= /ldc-v" > >> + version ".tar.gz")) > >> + (sha256 > >> + (base32 > >> + "0z4mkyddx6c4sy1vqgqvavz55083dsxws681qkh93jh1rpby9yg6")= ))) > >> + ("dmd-testsuite-src" > >> + ,(origin > >> + (method url-fetch) > >> + (uri (string-append > >> + "https://github.com/ldc-developers/dmd-testsuite/ar= chive/ldc-v" > >> + version ".tar.gz")) > >> + (sha256 > >> + (base32 > >> + "0yc6miidzgl9k33ygk7xcppmfd6kivqj02cvv4fmkbs3qz4yy3z1")= ))))) > >> + (home-page "http://wiki.dlang.org/LDC") > >> + (synopsis "LLVM compiler for the D programming language") > >> + (description > >> + "LDC is a compiler for the D programming language. It is base= d on the > >> +latest DMD frontend and uses LLVM as backend.") > >> + (license license:bsd-3))) ; with exceptions for the DMD fronten= d (custom) and code from GDC (GPLv2+) > > > > This comment is too long for a margin comment. Better place it above > > the =E2=80=98(license ...=E2=80=99 line (with double semicolon). >=20 > Done. >=20 > > I don=E2=80=99t understand the comment. What exceptions apply to the= DMD > > frontend? What does =E2=80=9C(custom)=E2=80=9D mean? Is it a differ= ent license? If > > this package contains code under different licenses it should be made > > clear by providing a list of licenses: > > > > ;; Most of the code is released under BSD-3, except for code from > > ;; GDC (what is this?), which is released under GPLv2+, and the D= MD > > ;; frontend, which is released under the =E2=80=9Cwhatever=E2=80=9D= license. > > (license (list license:bsd-3 > > license:gpl2+ > > license:whatever-custom-is)) > > > > If there is no matching license value for =E2=80=9Ccustom=E2=80=9D yo= u can use > > =E2=80=9C(license:non-copyleft uri)=E2=80=9D, where =E2=80=9Curi=E2=80= =9D is a string holding the URL > > where the license can be read. > > > > I think with these changes it=E2=80=99s okay. >=20 > It is the Boost Software License v1. So I peeked at boost.scm and > copied that license (license:x11-style ...). >=20 > The attached patch should be good, I believe. I hope the description > for the licenses is fine now. The LDC developers have just copied > source code files from GDC. >=20 > Thanks, > Roel Janssen --=20