[PATCH] gnu: Add microhs.

  • Open
  • quality assurance status badge
Details
3 participants
  • Homo
  • Lars-Dominik Braun
  • Ludovic Courtès
Owner
unassigned
Submitted by
Homo
Severity
normal

Debbugs page

Homo wrote 1 months ago
(name . Homo)(address . gay@disroot.org)
20250123073630.11285-1-gay@disroot.org
Thanks to cooperative work with Lennart Augustsson, MicroHs is now bootstrappable with Hugs.

Skipping build of CPPHS because it depends on CPPHS, as well as skipping build of MicroCabal because its source lives in https://github.com/augustss/MicroCabal, so need to package it separately.


* gnu/packages/patches/microhs-Makefile.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/haskell.scm (microhs): New variable.

Change-Id: Iedbec3fef125044a36f7beed0d5db0d7ad123d5d
---
gnu/local.mk | 1 +
gnu/packages/haskell.scm | 42 ++++++++++++
gnu/packages/patches/microhs-Makefile.patch | 76 +++++++++++++++++++++
3 files changed, 119 insertions(+)
create mode 100644 gnu/packages/patches/microhs-Makefile.patch

Toggle diff (163 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index ecea6ae9c7..0a56634eb5 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1824,6 +1824,7 @@ dist_patch_DATA = \
%D%/packages/patches/mia-vtk9.patch \
%D%/packages/patches/mia-vtk92.patch \
%D%/packages/patches/mia-vtk-version.patch \
+ %D%/packages/patches/microhs-Makefile.patch \
%D%/packages/patches/minisat-friend-declaration.patch \
%D%/packages/patches/minisat-install.patch \
%D%/packages/patches/miniz-for-pytorch.patch \
diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm
index 10803f5afe..43774dbc54 100644
--- a/gnu/packages/haskell.scm
+++ b/gnu/packages/haskell.scm
@@ -24,6 +24,7 @@
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2025 Homo <gay@disroot.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -54,6 +55,7 @@ (define-module (gnu packages haskell)
#:use-module (gnu packages gawk)
#:use-module (gnu packages gcc)
#:use-module (gnu packages ghostscript)
+ #:use-module (gnu packages hugs)
#:use-module (gnu packages libffi)
#:use-module (gnu packages linux)
#:use-module (gnu packages lisp)
@@ -113,6 +115,46 @@ (define-public cl-yale-haskell
top of CLISP.")
(license license:bsd-4))))
+(define-public microhs
+ ;; There are no tags, using latest commit from branch "hugs".
+ (let ((commit "c478ae10b84b722dc41b58d016fd28c8f7e97695")
+ (revision "0"))
+ (package
+ (name "microhs")
+ (version (git-version "0.11.2.4" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/augustss/MicroHs")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "09rx5zaygc0f3wx4pjxk58q7cfh9ac06194ha2gbqjdis71llfs4"))
+ (patches (search-patches "microhs-Makefile.patch"))
+ (modules '((guix build utils)))
+ ;; Remove pre-build binaries.
+ (snippet '(delete-file-recursively "generated"))))
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ ;; TODO: CONF=unix-32 if CPU is 32-bit.
+ #:make-flags #~(list "CC=gcc" (string-append "PREFIX=" #$output))
+ ;; Some tests require GHC and CPPHS.
+ #:tests? #f
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure))))
+ (inputs (list hugs))
+ (native-search-paths
+ (list (search-path-specification
+ (variable "MHSDIR")
+ (files '("lib/mhs")))))
+ (home-page "https://github.com/augustss/MicroHs")
+ (synopsis "A small compiler for Haskell")
+ (description "A compiler for an extended subset of Haskell-2010.
+The compiler translates to combinators and can compile itself.")
+ (license license:asl2.0))))
+
;; This package contains lots of generated .hc files containing C code to
;; bootstrap the compiler without a Haskell compiler. The included .hc files
;; cover not just the compiler sources but also all Haskell libraries.
diff --git a/gnu/packages/patches/microhs-Makefile.patch b/gnu/packages/patches/microhs-Makefile.patch
new file mode 100644
index 0000000000..1f407a860d
--- /dev/null
+++ b/gnu/packages/patches/microhs-Makefile.patch
@@ -0,0 +1,76 @@
+Avoid verbosity in (arguments) in Guile code.
+
+diff --git a/Makefile b/Makefile
+index 2b98363b..86d2260e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -34,7 +34,7 @@ MAINMODULE=src/MicroHs/Main.hs
+ #
+ .PHONY: clean bootstrap install ghcgen newmhs newmhsz cachelib timecompile exampletest cachetest runtest runtestmhs everytest everytestmhs nfibtest info
+
+-all: bin/mhs bin/cpphs bin/mcabal
++all: bin/mhs
+
+ targets.conf:
+ echo [default] > targets.conf
+@@ -56,11 +56,6 @@ newmhsz: newmhs
+ sanitizemhs: ghcgen targets.conf
+ $(CCEVAL) -fsanitize=undefined -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract generated/mhs.c -o bin/mhssane
+
+-# Compile mhs from distribution, with C compiler
+-bin/mhs: src/runtime/*.c src/runtime/*.h targets.conf #generated/mhs.c
+- @mkdir -p bin
+- $(CCEVAL) generated/mhs.c -o bin/mhs
+-
+ # Compile cpphs from distribution, with C compiler
+ bin/cpphs: src/runtime/*.c src/runtime/config*.h generated/cpphs.c
+ @mkdir -p bin
+@@ -108,16 +103,16 @@ mhs.js: src/*/*.hs src/runtime/*.[ch] targets.conf
+ bin/mhs $(MHSINC) -temscripten $(MAINMODULE) -o mhs.js
+
+ # Make sure boottrapping works
+-bootstrap: bin/mhs-stage2
++bin/mhs: bin/mhs-stage2
+ @echo "*** copy stage2 to bin/mhs"
+ cp bin/mhs-stage2 bin/mhs
+ cp generated/mhs-stage2.c generated/mhs.c
+
+ # Build stage1 compiler with existing compiler
+-bin/mhs-stage1: bin/mhs src/*/*.hs
++bin/mhs-stage1: bin/hmhs src/*/*.hs
+ @mkdir -p generated
+ @echo "*** Build stage1 compiler, using bin/mhs"
+- bin/mhs -z $(MHSINC) $(MAINMODULE) -ogenerated/mhs-stage1.c
++ bin/hmhs -z $(MHSINC) $(MAINMODULE) -ogenerated/mhs-stage1.c
+ $(CCEVAL) generated/mhs-stage1.c -o bin/mhs-stage1
+
+ # Build stage2 compiler with stage1 compiler, and compare
+@@ -178,10 +173,9 @@ clean:
+ cd tests; make clean
+ -cabal clean
+
+-oldinstall:
++install:
+ mkdir -p $(PREFIX)/bin
+ cp bin/mhs $(PREFIX)/bin
+- -cp bin/cpphs $(PREFIX)/bin
+ mkdir -p $(PREFIX)/lib/mhs/src/runtime
+ cp -r lib $(PREFIX)/lib/mhs
+ cp src/runtime/* $(PREFIX)/lib/mhs/src/runtime
+@@ -253,7 +247,7 @@ $(MCABALMHS)/packages/$(BASE).pkg: bin/mhs lib/*.hs lib/*/*.hs lib/*/*/*.hs
+ bin/mhs -Q $(BASE).pkg $(MCABALMHS)
+ @rm $(BASE).pkg
+
+-install: $(MCABALBIN)/mhs $(MCABALBIN)/cpphs $(MCABALBIN)/mcabal $(MCABALMHS)/packages/$(BASE).pkg
++newinstall: $(MCABALBIN)/mhs $(MCABALBIN)/cpphs $(MCABALBIN)/mcabal $(MCABALMHS)/packages/$(BASE).pkg
+ @echo $$PATH | tr ':' '\012' | grep -q $(MCABALBIN) || echo '***' Add $(MCABALBIN) to the PATH
+
+ # mkdir ~/.mcabal/packages/array-0.5.6.0
+@@ -277,6 +271,6 @@ generated/hmhs.c:
+ @mkdir -p generated
+ $(HUGS) $(HUGSINCS) $(MAINMODULE) $(MHSINC) $(MAINMODULE) -ogenerated/hmhs.c
+
+-bin/hmhs: generated/hmhs.c
++bin/hmhs: generated/hmhs.c src/runtime/*.c src/runtime/*.h targets.conf
+ @mkdir -p bin
+ $(CCEVAL) generated/hmhs.c -o bin/hmhs
--
2.47.1
gay wrote 4 weeks ago
25ce8eba9245ce9ea517a9b33e811d2e@disroot.org
Need help to change CONF=unix-64 to CONF=unix-32 on all 32-bit
architectures, MicroHs should work on every architecture without any
other modifications, provided Hugs itself is available for bootstrap.
Lars-Dominik Braun wrote 4 weeks ago
(address . gay@disroot.org)
Z5XfSL_LdHBMaID3@noor.fritz.box
Hi,

Toggle quote (4 lines)
> Need help to change CONF=unix-64 to CONF=unix-32 on all 32-bit
> architectures, MicroHs should work on every architecture without any
> other modifications, provided Hugs itself is available for bootstrap.

the attached patch should work and also enables tests.

Lars
gay wrote 4 weeks ago
046ba89455944db143aa84f1e3062443@disroot.org
Nice, thank you :)

To anyone having non-x86 hardware: testing would be helpful, especially
considering there is bug in Hugs that triggers randomly depending on
hardware and/or OS.
Ludovic Courtès wrote 2 weeks ago
Re: [bug#75778] [PATCH] gnu: Add microhs.
(name . Lars-Dominik Braun)(address . lars@6xq.net)
878qqb7ac2.fsf@gnu.org
Hello,

Lars-Dominik Braun <lars@6xq.net> skribis:

Toggle quote (17 lines)
>>From 30612fd4a49d73a9c9747b68d98ce94c1993ee08 Mon Sep 17 00:00:00 2001
> Message-ID: <30612fd4a49d73a9c9747b68d98ce94c1993ee08.1737875219.git.lars@6xq.net>
> From: Homo <gay@disroot.org>
> Date: Thu, 23 Jan 2025 09:36:26 +0200
> Subject: [PATCH] gnu: Add microhs.
>
> Thanks to cooperative work with Lennart Augustsson, MicroHs is now bootstrappable with Hugs.
>
> Skipping build of CPPHS because it depends on CPPHS, as well as skipping build of MicroCabal because its source lives in <https://github.com/augustss/MicroCabal>, so need to package it separately.
>
> * gnu/packages/patches/microhs-Makefile.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
> * gnu/packages/haskell.scm (microhs): New variable.
>
> Change-Id: Iedbec3fef125044a36f7beed0d5db0d7ad123d5d
> Signed-off-by: Lars-Dominik Braun <lars@6xq.net>

Lars, please commit if you think it’s ready.

Thanks,
Ludo’.
Lars-Dominik Braun wrote 2 weeks ago
(name . Ludovic Courtès)(address . ludo@gnu.org)
Z6y38LvWS1HRjs5D@noor.fritz.box
Hi,

Toggle quote (2 lines)
> Lars, please commit if you think it’s ready.

I’m not sure we should add microhs in its current state. This
package uses a random commit on the upstream hugs branch. And over at
https://issues.guix.gnu.org/75787we’re unsure how to actually make
use of it (i.e. make it build Haskell packages). So I would like to
wait until a) the hugs branch is merged into master and packaged into
a proper release b) we can figure out how to make microcabal work.

Lars
?
Your comment

Commenting via the web interface is currently disabled.

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

To respond to this issue using the mumi CLI, first switch to it
mumi current 75778
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
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help