diff mbox series

[bug#46163] staging gnu: Add wasm32 target to rustc.

Message ID 87czx1w6l8.fsf@asu.edu
State New
Headers show
Series [bug#46163] staging gnu: Add wasm32 target to rustc. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

John Soo Feb. 15, 2021, 6:04 p.m. UTC
Rebased on staging!

Comments

John Soo Feb. 15, 2021, 6:07 p.m. UTC | #1
Hi Jakub,

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

Kindly,

John
diff mbox series

Patch

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