From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sOWdHNmdKmAgLwAA0tVLHw (envelope-from ) for ; Mon, 15 Feb 2021 16:14:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id IHd4GNmdKmBTTAAA1q6Kng (envelope-from ) for ; Mon, 15 Feb 2021 16:14:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BDF3011B93 for ; Mon, 15 Feb 2021 17:14:16 +0100 (CET) Received: from localhost ([::1]:40034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBgVr-0006Qd-JJ for larch@yhetil.org; Mon, 15 Feb 2021 11:14:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBgVd-0006OL-UI for guix-patches@gnu.org; Mon, 15 Feb 2021 11:14:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:55262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBgVd-0007RK-NK for guix-patches@gnu.org; Mon, 15 Feb 2021 11:14:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lBgVd-0004Y2-JX for guix-patches@gnu.org; Mon, 15 Feb 2021 11:14: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: Mon, 15 Feb 2021 16:14: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.161340561117423 (code B ref 46162); Mon, 15 Feb 2021 16:14:01 +0000 Received: (at 46162) by debbugs.gnu.org; 15 Feb 2021 16:13:31 +0000 Received: from localhost ([127.0.0.1]:38568 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBgV3-0004Wm-CQ for submit@debbugs.gnu.org; Mon, 15 Feb 2021 11:13:31 -0500 Received: from mail-pf1-f171.google.com ([209.85.210.171]:35948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lBgUz-0004WW-Qh for 46162@debbugs.gnu.org; Mon, 15 Feb 2021 11:13:23 -0500 Received: by mail-pf1-f171.google.com with SMTP id z15so4448606pfc.3 for <46162@debbugs.gnu.org>; Mon, 15 Feb 2021 08:13:21 -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=xUXSHjD6QZqiZfM3ruHg+astR6rqcVT5Gd2QfCK+o70=; b=ZjSVa8cbLl93mi25AAa7lWENgMVKC5NYXixyezogW87PYKZdJRPCfB9oc5m1DsEvYb MSpfWOsb3ZfLoat7chGOW+oiDP/DcQSRt2N8YDy3pnjKfjzn8D8RIyJ6I+2BqWVlJ4ZZ 5udboRIuHorK7Kuw7VcmgUhxDRR70Q6uIX16BbGTrRFH5Ig/oK1rLuJNDqhdHVsCBG5+ e8CuNvsetXvmk8deO4cEL/QiSJM6XoHKjTnawIyZHiVID4/0BYlSNakshxMjXpROQYgT +YYIQChrOae3TJALyay2cAv4wWlKr9YC5ULI/9TXwf1XSh8dbA+v1bEp9JsqJ05+FFZZ hx3w== 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=xUXSHjD6QZqiZfM3ruHg+astR6rqcVT5Gd2QfCK+o70=; b=SIgUOQ47evwjmwEKM4IXgmOWUwd9Z6OpOuHBPTxgoyslaoHcRB0ftRv1GfkDRD6v9L 7goocF3TD+X+ZkdUS7c+QJ6C4sVvYA6Hug1i7sp++bSM7teEsLBTkdHLBnj2YzxBGrpg BmjHKURTngEAJS9I49oWSPG5FAQ+M3oL0g1hjRxzpw0wv7AyIUK8FKnS46A5NVNBcFO3 rK+dNPsiS20EY867uaerbUNRMNUBgUkjzGErFlMmZpRjzGWoioxM5pWKtY22fzPtLijw OGdLS296FwG7lmyFPwLqbR/OcZ3q9+9KJMF+HywpL668U1f6H8XxaW0JHd/+LBG3lJoS bjEQ== X-Gm-Message-State: AOAM533saSZ/6qlepmBJX0vBWujXCAGqbKfXl9pmNQL7sm8zKDieaqip QiZ2lYH1I8++aO2XlN/Pxu/gIossN1McmA== X-Google-Smtp-Source: ABdhPJy1CHFQgrQIdkhMufwjSqVNWzrqnjm9t+MUawrGiA4PU8sE3c2VlE3kBAr9jS3n6HB4uCIx1g== X-Received: by 2002:a62:1ad1:0:b029:1e8:228e:1cf5 with SMTP id a200-20020a621ad10000b02901e8228e1cf5mr15785663pfa.58.1613405595006; Mon, 15 Feb 2021 08:13:15 -0800 (PST) Received: from ecenter (cpe-76-175-213-72.socal.res.rr.com. [76.175.213.72]) by smtp.gmail.com with ESMTPSA id x11sm18936678pfr.24.2021.02.15.08.13.10 for <46162@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Feb 2021 08:13:11 -0800 (PST) From: John Soo References: <87eei4k9hn.fsf@asu.edu> Date: Mon, 15 Feb 2021 08:13:10 -0800 In-Reply-To: <87eei4k9hn.fsf@asu.edu> (John Soo's message of "Thu, 28 Jan 2021 14:00:20 -0800") Message-ID: <87ft1xwbqh.fsf@asu.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.26 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=asu-edu.20150623.gappssmtp.com header.s=20150623 header.b=ZjSVa8cb; dmarc=fail reason="SPF not aligned (relaxed)" header.from=asu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: BDF3011B93 X-Spam-Score: -1.26 X-Migadu-Scanner: scn0.migadu.com X-TUID: 1oF/Trr96TNZ --=-=-= Content-Type: text/plain Rebased on staging. There is one more question that I have about search paths. A lot of rust tools use the $RUST_SRC_PATH to find the source of rust. I add the source output as "src" but I am not sure how to specify a search path to the top directory of a separate output. Any pointers? Thanks! John --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-gnu-Add-more-tools-to-rust-outputs.patch Content-Transfer-Encoding: quoted-printable >From cd849893e7f9b6ad8c380b3ebc74ea92530f8c48 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. as a separate output= of rust. * 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 insta= ll logs and manifests. --- gnu/packages/rust.scm | 145 +++++++++++++++++++++++++++++++----------- 1 file changed, 109 insertions(+), 36 deletions(-) diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm index f72f310169..8a09e1077e 100644 --- a/gnu/packages/rust.scm +++ b/gnu/packages/rust.scm @@ -11,6 +11,7 @@ ;;; Copyright =C2=A9 2020, 2021 Jakub K=C4=85dzio=C5=82ka ;;; Copyright =C2=A9 2020 Pierre Langlois ;;; Copyright =C2=A9 2020 Matthew Kraai +;;; Copyright =C2=A9 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,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 + `(("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 =3D )\".*\"" 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. (let ((parallel-job-spec (string-append "-j" (number->string (min 4 @@ -1343,44 +1367,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 =3D \"[^\"]*\"") - (string-append "prefix =3D \"" (assoc-ref outputs "car= go") "\""))) - (invoke "./x.py" "install" "cargo") - (substitute* "config.toml" - ;; replace prefix to specific output - (("prefix =3D \"[^\"]*\"") - (string-append "prefix =3D \"" (assoc-ref outputs "rus= tfmt") "\""))) - (invoke "./x.py" "install" "rustfmt"))) + (("\\[build\\]" all) + (string-append all " +extended =3D true +tools =3D +"))) + (define (install-component component) + (substitute* "config.toml" + ;; replace prefix to specific output + (("(tools =3D).*" all tools) + (string-append tools " [\"" component "\"]\n")) + (("prefix =3D \"[^\"]*\"") + (string-append + "prefix =3D \"" (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/" fi= le))) - - (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))))))))))) =20 (define-public rust-1.47 (let ((base-rust @@ -1413,7 +1477,8 @@ move around." ;; particular, vendor/jemalloc/rep/Makefile). (lambda* _ (use-modules (guix build cargo-utils)) - (substitute* "Cargo.lock" + (substitute* '("Cargo.lock" + "src/tools/rust-analyzer/Cargo.lock") (("(checksum =3D )\".*\"" all name) (string-append name "\"" ,%cargo-reference-hash "\""))) (generate-all-checksums "vendor") @@ -1445,7 +1510,15 @@ move around." (("fn test_process_mask") "#[allow(unused_attributes)] #[ignore] fn test_process_mask")) - #t)))))))))) + #t))) + ;; FIXME: This fixes the "src" output which is not critical. = We + ;; should probably copy the source of the de-vendored libunwi= nd + ;; for completeness' sake. + (add-before 'install 'remove-vendored-llvm-reference-in-src + (lambda _ + (substitute* "src/bootstrap/dist.rs" + ((", \"src/llvm-project/libunwind\"") "")) + #t))))))))) =20 (define-public rust-1.49 (rust-bootstrapped-package rust-1.48 "1.49.0" --=20 2.30.0 --=-=-=--