From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iKrRFAjb32EC5gAAgWs5BA (envelope-from ) for ; Thu, 13 Jan 2022 08:55:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id SDGNDQjb32EGXgEAG6o9tA (envelope-from ) for ; Thu, 13 Jan 2022 08:55:52 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4D9452F00F for ; Thu, 13 Jan 2022 08:55:51 +0100 (CET) Received: from localhost ([::1]:35642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7uxZ-0002iF-UE for larch@yhetil.org; Thu, 13 Jan 2022 02:55:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7utv-0006q5-3q for guix-patches@gnu.org; Thu, 13 Jan 2022 02:52:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:38869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7utu-0000WM-CQ for guix-patches@gnu.org; Thu, 13 Jan 2022 02:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n7utu-0004hl-9t for guix-patches@gnu.org; Thu, 13 Jan 2022 02:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#48463] gnu: Add j. Resent-From: elaexuotee@wilsonb.com Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 13 Jan 2022 07:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48463 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Liliana Marie Prikler Cc: Maxime Devos , 48463@debbugs.gnu.org Received: via spool by 48463-submit@debbugs.gnu.org id=B48463.164206030018052 (code B ref 48463); Thu, 13 Jan 2022 07:52:02 +0000 Received: (at 48463) by debbugs.gnu.org; 13 Jan 2022 07:51:40 +0000 Received: from localhost ([127.0.0.1]:60003 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n7utQ-0004gn-DH for submit@debbugs.gnu.org; Thu, 13 Jan 2022 02:51:40 -0500 Received: from m42-5.mailgun.net ([69.72.42.5]:16371) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n7utN-0004gW-3p for 48463@debbugs.gnu.org; Thu, 13 Jan 2022 02:51:31 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.wilsonb.com; q=dns/txt; s=krs; t=1642060289; h=Content-Type: MIME-Version: Message-Id: In-Reply-To: References: From: Subject: Cc: To: Date: Sender; bh=EHk7TyEC5GxK28hM7IBOU3ZJHge+qXcBvFDCWTRqQ9Q=; b=pxqQmsAXfW1GNAWhRW1tKVBdoPPbHG2WX6yF3nqXGjiaAvgFWPCyNcP0pd2beJRdV5kMA+ZA JafUzmSTnVLGLr2g7VabvTPj5CiDxfQApburFhApg39wAi2JkSaLENLYETO2FIxr7qjzjseC BVPZfhX7xi7lpaPK7H0QwJuaO44lcuCuOw7lRIyO5r3vpz5yqL71IGVJxr+t9WRCb9jZWt5i 7gov8OvvlzKj9N89nFKapftH+pjduhOqGIg9o7by0ks+GaWVdbN/NkJdWLeI8ORMFfBPHIoL UuB0MdWg79NkHfy5JsuHI81tXvuS668WmyUpcNDkf4CInmkhfv32Og== X-Mailgun-Sending-Ip: 69.72.42.5 X-Mailgun-Sid: WyJjZGI4NCIsICI0ODQ2M0BkZWJidWdzLmdudS5vcmciLCAiMDg1NDdhIl0= Received: from wilsonb.com (wilsonb.com [104.199.203.42]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 61dfd9fb69943108c547b7f1 (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Thu, 13 Jan 2022 07:51:22 GMT Received: from localhost (aj097104.dynamic.ppp.asahi-net.or.jp [220.150.97.104]) by wilsonb.com (Postfix) with ESMTPSA id E73FAA04CC; Thu, 13 Jan 2022 07:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wilsonb.com; s=201703; t=1642060278; bh=EHk7TyEC5GxK28hM7IBOU3ZJHge+qXcBvFDCWTRqQ9Q=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=RCKH/0gxBoIaMZlwyrheoIYQGuVbsA4EaetpDFWV/DhJOBAFC78cHbbbU8seWSKbD fULTrrdTsZ80ep/OUNge5RmjsE/sqJmDBzb7iBZIicq3+cTVTlP5lix3NxCAHUYkwu BO1WI5itsp+taohKFPDtj6gDyPJYxa88YapaXRp5HSmUgYzjfkwWXiRyajQvhw/2sO 7Z3gN/KyzHhpLcvR2asV1CN4xLHhGeyVDCz2b2VtrA+tNoOzizTbmskJ//nfjzR7Pe 2UQq/46EpfzDkfDYCzsiB/yOWPg7aPC8lOBTNSJp1gR8GobKuhwH90g3DBFKvzG2OH kAG9Ba1WlxhkfyXZ5pm+LJnCf3pPhOeqSMgkod3qaTIZ2dd5EQ2yHrKsgRV0nvAoz0 IBOI6oLmDyj6a6614O/01F1MloccadO3H2SIz71OhXC0T81YXzCccWPTMHDhFwQttl ZixGXtBrK3hFklWHOcCefHO77jZ4m8h8+HubxeH66bpwgu34FpYJJwRc6cTgyrGjnZ Xtq8PjfJWHV7NnO8MOJ+rVtzTXHQt7lo82JufIGoAnvi7Hxr+ZJOUFIbxp2g2mQl24 GmcKX5hRa9YThs9D1xZSlZNLk5NTCQM29BMXaXZz+Q/ePTAgHGnL5esSjSs0uPDEqD C1ErWp/YEeWFzq7J6MAMR17Q= Date: Thu, 13 Jan 2022 16:51:08 +0900 References: <3LOAUDT0FLL4U.2SOD925YP915T@wilsonb.com> <8b853d0585505ce29c9afc638b644fa34805e6c0.camel@student.tugraz.at> <293L8YPQS4CLB.3VK1B1A36XNAY@wilsonb.com> <5d30160bd2a4592459cd407f99cbd3edadb1db1b.camel@student.tugraz.at> <27DCD25Y68ZWJ.2HRC4G65PWIA7@wilsonb.com> <94f4625dcb0479d873cf60449631527e841fd457.camel@gmail.com> <2JQJMV0O718S1.31FZE8GKCTLPF@wilsonb.com> <90704c2259f576a14fb1268219e8c0dc2b3bf289.camel@telenet.be> <2P322C327XW0Q.21O5A4IFGMNDI@wilsonb.com> <72aff035c93f9f91afa54ef5b51c7381b0b02ccb.camel@gmail.com> In-Reply-To: <72aff035c93f9f91afa54ef5b51c7381b0b02ccb.camel@gmail.com> Message-Id: <3MMTDZQJQ8IR6.334ZWY8AD0487@wilsonb.com> User-Agent: mblaze/1.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_4054760516fd6ec72eeb5231_=_" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: elaexuotee@wilsonb.com X-ACL-Warn: , elaexuotee--- via Guix-patches From: elaexuotee--- via Guix-patches via X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1642060551; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=EHk7TyEC5GxK28hM7IBOU3ZJHge+qXcBvFDCWTRqQ9Q=; b=D5LgQiziwsuFWY+JLq+OfKVkQ1T/yY7JL0NnzTQCBAI6KF0jnXBnh//PJD+7wUv3LPPexx FcRX/F01qoptAlIi00S32kmVbm2zmzltcDrqGaIEN2uqXoDU66KuRrR4vRrm/qNuU8PfE5 i/RQZiCa+Y+ehInly7Jr9kPD7V5hRgoLamXarvPLndJ1FKIOXVOP145zmSnsak2dQChqS8 h3t7F6DXkJtneFFsZA0ssomk6PHQJOVYRwOQtjU4FUYED9kAeQHkrAxLKjGMjoWvXpMtke F5uw6FoFLADy8pXP2aBXZ8+utt4u/X4aMTJ7kIoWisZSa4ziu0Zy5bVOKu7yCw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642060551; a=rsa-sha256; cv=none; b=OEypF0Ph1DKDwMej7ygDLqqtA08AqXEoGfmX0ob/UdljxFb/OW8XXtfb2rb3VakXfnRmFr hizcv3Asmnba5cpGpb3I1of+RP8s3WXZMbWgM7X8vTsFboXBVl2ns72aXcXgI7BF9uXoXI ldz4AnKMSFItuz5h3dvROxYz7vahEU3iXhcvsmBXUfx9lmzcgIRUjoJ2TdGz+IjVLrW+Nn xg+jJ72oIvicnWfD5laDL9VNEbTbnhHLQ7DxGjTbmt0200y0ygiATyX3SD0ihdNuTAufai LIY3LlP46F0fQybT5KvBkXE2ZpwjRsFU1N5q33aTPGW1RfjUQ03Gip543Hnd/w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mg.wilsonb.com header.s=krs header.b=pxqQmsAX; dkim=fail ("headers rsa verify failed") header.d=wilsonb.com header.s=201703 header.b="RCKH/0gx"; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.92 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mg.wilsonb.com header.s=krs header.b=pxqQmsAX; dkim=fail ("headers rsa verify failed") header.d=wilsonb.com header.s=201703 header.b="RCKH/0gx"; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 4D9452F00F X-Spam-Score: -4.92 X-Migadu-Scanner: scn0.migadu.com X-TUID: mLyMieHeYIn7 This is a multipart message in MIME format. ------_=_4054760516fd6ec72eeb5231_=_ Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > > +(define-module (gnu packages jsoftware) > > + #:use-module ((guix build utils)) > > + [...] >=20 > Double bracketing is pointless, use it only when needed. Ah, nice catch. I had a bunch of #:select keys and forgot to kill the paren= s when removing. > > +(define* (make-j #:key > > + (builder "guix.gnu.org") > > + vername > > + revision > > + hash > > + (type 'release) > > + commit > > + (patches '()) > > + (extra-inputs '()) > > + (extra-envars '())) > > + (package > > + (name (jname "jsoftware-j" type)) > > + (version (jversion->string vername revision)) > > + (source > > + (origin > > + (method git-fetch) > > + (uri (git-reference > > + (url "https://github.com/jsoftware/jsource") > > + (commit (or commit (jinfo->git-tag vername type > > revision)))) > Vername sounds a little weird, make that version-base or something > clearer. Also, the argument #:commit is used in an unclear fashion -- > if you were to pass an actual commit hash to it, it'd still be treated > as a release and not be using git-version.=20 Cool. I had a similar sense, but our ideas are a lot sharper than the ones = I had. This actually prompted me to do some code cleanup, leveraging now-me w= ho has a bit more Guile experience than past-me. At the very least, variable n= ames should be more descriptive and consistent, overall. > On a related note > > +(define (jversion->string version revision) > > + "Return a string representation of a J version and (optional) > > revision pair." > > + (let ((postfix (if (not revision) "" > > + (string-append "." revision)))) > > + (string-append version postfix))) > should also take commit and revision should probably be dashed. In > that way, when packaging commits between releases we can use > "jrevision.guix-revision" as the complete revision. >=20 > In short, I'd add a #:tag argument to override the tag and treat commit > like a let-bound commit. Done. > > + `(#:modules (((ice-9 ftw) #:select (scandir)) > > + ((ice-9 popen) #:select (open-pipe* close-pipe)) > > + ((ice-9 regex) #:select (match:substring string- > > match)) > > + ((ice-9 threads) #:select (parallel par-for-each)) > > + ((srfi srfi-26) #:select (cut)) > > + ((srfi srfi-1) #:select (fold)) > > + ,@%gnu-build-system-modules) > It's nice that you annotated all those, but note that it probably > wouldn't have been needed. If you notice this list getting longer and > longer as you update, consider dropping the #:selects. >=20 > > + (replace 'build > > + (lambda _ > > + (setenv "USE_OPENMP" "1") > > + (setenv "USE_THREAD" "1") > > + (for-each (lambda (var-val) (apply setenv var-val)) > > + (quote ,extra-envars)) > > + ;; The build scripts assume that PWD is make2. > > + (with-directory-excursion "make2" > > + (let* ((platform ,(if (target-arm?) "raspberry" > > "linux")) > > + (jplat (string-append "jplatform=3D" platform)) > > + (target-bit ,(if (target-64bit?) "64" "32")) > > + (jbit (string-append "j64x=3D" "j" target-bit)) > > + (jbit-avx (string-append jbit "avx")) > > + (jbit-avx2 (string-append jbit "avx2"))) > > + (parallel > > + ;; Since jconsole doesn't depend on AVX features, > > we just > > + ;; build it once. > > + (invoke "env" jplat jbit "./build_jconsole.sh") > > + (invoke "env" jplat jbit "./build_libj.sh") > > + (if ,(target-64bit?) > > + (parallel > > + (invoke "env" jplat jbit-avx > > "./build_libj.sh") > > + (invoke "env" jplat jbit-avx2 > > + "./build_libj.sh")))))))) > Maxime already made a comment w.r.t. 32bit AVX here, but I think this > would be a prime example to use the CPU tuning that was recently > landed. =20 Good idea. Upstream's build scripts condition a *lot* of behaviour on the j64avx environment variable, so it might not be straightforward, but I will= put this on the to-do list of future improvements. (Note, the code block quoted here got much simplified in the current patch.= ) > Most of the above (except the semantics of the make-j keyword > arguments) are not blockers in my opinion. Cheers! ------_=_4054760516fd6ec72eeb5231_=_ Content-Disposition: attachment; filename=0001-gnu-Add-j.patch Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable =46rom aa3015b070d2314e61a18072610bafb62cc41794 Mon Sep 17 00:00:00 2001 =46rom: "B. Wilson" =44ate: Wed, 12 Jan 2022 18:44:36 +0900 =53ubject: [PATCH] gnu: Add j. =54o: guix-patches@gnu.org =0A* gnu/packages/jsoftware.scm: New file. =2A gnu/packages/patches/jsoftware-j901-f-fixes.patch: New file. =2A gnu/local.mk: Register it. =2D-- =20gnu/local.mk | 1 + =20gnu/packages/jsoftware.scm | 457 ++++++++++++++++++ =20.../patches/jsoftware-j901-f-fixes.patch | 80 +++ =203 files changed, 538 insertions(+) =20create mode 100644 gnu/packages/jsoftware.scm =20create mode 100644 gnu/packages/patches/jsoftware-j901-f-fixes.patch =0Adiff --git a/gnu/local.mk b/gnu/local.mk =69ndex 1706663bde..0cbb8899ee 100644 =2D-- a/gnu/local.mk =2B++ b/gnu/local.mk =40@ -1290,6 +1290,7 @@ dist_patch_DATA =3D \ =20 %D%/packages/patches/irrlicht-use-system-libs.patch \ =20 %D%/packages/patches/isc-dhcp-gcc-compat.patch \ =20 %D%/packages/patches/isl-0.11.1-aarch64-support.patch \ =2B %D%/packages/patches/jsoftware-j901-f-fixes.patch \ =20 %D%/packages/patches/json-c-0.13-CVE-2020-12762.patch \ =20 %D%/packages/patches/json-c-0.12-CVE-2020-12762.patch \ =20 %D%/packages/patches/jsoncpp-pkg-config-version.patch \ =64iff --git a/gnu/packages/jsoftware.scm b/gnu/packages/jsoftware.scm =6Eew file mode 100644 =69ndex 0000000000..8c593b5b23 =2D-- /dev/null =2B++ b/gnu/packages/jsoftware.scm =40@ -0,0 +1,457 @@ =2B;;; GNU Guix --- Functional package management for GNU =2B;;; Copyright =C2=A9 2022 B. Wilson =2B;;; =2B;;; This file is part of GNU Guix. =2B;;; =2B;;; GNU Guix is free software; you can redistribute it and/or modify it =2B;;; under the terms of the GNU General Public License as published by =2B;;; the Free Software Foundation; either version 3 of the License, or (a= =74 =2B;;; your option) any later version. =2B;;; =2B;;; GNU Guix is distributed in the hope that it will be useful, but =2B;;; WITHOUT ANY WARRANTY; without even the implied warranty of =2B;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the =2B;;; GNU General Public License for more details. =2B;;; =2B;;; You should have received a copy of the GNU General Public License =2B;;; along with GNU Guix. If not, see . =2B =2B(define-module (gnu packages jsoftware) =2B #:use-module (guix build utils) =2B #:use-module (guix build-system gnu) =2B #:use-module (guix build-system trivial) =2B #:use-module (guix git-download) =2B #:use-module ((guix licenses) #:prefix license:) =2B #:use-module (guix packages) =2B #:use-module (guix utils) =2B #:use-module (gnu packages) =2B #:use-module (gnu packages libedit) =2B #:use-module (gnu packages llvm) =2B #:use-module (gnu packages maths) =2B #:use-module (guix gexp) =2B #:use-module (ice-9 ftw) =2B #:use-module (ice-9 match) =2B #:use-module (ice-9 regex) =2B #:use-module (ice-9 rdelim) =2B #:use-module (srfi srfi-26)) =2B =2B =2B;;; TODO: Make importer and packages for J addons: =2B;;; http://www.jsoftware.com/jal/ =2B =2B;;; TODO: Package up j80x series =2B =2B =2B(define (jname prefix release-type) =2B "Return a package name for J, including RELEASE-TYPE only if not 'rele= =61se." =2B (match release-type =2B ('release prefix) =2B (_ (string-append prefix "-" (symbol->string release-type))))= =29 =2B =2B(define* (jversion->string major #:optional revision commit) =2B "Return a version string formatted like MAJOR.REVISION-COMMIT or =2B MAJOR.REVISION, MAJOR.COMMIT, or just MAJOR according to existing =2B parameters." =2B (match `(,revision ,commit) =2B ((#f #f) major) =2B ((_ #f) (string-append major "." revision)) =2B ((#f _) (string-append major "." commit)) =2B ((_ _) (string-append major "." revision "-" commit)))) =2B =2B(define* (jrelease-string release-type #:optional version-revision) =2B "Construct J release identifier string." =2B (let ((release-type (symbol->string release-type))) =2B (if version-revision =2B (string-append release-type "-" version-revision) =2B release-type))) =2B =2B(define* (jinfo->git-tag version-major release-type #:optional version-r= =65vision) =2B "Given version parameters, construct a git tag for upstream releases."= =0A+ (string-append "j" version-major (jrelease-string release-type versio= =6E-revision))) =2B =2B(define (ijconsole) =2B "Generate a G-exp script that detects AVX/AVX2 support at runtime and =2B executes jconsole with the appropriate libj.so and profile.ijs." =2B (program-file "ijconsole" =2B #~(begin =2B (use-modules ((ice-9 rdelim) #:select (read-line)) =2B ((ice-9 regex) #:select (regexp-match? string-match= =29)) =2B =2B ;; Assume that this script will be installed under bin/. =2B (define %basedir (dirname (dirname (current-filename)))) =2B =2B (define (cpu-feature-line? string) =2B (string-prefix? "flags" string)) =2B =2B (define (contains-word? word string) =2B (regexp-match? =2B (string-match (string-join `("\\<" ,word "\\>") "") =2B string))) =2B =2B (define (has-cpu-feature? feature) =2B (with-input-from-file "/proc/cpuinfo" =2B (lambda () =2B (catch 'found =2B (lambda () =2B (let loop ((line (read-line))) =2B (cond ((eof-object? line) #f) =2B ((and (cpu-feature-line? line) =2B (contains-word? feature line)) =2B (throw 'found)) =2B (else (loop (read-line)))))) =2B (const #t))))) =2B =2B (let* ((jconsole (string-append %basedir "/libexec/j/jconsole"))= =0A+ (libj (format #f "~a/lib/j/libj-~a.so" %basedir =2B (cond ((has-cpu-feature? "avx2") "avx2") =2B ((has-cpu-feature? "avx") "avx") =2B (else "")))) =2B (jprofile (string-append %basedir "/etc/j/profile.ijs")))= =0A+ (apply execl jconsole "ijconsole" "-lib" libj "-jprofile" jpr= =6Ffile =2B (cdr (command-line))))))) =2B =2B(define* (make-j #:key =2B version-major =2B version-revision =2B hash =2B tag =2B (release-type 'release) =2B (patches '()) =2B (extra-inputs '()) =2B (extra-envars '()) =2B (builder "guix.gnu.org")) =2B (package =2B (name (jname "jsoftware-j" release-type)) =2B (version (jversion->string version-major version-revision)) =2B (source =2B (origin =2B (method git-fetch) =2B (uri (git-reference =2B (url "https://github.com/jsoftware/jsource") =2B (commit (or tag (jinfo->git-tag version-major =2B release-type =2B version-revision))))) =2B (sha256 (base32 hash)) =2B (file-name (git-file-name name version)) =2B (patches patches))) =2B (build-system gnu-build-system) =2B (native-inputs `(("clang-toolchain" ,clang-toolchain))) =2B (inputs (cons* `("libedit" ,libedit) =2B `("libomp" ,libomp) =2B `("ijconsole" ,(ijconsole)) =2B extra-inputs)) =2B (arguments =2B `(#:modules (((ice-9 ftw) #:select (scandir)) =2B ((ice-9 popen) #:select (open-pipe* close-pipe)) =2B ((ice-9 regex) #:select (match:substring string-match))= =0A+ ((ice-9 threads) #:select (parallel par-for-each)) =2B ((srfi srfi-26) #:select (cut)) =2B ((srfi srfi-1) #:select (fold)) =2B ,@%gnu-build-system-modules) =2B #:phases =2B ;; Upstream's build system consists of ad-hoc scripts that build b= =75ild up =2B ;; (very complicated) environment variables to pass to make. The = =62asic =2B ;; build process looks like this: =2B ;; =2B ;; 1) Copy jsrc/jversion-x.h to jsrc/jversion.h and edit values;= =0A+ ;; 2) Set jplatform and j64x environment variables; =2B ;; 3) Run make2/build_jconsole.sh and make2/build_libj.sh; =2B ;; =2B ;; However, upstream expects users to run J directly from the sour= =63e =2B ;; directory; they do not supply a make `install' target. Thus it= =20takes =2B ;; some massaging to install files in FHS-style directories. =2B (modify-phases %standard-phases =2B ;; In particular, we have to set up =2B ;; =2B ;; 1) jsrc/jversion.h as in a typical build; =2B ;; 2) jlibrary/bin/profilex.ijs to point to writable directori= =65s; =2B ;; 3) make2/build_*.sh to respect standard build conventions; =2B ;; 4) jsrc/jconsole.c to fix libedit dlopen; and =2B ;; 5) Hard coded references to addons directory. =2B (replace 'configure =2B (lambda* (#:key target inputs outputs #:allow-other-keys) =2B (let* ((clang-toolchain (assoc-ref inputs "clang-toolchain")= =29 =2B (clang (string-append clang-toolchain "/bin/clang")) =2B (libedit (assoc-ref inputs "libedit")) =2B (out (assoc-ref outputs "out"))) =2B ;; Set up build constants =2B (copy-file "jsrc/jversion-x.h" "jsrc/jversion.h") =2B (substitute* "jsrc/jversion.h" =2B (("^#define jversion.*$") =2B (format #f "#define jversion ~s\n" ,version-major)) =2B (("^#define jtype.*$") =2B (format #f "#define jtype ~s\n" =2B ,(jrelease-string release-type version-revision= =29)) =2B (("^#define jbuilder.*$") =2B (format #f "#define jbuilder ~s\n" ,builder))) =2B ;; Create profilex.ijs overrides to point to the correct s= =74ore =2B ;; items. Note that we set ~install and ~addons directori= =65s to =2B ;; reside under ~user to allow installing and loading addo= =6Es. =2B ;; TODO: Guix-ify J addons as well. =2B (call-with-output-file "jlibrary/bin/profilex.ijs" =2B (lambda (port) =2B (display =2B (string-join =2B (list =2B "share=3D. '/share/j',~ ({.~ _2 { I.@:=3D&'/') B= =49NPATH" =2B "system=3D. share,'/system'" =2B "tools=3D. share,'/tools'" =2B ;; Upstream defaults to spamming $HOME with unhi= =64den =2B ;; userdata directories. Set this to be =2B ;; $HOME/.config/j/ instead =2B "'jtype jversion'=3D. (3&{,{.) <;._2 ,&'/' 9!:14= =27'" =2B "jversion=3D. ({.~ i.&'-') jversion" =2B "user=3D. home,'/.config/j/',jversion" =2B "addons=3D. user,'/addons'" =2B "break=3D. user,'/break'" =2B "config=3D. user,'/config'" =2B "install=3D. user,'/install'" =2B "snap=3D. user,'/snap'" =2B "temp=3D. user,'/temp'" =2B "\n") =2B "\n") =2B port))) =2B ;; Munge the build scripts into reason: =2B ;; 1. Short-circuit the fragile compiler detection; =2B ;; 2. Make sure to include our CFLAGS and LFLAGS; and =2B ;; 3. Propagate script errors to top level. =2B (for-each =2B (lambda (file) =2B (with-directory-excursion "make2" =2B (substitute* file =2B ;; The `compiler' variable doesn't point to the act= =75al =2B ;; compiler. It is just a switch to tell the build= =0A+ ;; scripts whether to use gcc- or clang-specific f= =6Cags. =2B (("^compiler=3D.*$") "compiler=3Dclang\n") =2B (("^LDFLAGS=3D\"" def) (string-append def "$LDFLAGS= =20")) =2B (("^(common=3D\")(\\$USETHREAD.*)$" _ def rest) =2B (string-append def "$CFLAGS " rest)) =2B (("^#!.*" shebang) =2B (string-append shebang "set -o errexit\n"))))) =2B '("build_jconsole.sh" "build_libj.sh")) =2B ;; The jconsole manually loads libedit with dlopen. The p= =61th =2B ;; must be absolute to correctly point to our input. =2B (substitute* "jsrc/jconsole.c" =2B (("libedit\\.so\\.[0-9]" so-file) =2B (format #f "~a/lib/~a" libedit so-file))) =2B ;; The ~addons/dev directory supplies tentative J-script =2B ;; definitions of new J engine functionality. Since we po= =69nt =2B ;; ~addons under the ~user directory, we move it under ~sy= =73tem =2B ;; instead, which sits as-is in the output. =2B (with-directory-excursion "jsrc" =2B (for-each =2B (lambda (file) =2B (substitute* file (("~addons/dev") "~system/dev"))) =2B (scandir "." =2B (lambda (f) (eq? (stat:type (stat f)) 'regular))))) =2B ;; Implementation of 9!:14 records build time which breaks= =20build =2B ;; reproducibility. Note that upstream code depends on th= =65 exact =2B ;; format of these strings, so we need to mimic the standa= =72d. =2B (substitute* "jsrc/j.c" =2B (("__DATE__") "\"Jan 01 1970\"") =2B (("__TIME__") "\"00:00:00\"")) =2B ;; Upstream recommends using clang, with GCC support being= =0A+ ;; second-class, often resulting in build failures. =2B (setenv "CC" clang)))) =2B =2B ;; The build output depends primarily on the values of the `jpla= =74form' =2B ;; and `j64x' environment variables. If the target is ARM, then= =0A+ ;; `jplatform' is "raspberry", otherwise it is `linux'. In add= =69tion to =2B ;; 32- and 64- bit versions, `j64x' controlls whether AVX or AVX= =32 =2B ;; variants of libj are built. =2B ;; =2B ;; However, build targets are not fine-grained enough to disting= =75ish =2B ;; between CPU features. Thus we build and install all variants= =20of =2B ;; libj, expecting jconsole to be called with a wrapper script t= =68at =2B ;; detects AVX features and loads the appropriate libj at runtim= =65. =2B (replace 'build =2B (lambda _ =2B (setenv "USE_OPENMP" "1") =2B (setenv "USE_THREAD" "1") =2B (for-each (lambda (var-val) (apply setenv var-val)) =2B (quote ,extra-envars)) =2B ;; The build scripts assume that PWD is make2. =2B (with-directory-excursion "make2" =2B (let* ((platform ,(if (target-arm?) "raspberry" "linux")) =2B (target-bit ,(if (target-64bit?) "64" "32")) =2B (run (lambda* (script #:key (avx "")) =2B (invoke "env" =2B (string-append "jplatform=3D" platfo= =72m) =2B (string-append "j64x=3Dj" target-bit= =20avx) =2B script)))) =2B (parallel =2B ;; Since jconsole doesn't depend on AVX features, we j= =75st =2B ;; build it once. =2B (run "./build_jconsole.sh") =2B (run "./build_libj.sh") =2B (if ,(target-64bit?) =2B (parallel =2B (run "./build_libj.sh" #:avx "avx") =2B (run "./build_libj.sh" #:avx "avx2")))))))) =2B ;; The test suite is expected to be run as follows for each vari= =61nt of =2B ;; libj that we build: =2B ;; =2B ;; $ echo 'RUN ddall' | jconsole test/tsu.ijs =2B ;; =2B ;; This requires a working jconsole with accessible jlibrary fil= =65s. We =2B ;; simply place these all under test/bin. =2B (replace 'check =2B (lambda* (#:key tests? #:allow-other-keys) =2B (when tests? =2B (let ((platform ,(if (target-arm?) "raspberry" "linux"))) =2B (mkdir-p "test/bin") =2B (for-each =2B (lambda (dir) =2B (let ((source (string-append "jlibrary/" dir)) =2B (dest (string-append "test/bin/" dir))) =2B (begin =2B (mkdir-p dest) =2B (copy-recursively source dest)))) =2B '("system" "tools" "addons")) =2B ;; The jlibrary/dev directory only sometimes exists, but= =20needs =2B ;; to be copied into the ~system directory when it does.= =0A+ (for-each =2B (lambda (dev-dir) =2B (if (file-exists? dev-dir) =2B (copy-recursively dev-dir "test/bin/system/dev")))= =0A+ '("jlibrary/dev" "jlibrary/addons/dev")) =2B (par-for-each =2B (lambda (dir) =2B (let* ((bin (string-append "bin/" platform)) =2B (jbit ,(if (target-64bit?) "j64" "j32")) =2B (jconsole (string-append bin "/" jbit =2B "/jconsole")) =2B (source (string-append bin "/" dir)) =2B (dest (string-append "test/bin/" dir))) =2B (begin =2B (mkdir-p dest) =2B (copy-recursively source dest) =2B (install-file "jlibrary/bin/profile.ijs" dest) =2B (install-file jconsole dest) =2B (let* ((jconsole (string-append dest "/jconsole"= =29) =2B (tests "test/tsu.ijs") =2B (port (open-pipe* OPEN_WRITE jconsole tes= =74s))) =2B (display "RUN ddall\n" port) =2B (when (not (zero? (status:exit-val =2B (close-pipe port)))) =2B (error "Some J build tests failed.")))))) =2B (scandir (string-append "bin/" platform) =2B (negate (cut member <> '("." ".."))))) =2B #t)))) =2B ;; Now that everything is built, installation is fairly =2B ;; straightforward, following FHS conventions. The only quirk i= =73 that =2B ;; we install jconsole under /libexec to make room for the wrapp= =65r =2B ;; replacement under /bin. =2B (replace 'install =2B (lambda* (#:key outputs inputs #:allow-other-keys) =2B (let* ((platform ,(if (target-arm?) "raspberry" "linux")) =2B (jbit ,(if (target-64bit?) "j64" "j32")) =2B (ijconsole (assoc-ref inputs "ijconsole")) =2B (jconsole (string-append "bin/" platform "/" =2B jbit "/jconsole")) =2B (out (assoc-ref outputs "out")) =2B (bin (string-append out "/bin")) =2B (etc (string-append out "/etc/j")) =2B (lib (string-append out "/lib/j")) =2B (libexec (string-append out "/libexec/j")) =2B (share (string-append out "/share/j")) =2B (system (string-append share "/system")) =2B (dev (string-append system "/dev"))) =2B (mkdir-p bin) =2B (copy-file ijconsole (string-append bin "/ijconsole-" =2B ,version-major)) =2B (mkdir-p lib) =2B (for-each =2B (lambda (jarch) =2B (let* ((jbin (string-join `("bin" ,platform ,jarch) "/= =22)) =2B (javx-match (string-match "avx.*" jarch)) =2B (javx (if (not javx-match) "" =2B (match:substring javx-match))) =2B (sep (if javx-match "-" "")) =2B (source (string-append jbin "/libj.so")) =2B (dest (format #f "~a/libj~a~a.so" lib sep javx)= =29) =2B (copy-file source dest))) =2B (scandir (string-append "bin/" platform) =2B (negate (cut member <> '("." ".."))))) =2B (install-file jconsole libexec) =2B (copy-recursively "jlibrary/system" system) =2B (for-each =2B (lambda (source-dev) =2B (if (access? source-dev R_OK) =2B (copy-recursively source-dev dev))) =2B '("jlibrary/dev" "jlibrary/addons/dev")) =2B (install-file "jlibrary/bin/profile.ijs" etc) =2B (install-file "jlibrary/bin/profilex.ijs" etc))))))) =2B (home-page "https://www.jsoftware.com/") =2B (synopsis "Ascii-only, array programming language in the APL family")= =0A+ (description =2B "J is a high-level, general-purpose programming language that is =2Bparticularly suited to the mathematical, statistical, and logical analys= =69s of =2Bdata. It is a powerful tool for developing algorithms and exploring pro= =62lems =2Bthat are not already well understood.") =2B (license license:gpl3+))) =2B =2B =2B(define-public jsoftware-j-901 =2B (make-j =2B #:version-major "901" =2B #:version-revision "f" =2B #:hash "1776021m0j1aanzwg60by83n53pw7i6afd5wplfzczwk8bywax4p" =2B #:patches (search-patches "jsoftware-j901-f-fixes.patch"))) =2B =2B =2B(define j-build-configuration-with-sleef =2B `(#:extra-inputs (("sleef" ,sleef)) =2B #:extra-envars (("USE_SLEEF_SRC" "0") =2B ("LDFLAGS" "-lsleef")))) =2B =2B(define-public jsoftware-j-902 =2B (apply make-j =2B (append j-build-configuration-with-sleef =2B '(#:version-major "902" =2B #:version-revision "b" =2B #:hash "0j67vgikqflwjqacsdicasvyv1k54s2c8vjgwmf0ix7l41p4xqz0")))= =29 =2B =2B =2B(define-public jsoftware-j-903 =2B (apply make-j =2B (append j-build-configuration-with-sleef =2B '(#:version-major "903" =2B #:version-revision "a" =2B #:tag "903-release-a" =2B #:hash "1fcfl7q7c2vj4fmnqqc8c6hwgsjm20ff93v8xxfniasss1b2fmc4")))= =29 =2B =2B =2B(define-public (jsoftware-ijconsole-symlink jpkg) =2B "Provide bin/ijconsole symlink that points to pkg's bin/ijconsole-" =2B (package =2B (name "jsoftware-ijconsole") =2B (version (package-version jpkg)) =2B (source #f) =2B (build-system trivial-build-system) =2B (propagated-inputs `(("jpkg" ,jpkg))) =2B (arguments =2B `(#:modules ((guix build utils) =2B (srfi srfi-26)) =2B #:builder =2B (begin =2B (use-modules ((guix build utils) #:select (mkdir-p)) =2B ((ice-9 regex) #:select (string-match)) =2B ((ice-9 ftw) #:select (scandir)) =2B ((srfi srfi-26) #:select (cut))) =2B (let* ((out (assoc-ref %outputs "out")) =2B (jpkg (assoc-ref %build-inputs "jpkg")) =2B (ijconsole (car (scandir (string-append jpkg "/bin") =2B (cut string-match "ijconsole-.*" = =3C>)))) =2B (source (string-append jpkg "/bin/" ijconsole)) =2B (dest (string-append out "/bin/ijconsole"))) =2B (mkdir-p (dirname dest)) =2B (symlink source dest))))) =2B (home-page (package-home-page jpkg)) =2B (synopsis "Provide `ijconsole' symlink to default interpreter version"= =29 =2B (description =2B "The interpreter provided by the J package has a filename like =2Bijconsole-, which provides support for having multiple, concurr= =65nt =2Bversions installed. This package provides a version-agnostic `ijconsole= =27 =2Bsymlink to interpreter version indicated and build time.") =2B (license license:gpl3+))) =64iff --git a/gnu/packages/patches/jsoftware-j901-f-fixes.patch b/gnu/pack= =61ges/patches/jsoftware-j901-f-fixes.patch =6Eew file mode 100644 =69ndex 0000000000..0ac7e94de4 =2D-- /dev/null =2B++ b/gnu/packages/patches/jsoftware-j901-f-fixes.patch =40@ -0,0 +1,80 @@ =2BThis patch fixes two separate issues with ustream sources: =2B =2B* Normalize import paths in jsrc/cip.c =2B =2BUpstream claims to have some build requirements that force them to use s= =74range =2Bimport paths. However, these paths do not exist inside our build chroot.= =0A+ =2B* Fix unititialized variable warning =2B =2BClang 9 issues some warnings which cause the build to fail since upstrea= =6D =2Bcompiles with -Werror. =2B =2B =2Bdiff --git a/jsrc/cip.c b/jsrc/cip.c =2Bindex 61da4088..fb3c03b6 100644 =2B--- a/jsrc/cip.c =2B+++ b/jsrc/cip.c =2B@@ -3,9 +3,9 @@ =2B /* = =20 */ =2B /* Conjunctions: Inner Product = =20 */ =2B=20 =2B-#include "../../jsource/jsrc/j.h" =2B-#include "../../jsource/jsrc/vasm.h" =2B-#include "../../jsource/jsrc/gemm.h" =2B+#include "j.h" =2B+#include "vasm.h" =2B+#include "gemm.h" =2B=20 =2B #define MAXAROWS 384 // max rows of a that we can process to stay in L= =32 cache a strip is m*CACHEHEIGHT, z strip is m*CACHEWIDTH this is wir= =65d to 128*3 - check if you chage =2B=20 =2B@@ -1057,15 +1057,15 @@ static A jtipbx(J jt,A a,A w,C c,C d){A g=3D0,x0= =2Cx1,z;B*av,*av0,b,*v0,*v1,*zv;C c0 =2B switch(c){ =2B case CPLUSDOT: =2B #define F |=3D =2B-#include "../../jsource/jsrc/cip_t.h" =2B+#include "cip_t.h" =2B break; =2B case CSTARDOT: =2B #define F &=3D =2B-#include "../../jsource/jsrc/cip_t.h" =2B+#include "cip_t.h" =2B break; =2B case CNE: =2B #define F ^=3D =2B-#include "../../jsource/jsrc/cip_t.h" =2B+#include "cip_t.h" =2B break; =2B } =2B R z; =2Bdiff --git a/jsrc/gemm.c b/jsrc/gemm.c =2Bindex 51fe306e..b105dfc1 100644 =2B--- a/jsrc/gemm.c =2B+++ b/jsrc/gemm.c =2B@@ -318,7 +318,7 @@ dgemm_nn (I m, =2B _B); =2B=20 =2B // loop 3 =2B- I i; =2B+ I i=3D0; =2B #pragma omp parallel for default(none),private(i),shared(j,l,A,C,mb,nc,= =6Bc,alpha,_beta,_mc,_B,rs_a,cs_a,rs_c,cs_c) =2B for (i=3D0; i