From patchwork Tue Mar 18 14:26:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hilton Chain X-Patchwork-Id: 40327 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 A487127BBEA; Tue, 18 Mar 2025 14:28:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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=ham 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 285F227BBE2 for ; Tue, 18 Mar 2025 14:28:40 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuXvV-0004uW-CT; Tue, 18 Mar 2025 10:28:17 -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 1tuXvS-0004u9-V2 for guix-patches@gnu.org; Tue, 18 Mar 2025 10:28:15 -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 1tuXvS-0001LG-Jr for guix-patches@gnu.org; Tue, 18 Mar 2025 10:28:14 -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=tWCnhX4OoBIrcF5cBlDIauVuJiVPteEuBGDYdX+/oyI=; b=a9w+6+sUcjpOTPxwTlIeLgZyb6q2JDJdX4b5N2pI1ieC15N8IKcByfq1p7PsdESWKCocMRN4xzCP+9Skq1kK3N7sLCSASA8DlsVSsbiSvLDMclTonCSEBEt5EAox52cDzFa1ZE6ZNiIDG2GKdIZh79CJSFbxcp7ZqXonAX6FYEgxjQ9mQ8JasDoW9L7BAtoj32hlEJ+BjrKNv9bhM8e1ZboxbQWbnvU0hnMPtMUbBd19/K2WuT4hyBEiVyzYa4CyPOpNKZbo7XZU4pfG1kPSur+ynPxSZrRzsAcTyuvVFVglDQQ90htc0dFLIUyrRhNrjcOIZzfgGHqNwWQZJe/Bvw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tuXvO-0004Ym-DA; Tue, 18 Mar 2025 10:28:10 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77093] [PATCH rust-team v2 02/17] 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, steve@futurile.net, guix-patches@gnu.org Resent-Date: Tue, 18 Mar 2025 14:28:10 +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 , Efraim Flashner , Divya Ranjan Pattanaik , Efraim Flashner , Steve George X-Debbugs-Original-Xcc: Divya Ranjan Pattanaik , Efraim Flashner , Steve George Received: via spool by 77093-submit@debbugs.gnu.org id=B77093.174230807217305 (code B ref 77093); Tue, 18 Mar 2025 14:28:10 +0000 Received: (at 77093) by debbugs.gnu.org; 18 Mar 2025 14:27:52 +0000 Received: from localhost ([127.0.0.1]:41664 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tuXv2-0004UN-7O for submit@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:51 -0400 Received: from mx.boiledscript.com ([2a01:4f8:10b:392::42]:41348) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tuXul-0004RA-AC for 77093@debbugs.gnu.org; Tue, 18 Mar 2025 10:27:34 -0400 From: Hilton Chain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=mail; t=1742308048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tWCnhX4OoBIrcF5cBlDIauVuJiVPteEuBGDYdX+/oyI=; b=Q+FGJ79dZ/Bb/v3BD1Ny//thnaO/ficuGIf6+L4/pbz3tgLWhUb/8saZjwjGRiM4Og2qQP pR75+uVAtoUsId3aJHEKcZgFVH3VBQUp4eWx6ewgIIqPlXPwXtXhHsyQpsrk51xLB4o5iG EkzXUYlqE4L8cB+NxQLrEByUFhORQOAZKVSDA/wT1FBJGNbcnr1ENk2gf5XA6M9NaN72+C E2unnnAqLThQTbMfJt1uTsVtHbD4LtrUtYdBBk4ExBTBL2jSMAgRPeS7WXGt/i/99Yafv4 x0vHEDgrGT/EUd8D+2fcAIWTn74Sc6KYJyzrbISCh76H9S8ltRNlTd/5KXFBpg== Date: Tue, 18 Mar 2025 22:26:45 +0800 Message-ID: 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 | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 41f54f42b7..58238992b8 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -29,9 +29,11 @@ (define-module (guix build cargo-build-system) #:use-module ((guix build utils) #:hide (delete)) #: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 +113,29 @@ (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 (filename) + (call-with-ascii-input-file filename + (lambda (p) + (eqv? #\0 (read-char p))))))) + (n-par-for-each + (if parallel-build? + (parallel-job-count) + 1) + (lambda (file) + (unless (empty-file? 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 ".")))) (define* (configure #:key inputs target system @@ -380,8 +399,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)