From 31dd526e1cfc3a70c72c8906bef8f26b91f39ce4 Mon Sep 17 00:00:00 2001 From: Andreas Enge Date: Thu, 13 Apr 2023 11:46:47 +0200 Subject: 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 (make-libstdc++): Apply patch for gcc versions >= 11 and < 12 on ppc64le. Co-authored-by: Christopher Baines Signed-off-by: Christopher Baines --- gnu/local.mk | 1 + gnu/packages/gcc.scm | 20 ++++++++++++++++++-- gnu/packages/patches/gcc-11-libstdc++-powerpc.patch | 20 ++++++++++++++++++++ 3 files changed, 39 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..5b1ef83ce6 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -2,7 +2,7 @@ ;;; Copyright © 2012-2023 Ludovic Courtès ;;; Copyright © 2014, 2015, 2018 Mark H Weaver ;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus -;;; Copyright © 2015 Andreas Enge +;;; Copyright © 2015, 2023 Andreas Enge ;;; Copyright © 2015-2018, 2020-2023 Efraim Flashner ;;; Copyright © 2016 Carlos Sánchez de La Lama ;;; Copyright © 2018 Tobias Geerinckx-Rice @@ -889,6 +889,15 @@ (define-public (make-libstdc++ gcc) ":") "\nAM_CXXFLAGS = "))))))) '()) + ,@(let ((version (package-version gcc))) + (if (and (target-ppc64le?) + (version>=? version "11") + (not (version>=? version "12"))) + `((add-after 'unpack 'patch-powerpc + (lambda* (#:key inputs #:allow-other-keys) + (invoke "patch" "--force" "-p1" "-i" + (assoc-ref inputs "powerpc64le-patch"))))) + '())) ;; Force rs6000 (i.e., powerpc) libdir to be /lib and not /lib64. (add-before 'chdir 'fix-rs6000-libdir (lambda _ @@ -905,7 +914,14 @@ (define-public (make-libstdc++ gcc) "/include")))) (outputs '("out" "debug")) (inputs '()) - (native-inputs '()) + (native-inputs + `(,@(if (and (target-ppc64le?) + (let ((version (package-version gcc))) + (and + (version>=? version "11") + (not (version>=? version "12"))))) + `(("powerpc64le-patch" ,(search-patch "gcc-11-libstdc++-powerpc.patch"))) + '()))) (propagated-inputs '()) (synopsis "GNU C++ standard library"))) 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..c0b96c3bc8 --- /dev/null +++ b/gnu/packages/patches/gcc-11-libstdc++-powerpc.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]] -- cgit v1.2.3