[PATCH] staging gnu: Add wasm32 target to rustc.

  • Open
  • quality assurance status badge
Details
One participant
  • John Soo
Owner
unassigned
Submitted by
John Soo
Severity
normal
J
J
John Soo wrote on 28 Jan 2021 23:03
(address . guix-patches@gnu.org)
87bld8k9bn.fsf@asu.edu
Hi Guix!

Recently I had to work with some webassembly and rust and our current
compiler did not support the target. This patch adds wasm32 support.

Kindly,

John
From ab40dbfd2db1a06939c353d7cb0cb64841dbaa35 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Sat, 23 Jan 2021 08:43:52 -0800
Subject: [PATCH] gnu: Add wasm32 target to rust@1.46.

* gnu/packages/rust.scm (rust-1.46): [arguments] Add wasm32 to target
configuration, [native-inputs] Add node for tests.
---
gnu/packages/rust.scm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)

Toggle diff (40 lines)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 98ae770745..7b40372cb2 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1349,7 +1349,21 @@ move around."
(generate-all-checksums "vendor")
#t))
(replace 'build
- (lambda* _
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "config.toml"
+ (("\\[build\\]" all)
+ (string-append all "
+target = [\"" ,(nix-system->gnu-triplet-for-rust) "\", \"wasm32-unknown-unknown\"]
+"))
+ (("\\[dist\\]" all)
+ (string-append "
+[target.wasm32-unknown-unknown]
+llvm-config = \"" (assoc-ref inputs "llvm") "/bin/llvm-config\"
+cc = \"" (assoc-ref inputs "gcc") "/bin/gcc\"
+cxx = \"" (assoc-ref inputs "gcc") "/bin/g++\"
+ar = \"" (assoc-ref inputs "binutils") "/bin/ar\"
+"
+all)))
(invoke "./x.py" "build")
(invoke "./x.py" "build" "src/tools/cargo")
(invoke "./x.py" "build" "src/tools/rustfmt")
@@ -1364,7 +1378,9 @@ move around."
(string-append "-j" (number->string
(min 4
(parallel-job-count))))))
- (invoke "./x.py" parallel-job-spec "test" "-vv")
+ (invoke "./x.py" parallel-job-spec "test"
+ (string-append "--target=" ,(nix-system->gnu-triplet-for-rust))
+ "-vv")
(invoke "./x.py" parallel-job-spec "test"
"src/tools/cargo")
(invoke "./x.py" parallel-job-spec "test"
--
2.30.0
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCAAsFiEEWhWPr0BqdIqBqdxOT0N6drRIojsFAmATNMwOHGpzb28xQGFz
dS5lZHUACgkQT0N6drRIojsVHA//fBuXoEe8/4vTa8URvnxxe4QIFh7s1QNFOTU8
DKWIBzsRdY/TKnnt0VpPeJoVIjLXkQdSyLjiEmcag9aO/nLsjeD12Z5Tv3X+OoEH
H+nDY6u/ERfTAmsW1XFT7az9PGD+DeRWX4nKSYr+beuWlL+1Snn9KEZy3CcRPy0u
Lh+lgFdDyGfl28W/Z7LaJMbrsUJBgKbh0EqoUdyqJFAmpUL4kb7GXOfquGIvILvp
vLmRO5CVuMpWe/08DrRRtwSnCo5dnUKVA7Nvhwlqg83iP9hvSDbBhLH9tj28qCnM
KUrH8l1FhmsR2LiKtICM3G18xi8bFykNZgJmTLDMXs3YpB0/aqqTxfV/zikyESRi
jfewA0RlfefIuxdSgYaUZEs35E4VOpkmUciyQqzjczUkI+en5AvqTTUpHN2h0ITO
nxpS4izA4MQWJDWGyC0dQGGmS6sLxc+OW2VODg7Kmio6fP3+Gm2Re07HM0mrZoz5
Nr7v/hdR/dw5oEeRp/Rh7VDSTO/boGz4gegdlA+XJi1oL5ljVZV48PwvekARSzmR
3gPeYc5ZpBBdxd5Pc2sVN48tR2ycKVgeXZFmam9ALXvwV94RMZMzlz5v/ekUBVnD
bEG7XQ3xx6iPEXqtxmyqUt7gCB/MxKSXuzPaxapH6CWlKhZP6JLDjx30WXrMrLBG
1NaM70M=
=5UTx
-----END PGP SIGNATURE-----

J
J
John Soo wrote on 29 Jan 2021 00:31
(address . 46163@debbugs.gnu.org)
8735ykk5a2.fsf@asu.edu
Here is a fixed patch, I had rebased incorrectly. Thanks again!

- John
From d987b267c202f985808a19ebcb98ea5845a3a241 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Sat, 23 Jan 2021 08:43:52 -0800
Subject: [PATCH] gnu: Add wasm32 target to rust@1.46.

* gnu/packages/rust.scm (rust-1.46): [arguments] Add wasm32 to target
configuration, [native-inputs] Add node for tests.
---
gnu/packages/rust.scm | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)

Toggle diff (58 lines)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index b59fe98546..7b40372cb2 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -42,6 +42,7 @@
#:use-module (gnu packages jemalloc)
#:use-module (gnu packages linux)
#:use-module (gnu packages llvm)
+ #:use-module (gnu packages node)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages ssh)
@@ -1329,7 +1330,8 @@ move around."
`(("gcc-lib" ,gcc "lib")
,@(package-inputs base-rust)))
(native-inputs
- `(("patchelf" ,patchelf)
+ `(("node" ,node)
+ ("patchelf" ,patchelf)
,@(package-native-inputs base-rust)))
(arguments
(substitute-keyword-arguments (package-arguments base-rust)
@@ -1347,7 +1349,21 @@ move around."
(generate-all-checksums "vendor")
#t))
(replace 'build
- (lambda* _
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "config.toml"
+ (("\\[build\\]" all)
+ (string-append all "
+target = [\"" ,(nix-system->gnu-triplet-for-rust) "\", \"wasm32-unknown-unknown\"]
+"))
+ (("\\[dist\\]" all)
+ (string-append "
+[target.wasm32-unknown-unknown]
+llvm-config = \"" (assoc-ref inputs "llvm") "/bin/llvm-config\"
+cc = \"" (assoc-ref inputs "gcc") "/bin/gcc\"
+cxx = \"" (assoc-ref inputs "gcc") "/bin/g++\"
+ar = \"" (assoc-ref inputs "binutils") "/bin/ar\"
+"
+all)))
(invoke "./x.py" "build")
(invoke "./x.py" "build" "src/tools/cargo")
(invoke "./x.py" "build" "src/tools/rustfmt")
@@ -1362,7 +1378,9 @@ move around."
(string-append "-j" (number->string
(min 4
(parallel-job-count))))))
- (invoke "./x.py" parallel-job-spec "test" "-vv")
+ (invoke "./x.py" parallel-job-spec "test"
+ (string-append "--target=" ,(nix-system->gnu-triplet-for-rust))
+ "-vv")
(invoke "./x.py" parallel-job-spec "test"
"src/tools/cargo")
(invoke "./x.py" parallel-job-spec "test"
--
2.30.0
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCAAsFiEEWhWPr0BqdIqBqdxOT0N6drRIojsFAmATSUUOHGpzb28xQGFz
dS5lZHUACgkQT0N6drRIojshOQ/+JRp/ApfrWckidAgImXHu22D8wAKqzEc07VJr
f48brnsFmN1/rqKQd1Q//5QGoeAdk9naXV9KTHWKl0mg4hzfYrqGKd3C6QqNziPj
KsT2GT5pQOAgPq8swFAmQLEWjG3C3gGyME1GdIJDAE3t8JGaCHg8zbhntrgXqjP1
XjSfN1Dg/gHMc+ZNhAXZQur9ruxtSyWq00LegS8M+s6G+u+5vmcfoig0eBlb3qqy
WVh2hsrwvxG2l7VRNArzMbusOQZJOD6GPyGJz6Tkf/ZwCdYdscwpsc+iPmIDo01E
Q53LW1dWKxhQubVnalvmFm4HRFZbcrC6ZAtwK0oqSyS1O8OOIK6asOdpGd5tIkLN
HkhlGeh1260dnridzsnaOSccTq+VENZfC3hrZKS0OjAOrKSzu2+jX29tErqnNuBN
mkuPp1YVaXCbI5vyVwdgC58KRVV0PQ+OI14/dQ+Nox5ROCA/jbZIzIqcG5MOj6Um
994RUjcSgk/nwtnNSMPiKkRwu/+VHK/H3KgzU9tL9+PPOyabFiwODWKaD4HJxjlQ
BVgTDjzj8SCKJMOhTzOCDhAkCe6P9iStXBKUBixMeQ7XSTvHrFe016mllhjKykLh
oLT9DWUyBvjXJEebXz/jUp+gzBnrAkQQLqWfGaSOLiy4J9oDi3mHx0qWLG1ki5Mw
dbuAkFI=
=Dg0+
-----END PGP SIGNATURE-----

J
J
John Soo wrote on 15 Feb 2021 19:04
(address . 46163@debbugs.gnu.org)
87czx1w6l8.fsf@asu.edu
Rebased on staging!
From 610f9ba4c3d7c4e053929c57ddae25d55cf4682f Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Sat, 23 Jan 2021 08:43:52 -0800
Subject: [PATCH] gnu: Add wasm32 target to rust@1.46.

* gnu/packages/rust.scm (rust-1.46): [arguments] Add wasm32 to target
configuration, [native-inputs] Add node for tests.
---
gnu/packages/rust.scm | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)

Toggle diff (54 lines)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 8a09e1077e..01f9d26729 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1349,7 +1349,21 @@ move around."
(generate-all-checksums "vendor")
#t))
(replace 'build
- (lambda* _
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "config.toml"
+ (("\\[build\\]" all)
+ (string-append all "
+target = [\"" ,(nix-system->gnu-triplet-for-rust) "\", \"wasm32-unknown-unknown\"]
+"))
+ (("\\[dist\\]" all)
+ (string-append "
+[target.wasm32-unknown-unknown]
+llvm-config = \"" (assoc-ref inputs "llvm") "/bin/llvm-config\"
+cc = \"" (assoc-ref inputs "gcc") "/bin/gcc\"
+cxx = \"" (assoc-ref inputs "gcc") "/bin/g++\"
+ar = \"" (assoc-ref inputs "binutils") "/bin/ar\"
+"
+all)))
(invoke "./x.py" "build")
(invoke "./x.py" "build" "src/tools/cargo")
(invoke "./x.py" "build" "src/tools/rustfmt")
@@ -1363,7 +1377,9 @@ move around."
(string-append "-j" (number->string
(min 4
(parallel-job-count))))))
- (invoke "./x.py" parallel-job-spec "test" "-vv")
+ (invoke "./x.py" parallel-job-spec "test"
+ (string-append "--target=" ,(nix-system->gnu-triplet-for-rust))
+ "-vv")
(invoke "./x.py" parallel-job-spec "test"
"src/tools/cargo")
(invoke "./x.py" parallel-job-spec "test"
@@ -1459,6 +1475,13 @@ tools =
(substitute-keyword-arguments (package-arguments base-rust)
((#:phases phases)
`(modify-phases ,phases
+ ;; Rustdocs fail to build with wasm32 target
+ ;; See https://github.com/rust-lang/rust/issues/76526
+ (add-after 'configure 'deny-warnings
+ (lambda _
+ (substitute* "config.toml"
+ (("\\[rust\\]" all) (string-append all "
+deny-warnings = false")))))
;; The source code got rearranged: libstd is now in the newly created library folder.
(replace 'patch-tests
(lambda* (#:key inputs #:allow-other-keys)
--
2.30.0
J
J
John Soo wrote on 15 Feb 2021 19:07
(address . 46163@debbugs.gnu.org)(address . kuba@kadziolka.net)
87a6s5w6fh.fsf_-_@asu.edu
Hi Jakub,

Thanks for your work on rust! Any thoughts on this?

Kindly,

John
?
Your comment

Commenting via the web interface is currently disabled.

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

To respond to this issue using the mumi CLI, first switch to it
mumi current 46163
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