[PATCH] gnu: Add mrustc.

  • Done
  • quality assurance status badge
Details
2 participants
  • Catonano
  • Danny Milosavljevic
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal

Debbugs page

Danny Milosavljevic wrote 7 years ago
[FIXME] gnu: Add mrustc.
(address . guix-patches@gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20180402154851.15672-1-dannym@scratchpost.org
* gnu/packages/rust.scm (mrustc): New variable.
---
gnu/packages/rust.scm | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)

Toggle diff (113 lines)
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@member.fsf.org>
;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Danny Milosavljevic <dannym+a@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")
Danny Milosavljevic wrote 7 years ago
(no subject)
(address . control@debbugs.gnu.org)
20180402175522.58b72214@scratchpost.org
retitle 31024 [PATCH] gnu: Add mrustc.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlrCUmoACgkQ5xo1VCww
uqVt0gf/WdVgOkoRKMmP7fDULldIEONmoVFpMttF5Hvd89jt+hSQ+Smlth8hDo/n
2qmLRK7CohZZeQ3J1e9sdQOHbELwhAab9V3FEno6t2v5rxyvpPN9zYXa+zCPy6Hz
LPUoY3Dhn3x8DG6XBA40Y0qNg329gAwQCP/qMUp9FpEc62dfu9YAeczw8AhnUQfe
x+9PFZ0Xx+Y80/J4DyETdYLkn9ifnZGmw5pPiJYptMn7OsMZcI8O8XmbspPSLm/x
s69XEHGYpihfoywnr6WxlbbdMfHVk3Fcazot55rkS7VBfW/RhW0zBy3oawXT8smM
l3d5EgA9qVmjtwFmAStlzj7TlQnGKw==
=Cw8b
-----END PGP SIGNATURE-----


Catonano wrote 7 years ago
Re: [bug#31024] [FIXME] gnu: Add mrustc.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31024@debbugs.gnu.org)
CAJ98PDzo0aJ0-pWjC6WiPz3nEgZkTd5=-0KOeo0jrnSWpkm8KA@mail.gmail.com
2018-04-02 17:48 GMT+02:00 Danny Milosavljevic <dannym@scratchpost.org>:

Toggle quote (3 lines)
> * 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

Toggle quote (54 lines)
>
> ---
> 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@member.fsf.
> org>
> ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
> ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
> +;;; Copyright © 2018 Danny Milosavljevic <dannym+a@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 ?



Toggle quote (55 lines)
> + (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 ? 🤔


Toggle quote (13 lines)
> + ;; 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 ?



Toggle quote (15 lines)
> + (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 !
Attachment: file
Danny Milosavljevic wrote 7 years ago
Re: [PATCH] gnu: Add mrustc.
(name . Catonano)(address . catonano@gmail.com)(address . 31024@debbugs.gnu.org)
20180402205141.3d805093@scratchpost.org
Hi Catonano,

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

Toggle quote (2 lines)
> 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)

Toggle quote (3 lines)
> 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.

Toggle quote (3 lines)
> 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.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlrCe70ACgkQ5xo1VCww
uqXpDgf/Xh3tpUhyTBeMyTLGLq2etrXYcANlta3+B43wsLF1JhlrZBHq91SPr6HT
MrsRZoWGzBxnFfLvwmztt9K0Ka3h3uPZFoy+wA8p5bZrLQSUjxDPL5jTrs5a6QxX
gt7RHxu2M6Ax7vMev4XDGchQq6hZnGTOJQetuWhzX7Ciw7HaW1iSg2n9Cm8+eKA3
KPkwXkQfKxlgTwHlYowNfF5VBPMBFhenGp9lRd3Im63jS6ulPEMiILiOhmZHwDrL
WV60oLiHVY7LXu/f3coZYnyT9LkCkA8PbTRIhyJ/uOc0V3a2w2+LFLlOTYu5M8hx
4YW35DAq5RC8OYuCVJqdwHSRxMKmbg==
=R5B+
-----END PGP SIGNATURE-----


Danny Milosavljevic wrote 7 years ago
(no subject)
(address . control@debbugs.gnu.org)
20180415101456.19a162b2@scratchpost.org
close 31024
close 31040
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlrTCgAACgkQ5xo1VCww
uqVLDQf/fncc9zR2n253f48QR/9FxTirlAEuxEjooP8k2gJHLIBrKRajdnFsEpy0
zax4MB0oUMTMPBxV2oSOyukF6a8vRAsaJO7wMgcVMviV7x1F6vnrLNFZcv5Xo4Rx
XlABg6hfVXOS96yGCnc0J9g6mx7hFTmy2ZQDHQ2FEfxpBkoWnXndcQHZOhkVHc/q
xzIKKq6kLgh4rEO93SRtSm4WOfmnHoTdHOohMMF1U/H4F8aHk7PshLTNzAgnKX3S
1A2QPSjsjbTdnIVP57MEGVKzNhIcMWS3DKy6NjY2abcH5i1zVmk5q/zAq1Q2L49C
p85KbS44bUZtGkM4DC7GUH5m39Uhww==
=KSX0
-----END PGP SIGNATURE-----


?
Your comment

This issue is archived.

To comment on this conversation send an email to 31024@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 31024
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help