From patchwork Thu Jan 28 23:29:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Soo X-Patchwork-Id: 26712 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 7C43627BC1C; Thu, 28 Jan 2021 23:31:11 +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 28CC327BC1D for ; Thu, 28 Jan 2021 23:31:09 +0000 (GMT) Received: from localhost ([::1]:40264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5Gkm-0007lz-6H for patchwork@mira.cbaines.net; Thu, 28 Jan 2021 18:31:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5Gkg-0007lq-8f for guix-patches@gnu.org; Thu, 28 Jan 2021 18:31:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:39046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5Gkg-0007le-1V for guix-patches@gnu.org; Thu, 28 Jan 2021 18:31:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l5Gkf-0001mf-To for guix-patches@gnu.org; Thu, 28 Jan 2021 18:31:01 -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 23:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46162 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46162@debbugs.gnu.org Received: via spool by 46162-submit@debbugs.gnu.org id=B46162.16118766136797 (code B ref 46162); Thu, 28 Jan 2021 23:31:01 +0000 Received: (at 46162) by debbugs.gnu.org; 28 Jan 2021 23:30:13 +0000 Received: from localhost ([127.0.0.1]:50591 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5Gjo-0001lS-Hg for submit@debbugs.gnu.org; Thu, 28 Jan 2021 18:30:13 -0500 Received: from mail-pj1-f54.google.com ([209.85.216.54]:35051) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l5Gjj-0001jR-8C for 46162@debbugs.gnu.org; Thu, 28 Jan 2021 18:30:06 -0500 Received: by mail-pj1-f54.google.com with SMTP id e9so5315721pjj.0 for <46162@debbugs.gnu.org>; Thu, 28 Jan 2021 15:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20150623.gappssmtp.com; s=20150623; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=0rt6tFJHQ08vwyy/lqiMpm8Uxpvp+h71XJk76lDTM8I=; b=aSG3wTpX9aBzHfmbt7ANNgcd2ypF1nSTuZoOBatlYqnL8ZvqIG2zVXNU1xQ+P6xDWH 84dv7qHyJWDCZx4y4xmcrmN2beu9IgM5fNrY1ovD5cGa9i1ZcZX6AX3ZQQhqbkvai91n dgSnj+QC78H2yl0DGVaFCT5kbR6U2hTN+qzQIe1eGV+Y7TUz9u5GARxumGYX1NTooEy+ lZwGFq6iBuaEOlWriLlQo+jVaRE3MUgdWSRaT3RKIEIYtlXP+sQc+sTiMth8zIRYnGZa Jem4WWygG+clJFvHwZXfReMOG6PsbmNwBkQ94F7CpRM/JBf+qyP/RDxhaoqc9/lkIMjj JHYg== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=0rt6tFJHQ08vwyy/lqiMpm8Uxpvp+h71XJk76lDTM8I=; b=d4zjyBJs0reqxaQ0u5PG5NfATs1QUxhQ+Jo61sTJ7Y20VAbPxW8s6F730zh9NV6T5l dXIqzdajKIuHDIDoXGDEaGBAoUMZgHMJ3GNl7IcKazYLnBSSybFI6lHK3IeoJCUJY6NX D9iYVtInIzfl22mU3SNtaIQxCz4ww87NxipG7xLN07146zfvqH2kFYvalfLt+YUHFN1o PgC5Pe0DZYD9eeDLf6aRwPMOg8qg6yMSiNFPF62KFLqJAXbV9HDxkUYm3nJ0yLgKrCvq lTwzT3Xa/pRxPP5udJWlZMs58702hmrlGGi0TKFrDQ1Gxug+V/n6Xu0JOGt3JXe9YGUX /iwg== X-Gm-Message-State: AOAM533Bak4EuRYNO3gOguIss6R4DtmJHuIjMVHYVRjq8ZR45jXPM0e6 bd7FDjvtBJ1bsorf8d0lqMHzaUsHbkZJlA== X-Google-Smtp-Source: ABdhPJzm/0/WAJftAzWa9s3P1EZ9XDL2rd3MzLqCJyRSXwIXtdne6gAZvA5CK0DDmAVzTPdbPeHKyw== X-Received: by 2002:a17:90a:5993:: with SMTP id l19mr1590551pji.203.1611876596965; Thu, 28 Jan 2021 15:29:56 -0800 (PST) Received: from ecenter ([2600:1700:83b0:8bd0::7a8]) by smtp.gmail.com with ESMTPSA id 6sm6520838pfo.139.2021.01.28.15.29.55 for <46162@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jan 2021 15:29:56 -0800 (PST) From: John Soo References: <87eei4k9hn.fsf@asu.edu> Date: Thu, 28 Jan 2021 15:29:54 -0800 In-Reply-To: <87eei4k9hn.fsf@asu.edu> (John Soo's message of "Thu, 28 Jan 2021 14:00:20 -0800") Message-ID: <875z3gk5cd.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 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 Here is an edited patch. I had rebased incorrectly, my apologies. - John From cd3bddf4785f9efac275424c5c735092600f45c5 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 | 131 +++++++++++++++++++++++++++++++----------- 1 file changed, 97 insertions(+), 34 deletions(-) diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm index e646cd0091..b59fe98546 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. ;;; @@ -1322,19 +1323,41 @@ 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 + `(("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 +1366,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