Subject: [bug#57491] [PATCH] patch series: Update Raku ecosystem

From: "Daniel Sockwell" <[email-masked]>
Date: Tue, 30 Aug 2022 16:31:36 +0000

Hi all,

I am working on updating Guix's version of the compiler/related tools
for the Raku programming language.  The current versions are from March
of 2019, which makes them pretty out-of-date given Raku's monthly
release cadence.

This first patch is for MoarVM (the virtual machine that Raku runs on)
which is a dependency for later packages.  I note that, unfortunately,
the output of this package is currently non-deterministic; however, the
same is true of the 2019 version so that non-determinism isn't a
regression.

This is my first Guix package so I'd welcome any feedback you might
have.  I will follow up shortly with three additional patches that
Guix needs in order to provide an up-to-date Raku compiler.

Thanks in advance!

Best,
Daniel

From 18919edeb7ba1f3e3a18e710a715eec899f1910c Mon Sep 17 00:00:00 2001
Message-Id: <[email-masked]>
From: Daniel Sockwell <[email-masked]>
Date: Tue, 30 Aug 2022 12:23:21 -0400
Subject: [PATCH] Update moarvm 2019.03->2022.07

---
 gnu/packages/perl6.scm | 88 +++++++++++++++++++++---------------------
 1 file changed, 45 insertions(+), 43 deletions(-)

diff --git a/gnu/packages/perl6.scm b/gnu/packages/perl6.scm
index dab9dd477b..9b3d98987a 100644
--- a/gnu/packages/perl6.scm
+++ b/gnu/packages/perl6.scm
@@ -22,11 +22,13 @@ (define-module (gnu packages perl6)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix packages)
+  #:use-module (guix build-system gnu)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system rakudo)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages libffi)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages tls))
@@ -34,29 +36,27 @@ (define-module (gnu packages perl6)
 (define-public moarvm
   (package
     (name "moarvm")
-    (version "2019.03")
+    (version "2022.07")
     (source
-      (origin
-        (method url-fetch)
-        (uri (string-append "https://moarvm.org/releases/MoarVM-"
-                            version ".tar.gz"))
-        (sha256
-         (base32
-          "017w1zvr6yl0cgjfc1b3ddlc6vjw9q8p7alw1vvsckw95190xc14"))
-        (modules '((guix build utils)))
-        (snippet
-         '(begin
-            ;(delete-file-recursively "3rdparty/dynasm") ; JIT
-            (delete-file-recursively "3rdparty/dyncall")
-            (delete-file-recursively "3rdparty/freebsd")
-            (delete-file-recursively "3rdparty/libatomicops")
-            (delete-file-recursively "3rdparty/libuv")
-            (delete-file-recursively "3rdparty/libtommath")
-            (delete-file-recursively "3rdparty/msinttypes")
-            #t))))
-    (build-system perl-build-system)
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://moarvm.org/releases/MoarVM-" version ".tar.gz"))
+       (sha256 (base32 "0ijvdd7jyq990zyxrlv8pqhf53q20qhbjly6cnagj9pq2r6z0zik"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin (for-each
+                 delete-file-recursively
+                 '(;"3rdparty/dyncall" ; upstream prefers dyncall to libffi
+                   ;"3rdparty/dynasm"  ; needed for JIT
+                   ;"3rdparty/freebsd" ; freebsd/memmem.o is used on linux
+                   "3rdparty/libatomicops"
+                   "3rdparty/libtommath"
+                   "3rdparty/libuv"
+                   "3rdparty/msinttypes"))))))
+    (build-system gnu-build-system)
     (arguments
-     '(#:phases
+     '(#:test-target "test"
+       #:phases
        (modify-phases %standard-phases
          (replace 'configure
            (lambda* (#:key inputs outputs #:allow-other-keys)
@@ -65,34 +65,36 @@ (define-public moarvm
                (setenv "CFLAGS" "-fcommon")
                (setenv "LDFLAGS" (string-append "-Wl,-rpath=" out "/lib"))
                (invoke "perl" "Configure.pl"
-                       "--prefix" out
-                       "--pkgconfig" (string-append pkg-config "/bin/pkg-config")
-                       "--has-libtommath"
+                       "--mimalloc"
                        "--has-libatomic_ops"
-                       "--has-libffi"
-                       "--has-libuv")))))))
+                       "--has-libtommath"
+                       "--has-libuv"
+                       ;"--has-dyncall" ; TODO: package dyncall for guix
+                       "--toolchain" "gnu"
+                       "--os" "linux"
+                       "--pkgconfig" (string-append pkg-config "/bin/pkg-config")
+                       "--prefix" out)))))))
     (home-page "https://moarvm.org/")
     ;; These should be inputs but moar.h can't find them when building rakudo
-    (propagated-inputs
-     (list libatomic-ops libffi libtommath-1.0 libuv))
-    (native-inputs
-     (list pkg-config))
-    (synopsis "VM for NQP And Rakudo Perl 6")
+    (propagated-inputs (list libatomic-ops libtommath libuv))
+    (native-inputs (list pkg-config perl))
+    (synopsis "Virtual machine for the Raku programming language")
     (description
-     "Short for \"Metamodel On A Runtime\", MoarVM is a modern virtual machine
-built for the Rakudo Perl 6 compiler and the NQP Compiler Toolchain.  Highlights
-include:
+     "MoarVM (\"Metamodel On A Runtime\") is a modern virtual machine built for
+the Raku programming language, NQP, and the Rakudo Raku compiler.  MoarVM's
+features include:
 
 @itemize
-@item Great Unicode support, with strings represented at grapheme level
-@item Dynamic analysis of running code to identify hot functions and loops, and
-perform a range of optimizations, including type specialization and inlining
-@item Support for threads, a range of concurrency control constructs, and
-asynchronous sockets, timers, processes, and more
-@item Generational, parallel, garbage collection
-@item Support for numerous language features, including first class functions,
-exceptions, continuations, runtime loading of code, big integers and interfacing
-with native libraries.
+@item Just-in-time compilation of running code, allowing MoarVM to identify
+and optimize hot functions/loops.  Optimizations include type specialization,
+code inlining/elimination, and on-stack replacement.
+@item Unusually strong Unicode support enabled by strings represented at
+grapheme level and an embedded copy of the Unicode Character Database
+@item Support for numerous Raku language features, such as delimited
+continuations, first-class functions, resumable exceptions, runtime code
+loading, bounded serialization, and native calling/pointer manipulation.
+@item The low-level concurrency primitives required to implement Raku's
+high level concurrency system.
 @end itemize")
     (license license:artistic2.0)))
 
-- 
2.37.2