GNU bug report logs - #61776
[PATCH] gnu: perl-extutils-pkgconfig: Support cross-compilation.

Previous Next

Package: guix-patches;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Sat, 25 Feb 2023 01:20:01 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 61776 in the body.
You can then email your comments to 61776 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#61776; Package guix-patches. (Sat, 25 Feb 2023 01:20:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sat, 25 Feb 2023 01:20:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Josselin Poiret <dev <at> jpoiret.xyz>, Tobias Geerinckx-Rice <me <at> tobias.gr>,
 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Ludovic Courtès <ludo <at> gnu.org>,
 Christopher Baines <mail <at> cbaines.net>, Ricardo Wurmus <rekado <at> elephly.net>
Subject: [PATCH] gnu: perl-extutils-pkgconfig: Support cross-compilation.
Date: Fri, 24 Feb 2023 20:19:33 -0500
* 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(-)

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 <pgarlick <at> tourbillion-technology.com>
 ;;; Copyright © 2020 Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
 ;;; Copyright © 2020 Malte Frank Gerdes <malte.f.gerdes <at> gmail.com>
-;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2021, 2023 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2021 Xinglu Chen <public <at> yoctocell.xyz>
 ;;; Copyright © 2021 Raghav Gururajan <rg <at> raghavgururajan.name>
 ;;; Copyright © 2021 Maxime Devos <maximedevos <at> telenet.be>
@@ -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)

base-commit: b12ee1ee5b8b53bf27b79ce81b1b2158cc7de484
-- 
2.39.1





Information forwarded to guix-patches <at> gnu.org:
bug#61776; Package guix-patches. (Thu, 02 Mar 2023 09:57:02 GMT) Full text and rfc822 format available.

Message #8 received at 61776 <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 61776 <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: perl-extutils-pkgconfig: Support cross-compilation.
Date: Thu, 02 Mar 2023 09:51:58 +0000
[Message part 1 (text/plain, inline)]
Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

> * 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(-)

I guess I've been sent this email personally because of "teams", it's
quite confusing, I can't determine the bug number from the email, but I
believe it's #61776. I'm going to reply to that bug.

Anyway, according to QA this might break perl-gtk2. Unfortunately the
comparison is a bit confused due to the openmpi related breakage, so do
ignore that in the comparison.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#61776; Package guix-patches. (Thu, 02 Mar 2023 18:28:02 GMT) Full text and rfc822 format available.

Message #11 received at 61776 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Christopher Baines <mail <at> cbaines.net>
Cc: 61776 <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: perl-extutils-pkgconfig: Support cross-compilation.
Date: Thu, 02 Mar 2023 13:27:31 -0500
Hi Christopher,

Christopher Baines <mail <at> cbaines.net> writes:

> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:
>
>> * 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(-)
>
> I guess I've been sent this email personally because of "teams", it's
> quite confusing, I can't determine the bug number from the email, but I
> believe it's #61776. I'm going to reply to that bug.

Indeed!  Patman uses '--cc=email' instead of
'--add-header=X:-Debbugs-Cc: email', which explains why recipients do
not see the actual bug #.  I'll see if I can modify the behavior of the
tool.

> Anyway, according to QA this might break perl-gtk2. Unfortunately the
> comparison is a bit confused due to the openmpi related breakage, so do
> ignore that in the comparison.

I'll look into it and report back, thanks!

-- 
Thanks,
Maxim




Reply sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
You have taken responsibility. (Tue, 07 Mar 2023 03:13:02 GMT) Full text and rfc822 format available.

Notification sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
bug acknowledged by developer. (Tue, 07 Mar 2023 03:13:02 GMT) Full text and rfc822 format available.

Message #16 received at 61776-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Christopher Baines <mail <at> cbaines.net>
Cc: 61776-done <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: perl-extutils-pkgconfig: Support cross-compilation.
Date: Mon, 06 Mar 2023 22:12:28 -0500
Hi,

Christopher Baines <mail <at> cbaines.net> writes:

> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:
>
>> * 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(-)
>
> I guess I've been sent this email personally because of "teams", it's
> quite confusing, I can't determine the bug number from the email, but I
> believe it's #61776. I'm going to reply to that bug.
>
> Anyway, according to QA this might break perl-gtk2. Unfortunately the
> comparison is a bit confused due to the openmpi related breakage, so do
> ignore that in the comparison.

I fixed perl-gtk2; it also required pkg-config, which
perl-extutils-pkgconfig no longer propagates, and pushed.

Thanks for the heads-up and the useful data!

-- 
Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 04 Apr 2023 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.