* Re: Powerpc on core-updates
2023-04-13 9:32 ` Powerpc on core-updates Andreas Enge
@ 2023-04-13 9:51 ` Andreas Enge
2023-04-13 13:46 ` bug#61879: " Christopher Baines
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Enge @ 2023-04-13 9:51 UTC (permalink / raw)
To: guix-devel; +Cc: Efraim Flashner, 61879
[-- Attachment #1: Type: text/plain, Size: 302 bytes --]
I may as well try to provide a patch. It is untested even on x86_64,
since it requires quite a few rebuilds. If it works on powerpc, it should
probably be made conditional on the architecture to avoid a world rebuild.
I do not know whether this is possible in the patches field in an origin.
Andreas
[-- Attachment #2: 0001-gnu-gcc-11-Fix-build-on-powerpc64le.patch --]
[-- Type: text/plain, Size: 3561 bytes --]
From 5eb50bdc34759d4c917f2143e037fad62bc08ed7 Mon Sep 17 00:00:00 2001
From: Andreas Enge <andreas@enge.fr>
Date: Thu, 13 Apr 2023 11:46:47 +0200
Subject: [PATCH] gnu: gcc-11: Fix build on powerpc64le.
* gnu/packages/patches/gcc-11-libstdc++-powerpc.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register patch.
* gnu/packages/gcc.scm (gcc-11)[origin]: Use patch.
---
gnu/local.mk | 1 +
gnu/packages/gcc.scm | 5 +++--
.../patches/gcc-11-libstdc++-powerpc.patch | 18 ++++++++++++++++++
3 files changed, 22 insertions(+), 2 deletions(-)
create mode 100644 gnu/packages/patches/gcc-11-libstdc++-powerpc.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index b07811f1cb..1255846462 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1184,6 +1184,7 @@ dist_patch_DATA = \
%D%/packages/patches/gcc-11-libstdc++-hurd-libpthread.patch \
%D%/packages/patches/gcc-12-cross-environment-variables.patch \
%D%/packages/patches/gcc-10-tree-sra-union-handling.patch \
+ %D%/packages/patches/gcc-11-libstdc++-powerpc.patch \
%D%/packages/patches/gcolor3-update-libportal-usage.patch \
%D%/packages/patches/gd-fix-tests-on-i686.patch \
%D%/packages/patches/gd-brect-bounds.patch \
diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index a511cdbc45..631e08db25 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -2,7 +2,7 @@
;;; Copyright © 2012-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus <rekado@elephly.net>
-;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
+;;; Copyright © 2015, 2023 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2015-2018, 2020-2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Carlos Sánchez de La Lama <csanchezdll@gmail.com>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
@@ -703,7 +703,8 @@ (define-public gcc-11
"0fdclcwf728wbq52vphfcjywzhpsjp3kifzj3pib3xcihs0z4z5l"))
(patches (search-patches "gcc-9-strmov-store-file-names.patch"
"gcc-5.0-libvtv-runpath.patch"
- "gcc-10-tree-sra-union-handling.patch"))
+ "gcc-10-tree-sra-union-handling.patch"
+ "gcc-11-libstdc++-powerpc.patch"))
(modules '((guix build utils)))
(snippet gcc-canadian-cross-objdump-snippet)))
(arguments
diff --git a/gnu/packages/patches/gcc-11-libstdc++-powerpc.patch b/gnu/packages/patches/gcc-11-libstdc++-powerpc.patch
new file mode 100644
index 0000000000..aff2ef16f1
--- /dev/null
+++ b/gnu/packages/patches/gcc-11-libstdc++-powerpc.patch
@@ -0,0 +1,18 @@
+diff -u -r gcc-11.3.0.alt/libstdc++-v3/src/c++17/floating_from_chars.cc gcc-11.3.0/libstdc++-v3/src/c++17/floating_from_chars.cc
+--- gcc-11.3.0.alt/libstdc++-v3/src/c++17/floating_from_chars.cc 2023-04-13 11:36:08.169841428 +0200
++++ gcc-11.3.0/libstdc++-v3/src/c++17/floating_from_chars.cc 2023-04-13 11:36:54.825827304 +0200
+@@ -495,8 +495,14 @@
+ from_chars(const char* first, const char* last, __ieee128& value,
+ chars_format fmt) noexcept
+ {
++#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
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: bug#61879: Powerpc on core-updates
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
2023-04-13 14:06 ` Andreas Enge
1 sibling, 1 reply; 4+ messages in thread
From: Christopher Baines @ 2023-04-13 13:46 UTC (permalink / raw)
To: Andreas Enge; +Cc: guix-devel, 61879, Efraim Flashner
[-- 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 --]
^ permalink raw reply related [flat|nested] 4+ messages in thread