GNU bug report logs - #71174
libb2 fails to build during cross-compilation

Previous Next

Package: guix;

Reported by: Christoph Buck <dev <at> icepic.de>

Date: Fri, 24 May 2024 16:05:02 UTC

Severity: normal

To reply to this bug, email your comments to 71174 AT debbugs.gnu.org.

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

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


Report forwarded to bug-guix <at> gnu.org:
bug#71174; Package guix. (Fri, 24 May 2024 16:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christoph Buck <dev <at> icepic.de>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Fri, 24 May 2024 16:05:02 GMT) Full text and rfc822 format available.

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

From: Christoph Buck <dev <at> icepic.de>
To: bug-guix <at> gnu.org
Subject: libb2 fails to build during cross-compilation
Date: Fri, 24 May 2024 17:24:50 +0200
Hi!

The package libb2 in `(gnu packages crypto)` fails during
cross-compilation from `x86_64-linux-gn` to `aarch64-linux-gnu`, but
possible more combinations are broken.

Steps to reproduce:

> git log --oneline HEAD^..HEAD

> 9901416233 (origin/master, origin/HEAD) gnu: ctl: Update to 1.5.3.

> ./pre-inst-env guix build libb2 --system=x86_64-linux > --target=aarch64-linux-gnu --no-substitutes --no-grafts

> [...]
> checking for objdir... .libs
> checking if aarch64-linux-gnu-gcc supports -fno-rtti -fno-exceptions... no
> checking for aarch64-linux-gnu-gcc option to produce PIC... -fPIC -DPIC
> checking if aarch64-linux-gnu-gcc PIC flag -fPIC -DPIC works... yes
> checking if aarch64-linux-gnu-gcc static flag -static works... yes
> checking if aarch64-linux-gnu-gcc supports -c -o file.o... yes
> checking if aarch64-linux-gnu-gcc supports -c -o file.o... (cached) yes
> checking whether the aarch64-linux-gnu-gcc linker (/gnu/store/kh7kl57h5i3vzx9hbbairnkkgnx7kf61-gcc-cross-aarch64-linux-gnu-11.3.0/libexec/gcc/aarch64-linux-gnu/ld) supports shared libraries... yes
> checking whether -lc should be explicitly linked in... no
> checking dynamic linker characteristics... GNU/Linux ld.so
> checking how to hardcode library paths into programs... immediate
> checking whether stripping libraries is possible... yes
> checking if libtool supports shared libraries... yes
> checking whether to build shared libraries... yes
> checking whether to build static libraries... yes
> checking whether C compiler accepts -O3... yes
> checking whether C compiler accepts -msse2... no
> configure: error: Compiler does not know -msse2.
> error: in phase 'configure': uncaught exception:
> %exception #<&invoke-error program: "/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/bash" arguments: ("./configure" "CC_FOR_BUILD=gcc" "CONFIG_SHELL=/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/bash" "SHELL=/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/bash" "--prefix=/gnu/store/5cy4lw70ilgwbrmav12xli0lyqzwvmk5-libb2-0.98.1" "--enable-fast-install" "--build=x86_64-unknown-linux-gnu" "--host=aarch64-linux-gnu" "--enable-fat" "--disable-native") exit-status: 1 term-signal: #f stop-signal: #f>
> phase `configure' failed after 1.2 seconds
> command "/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/bash" "./configure" "CC_FOR_BUILD=gcc" "CONFIG_SHELL=/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/bash" "SHELL=/gnu/store/rib9g2ig1xf3kclyl076w28parmncg4k-bash-minimal-5.1.16/bin/bash" "--prefix=/gnu/store/5cy4lw70ilgwbrmav12xli0lyqzwvmk5-libb2-0.98.1" "--enable-fast-install" "--build=x86_64-unknown-linux-gnu" "--host=aarch64-linux-gnu" "--enable-fat" "--disable-native" failed with status 1
> builder for `/gnu/store/rlhm80fld1h2xszn3yh7x5fvr295x6qh-libb2-0.98.1.drv' failed with exit code 1
> build of /gnu/store/rlhm80fld1h2xszn3yh7x5fvr295x6qh-libb2-0.98.1.drv failed
> Could not find build log for '/gnu/store/rlhm80fld1h2xszn3yh7x5fvr295x6qh-libb2-0.98.1.drv'.
> guix build: error: build of > `/gnu/store/rlhm80fld1h2xszn3yh7x5fvr295x6qh-libb2-0.98.1.drv' failed


Root-cause:

The `configure-flags` in the package definition of libb2 are broken for
cross-compilation.

> `(#:configure-flags
>        (list
>         ,@(if (any (cute string-prefix? <> (or (%current-system)
>                                                (%current-target-system)))
>                    '("x86_64" "i686"))
>               ;; fat only checks for Intel optimisations
>               '("--enable-fat")
>               '())
>         "--disable-native"))

Shot-circuit evaluation of the `or` operator leads to enabling of `fat`
as long as `%current-system` is set to `x86_64/i686` regardless of the
value of `%current-target-system`. If `%current-target-system` is set
for example to the `aarch64-linux-gnu` triplet, `--enable-fat` is added
to the configure flags which in turn will break compilation. I am not
entirley sure, what `enable-fat` does. From my understanding this flag
enables fat binaries (or multiarchitecture binaries), which seems to
require the `sse2` instruction set. The cross compile toolchain for
aarch64-linux-gnu (and mostlikey other toolchains as well) does not
support this instruction set.

As a quick workaround, i came up with the following patch:

> `(#:configure-flags
>        (list
>         ,@(let ((check-x86 (lambda (triplet) (any (cute string-prefix? <> triplet) '("x86_64" "i868")))))
>             (if (%current-target-system)
>                 (if (check-x86 (%current-target-system))
>                     '("--enable-fat")
>                     '())
>                 (if (check-x86 (%current-system))
>                     '("--enable-fat")
>                     '())))
>         "--disable-native"))

This enables fat binaries if the target system is set to `x86_64/i868`
regardless of the value of `%current-system`. If the target system is
not set, fat binaries are only enabled if the `%current-system` is set
to `x86_64/i868`. Most likely there is a cleaner way to write this, but
i am a total scheme newbee. If required, i can submit a real patch.

Best regards

Christoph





Information forwarded to bug-guix <at> gnu.org:
bug#71174; Package guix. (Fri, 28 Jun 2024 14:16:02 GMT) Full text and rfc822 format available.

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

From: Christoph Buck <dev <at> icepic.org>
To: 71174 <at> debbugs.gnu.org
Cc: Christoph Buck <dev <at> icepic.org>
Subject: [PATCH] gnu: libb2: Fix cross-compilation for non x86_64 systems
Date: Fri, 28 Jun 2024 14:33:11 +0200
* gnu/packages/crypto.scm (libb2): Disable fat-binary compile time option for
non x86_64 target systems.

Change-Id: Ibdf009960fecae4ffc033a36b3abf28c2f8935aa
---
 gnu/packages/crypto.scm | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm
index 9c62689d18..1d376fb43c 100644
--- a/gnu/packages/crypto.scm
+++ b/gnu/packages/crypto.scm
@@ -809,12 +809,14 @@ (define-public libb2
     (arguments
      `(#:configure-flags
        (list
-        ,@(if (any (cute string-prefix? <> (or (%current-system)
-                                               (%current-target-system)))
-                   '("x86_64" "i686"))
-              ;; fat only checks for Intel optimisations
-              '("--enable-fat")
-              '())
+        ,@(let ((check-x86 (lambda (triplet) (any (cute string-prefix? <> triplet) '("x86_64" "i868")))))
+            (if (%current-target-system)
+                (if (check-x86 (%current-target-system))
+                    '("--enable-fat")
+                    '())
+                (if (check-x86 (%current-system))
+                    '("--enable-fat")
+                    '())))
         "--disable-native")))           ;don't optimise at build time
     (home-page "https://blake2.net/")
     (synopsis "Library implementing the BLAKE2 family of hash functions")

base-commit: 6a7d5cda17fd9d4bd99c58f7a5dbdd2d021354f9
-- 
2.45.1





Information forwarded to bug-guix <at> gnu.org:
bug#71174; Package guix. (Fri, 28 Jun 2024 14:16:02 GMT) Full text and rfc822 format available.

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

From: Christoph Buck <dev <at> icepic.de>
To: 71174 <at> debbugs.gnu.org
Cc: Christoph Buck <dev <at> icepic.de>
Subject: [PATCH] gnu: libb2: Fix cross-compilation for non x86_64 systems
Date: Fri, 28 Jun 2024 14:56:51 +0200
* gnu/packages/crypto.scm (libb2): Disable fat-binary compile time option for
non x86_64 target systems.

Change-Id: Ibdf009960fecae4ffc033a36b3abf28c2f8935aa
---
 gnu/packages/crypto.scm | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm
index 9c62689d18..1d376fb43c 100644
--- a/gnu/packages/crypto.scm
+++ b/gnu/packages/crypto.scm
@@ -809,12 +809,14 @@ (define-public libb2
     (arguments
      `(#:configure-flags
        (list
-        ,@(if (any (cute string-prefix? <> (or (%current-system)
-                                               (%current-target-system)))
-                   '("x86_64" "i686"))
-              ;; fat only checks for Intel optimisations
-              '("--enable-fat")
-              '())
+        ,@(let ((check-x86 (lambda (triplet) (any (cute string-prefix? <> triplet) '("x86_64" "i868")))))
+            (if (%current-target-system)
+                (if (check-x86 (%current-target-system))
+                    '("--enable-fat")
+                    '())
+                (if (check-x86 (%current-system))
+                    '("--enable-fat")
+                    '())))
         "--disable-native")))           ;don't optimise at build time
     (home-page "https://blake2.net/")
     (synopsis "Library implementing the BLAKE2 family of hash functions")

base-commit: 6a7d5cda17fd9d4bd99c58f7a5dbdd2d021354f9
-- 
2.45.1





This bug report was last modified 71 days ago.

Previous Next


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