From patchwork Mon Apr 28 16:23:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 42121 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 8639427BC4A; Mon, 28 Apr 2025 17:34:25 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id F224127BC49 for ; Mon, 28 Apr 2025 17:34:24 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9RQo-0008PR-48; Mon, 28 Apr 2025 12:34:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1u9ROz-0007be-7S for guix-patches@gnu.org; Mon, 28 Apr 2025 12:32:18 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u9ROy-0004PR-PL for guix-patches@gnu.org; Mon, 28 Apr 2025 12:32:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=Vt4y6CTOGVonuoCeKQ+8eMOJHJzylPrUcABgm21cTU8=; b=Hba/hem2tI9/G7VkcdkiSIrLv+MiIHdvPDcU9OLwo7kAo0ImRxZ7GVApLRRGGpRRb9ZO8URtmbbi3B+GRTbfgeuKdzRm6X4kVeRTFZ4VXKrE8RnopQTpmYjwVbNgCQ3wZGhBPXX3faR/v+oDGBKc6e3VCs8n8kU2cCsUeSqwFd9eAuwP0LjciZZIPtEhA4gnCygb5aX48ugN07Qufhyv8utkOXPBWSSYvRH31h4oYbzwNLEvAGO1AsUZyYEXLTeb0pA6zRV2W6FQseS1yCJw7XQrOd7FBQsmZioxT344yuFcv3akLczsKTwIex0RYSY3CPeAJnp3bxkVckxGhq7JFg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u9ROv-0003Iz-Fw; Mon, 28 Apr 2025 12:32:13 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH v4 rust-team 08/22] build/cargo: Print out all non-empty binary files. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, hako@ultrarare.space, steve@futurile.net, guix-patches@gnu.org Resent-Date: Mon, 28 Apr 2025 16:32:13 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77093 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77093@debbugs.gnu.org Cc: Hilton Chain , Divya Ranjan Pattanaik , Efraim Flashner , Hilton Chain , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Hilton Chain , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174585791812435 (code B ref 77093); Mon, 28 Apr 2025 16:32:13 +0000 Received: (at 77093) by debbugs.gnu.org; 28 Apr 2025 16:31:58 +0000 Received: from localhost ([127.0.0.1]:32852 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u9ROg-0003EV-3f for submit@debbugs.gnu.org; Mon, 28 Apr 2025 12:31:58 -0400 Received: from mail.boiledscript.com ([49.12.134.184]:50386) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u9ROF-00039n-3k for 77093@debbugs.gnu.org; Mon, 28 Apr 2025 12:31:35 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1745857889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Vt4y6CTOGVonuoCeKQ+8eMOJHJzylPrUcABgm21cTU8=; b=A7o4xRk7iNZumGFfokDX0HLiQLk5WABBgjkSQ1TQCsBZVcS8shBXN/Wqa6DhOEyCEoPArc 40Xhc2COztvgbe5YBGNjp65APua7CMXzof1i+6pkTtGhlQVJ6z4ai8OPcsKE/B+jbi0whF 2m3dkcQJZEnen4u4Sci5IVhf+BpWkVRb5fLfH41h2puH2JGTkegpIoPpIrh+CZHqmOFmwR zo4Xuv1rQR5qYT9JcmiSWadHGFluEc3ucZ1KETmYj9XVxyiH78Dq5Sp2js5JBglJSxg+RG Ref9+DvMdCPkf7DLPsXE9bBk46TU9pA6GKbKDbYhTuL7oqwMnJZxsFvR3xROfw== Date: Tue, 29 Apr 2025 00:23:05 +0800 Message-ID: <52b9d6c4f3904adee4b960ae327236c3814da139.1745855744.git.hako@ultrarare.space> In-Reply-To: References: 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/build/cargo-build-system.scm (%standard-phases): Move ‘unpack-rust-crates’ after ‘unpack’. Move ‘check-for-pregenerated-files’ after ‘configure’. (check-for-pregenerated-files): Only check non-empty files. Print out binary files. Run in parallel. Don't fail to keep compatibility for phase order change. Change-Id: I0a332fe843e97687324bd908fa111422a63e475d --- guix/build/cargo-build-system.scm | 33 +++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 41f54f42b7..c37fd70418 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -27,11 +27,14 @@ (define-module (guix build cargo-build-system) #:use-module ((guix build gnu-build-system) #:prefix gnu:) #:use-module (guix build json) #:use-module ((guix build utils) #:hide (delete)) + #:use-module (ice-9 binary-ports) #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) + #:use-module (ice-9 regex) #:use-module (ice-9 ftw) #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (ice-9 threads) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (%standard-phases @@ -111,12 +114,30 @@ (define* (unpack-rust-crates #:key inputs vendor-dir #:allow-other-keys) (define (rust-package? name) (string-prefix? "rust-" name)) -(define* (check-for-pregenerated-files #:rest _) +(define* (check-for-pregenerated-files #:key parallel-build? #:allow-other-keys) "Check the source code for files which are known to generally be bundled libraries or executables." - (let ((pregenerated-files (find-files "." "\\.(a|dll|dylib|exe|lib)$"))) - (when (not (null-list? pregenerated-files)) - (error "Possible pre-generated files found:" pregenerated-files)))) + (format #t "Searching for binary files...~%") + (let ((known-pattern (make-regexp "\\.(a|dll|dylib|exe|lib)$")) + (empty-file? + (lambda (file stat) + (let ((size (stat:size stat))) + (or (zero? size) + (and (eqv? 1 size) + (eqv? #\newline + (call-with-ascii-input-file file read-char)))))))) + (n-par-for-each + (if parallel-build? + (parallel-job-count) + 1) + (lambda (file) + ;; Print out binary files. + (false-if-exception (invoke "grep" "-IL" "." file)) + ;; Warn about known pre-generated files. + ;; Not failing here for compatibility with existing packages. + (when (regexp-exec known-pattern file) + (format #t "error: Possible pre-generated file found: ~a~%" file))) + (find-files "." (negate empty-file?))))) (define* (configure #:key inputs target system @@ -380,8 +401,8 @@ (define %standard-phases (replace 'check check) (replace 'install install) (add-after 'build 'package package) - (add-after 'unpack 'check-for-pregenerated-files check-for-pregenerated-files) - (add-after 'check-for-pregenerated-files 'unpack-rust-crates unpack-rust-crates) + (add-after 'unpack 'unpack-rust-crates unpack-rust-crates) + (add-after 'configure 'check-for-pregenerated-files check-for-pregenerated-files) (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums patch-cargo-checksums))) (define* (cargo-build #:key inputs (phases %standard-phases)