unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#46163] [PATCH] staging gnu: Add wasm32 target to rustc.
@ 2021-01-28 22:03 John Soo
  2021-01-28 23:31 ` John Soo
  2021-02-15 18:04 ` John Soo
  0 siblings, 2 replies; 4+ messages in thread
From: John Soo @ 2021-01-28 22:03 UTC (permalink / raw)
  To: 46163


[-- Attachment #1.1: Type: text/plain, Size: 165 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-Add-wasm32-target-to-rust-1.46.patch --]
[-- Type: text/x-patch, Size: 2239 bytes --]

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(-)

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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]

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

* [bug#46163] [PATCH] staging gnu: Add wasm32 target to rustc.
  2021-01-28 22:03 [bug#46163] [PATCH] staging gnu: Add wasm32 target to rustc John Soo
@ 2021-01-28 23:31 ` John Soo
  2021-02-15 18:04 ` John Soo
  1 sibling, 0 replies; 4+ messages in thread
From: John Soo @ 2021-01-28 23:31 UTC (permalink / raw)
  To: 46163


[-- Attachment #1.1: Type: text/plain, Size: 73 bytes --]

Here is a fixed patch, I had rebased incorrectly. Thanks again!

- John


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-Add-wasm32-target-to-rust-1.46.patch --]
[-- Type: text/x-patch, Size: 2900 bytes --]

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(-)

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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]

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

* [bug#46163] [PATCH] staging gnu: Add wasm32 target to rustc.
  2021-01-28 22:03 [bug#46163] [PATCH] staging gnu: Add wasm32 target to rustc John Soo
  2021-01-28 23:31 ` John Soo
@ 2021-02-15 18:04 ` John Soo
  2021-02-15 18:07   ` John Soo
  1 sibling, 1 reply; 4+ messages in thread
From: John Soo @ 2021-02-15 18:04 UTC (permalink / raw)
  To: 46163

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

Rebased on staging!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-Add-wasm32-target-to-rust-1.46.patch --]
[-- Type: text/x-patch, Size: 2891 bytes --]

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(-)

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


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

* [bug#46163] [PATCH] staging gnu: Add wasm32 target to rustc.
  2021-02-15 18:04 ` John Soo
@ 2021-02-15 18:07   ` John Soo
  0 siblings, 0 replies; 4+ messages in thread
From: John Soo @ 2021-02-15 18:07 UTC (permalink / raw)
  To: 46163; +Cc: kuba

Hi Jakub,

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

Kindly,

John




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

end of thread, other threads:[~2021-02-15 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28 22:03 [bug#46163] [PATCH] staging gnu: Add wasm32 target to rustc John Soo
2021-01-28 23:31 ` John Soo
2021-02-15 18:04 ` John Soo
2021-02-15 18:07   ` John Soo

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).