GNU bug report logs - #31024
[PATCH] gnu: Add mrustc.

Previous Next

Package: guix-patches;

Reported by: Danny Milosavljevic <dannym <at> scratchpost.org>

Date: Mon, 2 Apr 2018 15:50:01 UTC

Severity: normal

Done: Danny Milosavljevic <dannym <at> scratchpost.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31024 in the body.
You can then email your comments to 31024 AT debbugs.gnu.org in the normal way.

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#31024; Package guix-patches. (Mon, 02 Apr 2018 15:50:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 02 Apr 2018 15:50:02 GMT) Full text and rfc822 format available.

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

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: guix-patches <at> gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [FIXME] gnu: Add mrustc.
Date: Mon,  2 Apr 2018 17:48:51 +0200
* gnu/packages/rust.scm (mrustc): New variable.
---
 gnu/packages/rust.scm | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 70140579b..507c0fe25 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2017, 2018 Nikolai Merinov <nikolai.merinov <at> member.fsf.org>
 ;;; Copyright © 2017 Efraim Flashner <efraim <at> flashner.co.il>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2018 Danny Milosavljevic <dannym+a <at> scratchpost.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -46,6 +47,7 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module ((guix build utils) #:select (alist-replace))
@@ -150,6 +152,92 @@ in turn be used to build the final Rust.")
     (modules '((guix build utils)))
     (snippet '(begin (delete-file-recursively "src/llvm") #t))))
 
+(define-public mrustc
+  (let ((commit "1a16def28935548e29be0fe5a632e25c83045924")
+        (revision "0")
+        (rustc-version "1.19.0"))
+    (package
+      (name "mrustc")
+      (version (git-version "0.0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/thepowersgang/mrustc.git")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0i5kqnzsd1rkj8qm147jx934nyn9sd1fz2b4achj9z0r00h84dh6"))))
+      (outputs '("out" "cargo"))
+      (build-system gnu-build-system)
+      (inputs
+       `(("llvm" ,llvm-3.9.1)))
+      (native-inputs
+       `(("bison" ,bison)
+         ("flex" ,flex)
+         ;; Required for the libstd sources.
+         ("rustc"
+          ,(rust-source "1.19.0" "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))))
+      (arguments
+       `(#:tests? #f
+         #:make-flags (list (string-append "LLVM_CONFIG="
+                                           (assoc-ref %build-inputs "llvm")
+                                           "/bin/llvm-config"))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'unpack-target-compiler
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (substitute* "minicargo.mk"
+                 ;; Don't try to build LLVM.
+                 (("^[$][(]LLVM_CONFIG[)]:") "xxx:")
+                 ;; Build for the correct target architecture.
+                 (("^RUSTC_TARGET := x86_64-unknown-linux-gnu")
+                  (string-append "RUSTC_TARGET := "
+                                 ,(or (%current-target-system)
+                                      (nix-system->gnu-triplet
+                                       (%current-system))))))
+               (invoke "tar" "xf" (assoc-ref inputs "rustc"))
+               (chdir "rustc-1.19.0-src")
+               (invoke "patch" "-p0" "../rust_src.patch")
+               (chdir "..")
+               #t))
+           (delete 'configure)
+           (add-after 'build 'build-minicargo
+             (lambda _
+               (for-each (lambda (target)
+                           (invoke "make" "-f" "minicargo.mk" target))
+                         '("output/libstd.hir" "output/libpanic_unwind.hir"
+                           "output/libproc_macro.hir" "output/libtest.hir"))
+               ;; Technically the above already does it - but we want to be clear.
+               (invoke "make" "-C" "tools/minicargo")))
+           (replace 'install
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (bin (string-append out "/bin"))
+                      (tools-bin (string-append out "/tools/bin"))
+                      (cargo-out (assoc-ref outputs "cargo"))
+                      (cargo-bin (string-append cargo-out "/bin"))
+                      (lib (string-append out "/lib"))
+                      (lib/rust (string-append lib "/mrust"))
+                      (gcc (assoc-ref inputs "gcc")))
+                 ;; These files are not reproducible.
+                 (for-each delete-file (find-files "output" "\\.txt$"))
+                 (mkdir-p lib)
+                 (copy-recursively "output" lib/rust)
+                 (mkdir-p bin)
+                 (mkdir-p tools-bin)
+                 (install-file "bin/mrustc" bin)
+                 ;; minicargo uses relative paths to resolve mrustc.
+                 (install-file "tools/bin/minicargo" tools-bin)
+                 (install-file "tools/bin/minicargo" cargo-bin)
+                 #t))))))
+      (synopsis "Compiler for the Rust progamming language")
+      (description "Rust is a systems programming language that provides memory
+safety and thread safety guarantees.")
+      (home-page "https://github.com/thepowersgang/mrustc")
+      ;; Dual licensed.
+      (license (list license:asl2.0 license:expat)))))
+
 (define-public rust-1.23
   (package
     (name "rust")




Changed bug title to '[PATCH] gnu: Add mrustc.' from '[FIXME] gnu: Add mrustc.' Request was from Danny Milosavljevic <dannym <at> scratchpost.org> to control <at> debbugs.gnu.org. (Mon, 02 Apr 2018 15:56:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#31024; Package guix-patches. (Mon, 02 Apr 2018 17:22:01 GMT) Full text and rfc822 format available.

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

From: Catonano <catonano <at> gmail.com>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 31024 <at> debbugs.gnu.org
Subject: Re: [bug#31024] [FIXME] gnu: Add mrustc.
Date: Mon, 2 Apr 2018 19:21:27 +0200
[Message part 1 (text/plain, inline)]
2018-04-02 17:48 GMT+02:00 Danny Milosavljevic <dannym <at> scratchpost.org>:

> * gnu/packages/rust.scm (mrustc): New variable.
>

wow !

Thanks for working on Rust !

I'm not able to evaluate this patch, it's way too complicated for me and
yet I'd like to ask you a few questions

>
> ---
>  gnu/packages/rust.scm | 88 ++++++++++++++++++++++++++++++
> +++++++++++++++++++++
>  1 file changed, 88 insertions(+)
>
> diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
> index 70140579b..507c0fe25 100644
> --- a/gnu/packages/rust.scm
> +++ b/gnu/packages/rust.scm
> @@ -6,6 +6,7 @@
>  ;;; Copyright © 2017, 2018 Nikolai Merinov <nikolai.merinov <at> member.fsf.
> org>
>  ;;; Copyright © 2017 Efraim Flashner <efraim <at> flashner.co.il>
>  ;;; Copyright © 2018 Tobias Geerinckx-Rice <me <at> tobias.gr>
> +;;; Copyright © 2018 Danny Milosavljevic <dannym+a <at> scratchpost.org>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -46,6 +47,7 @@
>    #:use-module (guix build-system gnu)
>    #:use-module (guix build-system trivial)
>    #:use-module (guix download)
> +  #:use-module (guix git-download)
>    #:use-module ((guix licenses) #:prefix license:)
>    #:use-module (guix packages)
>    #:use-module ((guix build utils) #:select (alist-replace))
> @@ -150,6 +152,92 @@ in turn be used to build the final Rust.")
>      (modules '((guix build utils)))
>      (snippet '(begin (delete-file-recursively "src/llvm") #t))))
>
> +(define-public mrustc
> +  (let ((commit "1a16def28935548e29be0fe5a632e25c83045924")
> +        (revision "0")
> +        (rustc-version "1.19.0"))
> +    (package
> +      (name "mrustc")
> +      (version (git-version "0.0.0" revision commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://github.com/thepowersgang/mrustc.git")
> +                      (commit commit)))
> +                (file-name (git-file-name name version))
> +                (sha256
> +                 (base32
> +                  "0i5kqnzsd1rkj8qm147jx934nyn9sd
> 1fz2b4achj9z0r00h84dh6"))))
> +      (outputs '("out" "cargo"))
> +      (build-system gnu-build-system)
> +      (inputs
> +       `(("llvm" ,llvm-3.9.1)))
>

Why is llvm needed ?

I read on their git repo page that it's tested with the gcc 5.4 and 6 ?
https://github.com/thepowersgang/mrustc



> +      (native-inputs
> +       `(("bison" ,bison)
> +         ("flex" ,flex)
> +         ;; Required for the libstd sources.
> +         ("rustc"
> +          ,(rust-source "1.19.0" "0l8c14qsf42rmkqy92ahij4vf356db
> yspxcips1aswpvad81y8qm"))))
> +      (arguments
> +       `(#:tests? #f
> +         #:make-flags (list (string-append "LLVM_CONFIG="
> +                                           (assoc-ref %build-inputs
> "llvm")
> +                                           "/bin/llvm-config"))
> +         #:phases
> +         (modify-phases %standard-phases
> +           (add-after 'unpack 'unpack-target-compiler
> +             (lambda* (#:key inputs outputs #:allow-other-keys)
> +               (substitute* "minicargo.mk"
> +                 ;; Don't try to build LLVM.
> +                 (("^[$][(]LLVM_CONFIG[)]:") "xxx:")
> +                 ;; Build for the correct target architecture.
> +                 (("^RUSTC_TARGET := x86_64-unknown-linux-gnu")
> +                  (string-append "RUSTC_TARGET := "
> +                                 ,(or (%current-target-system)
> +                                      (nix-system->gnu-triplet
> +                                       (%current-system))))))
> +               (invoke "tar" "xf" (assoc-ref inputs "rustc"))
> +               (chdir "rustc-1.19.0-src")
> +               (invoke "patch" "-p0" "../rust_src.patch")
> +               (chdir "..")
> +               #t))
> +           (delete 'configure)
> +           (add-after 'build 'build-minicargo
> +             (lambda _
> +               (for-each (lambda (target)
> +                           (invoke "make" "-f" "minicargo.mk" target))
> +                         '("output/libstd.hir"
> "output/libpanic_unwind.hir"
> +                           "output/libproc_macro.hir"
> "output/libtest.hir"))
> +               ;; Technically the above already does it - but we want to
> be clear.
> +               (invoke "make" "-C" "tools/minicargo")))
> +           (replace 'install
> +             (lambda* (#:key inputs outputs #:allow-other-keys)
> +               (let* ((out (assoc-ref outputs "out"))
> +                      (bin (string-append out "/bin"))
> +                      (tools-bin (string-append out "/tools/bin"))
> +                      (cargo-out (assoc-ref outputs "cargo"))
> +                      (cargo-bin (string-append cargo-out "/bin"))
> +                      (lib (string-append out "/lib"))
> +                      (lib/rust (string-append lib "/mrust"))
> +                      (gcc (assoc-ref inputs "gcc")))
>

so there's the gcc too ? 🤔


> +                 ;; These files are not reproducible.
> +                 (for-each delete-file (find-files "output" "\\.txt$"))
> +                 (mkdir-p lib)
> +                 (copy-recursively "output" lib/rust)
> +                 (mkdir-p bin)
> +                 (mkdir-p tools-bin)
> +                 (install-file "bin/mrustc" bin)
> +                 ;; minicargo uses relative paths to resolve mrustc.
> +                 (install-file "tools/bin/minicargo" tools-bin)
> +                 (install-file "tools/bin/minicargo" cargo-bin)
> +                 #t))))))
>

but then it's not used ?



> +      (synopsis "Compiler for the Rust progamming language")
> +      (description "Rust is a systems programming language that provides
> memory
> +safety and thread safety guarantees.")
> +      (home-page "https://github.com/thepowersgang/mrustc")
> +      ;; Dual licensed.
> +      (license (list license:asl2.0 license:expat)))))
> +
>  (define-public rust-1.23
>    (package
>      (name "rust")
>
>
>
>
Thanks again !
[Message part 2 (text/html, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#31024; Package guix-patches. (Mon, 02 Apr 2018 18:52:02 GMT) Full text and rfc822 format available.

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

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Catonano <catonano <at> gmail.com>
Cc: 31024 <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: Add mrustc.
Date: Mon, 2 Apr 2018 20:51:41 +0200
[Message part 1 (text/plain, inline)]
Hi Catonano,

On Mon, 2 Apr 2018 19:21:27 +0200
Catonano <catonano <at> gmail.com> wrote:

> Why is llvm needed ?

Rust uses LLVM to generate the actual images.

But it should be a native-input since mrustc doesn't use it, only Rust uses it.
(But mrustc compiles parts of the Rust source code for use in minicargo)

> I read on their git repo page that it's tested with the gcc 5.4 and 6 ?
> https://github.com/thepowersgang/mrustc

Hmm, good to know.  Right now we use 5.5 since that's what the rest of Guix uses.
Let's see whether it's enough.

> so there's the gcc too ? 🤔
> but then it's not used ?

Right, it's a leftover from when I tried to get rust-1.19.0 to use gcc to link
its executables.  I might need to adapt it to "symlink gcc cc" in a later version
still.
[Message part 2 (application/pgp-signature, inline)]

bug closed, send any further explanations to 31024 <at> debbugs.gnu.org and Danny Milosavljevic <dannym <at> scratchpost.org> Request was from Danny Milosavljevic <dannym <at> scratchpost.org> to control <at> debbugs.gnu.org. (Sun, 15 Apr 2018 08:16:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 13 May 2018 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 95 days ago.

Previous Next


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