From 382862fc06085ba80380977caf2a1f9c3203a12d Mon Sep 17 00:00:00 2001 From: Christopher Baines 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 - ;; - ;; 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 + ;; + ;; 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