From patchwork Thu Jan 28 22:00:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Soo X-Patchwork-Id: 26710 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 576D327BC1D; Thu, 28 Jan 2021 22:01:48 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2C24E27BC1C for ; Thu, 28 Jan 2021 22:01:47 +0000 (GMT) Received: from localhost ([::1]:49884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5FMI-0002TZ-6A for patchwork@mira.cbaines.net; Thu, 28 Jan 2021 17:01:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5FLa-0002TO-O7 for guix-patches@gnu.org; Thu, 28 Jan 2021 17:01:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:38928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5FLa-0003jD-Fx for guix-patches@gnu.org; Thu, 28 Jan 2021 17:01:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l5FLa-0005sQ-EM for guix-patches@gnu.org; Thu, 28 Jan 2021 17:01:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46162] [PATCH] staging gnu: Add more tools to rust outputs. Resent-From: John Soo Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 28 Jan 2021 22:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46162 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46162@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161187124622560 (code B ref -1); Thu, 28 Jan 2021 22:01:02 +0000 Received: (at submit) by debbugs.gnu.org; 28 Jan 2021 22:00:46 +0000 Received: from localhost ([127.0.0.1]:50474 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5FLE-0005rh-NI for submit@debbugs.gnu.org; Thu, 28 Jan 2021 17:00:46 -0500 Received: from lists.gnu.org ([209.51.188.17]:43900) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5FLA-0005rX-U7 for submit@debbugs.gnu.org; Thu, 28 Jan 2021 17:00:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5FL7-0002KD-Oj for guix-patches@gnu.org; Thu, 28 Jan 2021 17:00:35 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:45667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5FL0-0003XD-Bn for guix-patches@gnu.org; Thu, 28 Jan 2021 17:00:31 -0500 Received: by mail-pf1-x434.google.com with SMTP id j12so4891694pfj.12 for ; Thu, 28 Jan 2021 14:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version; bh=cnBJLO5DlVxpRSxyhVMDVu2l8kkjzbNZr96hoZO77ZE=; b=IaNn13peu0zQLwsnd9p73P6IbOUQjVdc0o5/5DybD76Y/QYgj15nx7lvAtOypl+Ac7 6aAxFTf/9g4OBQGFOs9IW1QIouh9BaixNESCzRVTplpsrZbyoVfnVtho7LKFxo6iaiPU tr0/b7c6Ud/CMwqb/U+WhbpWXGIkJCR94NA72bGtpIHZWrj3SqLtjQlkWn/2bJU554qn me3HVP3Iy9l2tl8rMhdbeDbnJHF//aXCdkefWQz57BPHgwx6bVGMkhfOzRC/O0m/zAdA maWT3HyBPvxRmv8FpjsB8MgFdP3MGVDWSu4+6j85M8Wmy3j2fcz3hHUbIzfMvw3rsbWz 0F4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=cnBJLO5DlVxpRSxyhVMDVu2l8kkjzbNZr96hoZO77ZE=; b=dpLU0WKpyOT07qPbtTBZ5U9MnxKAbNfn3OaRdVq09LkKam541h3ByhwAWVTCXejTjq WCcYGYT046YdkhVMl1QSKG9c0uP2Pz+aV86rBhwRCLpo82VQ6xw8aGvCKnPdSdZEityK qM0mGHclxCg1fQu7naZNtUOcXhgx4Ud6OONnHsqW+5rIwJTn8uXBWXKCHheNE6gsO72K 5OhD8dmM/rV5rPrs0p/gx6znMmKy8DbyEAlclxIOzgiw3AzDXJnKf9iaWQO3Mox54x6H Ggvt//4rpxloBy0HcP+AqFLnFf8Fktw2ULpSZ+Xw2OquvXv3D3HeX5+DZiNUV5+OwxHO 3gEw== X-Gm-Message-State: AOAM531emh1BSiiUh8bedBOSao41IsyHbwZi9g+V04GSUgkgFFICimEc XvOMmyAgk2DCFGTC+ESLb33mXbLuOrHlSg== X-Google-Smtp-Source: ABdhPJwGxahRc8utwuZ4DVU0DhDr4lnyEuyvMaVTHIZ5TMKdAZ+MI83iR6Q+L2TKCETwFhXhRQotmA== X-Received: by 2002:a62:7b8a:0:b029:1bb:4a06:bb57 with SMTP id w132-20020a627b8a0000b02901bb4a06bb57mr1237027pfc.47.1611871223335; Thu, 28 Jan 2021 14:00:23 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id u12sm6179657pgi.91.2021.01.28.14.00.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jan 2021 14:00:22 -0800 (PST) From: John Soo Date: Thu, 28 Jan 2021 14:00:20 -0800 Message-ID: <87eei4k9hn.fsf@asu.edu> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=jsoo1@asu.edu; helo=mail-pf1-x434.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi Guix! I work with rust for my job and I would love to be able to use clippy and the other tools that are in the rustc tree. This patch installs those tools as other outputs in the same way we have cargo and rustfmt now. Thanks! All the best, John From 2f381b5af04a2e487242b3661edf088fecb6c484 Mon Sep 17 00:00:00 2001 From: John Soo Date: Wed, 25 Nov 2020 06:25:43 -0800 Subject: [PATCH] gnu: Add more tools to rust outputs. The goal is to provide standard rust tools as outputs of rustc. The tools we were missing were rls, clippy, src, and rust-analyzer. * gnu/packages/rust.scm (rust-1.46): [outputs] add rls, clippy, src, and rust-analyzer, [arguments] alter phases to build, test, and install each new output, [arguments] patch RUNPATHS of outputs that require it, [arguments] delete all uninstall scripts from outputs, [arguments] delete all the install logs and manifests. --- gnu/packages/rust.scm | 133 +++++++++++++++++++++++++++++++----------- 1 file changed, 99 insertions(+), 34 deletions(-) diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm index e646cd0091..98ae770745 100644 --- a/gnu/packages/rust.scm +++ b/gnu/packages/rust.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2020, 2021 Jakub Kądziołka ;;; Copyright © 2020 Pierre Langlois ;;; Copyright © 2020 Matthew Kraai +;;; Copyright © 2021 John Soo ;;; ;;; This file is part of GNU Guix. ;;; @@ -41,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) @@ -1322,19 +1324,42 @@ move around." "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid"))) (package (inherit base-rust) - (outputs (cons "rustfmt" (package-outputs base-rust))) + (outputs (append '("rustfmt" "rls" "src" "clippy" "rust-analyzer") + (package-outputs base-rust))) + (inputs + `(("gcc-lib" ,gcc "lib") + ,@(package-inputs base-rust))) + (native-inputs + `(("node" ,node) + ("patchelf" ,patchelf) + ,@(package-native-inputs base-rust))) (arguments (substitute-keyword-arguments (package-arguments base-rust) ((#:phases phases) `(modify-phases ,phases + (replace 'patch-cargo-checksums + ;; Generate checksums after patching generated files (in + ;; particular, vendor/jemalloc/rep/Makefile). + (lambda* _ + (use-modules (guix build cargo-utils)) + (substitute* '("Cargo.lock" + "src/tools/rust-analyzer/Cargo.lock") + (("(checksum = )\".*\"" all name) + (string-append name "\"" ,%cargo-reference-hash "\""))) + (generate-all-checksums "vendor") + #t)) (replace 'build (lambda* _ (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/clippy") + (invoke "./x.py" "build" "src/tools/rls") + (invoke "./x.py" "build" + "src/tools/rust-analyzer/crates/rust-analyzer"))) (replace 'check (lambda* _ - ;; Test rustfmt. + ;; Enable parallel execution. (let ((parallel-job-spec (string-append "-j" (number->string (min 4 @@ -1343,44 +1368,84 @@ 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") + ;; Clippy tests do not work. See + ;; https://github.com/rust-lang/rust/issues/78717 + ;; Even with --stage 1, they fail to compile + ;; (invoke "./x.py" parallel-job-spec "test" "--stage" "1" + ;; "src/tools/clippy") + (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 'install (lambda* (#:key outputs #:allow-other-keys) (invoke "./x.py" "install") + (for-each delete-file-recursively + (find-files (assoc-ref outputs "out") + "^uninstall\\.sh$")) (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"))) + (("\\[build\\]" all) + (string-append all " +extended = true +tools = +"))) + (define (install-component component) + (substitute* "config.toml" + ;; replace prefix to specific output + (("(tools =).*" all tools) + (string-append tools " [\"" component "\"]\n")) + (("prefix = \"[^\"]*\"") + (string-append + "prefix = \"" (assoc-ref outputs component) "\""))) + (mkdir-p (assoc-ref outputs component)) + (invoke "./x.py" "install" component) + (for-each delete-file-recursively + (find-files (assoc-ref outputs component) + "uninstall\\.sh"))) + (for-each install-component + '("cargo" + "rustfmt" + "clippy" + "rls" + "src" + "rust-analyzer")) + #t)) + (add-after 'install 'patch-tools-runpaths + (lambda* (#:key outputs inputs #:allow-other-keys) + (use-modules (ice-9 popen) + (ice-9 textual-ports)) + (define (patch-path path) + (let* ((read-rpath + (string-append + "patchelf --print-rpath " path)) + (pipe (open-input-pipe read-rpath)) + (current-rpath (get-string-all pipe)) + (out (assoc-ref outputs "out")) + (libc (assoc-ref inputs "libc")) + (gcc-lib (assoc-ref inputs "gcc-lib"))) + (close-pipe pipe) + (invoke "patchelf" "--set-rpath" + (string-append current-rpath + ":" out "/lib" + ":" libc "/lib" + ":" gcc-lib "/lib") + path))) + (define (patch-component component) + (for-each patch-path + (find-files (assoc-ref outputs component) + (lambda (p s) (executable-file? p))))) + (for-each patch-component '("clippy" "rls")))) (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)))))))))) + (define log-manifest-re + "^install\\.log$|^manifest-([a-z]|[0-9]|_|-)+(-preview)?$") + (define (delete-install-log output) + (for-each delete-file-recursively + (find-files output log-manifest-re))) + (for-each delete-install-log (map cdr outputs))))))))))) (define-public rust-1.47 (let ((base-rust -- 2.30.0