unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: Andreas Enge <andreas@enge.fr>
Cc: guix-devel@gnu.org, 61879@debbugs.gnu.org,
	Efraim Flashner <efraim@flashner.co.il>
Subject: Re: bug#61879: Powerpc on core-updates
Date: Thu, 13 Apr 2023 14:46:00 +0100	[thread overview]
Message-ID: <87mt3byjrp.fsf@cbaines.net> (raw)
In-Reply-To: <ZDfMJmRxU+bf9DDa@jurong>


[-- Attachment #1.1: Type: text/plain, Size: 910 bytes --]


Andreas Enge <andreas@enge.fr> writes:

> In the file
>    libstdc++-v3/src/c++17/floating_from_chars.cc
> previous functions have code like this:
> #if _GLIBCXX_USE_CXX11_ABI
>   buffer_resource mr;
>   pmr::string buf(&mr);
> #else
>   string buf;
>   if (!reserve_string(buf))
>     return make_result(first, 0, {}, ec);
> #endif
>
> while here we only have:
>   buffer_resource mr;
>   pmr::string buf(&mr);
>
> So my guess would be that we should simply replace this snippet with the
> one above.
>
> Could someone with access to a powerpc machine try out this change?

Thanks for figuring this out Andreas! I've managed to apply this change
in the relevant place, and it appears to work.

I tried to apply it in a way that only affected powerpc64le-linux, but
I'm not sure I was successful. I've got no idea where it's best to apply
this patch, or how describe it, but at least this is a step forward.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-WIP.patch --]
[-- Type: text/x-patch, Size: 7996 bytes --]

From 382862fc06085ba80380977caf2a1f9c3203a12d Mon Sep 17 00:00:00 2001
From: Christopher Baines <mail@cbaines.net>
Date: Thu, 13 Apr 2023 14:45:14 +0100
Subject: [PATCH] WIP

---
 gnu/packages/gcc.scm           | 108 ++++++++++++++++++---------------
 gnu/packages/patches/foo.patch |  20 ++++++
 2 files changed, 80 insertions(+), 48 deletions(-)
 create mode 100644 gnu/packages/patches/foo.patch

diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index a511cdbc45..6f6f2caa5e 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -853,56 +853,68 @@ (define-public (make-libstdc++ gcc)
     (inherit gcc)
     (name "libstdc++")
     (arguments
-     `(#:out-of-source? #t
-       #:modules ((srfi srfi-1)
+     (list
+      #:out-of-source? #t
+      #:modules `((srfi srfi-1)
                   (srfi srfi-26)
                   ,@%gnu-build-system-modules)
-       #:phases
-       (modify-phases %standard-phases
-         ,@(if (version>=? (package-version gcc) "11")
-               `((add-after 'unpack 'hide-gcc-headers
-                   (lambda* (#:key native-inputs inputs #:allow-other-keys)
-                     (let ((gcc (assoc-ref (or native-inputs inputs)
-                                           ,(if (%current-target-system)
-                                                "cross-gcc"
-                                                "gcc"))))
-                       ;; Fix a regression in GCC 11 where the GCC headers
-                       ;; shadows glibc headers when building libstdc++.  An
-                       ;; upstream fix was added in GCC 11.3.0, but it only
-                       ;; hides system include directories, not those on
-                       ;; CPLUS_INCLUDE_PATH.  See discussion at
-                       ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100017>
-                       ;; and the similar adjustment in GCC-FINAL.
-                       (substitute* "libstdc++-v3/src/c++17/Makefile.in"
-                         (("AM_CXXFLAGS = ")
-                          (string-append ,(if (%current-target-system)
-                                              "CROSS_CPLUS_INCLUDE_PATH = "
-                                              "CPLUS_INCLUDE_PATH = ")
-                                         (string-join
-                                          (remove (cut string-prefix? gcc <>)
-                                                  (string-split
-                                                   (getenv
-                                                    ,(if (%current-target-system)
-                                                         "CROSS_CPLUS_INCLUDE_PATH"
-                                                         "CPLUS_INCLUDE_PATH"))
-                                                   #\:))
-                                          ":")
-                                         "\nAM_CXXFLAGS = ")))))))
-               '())
-         ;; Force rs6000 (i.e., powerpc) libdir to be /lib and not /lib64.
-         (add-before 'chdir 'fix-rs6000-libdir
-           (lambda _
-             (when (file-exists? "gcc/config/rs6000")
-               (substitute* (find-files "gcc/config/rs6000")
-                 (("/lib64") "/lib")))))
-         (add-before 'configure 'chdir
-           (lambda _
-             (chdir "libstdc++-v3"))))
-
-       #:configure-flags `("--disable-libstdcxx-pch"
-                           ,(string-append "--with-gxx-include-dir="
-                                           (assoc-ref %outputs "out")
-                                           "/include"))))
+      #:phases
+      #~(modify-phases %standard-phases
+          #$@(if (and (target-ppc64le?)
+                      (version>=? (package-version gcc) "11"))
+                 #~((add-after 'unpack 'patch-foo
+                      (lambda _
+                        (define patch
+                          #$(local-file
+                             (search-patch "foo.patch")))
+                        (peek "CWD" (getcwd))
+                        (invoke "patch" "--force" "-p1" "-i" patch))))
+                 '())
+          #$@(if (version>=? (package-version gcc) "11")
+                 #~((add-after 'unpack 'hide-gcc-headers
+                      (lambda* (#:key native-inputs inputs #:allow-other-keys)
+                        (let ((gcc (assoc-ref (or native-inputs inputs)
+                                              #$(if (%current-target-system)
+                                                    "cross-gcc"
+                                                    "gcc"))))
+                          ;; Fix a regression in GCC 11 where the GCC headers
+                          ;; shadows glibc headers when building libstdc++.  An
+                          ;; upstream fix was added in GCC 11.3.0, but it only
+                          ;; hides system include directories, not those on
+                          ;; CPLUS_INCLUDE_PATH.  See discussion at
+                          ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100017>
+                          ;; and the similar adjustment in GCC-FINAL.
+                          (substitute* "libstdc++-v3/src/c++17/Makefile.in"
+                            (("AM_CXXFLAGS = ")
+                             (string-append #$(if (%current-target-system)
+                                                  "CROSS_CPLUS_INCLUDE_PATH = "
+                                                  "CPLUS_INCLUDE_PATH = ")
+                                            (string-join
+                                             (remove (cut string-prefix? gcc <>)
+                                                     (string-split
+                                                      (getenv
+                                                       #$(if (%current-target-system)
+                                                             "CROSS_CPLUS_INCLUDE_PATH"
+                                                             "CPLUS_INCLUDE_PATH"))
+                                                      #\:))
+                                             ":")
+                                            "\nAM_CXXFLAGS = ")))))))
+                 '())
+          ;; Force rs6000 (i.e., powerpc) libdir to be /lib and not /lib64.
+          (add-before 'chdir 'fix-rs6000-libdir
+            (lambda _
+              (when (file-exists? "gcc/config/rs6000")
+                (substitute* (find-files "gcc/config/rs6000")
+                  (("/lib64") "/lib")))))
+          (add-before 'configure 'chdir
+            (lambda _
+              (chdir "libstdc++-v3"))))
+
+      #:configure-flags #~(list
+                           "--disable-libstdcxx-pch"
+                           (string-append "--with-gxx-include-dir="
+                                          #$output
+                                          "/include"))))
     (outputs '("out" "debug"))
     (inputs '())
     (native-inputs '())
diff --git a/gnu/packages/patches/foo.patch b/gnu/packages/patches/foo.patch
new file mode 100644
index 0000000000..5f3ccda91d
--- /dev/null
+++ b/gnu/packages/patches/foo.patch
@@ -0,0 +1,20 @@
+--- a/libstdc++-v3/src/c++17/floating_from_chars.cc
++++ b/libstdc++-v3/src/c++17/floating_from_chars.cc
+@@ -495,10 +495,16 @@
+ from_chars(const char* first, const char* last, __ieee128& value,
+          chars_format fmt) noexcept
+ {
++  errc ec = errc::invalid_argument;
++#if _GLIBCXX_USE_CXX11_ABI
+   buffer_resource mr;
+   pmr::string buf(&mr);
++#else
++  string buf;
++  if (!reserve_string(buf))
++    return make_result(first, 0, {}, ec);
++#endif
+   size_t len = 0;
+-  errc ec = errc::invalid_argument;
+   __try
+     {
+       if (const char* pat = pattern(first, last, fmt, buf)) [[likely]]
-- 
2.32.0



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

  parent reply	other threads:[~2023-04-13 13:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87a60xcrdl.fsf@inria.fr>
2023-04-13  9:32 ` Powerpc on core-updates Andreas Enge
2023-04-13  9:51   ` Andreas Enge
2023-04-13 13:46   ` Christopher Baines [this message]
2023-04-13 14:06     ` bug#61879: " Andreas Enge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mt3byjrp.fsf@cbaines.net \
    --to=mail@cbaines.net \
    --cc=61879@debbugs.gnu.org \
    --cc=andreas@enge.fr \
    --cc=efraim@flashner.co.il \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).