all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#45252] [PATCH] gnu: libffi: Add unreleased patch to fix float128 on powerpc64le.
@ 2020-12-15  9:32 dftxbs3e
  2020-12-20 20:32 ` Chris Marusich
  0 siblings, 1 reply; 5+ messages in thread
From: dftxbs3e @ 2020-12-15  9:32 UTC (permalink / raw)
  To: 45252

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

Hello!

Based on previous discussions to apply <
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44778> on the master
branch instead I submit this new patch (attached) so that it does not
cause a world rebuild by not altering the package definition hash on
other platforms.

Thank you!

[-- Attachment #2: 0001-gnu-libffi-Add-unreleased-patch-to-fix-float128-on-p.patch --]
[-- Type: text/x-patch, Size: 6389 bytes --]

From 05c3dc588745240fb790f9a39111be70c153d70c Mon Sep 17 00:00:00 2001
From: John Doe <dftxbs3e@free.fr>
Date: Tue, 15 Dec 2020 10:24:11 +0100
Subject: [PATCH] gnu: libffi: Add unreleased patch to fix float128 on
 powerpc64le.

* gnu/packages/patches/libffi-float128-powerpc64le.patch: Import patch
  file from <https://github.com/libffi/libffi/pull/561.patch>.
* gnu/packages/libffi.scm (libffi):
  [arguments]: Apply patch conditionally for powerpc64le-* systems in a phase.
  [inputs]: Add patch as input conditionally for powerpc64le-* systems.
* gnu/local.mk (dist_patch_DATA): Add patch file to build system.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/libffi.scm                       | 25 ++++++--
 .../patches/libffi-float128-powerpc64le.patch | 58 +++++++++++++++++++
 3 files changed, 79 insertions(+), 5 deletions(-)
 create mode 100644 gnu/packages/patches/libffi-float128-powerpc64le.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 0b4cf23838..e190df0667 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1208,6 +1208,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/julia-SOURCE_DATE_EPOCH-mtime.patch	\
   %D%/packages/patches/kdbusaddons-kinit-file-name.patch	\
   %D%/packages/patches/libffi-3.3-powerpc-fixes.patch		\
+  %D%/packages/patches/libffi-float128-powerpc64le.patch	\
   %D%/packages/patches/libvirt-create-machine-cgroup.patch	\
   %D%/packages/patches/libziparchive-add-includes.patch		\
   %D%/packages/patches/localed-xorg-keyboard.patch		\
diff --git a/gnu/packages/libffi.scm b/gnu/packages/libffi.scm
index d324892330..e4bfe6731b 100644
--- a/gnu/packages/libffi.scm
+++ b/gnu/packages/libffi.scm
@@ -57,7 +57,7 @@
        ;; compiler.  See "ax_cc_maxopt.m4" and "ax_gcc_archflag.m4".
        #:configure-flags '("--enable-portable-binary" "--without-gcc-arch")
 
-       ;; TODO: Inline patch on next rebuild cycle.
+       ;; TODO: Inline patches on next rebuild cycle.
        ,@(if (string-prefix? "powerpc-" (or (%current-target-system)
                                             (%current-system)))
              '(#:phases (modify-phases %standard-phases
@@ -67,13 +67,28 @@
                                                       "powerpc-patch")))
                                 (invoke "patch" "--batch" "-p1"
                                         "-i" patch))))))
+             '())
+       ,@(if (string-prefix? "powerpc64le-" (or (%current-target-system)
+                                                (%current-system)))
+             '(#:phases (modify-phases %standard-phases
+                          (add-after 'unpack 'apply-patch2
+                            (lambda* (#:key inputs #:allow-other-keys)
+                              (let ((patch (assoc-ref inputs
+                                                      "powerpc64le-patch")))
+                                (invoke "patch" "--batch" "-p1"
+                                        "-i" patch))))))
              '())))
     (inputs
-     (if (string-prefix? "powerpc-" (or (%current-target-system)
+     (cond
+      ((string-prefix? "powerpc-" (or (%current-target-system)
                                         (%current-system)))
-         `(("powerpc-patch" ,@(search-patches
-                               "libffi-3.3-powerpc-fixes.patch")))
-         '()))
+       `(("powerpc-patch" ,@(search-patches
+                             "libffi-3.3-powerpc-fixes.patch"))))
+      ((string-prefix? "powerpc64le-" (or (%current-target-system)
+                                          (%current-system)))
+       `(("powerpc64le-patch" ,@(search-patches
+                                 "libffi-float128-powerpc64le.patch"))))
+      (else '())))
     (outputs '("out" "debug"))
     (synopsis "Foreign function call interface library")
     (description
diff --git a/gnu/packages/patches/libffi-float128-powerpc64le.patch b/gnu/packages/patches/libffi-float128-powerpc64le.patch
new file mode 100644
index 0000000000..4fd32b0102
--- /dev/null
+++ b/gnu/packages/patches/libffi-float128-powerpc64le.patch
@@ -0,0 +1,58 @@
+From de93adfb6f48100946bba2c3abad2a77a0cfde0b Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Sun, 24 Nov 2019 09:52:01 +0100
+Subject: [PATCH] ffi_powerpc.h: fix build failure with powerpc7
+
+This is a patch pulled down from the following:
+https://github.com/buildroot/buildroot/blob/78926f610b1411b03464152472fd430012deb9ac/package/libffi/0004-ffi_powerpc.h-fix-build-failure-with-powerpc7.patch
+
+This issue is being hit on OpenBMC code when pulling the latest
+libffi tag and building on a P8 ppc64le machine. I verified this
+patch fixes the issue we are seeing.
+
+Below is the original commit message:
+
+Sicne commit 73dd43afc8a447ba98ea02e9aad4c6898dc77fb0, build on powerpc7
+fails on:
+
+In file included from ../src/powerpc/ffi.c:33:0:
+../src/powerpc/ffi_powerpc.h:61:9: error: '_Float128' is not supported on this target
+ typedef _Float128 float128;
+         ^~~~~~~~~
+
+Fix this build failure by checking for __HAVE_FLOAT128 before using
+_Float128, as _Float128 is enabled only on specific conditions, see
+output/host/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/floatn.h:
+
+ /* Defined to 1 if the current compiler invocation provides a
+    floating-point type with the IEEE 754 binary128 format, and this glibc
+    includes corresponding *f128 interfaces for it.  */
+ #if defined _ARCH_PWR8 && defined __LITTLE_ENDIAN__ && (_CALL_ELF == 2) \
+     && defined __FLOAT128__ && !defined __NO_LONG_DOUBLE_MATH
+ # define __HAVE_FLOAT128 1
+ #else
+ # define __HAVE_FLOAT128 0
+ #endif
+
+Fixes:
+ - http://autobuild.buildroot.org/results/5c9dd8fb3b6a128882b6250f197c80232d8a3b53
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
+---
+ src/powerpc/ffi_powerpc.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/powerpc/ffi_powerpc.h b/src/powerpc/ffi_powerpc.h
+index 8e2f2f0e..960a5c42 100644
+--- a/src/powerpc/ffi_powerpc.h
++++ b/src/powerpc/ffi_powerpc.h
+@@ -57,7 +57,7 @@ typedef union
+   double d;
+ } ffi_dblfl;
+ 
+-#if defined(__FLOAT128_TYPE__)
++#if defined(__FLOAT128_TYPE__) && defined(__HAVE_FLOAT128)
+ typedef _Float128 float128;
+ #elif defined(__FLOAT128__)
+ typedef __float128 float128;
-- 
2.29.2


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

* [bug#45252] [PATCH] gnu: libffi: Add unreleased patch to fix float128 on powerpc64le.
  2020-12-15  9:32 [bug#45252] [PATCH] gnu: libffi: Add unreleased patch to fix float128 on powerpc64le dftxbs3e
@ 2020-12-20 20:32 ` Chris Marusich
  2020-12-20 20:36   ` dftxbs3e
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Marusich @ 2020-12-20 20:32 UTC (permalink / raw)
  To: dftxbs3e; +Cc: 45252

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

Hi,

dftxbs3e <dftxbs3e@free.fr> writes:

> Based on previous discussions to apply <
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44778> on the master
> branch instead I submit this new patch (attached) so that it does not
> cause a world rebuild by not altering the package definition hash on
> other platforms.

My understanding is as follows:

- Patch 44778, linked above, was committed on core-updates branch in
  4fff5ab24126a152b50c036b9bf8dc6f2740f094.
- The libffi patch in this patch (45252) is the same as it was in 44778,
  but the scheme code has been changed so that we can apply this patch
  to the master branch without causing a rebuild of many packages.

Is that right?

> +             '())
> +       ,@(if (string-prefix? "powerpc64le-" (or (%current-target-system)
> +                                                (%current-system)))
> +             '(#:phases (modify-phases %standard-phases
> +                          (add-after 'unpack 'apply-patch2
> +                            (lambda* (#:key inputs #:allow-other-keys)
> +                              (let ((patch (assoc-ref inputs
> +                                                      "powerpc64le-patch")))
> +                                (invoke "patch" "--batch" "-p1"
> +                                        "-i" patch))))))
>               '())))
>      (inputs
> -     (if (string-prefix? "powerpc-" (or (%current-target-system)
> +     (cond
> +      ((string-prefix? "powerpc-" (or (%current-target-system)
>                                          (%current-system)))
> -         `(("powerpc-patch" ,@(search-patches
> -                               "libffi-3.3-powerpc-fixes.patch")))
> -         '()))
> +       `(("powerpc-patch" ,@(search-patches
> +                             "libffi-3.3-powerpc-fixes.patch"))))
> +      ((string-prefix? "powerpc64le-" (or (%current-target-system)
> +                                          (%current-system)))
> +       `(("powerpc64le-patch" ,@(search-patches
> +                                 "libffi-float128-powerpc64le.patch"))))
> +      (else '())))

Looks good to me.  I'll test it locally and update here once I've
confirmed that it doesn't cause a full rebuild when applied to master.
Assuming all goes well, I intend to revert
4fff5ab24126a152b50c036b9bf8dc6f2740f094 on core-updates and apply this
patch to master.

> +++ b/gnu/packages/patches/libffi-float128-powerpc64le.patch

Based on...

https://patchwork.ozlabs.org/project/buildroot/patch/20191124090305.1015485-1-fontaine.fabrice@gmail.com/

...it sounds like upstream libffi maintainers may not have merged this
patch yet.  We should probably check with them to see when they plan to
merge it into upstream, but in the meantime there's no reason not to use
the patch if it works.  Based on what Fabrice said in that thread, it
sounds like the libffi maintainers may be a bit slow in responding to
power-related bugs.

-- 
Chris

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

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

* [bug#45252] [PATCH] gnu: libffi: Add unreleased patch to fix float128 on powerpc64le.
  2020-12-20 20:32 ` Chris Marusich
@ 2020-12-20 20:36   ` dftxbs3e
  2020-12-21  1:30     ` bug#45252: " Chris Marusich
  0 siblings, 1 reply; 5+ messages in thread
From: dftxbs3e @ 2020-12-20 20:36 UTC (permalink / raw)
  To: Chris Marusich; +Cc: 45252

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

On Sun, 2020-12-20 at 12:32 -0800, Chris Marusich wrote:
> Hi,
Hello!

> My understanding is as follows:
> 
> - Patch 44778, linked above, was committed on core-updates branch in
>   4fff5ab24126a152b50c036b9bf8dc6f2740f094.
> - The libffi patch in this patch (45252) is the same as it was in
> 44778,
>   but the scheme code has been changed so that we can apply this
> patch
>   to the master branch without causing a rebuild of many packages.
> 
> Is that right?

Exactly!

> Based on...
> 
> https://patchwork.ozlabs.org/project/buildroot/patch/20191124090305.1015485-1-fontaine.fabrice@gmail.com/
> 
> ...it sounds like upstream libffi maintainers may not have merged
> this
> patch yet.  We should probably check with them to see when they plan
> to
> merge it into upstream, but in the meantime there's no reason not to
> use
> the patch if it works.  Based on what Fabrice said in that thread, it
> sounds like the libffi maintainers may be a bit slow in responding to
> power-related bugs.
> 

That's not true, they've merged the patch: <
https://github.com/libffi/libffi/pull/561> - they just did not make a
release yet.

Leo

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* bug#45252: [PATCH] gnu: libffi: Add unreleased patch to fix float128 on powerpc64le.
  2020-12-20 20:36   ` dftxbs3e
@ 2020-12-21  1:30     ` Chris Marusich
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Marusich @ 2020-12-21  1:30 UTC (permalink / raw)
  To: dftxbs3e; +Cc: 45252-close

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

Hi,

dftxbs3e <dftxbs3e@free.fr> writes:

>> Based on...
>> 
>> https://patchwork.ozlabs.org/project/buildroot/patch/20191124090305.1015485-1-fontaine.fabrice@gmail.com/
>> 
>> ...it sounds like upstream libffi maintainers may not have merged
>> this
>> patch yet.  We should probably check with them to see when they plan
>> to
>> merge it into upstream, but in the meantime there's no reason not to
>> use
>> the patch if it works.  Based on what Fabrice said in that thread, it
>> sounds like the libffi maintainers may be a bit slow in responding to
>> power-related bugs.
>> 
>
> That's not true, they've merged the patch: <
> https://github.com/libffi/libffi/pull/561> - they just did not make a
> release yet.

Ah, OK.  That's good to know!

I've committed this patch in 7eaa2f24ea77cddbb4bbc2d6a6905673a36f8f99 on
master.  I've also reverted 4fff5ab24126a152b50c036b9bf8dc6f2740f094 in
commit b50341dba9811c048bed852c0279b828c7ddba66 on core-updates.  I
think we should be good to go to try building powerpc64-linux-gnu
bootstrap-tarballs now!

I confirmed that this commit on master would not cause dependents of
libffi to be rebuilt by verifying that the derivation for one of its
dependent packages, guile, did not change before/after the change.

-- 
Chris

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

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

* [bug#45252] [PATCH] gnu: libffi: Add unreleased patch to fix float128 on powerpc64le.
  2020-12-22  6:00 ` Mark H Weaver
@ 2020-12-23  6:38   ` Chris Marusich
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Marusich @ 2020-12-23  6:38 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel, John Doe, 45252

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

Hi Mark,

Mark H Weaver <mhw@netris.org> writes:

> Earlier, I wrote:
>> When invoking 'patch' in Guix, you should *always* use "--force" instead
>> of "--batch".
>
> (See <https://bugs.gnu.org/45252#19> for my earlier message).

Thank you for letting me know about this.  I didn't know about the
difference between "--batch" and "--force".  I agree we should use
"--force" instead of "--batch".  How do you recommend that I proceed?

I can definitely make another commit on the master branch to change the
option from "--batch" to "--force".  However, I'm reluctant to change
the option in the existing code on the master branch (introduced in
commit 02f5ee01c96589fc13f1e21b85b0b48100aec4e8), since I'm not sure how
many packages would be rebuilt as a result.  The powerpc64le
architecture is not bootstrapped at all yet, so it's not a problem for
that architecture, but I don't know the status for all the other
architectures beginning with "powerpc".

Before I make a new commit to change the patch option on the master
branch, I'd appreciate your advice on how to proceed.  Do you think it
would be better to make a commit on the master branch to fix just the
option I introduced in commit 7eaa2f24ea77cddbb4bbc2d6a6905673a36f8f99?
Or, do you think it would be better to make a commit on the core-updates
branch to change all the "--batch" options to "--force" options in the
libffi package definition?  If we did it on core-updates, we could just
replace the manual invocation of the "patch" tool with a change that
looks more like 4fff5ab24126a152b50c036b9bf8dc6f2740f094, in particular
this part:

diff --git a/gnu/packages/libffi.scm b/gnu/packages/libffi.scm
index 0e6a31d78c..0db8fa3e82 100644
--- a/gnu/packages/libffi.scm
+++ b/gnu/packages/libffi.scm
@@ -51,7 +51,8 @@
               (sha256
                (base32
                 "0mi0cpf8aa40ljjmzxb7im6dbj45bb0kllcd09xgmp834y9agyvj"))
-              (patches (search-patches "libffi-3.3-powerpc-fixes.patch"))))
+              (patches (search-patches "libffi-3.3-powerpc-fixes.patch"
+                                       "libffi-float128-powerpc64le.patch"))))
     (build-system gnu-build-system)
     (arguments
      `(;; Prevent the build system from passing -march and -mtune to the

I thought we wanted to apply patch 45252 on the master branch.  That's
why I made commit 7eaa2f24ea77cddbb4bbc2d6a6905673a36f8f99.  Afterwords,
I actually reverted commit 4fff5ab24126a152b50c036b9bf8dc6f2740f094 on
the core-updates branch in commit
b50341dba9811c048bed852c0279b828c7ddba66.  I reverted it because I
thought it would be undesirable to solve the same problem in two
different ways on two separate branches, and I thought that reverting it
would reduce the risk of merge conflicts later.

However, now that I think about it, I'm not sure the reversion was
necessary.  I'm actually not sure what the normal procedure is for
merging to/from core-updates and master (I've done many merges in my own
projects, but I've never done a merge in the Guix project), so I'm not
sure how a "TODO" task like the one mentioned in commit
7eaa2f24ea77cddbb4bbc2d6a6905673a36f8f99 ("Inline patches on next
rebuild cycle") would normally be resolved.  I would welcome any advice
you have about that.

By the way, a wip-ppc64le branch also exists, but I don't know what its
status is or whether I'm allowed to touch it.  I just assumed things
would be simpler if we applied patches to master branch when possible.

> Since writing the message above, I've found another problem in the same
> commit (7eaa2f24ea77cddbb4bbc2d6a6905673a36f8f99): it searches for the
> 'patch' program in 'inputs'.  This is a mistake, because when
> cross-compiling, 'inputs' will contain software compiled to run on the
> target system instead of the build system.

Is it searching for the "patch" program, or is it searching for the
patch file?  It looks to me like the code is searching for the patch
file in inputs, not the "patch" program.  The relevant code is here:

       ,@(if (string-prefix? "powerpc64le-" (or (%current-target-system)
                                                (%current-system)))
             '(#:phases (modify-phases %standard-phases
                          (add-after 'unpack 'apply-patch2
                            (lambda* (#:key inputs #:allow-other-keys)
                              (let ((patch (assoc-ref inputs
                                                      "powerpc64le-patch")))
                                (invoke "patch" "--batch" "-p1"
                                        "-i" patch))))))

The code invokes the "patch" program in the usual way.  My understanding
is that whatever version of the "patch" program that Guix has placed in
the PATH environment variable will be used.  Therefore, Guix will use
the correct "patch" program, regardless of whether or not the package is
being cross-compiled.  Am I misunderstanding something?

Again, thank you for taking the time to bring these topics up.  I'm
always trying to make sure I do things the best way I can in Guix, so I
appreciate the feedback.

-- 
Chris

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

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

end of thread, other threads:[~2020-12-23  6:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15  9:32 [bug#45252] [PATCH] gnu: libffi: Add unreleased patch to fix float128 on powerpc64le dftxbs3e
2020-12-20 20:32 ` Chris Marusich
2020-12-20 20:36   ` dftxbs3e
2020-12-21  1:30     ` bug#45252: " Chris Marusich
  -- strict thread matches above, loose matches on Subject: below --
2020-12-22  5:15 Mark H Weaver
2020-12-22  6:00 ` Mark H Weaver
2020-12-23  6:38   ` [bug#45252] " Chris Marusich

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.