[PATCH] gnu: rust-1.44: Add rustfmt output.

  • Done
  • quality assurance status badge
Details
3 participants
  • Efraim Flashner
  • John Soo
  • Matthew Kraai
Owner
unassigned
Submitted by
Matthew Kraai
Severity
normal
M
M
Matthew Kraai wrote on 9 Jul 2020 14:32
(address . guix-patches@gnu.org)(name . Matthew Kraai)(address . kraai@ftbfs.org)
20200709123256.7690-1-kraai@ftbfs.org
* gnu/packages/rust.scm (rust-1.44): Add a rustfmt output.
---
gnu/packages/rust.scm | 50 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)

Toggle diff (63 lines)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 6fc0fd4f52..52aef9478b 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1277,8 +1277,54 @@ move around."
"18akhk0wz1my6y9vhardriy2ysc482z0fnjdcgs9gy59kmnarxkm"))
(define-public rust-1.44
- (rust-bootstrapped-package rust-1.43 "1.44.1"
- "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky"))
+ (let ((base-rust
+ (rust-bootstrapped-package rust-1.43 "1.44.1"
+ "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky")))
+ (package
+ (inherit base-rust)
+ (outputs '("out" "doc" "cargo" "rustfmt"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments base-rust)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (replace 'build
+ (lambda* _
+ (invoke "./x.py" "build")
+ (invoke "./x.py" "build" "src/tools/cargo")
+ (invoke "./x.py" "build" "src/tools/rustfmt")))
+ (replace 'check
+ (lambda* _
+ ;; Enable parallel execution.
+ (let ((parallel-job-spec
+ (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"
+ "src/tools/cargo")
+ (invoke "./x.py" parallel-job-spec "test"
+ "src/tools/rustfmt"))))
+ (replace 'mkdir-prefix-paths
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; As result of https://github.com/rust-lang/rust/issues/36989
+ ;; `prefix' directory should exist before `install' call
+ (mkdir-p (assoc-ref outputs "out"))
+ (mkdir-p (assoc-ref outputs "cargo"))
+ (mkdir-p (assoc-ref outputs "rustfmt"))
+ #t))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (invoke "./x.py" "install")
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("prefix = \"[^\"]*\"")
+ (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
+ (invoke "./x.py" "install" "cargo")
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("prefix = \"[^\"]*\"")
+ (string-append "prefix = \"" (assoc-ref outputs "rustfmt") "\"")))
+ (invoke "./x.py" "install" "rustfmt"))))))))))
;; NOTE: An update to LLVM 10 is coming in 1.45, make sure not to miss it.
--
2.27.0
J
J
John Soo wrote on 25 Nov 2020 15:46
(name . Matthew Kraai)(address . kraai@ftbfs.org)(address . 42295@debbugs.gnu.org)
87blfltrxp.fsf@asu.edu
Hi Matthew,

Thanks! I had packaged rustfmt-nightly but this is much better.

Matthew Kraai <kraai@ftbfs.org> writes:

Toggle quote (13 lines)
> + (replace 'check
> + (lambda* _
> + ;; Enable parallel execution.
> + (let ((parallel-job-spec
> + (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"
> + "src/tools/cargo")
> + (invoke "./x.py" parallel-job-spec "test"
> + "src/tools/rustfmt"))))

Nice!

Toggle quote (2 lines)
> + (outputs '("out" "doc" "cargo" "rustfmt"))

Perhaps we should make anything that can be installed as a rustup
component an output (provided the source is in the rust tree). I think
rls can be added immediately in the same fashion.

Do you want to add a copyright line?

Otherwise, this looks good to me.

Best regards,

John
M
M
Matthew Kraai wrote on 26 Nov 2020 14:25
(name . John Soo)(address . jsoo1@asu.edu)(address . 42295@debbugs.gnu.org)
5407eb2f-b499-2520-e0e5-48ca7171e6bd@ftbfs.org
Hi John,

On 11/25/20 6:46 AM, John Soo wrote:
Toggle quote (24 lines)
> Hi Matthew,
>
> Thanks! I had packaged rustfmt-nightly but this is much better.
>
> Matthew Kraai <kraai@ftbfs.org> writes:
>
>> + (replace 'check
>> + (lambda* _
>> + ;; Enable parallel execution.
>> + (let ((parallel-job-spec
>> + (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"
>> + "src/tools/cargo")
>> + (invoke "./x.py" parallel-job-spec "test"
>> + "src/tools/rustfmt"))))
> Nice!
>
>> + (outputs '("out" "doc" "cargo" "rustfmt"))
> Perhaps we should make anything that can be installed as a rustup
> component an output (provided the source is in the rust tree). I think
> rls can be added immediately in the same fashion.
Is rls deprecated in favor of rust-analyzer?
Toggle quote (1 lines)
> Do you want to add a copyright line?
Done.
Toggle quote (2 lines)
> Otherwise, this looks good to me.

According to https://github.com/rust-lang/rustfmt,rustfmt was made a
component in 1.24.0.  Would it be better to add this support to the
rust-1.24 package instead?  I've attached the patch I'm currently testing.

--
Matthew Kraai
Toggle diff (85 lines)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 05404de1d8..d7a26d2f46 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -10,6 +10,7 @@
;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
;;; Copyright © 2020 Jakub K?dzio?ka <kuba@kadziolka.net>
;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2020 Matthew Kraai <kraai@ftbfs.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -690,6 +691,7 @@ jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
"1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
(package
(inherit base-rust)
+ (outputs (cons "rustfmt" (package-outputs base-rust)))
(arguments
(substitute-keyword-arguments (package-arguments base-rust)
((#:phases phases)
@@ -701,7 +703,36 @@ jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
;; This test is known to fail on aarch64 and powerpc64le:
;; https://github.com/rust-lang/rust/issues/45410
(("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
- #t)))))))))
+ #t))
+ (add-after 'configure 'enable-extended-build
+ (lambda* _
+ (substitute* "config.toml"
+ (("[[]build[]]") "[build]\nextended = true"))
+ #t))
+ (replace 'build
+ (lambda* _
+ (invoke "./x.py" "build")
+ (invoke "./x.py" "build" "src/tools/cargo")
+ (invoke "./x.py" "build" "src/tools/rustfmt")))
+ (replace 'check
+ (lambda* _
+ (invoke "./x.py" "-j1" "test" "-vv")
+ (invoke "./x.py" "-j1" "test" "src/tools/cargo")
+ (invoke "./x.py" "-j1" "test" "src/tools/rustfmt")
+ #t))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (invoke "./x.py" "install")
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("prefix = \"[^\"]*\"")
+ (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
+ (invoke "./x.py" "install" "cargo")
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("prefix = \"[^\"]*\"")
+ (string-append "prefix = \"" (assoc-ref outputs "rustfmt") "\"")))
+ (invoke "./x.py" "install" "rustfmt"))))))))))
;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is
;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>.
@@ -764,6 +795,7 @@ jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
`(modify-phases ,phases
;; binaryen was replaced with LLD project from LLVM
(delete 'dont-build-native)
+ (delete 'enable-extended-build)
(replace 'check
(lambda* _
;; Enable parallel execution.
@@ -773,7 +805,9 @@ jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
(parallel-job-count))))))
(invoke "./x.py" parallel-job-spec "test" "-vv")
(invoke "./x.py" parallel-job-spec "test"
- "src/tools/cargo"))))
+ "src/tools/cargo")
+ (invoke "./x.py" parallel-job-spec "test"
+ "src/tools/rustfmt"))))
(replace 'remove-unsupported-tests
(lambda* _
;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
@@ -844,6 +878,7 @@ jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
;; `prefix' directory should exist before `install' call
(mkdir-p (assoc-ref outputs "out"))
(mkdir-p (assoc-ref outputs "cargo"))
+ (mkdir-p (assoc-ref outputs "rustfmt"))
#t))
(add-after 'patch-cargo-tests 'disable-thinlto-test
(lambda* _
J
J
John Soo wrote on 26 Nov 2020 17:51
(name . Matthew Kraai)(address . kraai@ftbfs.org)(address . 42295@debbugs.gnu.org)
871rggt62e.fsf@asu.edu
Hi Matthew,

Matthew Kraai <kraai@ftbfs.org> writes:

Toggle quote (5 lines)
>> Perhaps we should make anything that can be installed as a rustup
>> component an output (provided the source is in the rust tree). I think
>> rls can be added immediately in the same fashion.
> Is rls deprecated in favor of rust-analyzer?

Yes but I think it should be included until it is not supported at all
anymore.

Toggle quote (4 lines)
> According to https://github.com/rust-lang/rustfmt,rustfmt was made a
> component in 1.24.0.  Would it be better to add this support to the
> rust-1.24 package instead?  I've attached the patch I'm currently testing.

Keep it on rust@1.44. Even though guix refresh --list-dependent will
report not many dependents, changing a current rust version would
trigger many rebuilds. There would be enough rebuilds to require it to
be applied to staging.

I've also attached a work in progress patch to add rls as an output,
too. I would love if all the "extended" tools can be included. Some
tools like clippy and the rust-src component would be very helpful.

One other thing:

Toggle quote (2 lines)
> + (outputs '("out" "doc" "cargo" "rustfmt"))

should probably be: (cons "rustfmt" (package-outputs base-rust))

to be more resistant to changes to older packages.

Best regards,

John
From 7e26e4c61a609e93199acdff608272e3cbc38c76 Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Wed, 25 Nov 2020 06:30:02 -0800
Subject: [PATCH] gnu: Add rls as an output of rust@1.44.

* gnu/packages/rust.scm (rust-1.44):[arguments] Build rls, [outputs] add rls.
---
gnu/packages/rust.scm | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)

Toggle diff (75 lines)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 23837ee5bf..ae23d98b98 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1284,16 +1284,24 @@ move around."
"0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky")))
(package
(inherit base-rust)
- (outputs (cons "rustfmt" (package-outputs base-rust)))
+ (outputs (append '("rustfmt" "rls") (package-outputs base-rust)))
(arguments
(substitute-keyword-arguments (package-arguments base-rust)
((#:phases phases)
`(modify-phases ,phases
(replace 'build
(lambda* _
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("\\[build\\]" all)
+ (string-append all "
+extended = true
+tools = [\"cargo\", \"rls\", \"clippy\", \"rustfmt\", \"analysis\", \"src\"]
+")))
(invoke "./x.py" "build")
(invoke "./x.py" "build" "src/tools/cargo")
- (invoke "./x.py" "build" "src/tools/rustfmt")))
+ (invoke "./x.py" "build" "src/tools/rustfmt")
+ (invoke "./x.py" "build" "src/tools/rls")))
(replace 'check
(lambda* _
;; Enable parallel execution.
@@ -1305,7 +1313,12 @@ move around."
(invoke "./x.py" parallel-job-spec "test"
"src/tools/cargo")
(invoke "./x.py" parallel-job-spec "test"
- "src/tools/rustfmt"))))
+ "src/tools/rustfmt")
+ (substitute* "src/tools/rls/tests/client.rs"
+ (("fn client_dependency_typo_and_fix" all)
+ (string-append "#[ignore]\n" all)))
+ (invoke "./x.py" parallel-job-spec "test"
+ "src/tools/rls"))))
(replace 'mkdir-prefix-paths
(lambda* (#:key outputs #:allow-other-keys)
;; As result of https://github.com/rust-lang/rust/issues/36989
@@ -1313,6 +1326,7 @@ move around."
(mkdir-p (assoc-ref outputs "out"))
(mkdir-p (assoc-ref outputs "cargo"))
(mkdir-p (assoc-ref outputs "rustfmt"))
+ (mkdir-p (assoc-ref outputs "rls"))
#t))
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
@@ -1326,7 +1340,18 @@ move around."
;; replace prefix to specific output
(("prefix = \"[^\"]*\"")
(string-append "prefix = \"" (assoc-ref outputs "rustfmt") "\"")))
- (invoke "./x.py" "install" "rustfmt"))))))))))
+ (invoke "./x.py" "install" "rustfmt")
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("prefix = \"[^\"]*\"")
+ (string-append "prefix = \"" (assoc-ref outputs "rls") "\"")))
+ (invoke "./x.py" "install" "rls")))
+ (replace 'validate-runpath
+ (lambda* (#:key outputs #:allow-other-keys #:rest rest)
+ (apply (assoc-ref %standard-phases 'validate-runpath)
+ ;; rls has references to "out"
+ #:outputs (alist-delete "rls" outputs)
+ rest))))))))))
(define-public rust-1.45
(let ((base-rust
--
2.29.2
M
M
Matthew Kraai wrote on 2 Dec 2020 14:29
(name . John Soo)(address . jsoo1@asu.edu)(address . 42295@debbugs.gnu.org)
977d1171-d1af-5705-3852-1bee82047445@ftbfs.org
Hi John,

On 11/26/20 8:51 AM, John Soo wrote:
Toggle quote (19 lines)
> Matthew Kraai <kraai@ftbfs.org> writes:
>> According to https://github.com/rust-lang/rustfmt, rustfmt was made a
>> component in 1.24.0.  Would it be better to add this support to the
>> rust-1.24 package instead?  I've attached the patch I'm currently testing.
> Keep it on rust@1.44. Even though guix refresh --list-dependent will
> report not many dependents, changing a current rust version would
> trigger many rebuilds. There would be enough rebuilds to require it to
> be applied to staging.
>
> I've also attached a work in progress patch to add rls as an output,
> too. I would love if all the "extended" tools can be included. Some
> tools like clippy and the rust-src component would be very helpful.
>
> One other thing:
>
>> + (outputs '("out" "doc" "cargo" "rustfmt"))
> should probably be: (cons "rustfmt" (package-outputs base-rust))
>
> to be more resistant to changes to older packages.
Here is an updated patch.  I modified the rust-1.46 package, used your
suggestion to add rustfmt to the list of outputs, did not modify the
mkdir-prefix-paths phase (which doesn't seem to be necessary), and
updated the delete-install-logs phase.

--
Matthew Kraai
From 600cc3f1f4a38847aea48edb0e1e7e365bd00d8c Mon Sep 17 00:00:00 2001
From: Matthew Kraai <kraai@ftbfs.org>
Date: Wed, 2 Dec 2020 05:18:35 -0800
Subject: [PATCH] gnu: rust-1.46: Add rustfmt output

* gnu/packages/rust.scm (rust-1.46): Add a rustfmt output.
---
gnu/packages/rust.scm | 67 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 65 insertions(+), 2 deletions(-)

Toggle diff (87 lines)
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 35a96b5754..749d1f031f 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -10,6 +10,7 @@
;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
;;; Copyright © 2020 Jakub K?dzio?ka <kuba@kadziolka.net>
;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
+;;; Copyright © 2020 Matthew Kraai <kraai@ftbfs.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1315,8 +1316,70 @@ move around."
#t)))))))))
(define-public rust-1.46
- (rust-bootstrapped-package rust-1.45 "1.46.0"
- "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid"))
+ (let ((base-rust
+ (rust-bootstrapped-package rust-1.45 "1.46.0"
+ "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid")))
+ (package
+ (inherit base-rust)
+ (outputs (cons "rustfmt" (package-outputs base-rust)))
+ (arguments
+ (substitute-keyword-arguments (package-arguments base-rust)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (replace 'build
+ (lambda* _
+ (invoke "./x.py" "build")
+ (invoke "./x.py" "build" "src/tools/cargo")
+ (invoke "./x.py" "build" "src/tools/rustfmt")))
+ (replace 'check
+ (lambda* _
+ ;; Test rustfmt.
+ (let ((parallel-job-spec
+ (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"
+ "src/tools/cargo")
+ (invoke "./x.py" parallel-job-spec "test"
+ "src/tools/rustfmt"))))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ (invoke "./x.py" "install")
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("prefix = \"[^\"]*\"")
+ (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
+ (invoke "./x.py" "install" "cargo")
+ (substitute* "config.toml"
+ ;; replace prefix to specific output
+ (("prefix = \"[^\"]*\"")
+ (string-append "prefix = \"" (assoc-ref outputs "rustfmt") "\"")))
+ (invoke "./x.py" "install" "rustfmt")))
+ (replace 'delete-install-logs
+ (lambda* (#:key outputs #:allow-other-keys)
+ (define (delete-manifest-file out-path file)
+ (delete-file (string-append out-path "/lib/rustlib/" file)))
+
+ (let ((out (assoc-ref outputs "out"))
+ (cargo-out (assoc-ref outputs "cargo"))
+ (rustfmt-out (assoc-ref outputs "rustfmt")))
+ (for-each
+ (lambda (file) (delete-manifest-file out file))
+ '("install.log"
+ "manifest-rust-docs"
+ ,(string-append "manifest-rust-std-"
+ (nix-system->gnu-triplet-for-rust))
+ "manifest-rustc"))
+ (for-each
+ (lambda (file) (delete-manifest-file cargo-out file))
+ '("install.log"
+ "manifest-cargo"))
+ (for-each
+ (lambda (file) (delete-manifest-file rustfmt-out file))
+ '("install.log"
+ "manifest-rustfmt-preview"))
+ #t))))))))))
;; TODO(staging): Bump this variable to the latest packaged rust.
(define-public rust rust-1.45)
--
2.29.2
E
E
Efraim Flashner wrote on 28 Jan 2021 19:32
(address . 42295-done@debbugs.gnu.org)
YBMDTsBnB4Z/O+fN@3900XT
This is applied on staging so closing the bug

--
Efraim Flashner <efraim@flashner.co.il> ????? ?????
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmATA04ACgkQQarn3Mo9
g1G/TA/+JZVbeFe5rpjVzs7q4MlhYaU251m6eGSb+rMlkjzXD+EgPZmsWBUt1KKY
ZvaBxjp8AmzI2S1oZ8hCCJJnumDpJ72CX85ycc96Dxs/0rCM301ZpkWJSObXreZg
HAUw3wiD0/lffc2yMU02kNBe6/QqSgJp3wP5y0z6tg5slU2NNpiNDI5xwHBEcdZ9
4BdIq4v8z0gW2I8VazVHEqmzOJ2V8Fz3f0PVfCGP9XKmWOfL8nqDGr1ardychNOE
TgmRZ4MQInz+A2185nocIG3KmKLjLAe0vUSPUxbvsBqtvkoyRgoDdn2pUvRMFIer
MD04S8mDfeTkm8o22btXJq40iRrWf1Tw/0EfeiDl+EDJWEy40yfB3p/ioQqd3C0e
TcGWGhIhyUu6vf405ZOflH3/SDqrete6AxHVI+28eOJH/44t6CEwVIDLJq5Ya37j
VfgSgAu0Ttdc56jAdbOic1bY41RasuPr88V7z3Uk6COoOXNG8mMV1ndrGY1mC8s5
+uX89UWvmH3vc8pUN0yBSktjUYqmrPLfb5yOhRrRaV9BSmfMKXryo1DOW1k1IBfH
XPbaXyOaHiUzDR2RCw/XBKsqRerJ5xjOugymW6bKJYWa3pVjwbJEI4GFga1IP1ho
Ml2YdbB/F8qEhMX7YiS6XTIsY3vBsNMd42S+WMbecjith69EIBU=
=elxM
-----END PGP SIGNATURE-----


Closed
?