[PATCH 1/2] gnu: gmp-boot: Fix build on powerpc64le-linux

  • Done
  • quality assurance status badge
Details
2 participants
  • Thiago Jung Bauermann
  • Ludovic Courtès
Owner
unassigned
Submitted by
Thiago Jung Bauermann
Severity
normal
Merged with
T
T
Thiago Jung Bauermann wrote on 4 Aug 2021 20:34
(address . guix-patches@gnu.org)(name . Thiago Jung Bauermann)(address . bauermann@kolabnow.com)
20210804183454.153783-1-bauermann@kolabnow.com
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(-)

Toggle diff (29 lines)
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
T
T
Thiago Jung Bauermann wrote on 4 Aug 2021 20:41
[PATCH 2/2] gnu: gmp-boot: Fix t-scan test crash
(address . 49880@debbugs.gnu.org)(name . Thiago Jung Bauermann)(address . bauermann@kolabnow.com)
20210804184128.153984-1-bauermann@kolabnow.com
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:


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

Toggle diff (45 lines)
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@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)
+
T
T
Thiago Jung Bauermann wrote on 4 Aug 2021 20:51
(address . 49880@debbugs.gnu.org)
1657454.uzBIRb8K2f@popigai
Em quarta-feira, 4 de agosto de 2021, às 15:41:28 -03, Thiago Jung Bauermann escreveu:
Toggle quote (4 lines)
> * 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.

Toggle diff (17 lines)
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
L
L
Ludovic Courtès wrote on 11 Aug 2021 23:29
Re: bug#49880: [PATCH 1/2] gnu: gmp-boot: Fix build on powerpc64le-linux
(name . Thiago Jung Bauermann)(address . bauermann@kolabnow.com)(address . 49880@debbugs.gnu.org)
878s17k6vd.fsf@gnu.org
Hi!

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

Toggle quote (14 lines)
> 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.

[...]

Toggle quote (16 lines)
> + (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’.
L
L
Ludovic Courtès wrote on 11 Aug 2021 23:34
(name . Thiago Jung Bauermann)(address . bauermann@kolabnow.com)(address . 49880@debbugs.gnu.org)
87zgtnis2g.fsf_-_@gnu.org
Thiago Jung Bauermann <bauermann@kolabnow.com> skribis:

Toggle quote (7 lines)
> 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.

Toggle quote (3 lines)
> + (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’.
L
L
Ludovic Courtès wrote on 11 Aug 2021 23:50
control message for bug #49881
(address . control@debbugs.gnu.org)
87r1ezirbg.fsf@gnu.org
merge 49881 49880
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 49880@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 49880
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch