all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Cross-compiling libfido2
@ 2022-03-26 13:51 Sébastien Lerique
  2022-03-26 14:38 ` Pierre Langlois
  0 siblings, 1 reply; 3+ messages in thread
From: Sébastien Lerique @ 2022-03-26 13:51 UTC (permalink / raw)
  To: help-guix

Hello Guix!

I'm trying to build a raw image for a rock64 board, from my x86_64
laptop (using Guix on PopOS), and bumping into some
packages seemingly not ready for cross-compilation.

I am adding `(service openssh-service-type ...)` to the base
gnu/system/images/rock64.scm (building the original rock64.scm config
works fine), and my build fails at libfido2.

My config is
https://gitlab.com/wehlutyk/matrixbox/-/blob/eacc326b8a7d41f3113e3768302c59687402a536/config.scm
and building libfido2 fails at the configure phase with

```
(...)

-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Checking for one of the modules 'libcbor'
-- Checking for one of the modules 'libcrypto'
-- Checking for one of the modules 'zlib'
CMake Error at CMakeLists.txt:206 (message):
  could not find zlib

(...)
```

but no amount of moving pkg-config or zlib across inputs and
native-inputs changes anything.

In /tmp/guix-build-libfido2-1.9.0.drv-0/environment-variables, the only
pkg-config included in PATH is
pkg-config-aarch64-linux-gnu-0.29.2/bin/pkg-config, which makes me
suspect that the host pkg-config is needed in this case, and not found.

(Indeed, building manually from the left-over /tmp folder, using my normal
environment, and sourcing environment-variables, finds
/usr/bin/pkg-config, and cmake successfully configures the build; why do
report this and not a manual attempt on a clean environment? I couldn't
manage to ``guix shell`` into a container with cmake-minimal-cross as
cmake.)

Just in case, I played around with pkg-config-for-build which also
doesn't seem to be the solution.

Other packages relying on cmake and pkg-config, and prepared for
cross-compilation, don't seem to do anything different than libfido2
(e.g. cppzmq), so I'm out of things to try :)

Does anybody have an idea of what's going on? I could try to build
libfido2 without pkg-config, but maybe there is something simpler to try
out?

Thank you and happy hacking!
Sébastien


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Cross-compiling libfido2
  2022-03-26 13:51 Cross-compiling libfido2 Sébastien Lerique
@ 2022-03-26 14:38 ` Pierre Langlois
  2022-03-27 12:31   ` Sébastien Lerique
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Langlois @ 2022-03-26 14:38 UTC (permalink / raw)
  To: Sébastien Lerique; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 3038 bytes --]

Hi!

Sébastien Lerique <sl@eauchat.org> writes:

> Hello Guix!
>
> I'm trying to build a raw image for a rock64 board, from my x86_64
> laptop (using Guix on PopOS), and bumping into some
> packages seemingly not ready for cross-compilation.
>
> I am adding `(service openssh-service-type ...)` to the base
> gnu/system/images/rock64.scm (building the original rock64.scm config
> works fine), and my build fails at libfido2.
>
> My config is
> https://gitlab.com/wehlutyk/matrixbox/-/blob/eacc326b8a7d41f3113e3768302c59687402a536/config.scm
> and building libfido2 fails at the configure phase with
>
> ```
> (...)
>
> -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
> -- Checking for one of the modules 'libcbor'
> -- Checking for one of the modules 'libcrypto'
> -- Checking for one of the modules 'zlib'
> CMake Error at CMakeLists.txt:206 (message):
>   could not find zlib
>
> (...)
> ```

Doing some grepping in Guix and a quick test, I think what you need to
do is set PKG_CONFIG_EXECUTABLE to (pkg-config-for-target) when
cross-compiling.  I can see that the libgit2 package does this for example


--8<---------------cut here---------------start------------->8---
     `(#:configure-flags
       (list "-DUSE_NTLMCLIENT=OFF" ;TODO: package this
             "-DREGEX_BACKEND=pcre2"
             "-DUSE_HTTP_PARSER=system"
             ,@(if (%current-target-system)
                   `((string-append
                      "-DPKG_CONFIG_EXECUTABLE="
                      (search-input-file
                       %build-inputs
                       (string-append "/bin/" ,(%current-target-system)
                                      "-pkg-config"))))
                   '()))
       #:phases
--8<---------------cut here---------------end--------------->8---

Doing the same thing for libfido2 seems to fix it for me!

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index 129b8f6122..092fe13f58 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -910,7 +910,16 @@ (define-public libfido2
        ("openssl" ,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))))
--8<---------------cut here---------------end--------------->8---

Does this work for you as well?  Let us know if you want to prepare a
patch :-).

Thanks,
Pierre

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 519 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Cross-compiling libfido2
  2022-03-26 14:38 ` Pierre Langlois
@ 2022-03-27 12:31   ` Sébastien Lerique
  0 siblings, 0 replies; 3+ messages in thread
From: Sébastien Lerique @ 2022-03-27 12:31 UTC (permalink / raw)
  To: Pierre Langlois; +Cc: help-guix


On 26 Mar 2022 at 14:38, Pierre Langlois <pierre.langlois@gmx.com> wrote:

> Doing some grepping in Guix and a quick test, I think what you need to
> do is set PKG_CONFIG_EXECUTABLE to (pkg-config-for-target) when
> cross-compiling.  I can see that the libgit2 package does this for example

[...]

> Doing the same thing for libfido2 seems to fix it for me!
>

Thanks! That indeed works :). I just submitted a patch following this:
https://issues.guix.gnu.org/54595.

Thank again for the help, and happy hacking!
Sébastien


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-27 12:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-26 13:51 Cross-compiling libfido2 Sébastien Lerique
2022-03-26 14:38 ` Pierre Langlois
2022-03-27 12:31   ` Sébastien Lerique

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.