GNU bug report logs - #49880
[PATCH 1/2] gnu: gmp-boot: Fix build on powerpc64le-linux

Previous Next

Package: guix-patches;

Reported by: Thiago Jung Bauermann <bauermann <at> kolabnow.com>

Date: Wed, 4 Aug 2021 18:36:02 UTC

Severity: normal

Tags: patch

Merged with 49881, 49882

Done: Ludovic Courtès <ludo <at> gnu.org>

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 49880 in the body.
You can then email your comments to 49880 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#49880; Package guix-patches. (Wed, 04 Aug 2021 18:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thiago Jung Bauermann <bauermann <at> kolabnow.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 04 Aug 2021 18:36:02 GMT) Full text and rfc822 format available.

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

From: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
To: guix-patches <at> gnu.org
Cc: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
Subject: [PATCH 1/2] gnu: gmp-boot: Fix build on powerpc64le-linux
Date: Wed,  4 Aug 2021 15:34:54 -0300
Linux on powerpc64 used to run in big-endian mode only.  When support for
little-endian mode was added around 2014, they took the opportunity to
update the ELF ABI.  The new ABI is known as ELF ABI v2, and the old one
retroactively called ELF ABI v1.

GMP 4.3.2 was released in 2010, so its hand-optimized assembly code for
powerpc64 only support ELF ABI v1.  This causes a build failure on
powerpc64le-linux, which can be fixed by passing a host triplet with the
“none” CPU type.  This tells the configure script to use generic C code for
the build.

* gnu/packages/commencement.scm (gmp-boot)[arguments]{#:configure-flags}: Add
“--host=none-unknown-linux-gnu” for powerpc64le targets.
---

Hello,

This patch fixes the following build error on powerpc64le-linux (shown
below for one file, but happens on several):

ld: mpn/.libs/add_n.o: ABI version 1 is not compatible with ABI version 2 output
ld: failed to merge target specific data of file mpn/.libs/add_n.o

I started investigating the problem in core-udpates-frozen but the same
issue happens in master as well so I suggest comitting it there instead.
The patch applies cleanly to both branches.

Thanks,
Thiago

 gnu/packages/commencement.scm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index e7bd6cf002c7..ae3f07bc59ef 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -1840,7 +1840,23 @@ ac_cv_c_float_format='IEEE (little-endian)'
               (uri (string-append "mirror://gnu/gmp/gmp-" version
                                   ".tar.gz"))
               (sha256 (base32
-                       "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))))
+                       "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments gmp)
+       ((#:configure-flags gmp-configure-flags)
+        `(cons* ,@(if (string-prefix? "powerpc64le-" (or (%current-target-system)
+                                                         (%current-system)))
+                      ;; The powerpc64 assembly code in this version of GMP
+                      ;; only supports the ELF ABI v1 but powerpc64le uses ELF
+                      ;; ABI v2, so use the generic C code instead.  This is
+                      ;; done by specifying the CPU type as “none”.
+                      ;;
+                      ;; According to the manual, “this will run quite slowly,
+                      ;; but it should be portable and should at least make it
+                      ;; possible to get something running if all else fails.”
+                      '("--host=none-unknown-linux-gnu")
+                      '())
+                ,gmp-configure-flags))))))
 
 (define mpfr-boot
   (package




Information forwarded to guix-patches <at> gnu.org:
bug#49880; Package guix-patches. (Wed, 04 Aug 2021 18:42:01 GMT) Full text and rfc822 format available.

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

From: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
To: 49880 <at> debbugs.gnu.org
Cc: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
Subject: [PATCH 2/2] gnu: gmp-boot: Fix t-scan test crash
Date: Wed,  4 Aug 2021 15:41:28 -0300
GMP 4.3 was released with a bug in the t-scan test which causes it to crash
with a segmentation fault. Backport fix from upstream.

* gnu/packages/commencement.scm (gmp-boot): Apply
gmp-4.3-fix-t-scan-test.patch.
* gnu/packages/patches/gmp-4.3-fix-t-scan-test.patch: New file.
---

Hello,

With this and the previous patch applied, gmp-boot builds successfully
on powerpc64le-linux both in master and core-updates-frozen.

It should also fix the same problem in i686-linux:

https://ci.guix.gnu.org/build/699347/details

 gnu/packages/commencement.scm                 |  4 +++-
 .../patches/gmp-4.3-fix-t-scan-test.patch     | 24 +++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/gmp-4.3-fix-t-scan-test.patch

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index ae3f07bc59ef..16eb46d44d77 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -1840,7 +1840,9 @@ ac_cv_c_float_format='IEEE (little-endian)'
               (uri (string-append "mirror://gnu/gmp/gmp-" version
                                   ".tar.gz"))
               (sha256 (base32
-                       "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))))
+                       "15rwq54fi3s11izas6g985y9jklm3xprfsmym3v1g6xr84bavqvv"))
+              ;; See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60933#c11
+              (patches (search-patches "gmp-4.3-fix-t-scan-test.patch"))))
     (arguments
      (substitute-keyword-arguments (package-arguments gmp)
        ((#:configure-flags gmp-configure-flags)
diff --git a/gnu/packages/patches/gmp-4.3-fix-t-scan-test.patch b/gnu/packages/patches/gmp-4.3-fix-t-scan-test.patch
new file mode 100644
index 000000000000..85b4b666215a
--- /dev/null
+++ b/gnu/packages/patches/gmp-4.3-fix-t-scan-test.patch
@@ -0,0 +1,24 @@
+Testcase fix obtained from upstream at:
+
+https://gmplib.org/repo/gmp/raw-rev/966737bd91ed
+
+# HG changeset patch
+# User Torbjorn Granlund <tege <at> gmplib.org>
+# Date 1318259187 -7200
+# Node ID 966737bd91ed4cd158ca9730167f70db47442fc1
+# Parent  27913f466a23776215bd9341866e10a50cf61c01
+(check_ref): Fix loop end bound.
+
+diff -r 27913f466a23 -r 966737bd91ed tests/mpz/t-scan.c
+--- a/tests/mpz/t-scan.c	Mon Oct 10 12:06:39 2011 +0200
++++ b/tests/mpz/t-scan.c	Mon Oct 10 17:06:27 2011 +0200
+@@ -79,7 +79,7 @@
+ 
+               for (isize = 0; isize <= size; isize++)
+                 {
+-                  for (oindex = 0; oindex <= numberof (offset); oindex++)
++                  for (oindex = 0; oindex < numberof (offset); oindex++)
+                     {
+                       o = offset[oindex];
+                       if ((int) isize*GMP_NUMB_BITS < -o)
+




Information forwarded to guix-patches <at> gnu.org:
bug#49880; Package guix-patches. (Wed, 04 Aug 2021 18:52:01 GMT) Full text and rfc822 format available.

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

From: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
To: 49880 <at> debbugs.gnu.org
Subject: Re: [PATCH 2/2] gnu: gmp-boot: Fix t-scan test crash
Date: Wed, 04 Aug 2021 15:51:19 -0300
Em quarta-feira, 4 de agosto de 2021, às 15:41:28 -03, Thiago Jung Bauermann escreveu:
> * gnu/packages/commencement.scm (gmp-boot): Apply
> gmp-4.3-fix-t-scan-test.patch.
> * gnu/packages/patches/gmp-4.3-fix-t-scan-test.patch: New file.

Sorry, I just noticed that I forgot to add the new file to local.mk.
Could you please squash this change when applying the patch?

Alternatively, I can send a v2. Whichever you prefer.

* gnu/local.mk (dist_patch_DATA): Add new patch.

diff --git a/gnu/local.mk b/gnu/local.mk
index e8494806fda5..ca8254c22320 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1163,6 +1163,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/glibc-2.28-supported-locales.patch     	\
   %D%/packages/patches/glibc-2.29-supported-locales.patch     	\
   %D%/packages/patches/glibc-supported-locales.patch     	\
+  %D%/packages/patches/gmp-4.3-fix-t-scan-test.patch		\
   %D%/packages/patches/gmp-arm-asm-nothumb.patch		\
   %D%/packages/patches/gmp-faulty-test.patch			\
   %D%/packages/patches/gnash-fix-giflib-version.patch	        \


-- 
Thanks,
Thiago






Information forwarded to guix-patches <at> gnu.org:
bug#49880; Package guix-patches. (Wed, 11 Aug 2021 21:30:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
Cc: 49880 <at> debbugs.gnu.org
Subject: Re: bug#49880: [PATCH 1/2] gnu: gmp-boot: Fix build on
 powerpc64le-linux
Date: Wed, 11 Aug 2021 23:29:26 +0200
Hi!

Thiago Jung Bauermann <bauermann <at> kolabnow.com> skribis:

> Linux on powerpc64 used to run in big-endian mode only.  When support for
> little-endian mode was added around 2014, they took the opportunity to
> update the ELF ABI.  The new ABI is known as ELF ABI v2, and the old one
> retroactively called ELF ABI v1.
>
> GMP 4.3.2 was released in 2010, so its hand-optimized assembly code for
> powerpc64 only support ELF ABI v1.  This causes a build failure on
> powerpc64le-linux, which can be fixed by passing a host triplet with the
> “none” CPU type.  This tells the configure script to use generic C code for
> the build.
>
> * gnu/packages/commencement.scm (gmp-boot)[arguments]{#:configure-flags}: Add
> “--host=none-unknown-linux-gnu” for powerpc64le targets.

[...]

> +     (substitute-keyword-arguments (package-arguments gmp)
> +       ((#:configure-flags gmp-configure-flags)
> +        `(cons* ,@(if (string-prefix? "powerpc64le-" (or (%current-target-system)
> +                                                         (%current-system)))
> +                      ;; The powerpc64 assembly code in this version of GMP
> +                      ;; only supports the ELF ABI v1 but powerpc64le uses ELF
> +                      ;; ABI v2, so use the generic C code instead.  This is
> +                      ;; done by specifying the CPU type as “none”.
> +                      ;;
> +                      ;; According to the manual, “this will run quite slowly,
> +                      ;; but it should be portable and should at least make it
> +                      ;; possible to get something running if all else fails.”
> +                      '("--host=none-unknown-linux-gnu")
> +                      '())
> +                ,gmp-configure-flags))))))

The patch LGTM.  However, could you tweak it so we can apply it on
‘core-updates-frozen’ while not triggering a rebuild on other arches?
Something like:

  (if (string-prefix? …)
      `(cons … ,gmp-configure-flags)
      gmp-configure-flags)

TIA!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49880; Package guix-patches. (Wed, 11 Aug 2021 21:35:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Thiago Jung Bauermann <bauermann <at> kolabnow.com>
Cc: 49880 <at> debbugs.gnu.org
Subject: Re: bug#49880: [PATCH 1/2] gnu: gmp-boot: Fix build on
 powerpc64le-linux
Date: Wed, 11 Aug 2021 23:34:31 +0200
Thiago Jung Bauermann <bauermann <at> kolabnow.com> skribis:

> GMP 4.3 was released with a bug in the t-scan test which causes it to crash
> with a segmentation fault. Backport fix from upstream.
>
> * gnu/packages/commencement.scm (gmp-boot): Apply
> gmp-4.3-fix-t-scan-test.patch.
> * gnu/packages/patches/gmp-4.3-fix-t-scan-test.patch: New file.

Please add the file to gnu/local.mk as well.

> +              ;; See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60933#c11
> +              (patches (search-patches "gmp-4.3-fix-t-scan-test.patch"))))

Comments about the patch should go at the top of the patch, preferably.

So, we could avoid a world rebuild by applying the patch in a
powerpc64le-specific build phase instead of adding it to ‘patches’.

Now, I suppose we’re just lucky that this test hasn’t crashed on other
platforms, aren’t we?  In that case, that would call for applying the
patch (or skipping tests, even) unconditionally, thus triggering a world
rebuild on all arches.

Thoughts?

Ludo’.




Merged 49880 49881 49882. Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 11 Aug 2021 21:51:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 12 Sep 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 344 days ago.

Previous Next


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