unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#31940] [PATCH] gnu: Add Stalin.
@ 2018-06-22 18:35 Adam Massmann
  2018-06-25 20:36 ` bug#31940: " Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Massmann @ 2018-06-22 18:35 UTC (permalink / raw)
  To: 31940

[-- Attachment #1: Type: text/plain, Size: 96 bytes --]

Hi Guix,

Below is a patch to add the Stalin compiler to Guix. Feedback welcome.

Thanks,
Adam


[-- Attachment #2: 0001-gnu-Add-stalin.patch --]
[-- Type: text/x-patch, Size: 4966 bytes --]

From dbd3395c90aa443a7c6bad9155e6bfc7053bfbf0 Mon Sep 17 00:00:00 2001
From: Adam Massmann <massmannak@gmail.com>
Date: Fri, 22 Jun 2018 14:29:23 -0400
Subject: [PATCH] gnu: Add stalin.

* gnu/packages/scheme.scm (stalin): New variable.
---
 gnu/packages/scheme.scm | 78 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/scheme.scm b/gnu/packages/scheme.scm
index dba5067e9..dbb545532 100644
--- a/gnu/packages/scheme.scm
+++ b/gnu/packages/scheme.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2017 John Darrington <jmd@gnu.org>
 ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Adam Massmann <massmannak@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -356,7 +357,7 @@ mashups, office (web agendas, mail clients, ...), etc.")
      `(#:modules ((guix build gnu-build-system)
                   (guix build utils)
                   (srfi srfi-1))
-       
+
        ;; No `configure' script; run "make check" after "make install" as
        ;; prescribed by README.
        #:phases
@@ -1025,3 +1026,78 @@ the same program, without any interference between them.  Foreign functions in C
 can be added and values can be defined in the Scheme environment.  Being quite a
 small program, it is easy to comprehend, get to grips with, and use.")
     (license bsd-3)))                   ; there are no licence headers
+
+(define-public stalin
+  (let ((commit "ed1c9e339c352b7a6fee40bb2a47607c3466f0be"))
+    (package
+      (name "stalin")
+      (version "0.11")
+      (source (origin
+                ;; Use Pearlmutter's upstream branch with AMD64 patches
+                ;; applied. Saves us from including those 20M! patches
+                ;; in Guix. For more info, see:
+                ;; <ftp.ecn.purdue.edu/qobi/stalin-0.11-amd64-patches.tgz>
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/barak/stalin.git")
+                      (commit commit)))
+                (file-name (string-append name "-" version "-checkout"))
+                (sha256
+                 (base32
+                  "15a5gxj9v7jqlgkg0543gdflw0rbrir7fj5zgifnb33m074wiyhn"))
+                (modules '((guix build utils)))
+                (snippet
+                 ;; remove gc libs from build, we have them as input
+                 '(begin
+                    (delete-file "gc6.8.tar.gz")
+                    (delete-file-recursively "benchmarks")
+                    (substitute* "build"
+                      ((".*gc6.8.*") "")
+                      (("  cd \\.\\.") "")
+                      ((".*B include/libgc.a") "")
+                      ((".*make.*") ""))
+                    #t))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:make-flags (list "ARCH_OPTS=-freg-struct-return")
+         #:phases
+         (modify-phases %standard-phases
+           (replace 'configure
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (include-out (string-append out "/include")))
+                 (invoke "./build")
+                 (for-each (lambda (fname)
+                             (install-file fname include-out))
+                           (find-files "include"))
+                 (substitute* "makefile"
+                   (("\\./include") include-out))
+                 (substitute* "post-make"
+                   (("`pwd`") out))
+                 #t)))
+           (delete 'check)
+           (replace 'install
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out")))
+                 (install-file "stalin.1"
+                               (string-append out "/share/man/man1"))
+                 (install-file "stalin"
+                               (string-append out "/bin"))
+                 #t))))))
+      (inputs
+       `(("libx11" ,libx11)))
+      (propagated-inputs
+       `(("libgc" ,libgc)))
+      (supported-systems '("x86_64-linux"))
+      (home-page "https://engineering.purdue.edu/~qobi/papers/fdlcc.pdf")
+      (synopsis "Brutally efficient Scheme compiler")
+      (description
+       "Stalin is an aggressively optimizing whole-program compiler
+for Scheme that does polyvariant interprocedural flow analysis,
+flow-directed interprocedural escape analysis, flow-directed
+lightweight CPS conversion, flow-directed lightweight closure
+conversion, flow-directed interprocedural lifetime analysis, automatic
+in-lining, unboxing, and flow-directed program-specific and
+program-point-specific low-level representation selection and code
+generation.")
+      (license gpl2+))))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#31940: [PATCH] gnu: Add Stalin.
  2018-06-22 18:35 [bug#31940] [PATCH] gnu: Add Stalin Adam Massmann
@ 2018-06-25 20:36 ` Ludovic Courtès
  2018-06-26  1:07   ` [bug#31940] " Adam Massmann
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2018-06-25 20:36 UTC (permalink / raw)
  To: Adam Massmann; +Cc: 31940-done

Hello Adam,

Adam Massmann <massmannak@gmail.com> skribis:

>>From dbd3395c90aa443a7c6bad9155e6bfc7053bfbf0 Mon Sep 17 00:00:00 2001
> From: Adam Massmann <massmannak@gmail.com>
> Date: Fri, 22 Jun 2018 14:29:23 -0400
> Subject: [PATCH] gnu: Add stalin.
>
> * gnu/packages/scheme.scm (stalin): New variable.

Another Scheme, woohoo!  :-)  Applied!

I applied the patch, but I added a FIXME about the fact that it’s
“yogurt software” as Ricardo says: its “source” includes C files
generated by itself, which are obviously not source code.  We try to
avoid that, but OTOH we already have the same problem for several
compilers, for instance MIT/GNU Scheme.

From the README, previous versions were apparently bootstrapped using a
separate Scheme->C compiler.  We could perhaps fix the problem by
building one of these older versions of Stalin, and using it to build
the latest one.  Would you like to give it a try?  (On this topic, don’t
miss <http://bootstrappable.org/>.)

Anyway, thanks for the patch!

Ludo’.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bug#31940] [PATCH] gnu: Add Stalin.
  2018-06-25 20:36 ` bug#31940: " Ludovic Courtès
@ 2018-06-26  1:07   ` Adam Massmann
  0 siblings, 0 replies; 3+ messages in thread
From: Adam Massmann @ 2018-06-26  1:07 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31940-done

Hi Ludo,

ludo@gnu.org (Ludovic Courtès) writes:

> I applied the patch, but I added a FIXME about the fact that it’s
> “yogurt software” as Ricardo says: its “source” includes C files
> generated by itself, which are obviously not source code.  We try to
> avoid that, but OTOH we already have the same problem for several
> compilers, for instance MIT/GNU Scheme.
>
> From the README, previous versions were apparently bootstrapped using
> a separate Scheme->C compiler.  We could perhaps fix the problem by
> building one of these older versions of Stalin, and using it to build
> the latest one.  Would you like to give it a try?  (On this topic,
> don’t miss <http://bootstrappable.org/>.)

Thanks a lot for the code review and feedback - it's very helpful for me
as I learn. At first glance I think in this case, as you point out, we
should be able to use Scheme->C to generate the C files explicitly in
the build process. Also, some of the documentation suggests that
upstream *might* maintain a Scheme->C version for v0.11 and be willing
to share it, which would make it even easier.

I put it on my TODO list to dig in and try to fix it, but realistically
might not get to it until August due to work. Bootstrapping the build
should also extend the package to other architectures, which was
something I also wanted to do at some point.

> Anyway, thanks for the patch!

Thank you!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-26  1:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-22 18:35 [bug#31940] [PATCH] gnu: Add Stalin Adam Massmann
2018-06-25 20:36 ` bug#31940: " Ludovic Courtès
2018-06-26  1:07   ` [bug#31940] " Adam Massmann

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).