From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brett Gilio Subject: Packaging Mercury & Some Struggles Date: Mon, 02 Dec 2019 19:23:23 -0600 Message-ID: <87blsqgq2c.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:56107) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibwuX-0004qY-GZ for guix-devel@gnu.org; Mon, 02 Dec 2019 20:23:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibwuR-0008DX-NP for guix-devel@gnu.org; Mon, 02 Dec 2019 20:23:26 -0500 Received: from mout01.posteo.de ([185.67.36.65]:46262) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ibwuP-00088L-Om for guix-devel@gnu.org; Mon, 02 Dec 2019 20:23:22 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id C82E316005E for ; Tue, 3 Dec 2019 02:23:19 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 47Rkkt3mFYz6tm7 for ; Tue, 3 Dec 2019 02:23:17 +0100 (CET) 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" To: guix-devel@gnu.org Greetings all! I am continuing my prolific streak of trying to move as many things from my channel to the main repository as possible. Up next on the menu: the Mercury language and compiler. http://mercurylang.org/ So here are a few issues I am wanting to get resolved with this package, and I am hoping some support from the community can get this package further along. 1. Mercury comes with a number of "grades", which you can think of as anything relating to do with support for extra backends, libraries, and a number of other functionalities. The default setting in Mercury is to compile the compiler including all of the standard grades, which can take one heck of a long time! As a result, I was thinking of adopting something similar to `emacs-minimal`, for people who need to use the Mercury compiler but do not need all of that overhead of having all of the grades included by default. --8<---------------cut here---------------start------------->8--- (define-public mercury-minimal (package (inherit mercury) (name "mercury-minimal") (build-system gnu-build-system) (arguments (substitute-keyword-arguments (package-arguments mercury) ((#:configure-flags flags ''()) `(list "--enable-minimal-install")))) (inputs `(("gcc-toolchain" ,gcc-toolchain))) (synopsis "A pure logic programming language (used only for compiling packages dependent on base Mercury)"))) --8<---------------cut here---------------end--------------->8--- So this example comes with a few points I want to address. Most distinct is the modification of the inherited mercury args to use the minimal-install flag (disabling grades not related to the compiler itself). Additionally, to use the mercury compiler in projects it depends on having some C-based toolchain to handoff the extracted code to. Is including gcc-toolchain as an Input/Prop-Input the best solution here? I worry that it might conflict with versions of the toolchain already in a user profile, or if somebody wants to use a different version of the gcc-toolchain (though they could replace the input using the appropriate guix flag.) 2. The Mercury source tarball includes a git submodule copy of boehm-gc. Of course, I think the "Guix way"TM of doing this is to strip out the submodule and replace it using a Native-Input (assuming the two versions are compatible, anyways). Here is the method I have assumed for trying to get that done. --8<---------------cut here---------------start------------->8--- (add-after 'unpack 'replace-boehm (lambda* (#:key inputs #:allow-other-keys) (let ((boehm (assoc-ref inputs "libgc"))) (map (match-lambda ((src orig-name new-name) (with-directory-excursion "." (apply unpack (list #:source src)) (apply patch-source-shebangs (list #:source src))) (delete-file-recursively new-name) (invoke "mv" orig-name new-name))) `((,boehm "source" "libgc")))))) --8<---------------cut here---------------end--------------->8--- Now, this code may not be perfectly correct (feel free to do the work for me here, if you want, but I can probably figure it out ;). But, the code is at least in the spirit of what I am trying to achieve here. The issue here may just be that I am tired, but for whatever reason `match-lambda' is not resolving. --8<---------------cut here---------------start------------->8--- starting phase `replace-boehm' Backtrace: 8 (primitive-load "/gnu/store/z0wfywmlbn079q07hgab4fafmqx=E2=80= =A6") In ice-9/eval.scm: 191:35 7 (_ #f) In ice-9/boot-9.scm: 829:9 6 (catch srfi-34 # =E2=80=A6) In srfi/srfi-1.scm: 863:16 5 (every1 # =E2=80=A6) In /gnu/store/w3jlc8pk8416m7h677r5vq92b66h8cqd-module-import/guix/build/gnu= -build-system.scm: 839:30 4 (_ _) In ice-9/eval.scm: 159:9 3 (_ #(#(#(#) (=E2=80=A6)) = #)) 182:19 2 (proc #(#(#(#) =E2=80=A6)= =E2=80=A6)) 142:16 1 (compile-top-call _ (7 . match-lambda) ((10 (10 # =E2=80=A6) = =E2=80=A6))) In unknown file: 0 (%resolve-variable (7 . match-lambda) #) ERROR: In procedure %resolve-variable: Unbound variable: match-lambda --8<---------------cut here---------------end--------------->8--- Last I checked, match-lambda belongs to `(ice-9 match)`. Though it is very possible that there is just some syntactical issue here that I am just not seeing right now. Again, eyes on this would be appreciated :). 3. Last, but not least: If any of you can find documentation on how to run the tests for the Mercury compiler, I would greatly appreciate it! I am completely lost on how to run them. I can not find an appropriate make target for them to run off of. 4. This one is not a real issue, per se; however, so far I am doing this work in a new module (gnu packages mercury). I would have preferred to place this in a (gnu packages prolog), but we only have a (gnu packages gprolog) named for the GNU implementation. I personally find this naming convention unfortunate, as I have SWI-Prolog packaged in my channel too, and I would like to see SWI-Prolog, gprolog, and mercury all reside in an appropriately named module. Alright, hopefully this is enough information to get some help but not too much for you all to not eventually consider me for maintainer status in the project. Haha. Below is the complete WIP for Mercury. All thoughts, criticism, and confused stares are welcome: --8<---------------cut here---------------start------------->8--- (define-public mercury (package (name "mercury") (version "14.01.1") (source (origin (method url-fetch) (uri (string-append "https://dl.mercurylang.org/release/mercu= ry-srcdist-" version ".tar.gz")) (sha256 (base32 "12z8qi3da8q50mcsjsy5bnr4ia6ny5lkxvzy01a3c9blgbgcpxwq")))) (build-system gnu-build-system) (arguments '(#:tests? #f ; TODO: tests are cryptic. Figure it out later. #:phases (modify-phases %standard-phases (add-after 'unpack 'patch (lambda _ (substitute* (list "Makefile" "Mmakefile" "scripts/mercury_update_interface.in" "scripts/mercury_config.in" "scripts/mmake.in" "scripts/mmake.sh" "scripts/Mmake.vars.in" "scripts/mdb.in" "scripts/rs6000_hack" "scripts/fullarch" "scripts/mmc.in" "scripts/canonical_grade" "scripts/mprof.in" "scripts/gud.el" "scripts/ml.in" "scripts/canonical_grade.in" "scripts/mdprof.in" "scripts/vpath_find" "scripts/mkfifo_using_mknod.in" "scripts/prepare_install_dir.in" "scripts/ml.sh" "scripts/mprof_merge_runs" "scripts/mtc" "scripts/mgnuc.in" "scripts/c2init.in" "bindist/bindist.Makefile") (("/bin/sh") (which "sh")) (("/bin/pwd") (which "pwd")) (("/bin/rm") (which "rm"))))) (add-after 'unpack 'replace-boehm (lambda* (#:key inputs #:allow-other-keys) (let ((boehm (assoc-ref inputs "libgc"))) (map (match-lambda ((src orig-name new-name) (with-directory-excursion "." (apply unpack (list #:source src)) (apply patch-source-shebangs (list #:source src))) (delete-file-recursively new-name) (invoke "mv" orig-name new-name))) `((,boehm "source" "libgc"))))))))) (native-inputs `(("texinfo" ,texinfo) ("flex" ,flex) ("tcsh", tcsh) ("bison" ,bison) ("readline" ,readline) ("libgc" ,libgc))) (synopsis "A pure logic programming language") (description "Mercury is a logic/functional programming language which= =20 combines the clarity and expressiveness of declarative programming with adv= anced static analysis and error detection features. Its highly optimized executi= on=20 algorithm delivers efficiency far in excess of existing logic programming=20 systems, and close to conventional programming systems. Mercury addresses=20 the problems of large-scale program development, allowing modularity,=20 separate compilation, and numerous optimization/time trade-offs.") (home-page "https://mercurylang.org") (license license:gpl2))) (define-public mercury-minimal (package (inherit mercury) (name "mercury-minimal") (build-system gnu-build-system) (arguments (substitute-keyword-arguments (package-arguments mercury) ((#:configure-flags flags ''()) `(list "--enable-minimal-install")))) (inputs `(("gcc-toolchain" ,gcc-toolchain))) (synopsis "A pure logic programming language (used only for compiling packages dependent on base Mercury)"))) --8<---------------cut here---------------end--------------->8--- --=20 Brett M. Gilio https://git.sr.ht/~brettgilio/