[PATCH 0/2] Fix cross-compilation for libfido2

  • Done
  • quality assurance status badge
Details
5 participants
  • Thiago Jung Bauermann
  • Ludovic Courtès
  • Maxime Devos
  • Pierre Langlois
  • Sébastien Lerique
Owner
unassigned
Submitted by
Sébastien Lerique
Severity
normal
S
S
Sébastien Lerique wrote on 27 Mar 2022 14:28
(address . guix-patches@gnu.org)(name . Sébastien Lerique)(address . sl@eauchat.org)
20220327122822.523780-1-sl@eauchat.org
Hello guix!

This small patch fixes cross-compilation for libfido2, which in turn is
necessary to cross-compile openssh.

Thank you to Pierre Langlois and for help on IRC!

Sébastien Lerique (2):
gnu: libfido2: Use new style.
gnu: libfido2: Fix cross-compilation.

gnu/packages/security-token.scm | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)


base-commit: cabda1197e7925f58a8532534afc1bde6c5eb377
--
2.34.0
S
S
Sébastien Lerique wrote on 27 Mar 2022 14:29
[PATCH 1/2] gnu: libfido2: Use new style.
(address . 54595@debbugs.gnu.org)(name . Sébastien Lerique)(address . sl@eauchat.org)
20220327122956.524901-1-sl@eauchat.org
* gnu/packages/security-token.scm (libfido2)[inputs]: Use new style.
---
gnu/packages/security-token.scm | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

Toggle diff (19 lines)
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index 129b8f6122..6853d5bc9e 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -903,11 +903,7 @@ (define-public libfido2
(file-name (git-file-name name version))
(sha256 (base32 "12zy4cnlcffcb64lsx8198y09j1dwi0bcn9rr82q6i1k950yzd3p"))))
(native-inputs (list pkg-config))
- (inputs
- `(("zlib" ,zlib)
- ("udev" ,eudev)
- ("libcbor" ,libcbor)
- ("openssl" ,openssl)))
+ (inputs (list zlib eudev libcbor openssl))
(build-system cmake-build-system)
(arguments
'(#:phases
--
2.34.0
S
S
Sébastien Lerique wrote on 27 Mar 2022 14:29
[PATCH 2/2] gnu: libfido2: Fix cross-compilation.
(address . 54595@debbugs.gnu.org)(name . Sébastien Lerique)(address . sl@eauchat.org)
20220327122956.524901-2-sl@eauchat.org
* gnu/packages/security-token.scm (libfido2)[arguments]: Set
PKG_CONFIG_EXECUTABLE variable when cross-compiling.
---
gnu/packages/security-token.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

Toggle diff (24 lines)
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index 6853d5bc9e..903da686f9 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -906,7 +906,16 @@ (define-public libfido2
(inputs (list zlib eudev libcbor openssl))
(build-system cmake-build-system)
(arguments
- '(#:phases
+ `(#:configure-flags (list ,@(if (%current-target-system)
+ `((string-append
+ "-DPKG_CONFIG_EXECUTABLE="
+ (search-input-file %build-inputs
+ (string-append
+ "/bin/"
+ ,(%current-target-system)
+ "-pkg-config"))))
+ '()))
+ #:phases
(modify-phases %standard-phases
;; regress tests enabled only for debug builds
(delete 'check))))
--
2.34.0
M
M
Maxime Devos wrote on 27 Mar 2022 14:36
cee568010458ba7d69c942bfb5c356f8956d6975.camel@telenet.be
Sébastien Lerique schreef op zo 27-03-2022 om 21:29 [+0900]:
Toggle quote (3 lines)
> +                                                            ,(%current-target-system)
> +                                                            "-pkg-config"))))

This can be simplified with 'pkg-config-for-target':

#:configure-flags
(list (string-append "-DPKG_CONFIG_EXECUTABLE="
(search-input-file %build-inputs
(string-append "/bin/" ,(pkg-config-for-target)))))

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkBaYhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7vgcAP45/+wwDkvFD5bW/2xdsjzIupZP
6piyEA4oywJUpxtmVwD/YBjvEfQBE5tguTVSMOvhD3W4I3ifvj3LtDgrpiADPgc=
=pm9i
-----END PGP SIGNATURE-----


S
S
Sébastien Lerique wrote on 27 Mar 2022 15:00
[PATCH v2 1/2] gnu: libfido2: Use new style.
(address . 54595@debbugs.gnu.org)(name . Sébastien Lerique)(address . sl@eauchat.org)
20220327130004.533714-1-sl@eauchat.org
* gnu/packages/security-token.scm (libfido2)[inputs]: Use new style.
---
gnu/packages/security-token.scm | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

Toggle diff (21 lines)
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index 129b8f6122..6853d5bc9e 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -903,11 +903,7 @@ (define-public libfido2
(file-name (git-file-name name version))
(sha256 (base32 "12zy4cnlcffcb64lsx8198y09j1dwi0bcn9rr82q6i1k950yzd3p"))))
(native-inputs (list pkg-config))
- (inputs
- `(("zlib" ,zlib)
- ("udev" ,eudev)
- ("libcbor" ,libcbor)
- ("openssl" ,openssl)))
+ (inputs (list zlib eudev libcbor openssl))
(build-system cmake-build-system)
(arguments
'(#:phases

base-commit: cabda1197e7925f58a8532534afc1bde6c5eb377
--
2.34.0
S
S
Sébastien Lerique wrote on 27 Mar 2022 15:00
[PATCH v2 2/2] gnu: libfido2: Fix cross-compilation.
(address . 54595@debbugs.gnu.org)(name . Sébastien Lerique)(address . sl@eauchat.org)
20220327130004.533714-2-sl@eauchat.org
* gnu/packages/security-token.scm (libfido2)[arguments]: Set
PKG_CONFIG_EXECUTABLE variable when cross-compiling.
---
gnu/packages/security-token.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

Toggle diff (31 lines)
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index 6853d5bc9e..db8a8a53d3 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -44,6 +44,7 @@ (define-module (gnu packages security-token)
#:use-module (guix build-system gnu)
#:use-module (guix build-system glib-or-gtk)
#:use-module (guix build-system python)
+ #:use-module (guix utils)
#:use-module (gnu packages autotools)
#:use-module (gnu packages base)
#:use-module (gnu packages curl)
@@ -906,7 +907,15 @@ (define-public libfido2
(inputs (list zlib eudev libcbor openssl))
(build-system cmake-build-system)
(arguments
- '(#:phases
+ `(#:configure-flags (list ,@(if (%current-target-system)
+ `((string-append
+ "-DPKG_CONFIG_EXECUTABLE="
+ (search-input-file %build-inputs
+ (string-append
+ "/bin/"
+ ,(pkg-config-for-target)))))
+ '()))
+ #:phases
(modify-phases %standard-phases
;; regress tests enabled only for debug builds
(delete 'check))))
--
2.34.0
S
S
Sébastien Lerique wrote on 27 Mar 2022 15:01
Re: [bug#54595] [PATCH 2/2] gnu: libfido2: Fix cross-compilation.
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 54595@debbugs.gnu.org)
87k0cflfbg.fsf@eauchat.org
On 27 Mar 2022 at 14:36, Maxime Devos <maximedevos@telenet.be> wrote:

Toggle quote (3 lines)
> This can be simplified with 'pkg-config-for-target':
>

Indeed, thanks! Just tried again with a v2.

Best,
Sébastien
M
M
Maxime Devos wrote on 27 Mar 2022 16:09
Re: [bug#54595] [PATCH v2 2/2] gnu: libfido2: Fix cross-compilation.
a8df2ce7774466766dd4e50530a273f3ab869bd4.camel@telenet.be
Sébastien Lerique schreef op zo 27-03-2022 om 22:00 [+0900]:
Toggle quote (9 lines)
> +     `(#:configure-flags (list ,@(if (%current-target-system)
> +                                     `((string-append
> +                                        "-DPKG_CONFIG_EXECUTABLE="
> +                                        (search-input-file %build-inputs
> +                                                           (string-append
> +                                                            "/bin/"
> +                                                            ,(pkg-config-for-target)))))
> +                                     '()))

'pkg-config-for-target' just returns "pkg-config" when compiling
natively, so the 'if' can be dropped here and the "-
DPKG_CONFIG_EXECUTABLE=..." be made unconditional.

For clarity, I would put the 'list' on a separate line, though for
style reasons that might require removing the quasiquote and turning it
in a 'list': (arguments (list #:phases #~(foo ...) #:configure-flags
#~(bar ... #$(pkg-config-for-target)))).

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkBv/xccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7gueAQDreqPe+7oBz1mVfhCFbCgdHTDW
LAqelY5BlEPXZnXNrwD8D05oCQZRDiA7oodh8+byHQhJwe77V389s6g0yAmj5g0=
=lu6E
-----END PGP SIGNATURE-----


P
P
Pierre Langlois wrote on 27 Mar 2022 16:04
Re: [bug#54595] [PATCH 2/2] gnu: libfido2: Fix cross-compilation.
(name . Maxime Devos)(address . maximedevos@telenet.be)
871qyn7afq.fsf@gmx.com
Hi,

Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (12 lines)
> [[PGP Signed Part:Undecided]]
> Sébastien Lerique schreef op zo 27-03-2022 om 21:29 [+0900]:
>> +                                                            ,(%current-target-system)
>> +                                                            "-pkg-config"))))
>
> This can be simplified with 'pkg-config-for-target':
>
> #:configure-flags
> (list (string-append "-DPKG_CONFIG_EXECUTABLE="
> (search-input-file %build-inputs
> (string-append "/bin/" ,(pkg-config-for-target)))))

For my own benefit trying to get better at writing gexps, I was
wondering how to write in order to remove the %build-inputs reference.
I came up with the following:

Toggle snippet (16 lines)
(arguments
(list
#:configure-flags
#~(list #$@(if (%current-target-system)
(list
#~(string-append
"-DPKG_CONFIG_EXECUTABLE="
#+pkg-config "/bin/"
#$(pkg-config-for-target)))
'()))
#:phases
#~(modify-phases %standard-phases
;; regress tests enabled only for debug builds
(delete 'check))))

Would this a the better way to do this? It looks a bit complex to me so
I wonder if there's a simpler way. I'm also not entirely sure if it's
#+pkg-config or #$pkg-config, both seem to work, however I thought we
should be using #+ for native inputs and #$ for regular inputs.

Thanks,
Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmJAcGkYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UnR0H/jFxhsl/8U8tWQrhRUhMcku1
1hAadeXvXbCXXFJmVH7qYPhe65bty0HYUHAVs/TtC8t3beV6bCNH4qe9TnfeHv3L
3kgifOpv2mPck0P/dV64xlKHExIWTKk7Oslqc4pB9/WlyllpWwWekgzc/IyFRZU4
MSVuGTaZOfxg7i0ruOwh7CEzprkduTgEC1RP1n7yeRsrLe2p5Dc8TsmFBITNzfLY
O9KHOXm+Sjiv3ujswJoUtJXyBq05UvtdehOTirEyDsIPMpZ/DhsttqJa/U+WXjSu
6VNn+VKdRU/HGaLJ1v14qoYbdFZmikZsby8fT19/4+uE0z4OM+iy+Uu109ZBw8w=
=GH8F
-----END PGP SIGNATURE-----

M
M
Maxime Devos wrote on 27 Mar 2022 17:43
(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
1fd85fd1bd5389fbe4f14325e22fac8705b9807b.camel@telenet.be
Pierre Langlois schreef op zo 27-03-2022 om 15:04 [+0100]:
Toggle quote (3 lines)
> I'm also not entirely sure if it's
> #+pkg-config or #$pkg-config, both seem to work

#+pkg-config, given that it is a thing that needs to be run during
compilation. I'm wondering, do you have transparant QEMU emulation
enabled? If so, both seeming to work is expected since QEMU will
emulate the cross-compiled cross-compiling (IIUC a canadian cross, in
GCC terminology) pkg-config. If not, I would expect some kind of error
...

Or, to allow for package transformations:

#+(file-append (this-package-native-input (pkg-config-for-target))
"/bin/" (pkg-config-for-target))

though maybe package transformations should just transform the G-exp as
well, dunno. ('file-append' is not strictly required here.) Maybe we can
have a macro (pkg-config-binary) that expands to that thing, and
use it in other packages?

Possibly interesting or irrelevant: the following will produce an
x86_64-linux-gnu-pkg-config that can be run on a aarch64-linux-gnu
computer to find libraries for x86_64-linux-gnu.

$ guix build -e '(parameterize (((@ (guix utils) %current-target-system) "x86_64-linux-gnu")) (@ (gnu packages pkg-config) pkg-config))' --target=aarch64-linux-gnu

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkCGJxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7oCYAP0bfhKPd1B0EcpeDzbFiRJVx/Nh
TDPHSqJ7xEJC72dbXQEAqfyK3P6TRDTQuDnr33GVzeW//Mcfb+JyJ87vz54nzws=
=rL9K
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 27 Mar 2022 17:44
(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
c749c0b168bdcffd94d81331d1fb374378e9aaa3.camel@telenet.be
Pierre Langlois schreef op zo 27-03-2022 om 15:04 [+0100]:
Toggle quote (4 lines)
>        #~(modify-phases %standard-phases
>            ;; regress tests enabled only for debug builds
>            (delete 'check))))

FWIW, given that this is old code, '#:tests #false' + comment would
suffice here and is a bit simpler.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkCGWxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7oUhAP49+aaugdJ5tQkeOU8JHtGHsIwI
jX1O+ks2Pvk2z3wBQwD9F5nlH8Z+kqfoNCk+PnTl7sUZPwvXFleO8jo3m/v8NwM=
=egQV
-----END PGP SIGNATURE-----


P
P
Pierre Langlois wrote on 27 Mar 2022 19:27
(name . Maxime Devos)(address . maximedevos@telenet.be)
87y20v47of.fsf@gmx.com
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (12 lines)
> [[PGP Signed Part:Undecided]]
> Pierre Langlois schreef op zo 27-03-2022 om 15:04 [+0100]:
>> I'm also not entirely sure if it's
>> #+pkg-config or #$pkg-config, both seem to work
>
> #+pkg-config, given that it is a thing that needs to be run during
> compilation. I'm wondering, do you have transparant QEMU emulation
> enabled? If so, both seeming to work is expected since QEMU will
> emulate the cross-compiled cross-compiling (IIUC a canadian cross, in
> GCC terminology) pkg-config. If not, I would expect some kind of error
> ...

Ooooh I do have qemu emulation enabled, that must be it, thanks! I'll
need to be careful about that, seems too easy to make a mistake.

Toggle quote (11 lines)
>
> Or, to allow for package transformations:
>
> #+(file-append (this-package-native-input (pkg-config-for-target))
> "/bin/" (pkg-config-for-target))
>
> though maybe package transformations should just transform the G-exp as
> well, dunno. ('file-append' is not strictly required here.) Maybe we can
> have a macro (pkg-config-binary) that expands to that thing, and
> use it in other packages?

Yeah, if we have this pattern often it sounds like a good idea.
However, better yet maybe could be to make the cmake build-system handle
it automagically. I see `PKG_CONFIG_EXECUTABLE' is part of cmake itself
so that might be OK?


Toggle quote (7 lines)
>
> Possibly interesting or irrelevant: the following will produce an
> x86_64-linux-gnu-pkg-config that can be run on a aarch64-linux-gnu
> computer to find libraries for x86_64-linux-gnu.
>
> $ guix build -e '(parameterize (((@ (guix utils) %current-target-system) "x86_64-linux-gnu")) (@ (gnu packages pkg-config) pkg-config))' --target=aarch64-linux-gnu

Ha! That's pretty cool :-).

Thanks,
Pierre
-----BEGIN PGP SIGNATURE-----

iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmJAoSAYHHBpZXJyZS5s
YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UFssIAKK6UVS3ChzllfugTqSy3G4Q
Gfi7BFHnsD6YXNVBLTap51lYrisQHKGE7ROIhf7fUDga3wavvkXmGuP8nYW2Y6Hl
skdY9GeYbpPnWRuag2XyzWG4K5MyKgYpDCTZi0D73ryCiVnd/Q1nwuFVdD8nV12a
dQiDLDo6YGJENQPl7bxSOD3/cyP6XHycMa3YnNTSy6e0Gj8mm4cbvv04iz1MMyAl
iY0PULiosDq6mbQBjMPJ0Y2qYJHJMV6WPXbMCPYVHWYjBVN/q8oBGZpLV/zYpoBt
2i6RAmhUCEDbvq5pZGHD3O1VmXj5SZ3GFQet3nBJ9NzyCGwKGTEnRdEQ8Y/jjzs=
=QbDb
-----END PGP SIGNATURE-----

M
M
Maxime Devos wrote on 27 Mar 2022 20:00
(name . Pierre Langlois)(address . pierre.langlois@gmx.com)
1d2b3dc1ff2195c9e9df86f0943cdaf024cb0234.camel@telenet.be
Pierre Langlois schreef op zo 27-03-2022 om 18:27 [+0100]:
Toggle quote (9 lines)
> Yeah, if we have this pattern often it sounds like a good idea.
> However, better yet maybe could be to make the cmake build-system
> handle
> it automagically.  I see `PKG_CONFIG_EXECUTABLE' is part of cmake
> itself
> so that might be OK?
>
> https://cmake.org/cmake/help/latest/module/FindPkgConfig.html

Seems reasonable to me, though it that probably needs to be on core-
updates due to many impacted packages, so that's more of a long-term
thing.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYkCmVxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7oatAQDzB+0Ql4dG9UlGkDHcyM+xCs3J
vXAJcyweI6z5D7HfTQEAtSJcbULaV5nWoaO6X7culHrlNZDUVZRh+h6vNG74bgg=
=a8g9
-----END PGP SIGNATURE-----


T
T
Thiago Jung Bauermann wrote on 28 Mar 2022 00:12
(name . Maxime Devos)(address . maximedevos@telenet.be)
87o81r2g05.fsf@kolabnow.com
Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (15 lines)
> [[PGP Signed Part:Undecided]]
> Pierre Langlois schreef op zo 27-03-2022 om 18:27 [+0100]:
>> Yeah, if we have this pattern often it sounds like a good idea.
>> However, better yet maybe could be to make the cmake build-system
>> handle
>> it automagically.  I see `PKG_CONFIG_EXECUTABLE' is part of cmake
>> itself
>> so that might be OK?
>>
>> https://cmake.org/cmake/help/latest/module/FindPkgConfig.html
>
> Seems reasonable to me, though it that probably needs to be on core-
> updates due to many impacted packages, so that's more of a long-term
> thing.

IMHO the most correct way to fix this problem is in CMake itself. If
it's cross-compiling and there's a $TARGET_PREFIX-pkg-config in path,
then it ought to use it automatically.

I'm not volunteering to champion that solution though. :-)

So of course the next best thing is to make Guix's build system do that
for us.

--
Thanks
Thiago
L
L
Ludovic Courtès wrote on 8 Apr 2022 23:46
control message for bug #54595
(address . control@debbugs.gnu.org)
8735in9rk9.fsf@gnu.org
close 54595
quit
?