From patchwork Sat Feb 25 01:19:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 47291 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 83B5316AF4; Sat, 25 Feb 2023 01:20:31 +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=-1.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,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 6738D16934 for ; Sat, 25 Feb 2023 01:20:29 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVjEL-0000iz-8S; Fri, 24 Feb 2023 20:20:05 -0500 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 1pVjEI-0000iS-RO for guix-patches@gnu.org; Fri, 24 Feb 2023 20:20:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVjEI-00034O-E5 for guix-patches@gnu.org; Fri, 24 Feb 2023 20:20:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVjEI-0002hx-00 for guix-patches@gnu.org; Fri, 24 Feb 2023 20:20:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61776] [PATCH] gnu: perl-extutils-pkgconfig: Support cross-compilation. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 25 Feb 2023 01:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61776 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 61776@debbugs.gnu.org Cc: Josselin Poiret , Tobias Geerinckx-Rice , Maxim Cournoyer , Simon Tournier , Mathieu Othacehe , Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Ricardo Wurmus X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167728799410388 (code B ref -1); Sat, 25 Feb 2023 01:20:01 +0000 Received: (at submit) by debbugs.gnu.org; 25 Feb 2023 01:19:54 +0000 Received: from localhost ([127.0.0.1]:38642 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVjEA-0002hU-0N for submit@debbugs.gnu.org; Fri, 24 Feb 2023 20:19:54 -0500 Received: from lists.gnu.org ([209.51.188.17]:60190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVjE7-0002hM-UB for submit@debbugs.gnu.org; Fri, 24 Feb 2023 20:19:52 -0500 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 1pVjE7-0000gs-Gm for guix-patches@gnu.org; Fri, 24 Feb 2023 20:19:51 -0500 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVjE5-00032z-5b; Fri, 24 Feb 2023 20:19:50 -0500 Received: by mail-qt1-x82a.google.com with SMTP id ay9so1325850qtb.9; Fri, 24 Feb 2023 17:19:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yaMz1S7I3rqjlxiMwP/i9VRdL9fl/5KgAhE3ZHni+8A=; b=kiWsxs1319R4Ls05PsBai8ZP743dicJsqGj/Qu/1lL47h1rHIdETCDCt+OJlblAAu/ +/8bH2uD+YHiyL9TURoDlFjpJyNGYqaLf00BTzpRAr6yb4XtXQ9gi3DPA0LPBnD+PIbc K4aqtynpIOuOuuXnkqH42NcLVeTj51TIXHDoHcXEqkYcbeK5V+ftjRZoE5kVbTDu9Lk8 Xy8bgfHjQCPhelRllosAfg8/8ZpYvPa+TogZhcJ/aY5t6SAdP6vNnbybDSuhWzVY+sND BUhADRVCWXID5lhneLOxCrJdrUYGnES4dtTAAXcmyPG0m8AbsmjjuwYluKtdg5Z4jNFp AiQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yaMz1S7I3rqjlxiMwP/i9VRdL9fl/5KgAhE3ZHni+8A=; b=GUHrFrnRifZlEWLc6GKN8qC9T8G0Ab+6bjfU3dLIOpbej4T70IcJSO61Ww0RC8/t3Y oEHZYq3KHq7XSJ7Q5HcbHmMVqAfrvYKSQqCJhvfR6cZWvhke6eUc9rEeB83HIwhJhWXD jbv8zxSRGlZD0hzzHCxFYWBRfUHBsd8g2JPlq1WIKxdL+YqqyVeXcESrf/Rh8/DhgUpL tNp1Is+XqtnsbOBEADNYrOgxNBXZ1ujsd8fnfbtUWkyAxXB3lELQOMBIR+oBiEBGu3ed 32P4lMKtQ72Nf1FA5rqo+UB/1SP5d1zkom7Kdb5F7oYyQLSRHyrlPHFgbwny+oAQe1S3 P6LA== X-Gm-Message-State: AO0yUKW621eDlbAE/N69AINQ3AAYDYN4/J7ork6Z6qEfTJkPoLkjqElf YHIkNNPmfHt2OxdIih9+3u4q2iYIK163u9/F X-Google-Smtp-Source: AK7set8C9jygrwE6iTCb5qQW1vwDzG3F4eYllEev/qVZqNrdEc1CuKdegZVP/JiwoHb9GHqak6gXYg== X-Received: by 2002:a05:622a:390:b0:3af:b6bd:aba7 with SMTP id j16-20020a05622a039000b003afb6bdaba7mr19120409qtx.43.1677287986095; Fri, 24 Feb 2023 17:19:46 -0800 (PST) Received: from localhost.localdomain (dsl-141-27.b2b2c.ca. [66.158.141.27]) by smtp.gmail.com with ESMTPSA id f16-20020ac86ed0000000b003bfa66b7484sm540830qtv.35.2023.02.24.17.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 17:19:45 -0800 (PST) From: Maxim Cournoyer Date: Fri, 24 Feb 2023 20:19:33 -0500 Message-Id: <20230225011934.27451-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x82a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/search-paths.scm ($PKG_CONFIG_PATH): New variable. * gnu/packages/pkg-config.scm (%pkg-config): Use it. * gnu/packages/perl.scm (perl-extutils-pkgconfig-for-target): New procedure. (perl-extutils-pkgconfig): Turn into a syntax that conditionally expands to... (cross-perl-extutils-pkgconfig): ... this when %current-target-system is set, or... (%perl-extutils-pkgconfig): ... this in a native compilation context. [arguments]: New field. [propagated-inputs]: Turn into... [native-inputs]: ... this. [native-search-paths]: New field. --- gnu/packages/perl.scm | 63 ++++++++++++++++++++++++++++++++++--- gnu/packages/pkg-config.scm | 5 ++- guix/search-paths.scm | 8 +++++ 3 files changed, 68 insertions(+), 8 deletions(-) base-commit: b12ee1ee5b8b53bf27b79ce81b1b2158cc7de484 diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm index 7b97e7adfa..69a897d827 100644 --- a/gnu/packages/perl.scm +++ b/gnu/packages/perl.scm @@ -28,7 +28,7 @@ ;;; Copyright © 2020 Paul Garlick ;;; Copyright © 2020 Nicolas Goaziou ;;; Copyright © 2020 Malte Frank Gerdes -;;; Copyright © 2021 Maxim Cournoyer +;;; Copyright © 2021, 2023 Maxim Cournoyer ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021 Raghav Gururajan ;;; Copyright © 2021 Maxime Devos @@ -63,6 +63,8 @@ (define-module (gnu packages perl) #:use-module (guix utils) #:use-module (guix build-system gnu) #:use-module (guix build-system perl) + #:use-module (guix memoization) + #:use-module (guix search-paths) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages compression) @@ -90,7 +92,8 @@ (define-module (gnu packages perl) #:use-module (gnu packages video) #:use-module (gnu packages web) #:use-module (gnu packages xml) - #:use-module (gnu packages xorg)) + #:use-module (gnu packages xorg) + #:export (perl-extutils-pkgconfig)) ;;; ;;; Please: Try to add new module packages in alphabetic order. @@ -4618,7 +4621,10 @@ (define-public perl-extutils-parsexs handle Perl/XS typemap files, and their submodules.") (license (package-license perl)))) -(define-public perl-extutils-pkgconfig +;; This is the "primitive" perl-extutils-pkgconfig package. People should use +;; `perl-extutils-pkgconfig' instead (see below)', but we export +;; %perl-extutils-pkgconfig so that `fold-packages' finds it. +(define-public %perl-extutils-pkgconfig (package (name "perl-extutils-pkgconfig") (version "1.16") @@ -4630,8 +4636,32 @@ (define-public perl-extutils-pkgconfig (base32 "0vhwh0731rhh1sswmvagq0myn754dnkab8sizh6d3n6pjpcwxsmv")))) (build-system perl-build-system) - (propagated-inputs - (list pkg-config)) + ;; XXX: Patch the pkg-config references to avoid propagating it, as that + ;; would cause the search path to be wrong when cross-building, due to + ;; propagated inputs being treated as host inputs, not native inputs. + (arguments + (list + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'patch-pkg-config-path + (lambda* (#:key native-inputs inputs #:allow-other-keys) + (let* ((target #$(%current-target-system)) + (pkg-config-name (if target + (string-append target "-pkg-config") + "pkg-config")) + (pkg-config (search-input-file + (or native-inputs inputs) + (string-append "bin/" pkg-config-name)))) + (substitute* '("Makefile.PL" + "lib/ExtUtils/PkgConfig.pm") + (("qx/pkg-config([^/]*)/" _ args) + (string-append "`" pkg-config args "`")) + (("(`|\")pkg-config" _ quote) + (string-append quote pkg-config))))))))) + (native-inputs (list pkg-config)) + ;; Note: do not use the pkg-config syntax here, as the search paths fields + ;; are not thunked and its value could be wrong. + (native-search-paths (list $PKG_CONFIG_PATH)) (home-page "https://metacpan.org/release/ExtUtils-PkgConfig") (synopsis "Simplistic interface to pkg-config") (description @@ -4641,6 +4671,29 @@ (define-public perl-extutils-pkgconfig It is really just boilerplate code that you would have written yourself.") (license license:lgpl2.1+))) +(define-public cross-perl-extutils-pkgconfig + (mlambda (target) + "Return a perl-extutils-pkgconfig for TARGET, adjusting the search paths." + (package + (inherit %perl-extutils-pkgconfig) + ;; Ignore native inputs, and set `PKG_CONFIG_PATH' for target inputs. + (native-search-paths '()) + (search-paths (list $PKG_CONFIG_PATH))))) + +(define (perl-extutils-pkgconfig-for-target target) + "Return a perl-extutils-pkgconfig package for TARGET, which may be either #f +for a native build, or a GNU triplet." + (if target + (cross-perl-extutils-pkgconfig target) + %perl-extutils-pkgconfig)) + +;; This hack mimics the one for pkg-config, to allow automatically choosing +;; the native or the cross `pkg-config' depending on whether it's being used +;; in a cross-build environment or not. +(define-syntax perl-extutils-pkgconfig + (identifier-syntax (perl-extutils-pkgconfig-for-target + (%current-target-system)))) + (define-public perl-extutils-typemaps-default (package (name "perl-extutils-typemaps-default") diff --git a/gnu/packages/pkg-config.scm b/gnu/packages/pkg-config.scm index 6263e90f1f..b15b646416 100644 --- a/gnu/packages/pkg-config.scm +++ b/gnu/packages/pkg-config.scm @@ -24,6 +24,7 @@ (define-module (gnu packages pkg-config) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix gexp) + #:use-module (guix search-paths) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #:use-module (gnu packages bash) @@ -66,9 +67,7 @@ (define-public %pkg-config "ac_cv_func_posix_getgrgid_r=yes") '())))) (native-search-paths - (list (search-path-specification - (variable "PKG_CONFIG_PATH") - (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig"))))) + (list $PKG_CONFIG_PATH)) (home-page "https://www.freedesktop.org/wiki/Software/pkg-config") (license gpl2+) (synopsis "Helper tool used when compiling applications and libraries") diff --git a/guix/search-paths.scm b/guix/search-paths.scm index 4a8f5131ed..fcbe7b7953 100644 --- a/guix/search-paths.scm +++ b/guix/search-paths.scm @@ -34,6 +34,7 @@ (define-module (guix search-paths) $PATH $GUIX_EXTENSIONS_PATH + $PKG_CONFIG_PATH $SSL_CERT_DIR $SSL_CERT_FILE @@ -83,6 +84,13 @@ (define $GUIX_EXTENSIONS_PATH (variable "GUIX_EXTENSIONS_PATH") (files '("share/guix/extensions")))) +(define $PKG_CONFIG_PATH + ;; 'PKG_CONFIG_PATH' is used by pkg-config to locate available header files + ;; and libraries, via their .pc files. + (search-path-specification + (variable "PKG_CONFIG_PATH") + (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig")))) + ;; Two variables for certificates (info "(guix)X.509 Certificates"), ;; respected by OpenSSL and possibly GnuTLS in the future ;; (https://gitlab.com/gnutls/gnutls/-/merge_requests/1541)