[PATCH 0/2] Add miking

  • Open
  • quality assurance status badge
Details
One participant
  • Liliana Marie Prikler
Owner
unassigned
Submitted by
Liliana Marie Prikler
Severity
normal
L
L
Liliana Marie Prikler wrote on 17 Jun 2023 19:25
(address . guix-patches@gnu.org)
cover.1687022754.git.liliana.prikler@gmail.com
Hi Guix,

this series adds Miking, a framework for defining domain-specific
languages, which has applications in object-oriented modeling (think
OpenModelica, but less of a pain to bootstrap and with an ML-style
syntax) and probabilistic programming.

It does require some patches to drop the dreaded CUDA, but also to make
the build work with Guix' setup where environment variables have a
meaning, actually. Especially for the latter patch, I'm still trying
to figure out how to best transform the build system into one that is
usable with little overhead. Currently, I've snarfed just about enough
information from the build files to run meaningful tests.

Cheers

Liliana Marie Prikler (2):
gnu: Add miking-boot.
gnu: Add miking.

gnu/local.mk | 2 +
gnu/packages/miking.scm | 127 ++++++++++++++++++
.../patches/miking-drop-acceleration.patch | 106 +++++++++++++++
.../patches/miking-preserve-OCAMLPATH.patch | 28 ++++
4 files changed, 263 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


base-commit: 31336e9f5d68512a9c1c6826bce9f17c892a2125
--
2.40.1
L
L
Liliana Marie Prikler wrote on 17 Jun 2023 19:08
[PATCH 2/2] gnu: Add miking.
(address . 64135@debbugs.gnu.org)
c225fb49f3b105f2426e5d312caf334788889051.1687022754.git.liliana.prikler@gmail.com
* gnu/packages/miking.scm (miking): New variable.
---
gnu/packages/miking.scm | 52 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)

Toggle diff (62 lines)
diff --git a/gnu/packages/miking.scm b/gnu/packages/miking.scm
index 7d65e98970..83a431d443 100644
--- a/gnu/packages/miking.scm
+++ b/gnu/packages/miking.scm
@@ -73,3 +73,55 @@ (define-public miking-boot
(description "@acronym{Miking, Meta Viking} is a meta language system
for creating embedded domain-specific and general-purpose languages.")
(license license:expat))))
+
+(define-public miking
+ (package/inherit
+ miking-boot
+ (name "miking")
+ (build-system copy-build-system)
+ (arguments
+ (list #:install-plan #~`(("build/mi" "bin/")
+ ("stdlib" "lib/mcore"))
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-before 'install 'build
+ (lambda _
+ (invoke "boot" "eval" "src/main/mi-lite.mc"
+ "--"
+ "0" "src/main/mi-lite.mc" "mi-lite")
+ (invoke "./mi-lite" "1" "src/main/mi.mc" "./mi")
+ (invoke "./mi" "compile" "src/main/mi.mc")
+ (mkdir "build")
+ (rename-file "mi" "build/mi")))
+ (add-after 'build 'check
+ (lambda* (#:key tests? #:allow-other-keys)
+ (when tests?
+ (for-each (compose
+ (lambda (file check)
+ (invoke "make" "-f" file check))
+ (lambda (pair) (values (car pair) (cdr pair))))
+ '(("test-compile.mk" . "selected")
+ ("test-run.mk" . "selected")
+ ("test-tune.mk" . "all"))))))
+ (add-after 'install 'wrap
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (wrap-program (string-append (assoc-ref outputs "out")
+ "/bin/mi")
+ `("PATH" suffix
+ (,(dirname (search-input-file inputs "bin/dune"))
+ ,(dirname (search-input-file inputs "bin/ocaml"))
+ ,(dirname (search-input-file inputs "bin/which"))))
+ `("OCAMLPATH" suffix (,(getenv "OCAMLPATH")))))))))
+ (inputs (list bash-minimal
+ dune
+ miking-boot
+ ocaml
+ ocaml-linenoise
+ which))
+ (native-inputs (list dune
+ gnu-make
+ miking-boot
+ ocaml
+ ;; needed for tests
+ coreutils
+ which))))
--
2.40.1
L
L
Liliana Marie Prikler wrote on 17 Jun 2023 19:06
[PATCH 1/2] gnu: Add miking-boot.
(address . 64135@debbugs.gnu.org)
2e4aa0048428b0d2b08c46b03d8f21b54623e580.1687022754.git.liliana.prikler@gmail.com
* 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

Toggle diff (242 lines)
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
+
--
2.40.1
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 64135@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 64135
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch