summary refs log tree commit diff
path: root/gnu/packages/ocaml.scm
diff options
context:
space:
mode:
authorJulien Lepiller <julien@lepiller.eu>2021-02-27 00:07:20 +0100
committerJulien Lepiller <julien@lepiller.eu>2021-03-03 17:02:23 +0100
commit63df962225a92a4a51dbc31b6e41bc15fe0962b9 (patch)
tree27386eb3c1cbbbcac6793b81d44e63bfd1afb2c5 /gnu/packages/ocaml.scm
parent7309aab0d4703cf08d41cfb0276e7382fd15d88b (diff)
downloadguix-63df962225a92a4a51dbc31b6e41bc15fe0962b9.tar.gz
gnu: Add camlboot.
* gnu/packages/ocaml.scm (camlboot): New variable.
Diffstat (limited to 'gnu/packages/ocaml.scm')
-rw-r--r--gnu/packages/ocaml.scm66
1 files changed, 66 insertions, 0 deletions
diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index b561f11d34..604812261d 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -52,6 +52,7 @@
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gtk)
+  #:use-module (gnu packages guile)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages libffi)
   #:use-module (gnu packages llvm)
@@ -104,6 +105,71 @@
                               ".tar.gz"))
           (sha256 (base32 hash))))
 
+(define-public camlboot
+  (let ((commit "506280c6e0813e0e794988151a8e46be55373ebc")
+        (revision "0"))
+    (package
+      (name "camlboot")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/Ekdohibs/camlboot")
+                      (commit commit)
+                      (recursive? #t)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0vimxl4karw9ih3npyc5rhxg85cjh6fqjbq3dzj7j2iymlhwfbkv"))
+                (modules '((guix build utils)))
+                (snippet
+                 `(begin
+                    ;; Remove bootstrap binaries and pre-generated source files,
+                    ;; to ensure we actually bootstrap properly.
+                    (for-each delete-file (find-files "ocaml-src" "^.depend$"))
+                    (delete-file "ocaml-src/boot/ocamlc")
+                    (delete-file "ocaml-src/boot/ocamllex")
+                    ;; Ensure writable
+                    (for-each
+                     (lambda (file)
+                       (chmod file (logior (stat:mode (stat file)) #o200)))
+                     (find-files "." "."))))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:make-flags (list "_boot/ocamlc") ; build target
+         #:tests? #f                        ; no tests
+         #:phases
+         (modify-phases %standard-phases
+           (delete 'configure)
+           (add-before 'build 'no-autocompile
+             (lambda _
+               ;; prevent a guile warning
+               (setenv "GUILE_AUTO_COMPILE" "0")))
+           (replace 'install
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (bin (string-append out "/bin")))
+                 (mkdir-p bin)
+                 (install-file "_boot/ocamlc" bin)
+                 (rename-file "miniml/interp/lex.byte" "ocamllex")
+                 (install-file "ocamllex" bin)))))))
+      (native-inputs
+       `(("guile" ,guile-3.0)))
+      (home-page "https://github.com/Ekdohibs/camlboot")
+      (synopsis "OCaml souce bootstrap")
+      (description "OCaml is written in OCaml.  Its sources contain a pre-compiled
+bytecode version of @command{ocamlc} and @command{ocamllex} that are used to
+build the next version of the compiler.  Camlboot implements a bootstrap for
+the OCaml compiler and provides a bootstrapped equivalent to these files.
+
+It contains a compiler for a small subset of OCaml written in Guile Scheme,
+an interpreter for OCaml written in that subset and a manually-written lexer
+for OCaml.  These elements eliminate the need for the binary bootstrap in
+OCaml and can effectively bootstrap OCaml 4.07.
+
+This package produces a native @command{ocamlc} and a bytecode @command{ocamllex}.")
+      (license license:expat))))
+
 (define-public ocaml-4.11
   (package
     (name "ocaml")