diff mbox series

[bug#64135,1/2] gnu: Add miking-boot.

Message ID 2e4aa0048428b0d2b08c46b03d8f21b54623e580.1687022754.git.liliana.prikler@gmail.com
State New
Headers show
Series Add miking | expand

Commit Message

Liliana Marie Prikler June 17, 2023, 5:06 p.m. UTC
* gnu/packages/miking.scm: New file.
(miking-boot): New variable.
* gnu/packages/patches/miking-drop-acceleration.patch: New file.
* gnu/packages/patches/miking-preserve-OCAMLPATH: New file.
* gnu/local.mk (dist_patch_DATA): Register them here.
---
 gnu/local.mk                                  |   2 +
 gnu/packages/miking.scm                       |  75 +++++++++++++
 .../patches/miking-drop-acceleration.patch    | 106 ++++++++++++++++++
 .../patches/miking-preserve-OCAMLPATH.patch   |  28 +++++
 4 files changed, 211 insertions(+)
 create mode 100644 gnu/packages/miking.scm
 create mode 100644 gnu/packages/patches/miking-drop-acceleration.patch
 create mode 100644 gnu/packages/patches/miking-preserve-OCAMLPATH.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 2b3df5d75a..74676499b8 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1565,6 +1565,8 @@  dist_patch_DATA =						\
   %D%/packages/patches/maxima-defsystem-mkdir.patch		\
   %D%/packages/patches/maven-generate-component-xml.patch		\
   %D%/packages/patches/maven-generate-javax-inject-named.patch		\
+  %D%/packages/patches/miking-drop-acceleration.patch		\
+  %D%/packages/patches/miking-preserve-OCAMLPATH.patch		\
   %D%/packages/patches/mcrl2-fix-1687.patch			\
   %D%/packages/patches/mcrl2-fix-counterexample.patch		\
   %D%/packages/patches/mcrypt-CVE-2012-4409.patch			\
diff --git a/gnu/packages/miking.scm b/gnu/packages/miking.scm
new file mode 100644
index 0000000000..7d65e98970
--- /dev/null
+++ b/gnu/packages/miking.scm
@@ -0,0 +1,75 @@ 
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Liliana Marie Prikler <liliana.prikler@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; 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 <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages miking)
+  #:use-module (guix packages)
+  #:use-module (guix gexp)
+  #:use-module (guix git-download)
+  #:use-module (guix build-system copy)
+  #:use-module (guix build-system dune)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages ocaml))
+
+(define-public miking-boot
+  (let ((commit "539bd577c85d521559f630f2dbe78d2a1c80a26d")
+        (revision "1"))
+    (package
+     (name "miking-boot")
+     (version (git-version "0.0.0" revision commit))
+     (source (origin
+              (method git-fetch)
+              (uri (git-reference (url "https://github.com/miking-lang/miking")
+                                  (commit commit)))
+              (file-name (git-file-name "miking" version))
+              (patches (search-patches
+                        "miking-drop-acceleration.patch"
+                        "miking-preserve-OCAMLPATH.patch"))
+              (modules '((guix build utils)))
+              (snippet
+               #~(begin
+                   (for-each delete-file-recursively
+                             '("src/main/accelerate.mc"
+                               "stdlib/cuda"
+                               "stdlib/futhark"
+                               "stdlib/pmexpr/build.mc"
+                               "stdlib/pmexpr/classify.mc"
+                               "stdlib/pmexpr/compile.mc"
+                               "stdlib/pmexpr/wrapper.mc"
+                               "test/examples/accelerate"))
+                   (substitute* "test-files.mk"
+                     (("special_dependencies_files \\+=.*" all)
+                      (string-append all
+                                     ;; requires Domain module, which is unbound
+                                     "\t$(wildcard stdlib/multicore/*.mc) \\\n"
+                                     ;; require external ocaml packages
+                                     "\tstdlib/ext/async-ext.mc \\\n"
+                                     "\tstdlib/ext/dist-ext.mc \\\n"
+                                     "\tstdlib/ext/toml-ext.mc \\\n")))))
+              (sha256
+               (base32
+                "1qg5w2pdsjfy03qcw8bj4nv9imyb361nws9vmr91xfbjv33m18sm"))))
+     (build-system dune-build-system)
+     (inputs (list ocaml-linenoise))
+     (home-page "https://github.com/miking-lang/miking")
+     (synopsis "Meta language system")
+     (description "@acronym{Miking, Meta Viking} is a meta language system
+for creating embedded domain-specific and general-purpose languages.")
+     (license license:expat))))
diff --git a/gnu/packages/patches/miking-drop-acceleration.patch b/gnu/packages/patches/miking-drop-acceleration.patch
new file mode 100644
index 0000000000..74efb4fd4d
--- /dev/null
+++ b/gnu/packages/patches/miking-drop-acceleration.patch
@@ -0,0 +1,106 @@ 
+From c04bae74e04a19c3bcbfa2e767a882227f7d0a98 Mon Sep 17 00:00:00 2001
+From: Liliana Marie Prikler <liliana.prikler@ist.tugraz.at>
+Date: Fri, 16 Jun 2023 14:10:54 +0200
+Subject: [PATCH] main: Drop acceleration support.
+
+This still leaves all the acceleration-specific code in stdlib, but breaks
+the dependencies, allowing users to simply delete the files.
+---
+ src/main/compile.mc        | 13 ++-----------
+ src/main/mi.mc             |  1 -
+ src/main/options-config.mc |  6 ------
+ src/main/options-type.mc   |  1 -
+ src/main/options.mc        |  1 -
+ 5 files changed, 2 insertions(+), 20 deletions(-)
+
+diff --git a/src/main/compile.mc b/src/main/compile.mc
+index bf8a4d6..63f8e49 100644
+--- a/src/main/compile.mc
++++ b/src/main/compile.mc
+@@ -1,7 +1,6 @@
+ -- Miking is licensed under the MIT license.
+ -- Copyright (C) David Broman. See file LICENSE.txt
+ 
+-include "accelerate.mc"
+ include "mi-lite.mc"
+ include "options.mc"
+ include "parse.mc"
+@@ -130,14 +129,7 @@ let compile = lam files. lam options : Options. lam args.
+     -- backends.
+     -- TODO(larshum, 2022-06-29): Rewrite compilation so that we don't
+     -- duplicate symbolization and type-checking when compiling in debug mode.
+-    let ast =
+-      if options.debugAccelerate then
+-        let ast = symbolizeExpr keywordsSymEnv ast in
+-        let ast = typeCheck ast in
+-        let ast = removeTypeAscription ast in
+-        match checkWellFormedness options ast with (ast, _, _) in
+-        demoteParallel ast
+-      else demoteParallel ast in
++    let ast = demoteParallel ast in
+     endPhaseStats log "accelerate" ast;
+ 
+     -- Insert tuned values, or use default values if no .tune file present
+@@ -149,5 +141,4 @@ let compile = lam files. lam options : Options. lam args.
+ 
+     compileWithUtests options file ast; ()
+   in
+-  if options.accelerate then compileAccelerate files options args
+-  else iter compileFile files
++  iter compileFile files
+diff --git a/src/main/mi.mc b/src/main/mi.mc
+index df52d1f..fb78f69 100644
+--- a/src/main/mi.mc
++++ b/src/main/mi.mc
+@@ -3,7 +3,6 @@
+ --
+ -- File miking.mi is the main file of the Miking tool chain.
+ 
+-include "accelerate.mc"
+ include "compile.mc"
+ include "seq.mc"
+ include "string.mc"
+diff --git a/src/main/options-config.mc b/src/main/options-config.mc
+index 2284e59..33dd22b 100644
+--- a/src/main/options-config.mc
++++ b/src/main/options-config.mc
+@@ -77,12 +77,6 @@ let optionsConfig : ParseConfig Options = [
+     lam p: ArgPart Options.
+       let o: Options = p.options in
+       {o with accelerateTensorMaxRank = string2int (argToString p)}),
+-  ([("--debug-accelerate", "", "")],
+-    join ["Enables static and dynamic checks for accelerated expressions, ",
+-          "and runs the program on the CPU."],
+-    lam p: ArgPart Options.
+-      let o: Options = p.options in {o with debugAccelerate = true,
+-                                            runtimeChecks = true}),
+   ([("--cpu-only", "", "")],
+     "Translate accelerated code to multicore CPU code",
+     lam p: ArgPart Options.
+diff --git a/src/main/options-type.mc b/src/main/options-type.mc
+index 52e6fcb..d27a919 100644
+--- a/src/main/options-type.mc
++++ b/src/main/options-type.mc
+@@ -20,7 +20,6 @@ type Options = {
+   compileAfterTune : Bool,
+   accelerate : Bool,
+   accelerateTensorMaxRank : Int,
+-  debugAccelerate : Bool,
+   cpuOnly : Bool,
+   use32BitIntegers : Bool,
+   use32BitFloats : Bool,
+diff --git a/src/main/options.mc b/src/main/options.mc
+index b870e47..246c03d 100644
+--- a/src/main/options.mc
++++ b/src/main/options.mc
+@@ -23,7 +23,6 @@ let optionsDefault : Options = {
+   compileAfterTune = false,
+   accelerate = false,
+   accelerateTensorMaxRank = 3,
+-  debugAccelerate = false,
+   cpuOnly = false,
+   use32BitIntegers = false,
+   use32BitFloats = false,
+-- 
+2.40.1
+
diff --git a/gnu/packages/patches/miking-preserve-OCAMLPATH.patch b/gnu/packages/patches/miking-preserve-OCAMLPATH.patch
new file mode 100644
index 0000000000..4baa966ad4
--- /dev/null
+++ b/gnu/packages/patches/miking-preserve-OCAMLPATH.patch
@@ -0,0 +1,28 @@ 
+From bef5aa66be782f0b030cf1fec40612acd03ecd92 Mon Sep 17 00:00:00 2001
+From: Liliana Marie Prikler <liliana.prikler@ist.tugraz.at>
+Date: Fri, 16 Jun 2023 08:03:52 +0200
+Subject: [PATCH] Preserve existing OCAMLPATH.
+
+This fixes an issue that causes builds to fail when linenoise (and potentially
+other OCaml libraries) are only found via OCAMLPATH.
+---
+ make.sh | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/make.sh b/make.sh
+index 402b5ec..d967342 100755
+--- a/make.sh
++++ b/make.sh
+@@ -25,7 +25,8 @@ LIB_PATH=$HOME/.local/lib/mcore
+ export MCORE_LIBS=stdlib=`pwd`/stdlib:test=`pwd`/test
+ 
+ # Setup dune/ocamlfind to use local boot library when available
+-export OCAMLPATH=`pwd`/build/lib
++# Do preserve existing OCAML_PATH to find linenoise et al.
++export OCAMLPATH="$(pwd)/build/lib${OCAMLPATH:+:}$OCAMLPATH"
+ 
+ # Compile and build the boot interpreter
+ build_boot(){
+-- 
+2.40.1
+