GNU bug report logs - #75778
[PATCH] gnu: Add microhs.

Previous Next

Package: guix-patches;

Reported by: Homo <gay <at> disroot.org>

Date: Thu, 23 Jan 2025 07:38:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 75778 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#75778; Package guix-patches. (Thu, 23 Jan 2025 07:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Homo <gay <at> disroot.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 23 Jan 2025 07:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Homo <gay <at> disroot.org>
To: guix-patches <at> gnu.org,
	lars <at> 6xq.net,
	divya <at> subvertising.org
Cc: Homo <gay <at> disroot.org>
Subject: [PATCH] gnu: Add microhs.
Date: Thu, 23 Jan 2025 09:36:26 +0200
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.

Depends on <https://issues.guix.gnu.org/75745>.

* 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

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 <at> yoctocell.xyz>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2025 Homo <gay <at> 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





Information forwarded to guix-patches <at> gnu.org:
bug#75778; Package guix-patches. (Sat, 25 Jan 2025 18:17:01 GMT) Full text and rfc822 format available.

Message #8 received at 75778 <at> debbugs.gnu.org (full text, mbox):

From: gay <at> disroot.org
To: 75778 <at> debbugs.gnu.org, Lars-Dominik Braun <lars <at> 6xq.net>,
 divya <at> subvertising.org
Subject: Re: [PATCH] gnu: Add microhs.
Date: Sat, 25 Jan 2025 20:16:31 +0200
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.




Information forwarded to guix-patches <at> gnu.org:
bug#75778; Package guix-patches. (Sun, 26 Jan 2025 07:09:02 GMT) Full text and rfc822 format available.

Message #11 received at 75778 <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <lars <at> 6xq.net>
To: gay <at> disroot.org
Cc: 75778 <at> debbugs.gnu.org, divya <at> subvertising.org
Subject: Re: [PATCH] gnu: Add microhs.
Date: Sun, 26 Jan 2025 08:07:52 +0100
[Message part 1 (text/plain, inline)]
Hi,

> 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

[0001-gnu-Add-microhs.patch (text/plain, attachment)]

Information forwarded to guix-patches <at> gnu.org:
bug#75778; Package guix-patches. (Sun, 26 Jan 2025 14:52:01 GMT) Full text and rfc822 format available.

Message #14 received at 75778 <at> debbugs.gnu.org (full text, mbox):

From: gay <at> disroot.org
To: Lars-Dominik Braun <lars <at> 6xq.net>, 75778 <75778 <at> debbugs.gnu.org>
Subject: Re: [PATCH] gnu: Add microhs.
Date: Sun, 26 Jan 2025 16:51:25 +0200
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.




Information forwarded to guix-patches <at> gnu.org:
bug#75778; Package guix-patches. (Wed, 12 Feb 2025 10:00:02 GMT) Full text and rfc822 format available.

Message #17 received at 75778 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Lars-Dominik Braun <lars <at> 6xq.net>
Cc: 75778 <at> debbugs.gnu.org, divya <at> subvertising.org, gay <at> disroot.org
Subject: Re: [bug#75778] [PATCH] gnu: Add microhs.
Date: Wed, 12 Feb 2025 10:59:09 +0100
Hello,

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

>>From 30612fd4a49d73a9c9747b68d98ce94c1993ee08 Mon Sep 17 00:00:00 2001
> Message-ID: <30612fd4a49d73a9c9747b68d98ce94c1993ee08.1737875219.git.lars <at> 6xq.net>
> From: Homo <gay <at> 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 <at> 6xq.net>

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

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#75778; Package guix-patches. (Wed, 12 Feb 2025 15:03:02 GMT) Full text and rfc822 format available.

Message #20 received at 75778 <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <lars <at> 6xq.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 75778 <at> debbugs.gnu.org, divya <at> subvertising.org, gay <at> disroot.org
Subject: Re: [bug#75778] [PATCH] gnu: Add microhs.
Date: Wed, 12 Feb 2025 16:02:08 +0100
Hi,

> 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/75787 we’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





Information forwarded to guix-patches <at> gnu.org:
bug#75778; Package guix-patches. (Sat, 05 Apr 2025 15:10:01 GMT) Full text and rfc822 format available.

Message #23 received at 75778 <at> debbugs.gnu.org (full text, mbox):

From: Divya Ranjan <divya <at> subvertising.org>
To: Lars-Dominik Braun <lars <at> 6xq.net>
Cc: 75778 <at> debbugs.gnu.org, Ludovic Courtès <ludo <at> gnu.org>,
 lennart <at> augustsson.net, gay <at> disroot.org
Subject: Re: [bug#75778] [PATCH] gnu: Add microhs.
Date: Sat, 05 Apr 2025 15:09:06 +0000
Hello Lars,

> 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/75787 we’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.

Have you looked into microhs since then?

It would be nice to have a bootstrappable implementation of Haskell, and moreover, have you considered if we could compile any version of GHC through MicroHS. I’ve CC’ed Lennard (author of MicroHS), hopefully he can provide us with more input.

Regards,
-- 
Divya Ranjan,
Philosophy, Mathematics, Libre Software.

PGP Fingerprint: F0B3 1A69 8006 8FB8 096A  2F12 B245 10C6 108C 8D4A




Information forwarded to guix-patches <at> gnu.org:
bug#75778; Package guix-patches. (Wed, 23 Apr 2025 14:22:07 GMT) Full text and rfc822 format available.

Message #26 received at 75778 <at> debbugs.gnu.org (full text, mbox):

From: Lars-Dominik Braun <lars <at> 6xq.net>
To: Divya Ranjan <divya <at> subvertising.org>
Cc: 75778 <at> debbugs.gnu.org
Subject: Re: [bug#75778] [PATCH] gnu: Add microhs.
Date: Wed, 23 Apr 2025 16:20:59 +0200
Hi,

> Have you looked into microhs since then?

unfortunately I have not, so I cannot provide any updates.

Lars





This bug report was last modified 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.