From patchwork Thu Jan 23 07:36:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Homo X-Patchwork-Id: 37619 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 3196E27BBEA; Thu, 23 Jan 2025 07:38:11 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,LONGWORDS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D640827BBE2 for ; Thu, 23 Jan 2025 07:38:08 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tarmu-0005ly-CX; Thu, 23 Jan 2025 02:38:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tarmt-0005lp-CU for guix-patches@gnu.org; Thu, 23 Jan 2025 02:38:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tarms-0000vt-Vm for guix-patches@gnu.org; Thu, 23 Jan 2025 02:38:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=UZdbBlAoSXHZVpHDsrkPZTDt8dUmJuaqLdgvLsx5gIs=; b=b1QDQTb6lBmceItoYFKsVJcvCxQbo3AdtBMTAIWtWutErD6rudT3di89LVPbueCxsvnWYH7ZmBfti+iuLAwF3gyv1+ev5aGW+ZeyOKP61fc0X9D3mcKkSz3jJLwd2GvEYr2sjym3adt+wGF9drAalOAx9JVOuQxn4N6X2p9uM8XgGXEgdaxpJdCHG/HCiMCoi6A4e6dlwaCDbiIZBsQj8jxPTA31lfB7xmnWV0TvfI3lHfBFuy1Pv6O3hHWkIZ5kIDlfPmHpZz2NBv20fS6Cu1r1tU/KrVky9KOp1SGdFA63J1LegjM+X3C8Df8qjpqAcWAPPSK5e2UkoySm2YAtqw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tarms-0002iq-NU for guix-patches@gnu.org; Thu, 23 Jan 2025 02:38:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#75778] [PATCH] gnu: Add microhs. Resent-From: Homo Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 23 Jan 2025 07:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75778 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 75778@debbugs.gnu.org, lars@6xq.net, divya@subvertising.org Cc: Homo X-Debbugs-Original-To: guix-patches@gnu.org, lars@6xq.net, divya@subvertising.org Received: via spool by submit@debbugs.gnu.org id=B.173761783610399 (code B ref -1); Thu, 23 Jan 2025 07:38:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Jan 2025 07:37:16 +0000 Received: from localhost ([127.0.0.1]:38930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tarm7-0002he-Ej for submit@debbugs.gnu.org; Thu, 23 Jan 2025 02:37:16 -0500 Received: from lists.gnu.org ([2001:470:142::17]:38412) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tarm5-0002hO-Hf for submit@debbugs.gnu.org; Thu, 23 Jan 2025 02:37:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tarlw-0005cl-Ta for guix-patches@gnu.org; Thu, 23 Jan 2025 02:37:06 -0500 Received: from layka.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tarlp-0000dc-Lh for guix-patches@gnu.org; Thu, 23 Jan 2025 02:37:03 -0500 Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 98ADC25C79; Thu, 23 Jan 2025 08:36:54 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id cMK3kk7Ft-kc; Thu, 23 Jan 2025 08:36:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1737617810; bh=CX6oHJ+pRfcLeq2dMU5DPTnAGFEvdjcDzjKWiw3scJI=; h=From:To:Cc:Subject:Date; b=S1i1KIby2YpKhXSP3zG2e1R0rDn5TjDFOVn5JG6kUVDSXtzjNxvUZchiVMQJSH8NX AupTkVG111Lh56/ttSwdEwQel5fg1GF165GcsvIaqNxrTxgsLaQHvygUES/2sgL8Qm NMHFi0nwOVj0asXJ//hPLcUVoEOGAuIgIHSxrlK12uUAII9v3zC/570P+LZckr/D2t hbhJK7ccBK1t6CFf8LJVpYaUvcqnpNbD0i3bM5AwyTlte5NvDd7+oLmhg5WCscJkg1 1wmA/a1R2GmQgFh1VY4VR6xTo23Gudf6MFROU4g2foV0RjPaXSennXEArOCortCYZv eZi9PeHN2fQ4Q== Date: Thu, 23 Jan 2025 09:36:26 +0200 Message-ID: <20250123073630.11285-1-gay@disroot.org> MIME-Version: 1.0 Received-SPF: pass client-ip=178.21.23.139; envelope-from=gay@disroot.org; helo=layka.disroot.org X-Spam_score_int: 0 X-Spam_score: -0.1 X-Spam_bar: / X-Spam_report: (-0.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, LONGWORDS=2.035, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Homo X-ACL-Warn: , Homo via Guix-patches X-Patchwork-Original-From: Homo via Guix-patches via From: Homo Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 , so need to package it separately. Depends on . * 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 ;;; Copyright © 2021 Simon Tournier ;;; Copyright © 2023 Maxim Cournoyer +;;; Copyright © 2025 Homo ;;; ;;; 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