From unknown Sat Jun 21 03:28:33 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63329] [PATCH] gnu: Use gexps for gcc-boot0 and related packages. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 06 May 2023 13:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63329 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63329@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.168337936931687 (code B ref -1); Sat, 06 May 2023 13:23:02 +0000 Received: (at submit) by debbugs.gnu.org; 6 May 2023 13:22:49 +0000 Received: from localhost ([127.0.0.1]:59688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvHs8-0008Ey-1U for submit@debbugs.gnu.org; Sat, 06 May 2023 09:22:49 -0400 Received: from lists.gnu.org ([209.51.188.17]:55158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvHs2-0008Eh-0R for submit@debbugs.gnu.org; Sat, 06 May 2023 09:22:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pvHry-0001Nk-Fq for guix-patches@gnu.org; Sat, 06 May 2023 09:22:39 -0400 Received: from mira.cbaines.net ([212.71.252.8]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pvHrs-000533-QT for guix-patches@gnu.org; Sat, 06 May 2023 09:22:37 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id 8683E27BBE2 for ; Sat, 6 May 2023 14:22:30 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 8117863e for ; Sat, 6 May 2023 13:22:29 +0000 (UTC) From: Christopher Baines Date: Sat, 6 May 2023 14:22:29 +0100 Message-Id: <54e8a32abd9f31253787d5997dbed172d794024f.1683379349.git.mail@cbaines.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=212.71.252.8; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) There are currently problems with native or cross building for i586-gnu, and one factor mixed up with this is that some of the gcc packages use sexp's for the phases, and thus introducing gexp's has caused problems. As part of the going in circles with this, this commit switches gcc-boot0 to use gexp's in it's arguments, and then also modifies libstdc++-boot0, cross-gcc-wrapper, gcc-final and make-libstdc++ to handle this change. If done correctly, this change shouldn't affect any derivations. * gnu/packages/commencement.scm (libstdc++-boot0, gcc-boot0, gcc-final)[arguments]: Use gexps. (cross-gcc-wrapper): Use gexps in the generated package. * gnu/packages/gcc.scm (make-libstdc++): Use gexps in the generated package. --- gnu/packages/commencement.scm | 377 +++++++++++++++++----------------- gnu/packages/gcc.scm | 109 +++++----- 2 files changed, 245 insertions(+), 241 deletions(-) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index fc1c508b38..5e47b272e4 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -2259,13 +2259,13 @@ (define libstdc++-boot0 ((or "i686-linux" "x86_64-linux") (substitute-keyword-arguments (package-arguments lib) ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'workaround-wrapper-bug - ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to - ;; fail, which in turn confuses the configure script. - (lambda _ - (substitute* "libstdc++-v3/configure" - (("g\\+\\+ -v") "true")))))))) + #~(modify-phases #$phases + (add-after 'unpack 'workaround-wrapper-bug + ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to + ;; fail, which in turn confuses the configure script. + (lambda _ + (substitute* "libstdc++-v3/configure" + (("g\\+\\+ -v") "true")))))))) (_ (package-arguments lib))) ;; Explicitly add #:modules so MAKE-LIBSTDC++ can be changed @@ -2338,81 +2338,82 @@ (define gcc-boot0 (system* #$(file-append coreutils-boot0 "/bin/rm") "-rf" "gcc/testsuite/go.test/test/fixedbugs/issue27836.dir")))))) (arguments - `(#:guile ,%bootstrap-guile - #:implicit-inputs? #f - #:modules ((guix build gnu-build-system) + (cons* + #:guile %bootstrap-guile + #:implicit-inputs? #f + #:modules '((guix build gnu-build-system) (guix build utils) (ice-9 regex) (srfi srfi-1) (srfi srfi-26)) - ,@(substitute-keyword-arguments (package-arguments gcc) - ((#:configure-flags flags) - `(append (list ,(string-append "--target=" (boot-triplet)) - - ;; No libc yet. - "--without-headers" - - ;; Disable features not needed at this stage. - "--disable-shared" - "--enable-languages=c,c++" - - ;; libstdc++ cannot be built at this stage - ;; ("Link tests are not allowed after - ;; GCC_NO_EXECUTABLES."). - "--disable-libstdc++-v3" - - "--disable-threads" - "--disable-libmudflap" - "--disable-libatomic" - "--disable-libsanitizer" - "--disable-libitm" - "--disable-libgomp" - "--disable-libmpx" - "--disable-libcilkrts" - "--disable-libvtv" - "--disable-libssp" - "--disable-libquadmath" - "--disable-decimal-float") - (remove (cut string-match - "--(with-system-zlib|enable-languages.*)" <>) - ,flags))) - ((#:make-flags flags) - `(let* ((libc (assoc-ref %build-inputs "libc")) - (libc-native (or (assoc-ref %build-inputs "libc-native") - libc))) - `(,(string-append "LDFLAGS=" - "-Wl,-rpath=" libc-native "/lib " - "-Wl,-dynamic-linker " - "-Wl," libc-native ,(glibc-dynamic-linker - (match (%current-system) - ("x86_64-linux" "i686-linux") - (_ (%current-system)))))))) - ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'unpack-gmp&co - (lambda* (#:key inputs #:allow-other-keys) - (let ((gmp (assoc-ref %build-inputs "gmp-source")) - (mpfr (assoc-ref %build-inputs "mpfr-source")) - (mpc (assoc-ref %build-inputs "mpc-source"))) - - ;; To reduce the set of pre-built bootstrap inputs, build - ;; GMP & co. from GCC. - (for-each (lambda (source) - (invoke "tar" "xvf" source)) - (list gmp mpfr mpc)) - - ;; Create symlinks like `gmp' -> `gmp-x.y.z'. - ,@(map (lambda (lib) - ;; Drop trailing letters, as gmp-6.0.0a unpacks - ;; into gmp-6.0.0. - `(symlink ,(string-trim-right - (package-full-name lib "-") - char-set:letter) - ,(package-name lib))) - (list gmp-6.0 mpfr mpc))))) - ,(match (%current-system) - ((or "i686-linux" "x86_64-linux") - '(add-before 'configure 'fix-libcc1 + (substitute-keyword-arguments (package-arguments gcc) + ((#:configure-flags flags) + #~(append (list #$(string-append "--target=" (boot-triplet)) + + ;; No libc yet. + "--without-headers" + + ;; Disable features not needed at this stage. + "--disable-shared" + "--enable-languages=c,c++" + + ;; libstdc++ cannot be built at this stage + ;; ("Link tests are not allowed after + ;; GCC_NO_EXECUTABLES."). + "--disable-libstdc++-v3" + + "--disable-threads" + "--disable-libmudflap" + "--disable-libatomic" + "--disable-libsanitizer" + "--disable-libitm" + "--disable-libgomp" + "--disable-libmpx" + "--disable-libcilkrts" + "--disable-libvtv" + "--disable-libssp" + "--disable-libquadmath" + "--disable-decimal-float") + (remove (cut string-match + "--(with-system-zlib|enable-languages.*)" <>) + #$flags))) + ((#:make-flags flags) + `(let* ((libc (assoc-ref %build-inputs "libc")) + (libc-native (or (assoc-ref %build-inputs "libc-native") + libc))) + `(,(string-append "LDFLAGS=" + "-Wl,-rpath=" libc-native "/lib " + "-Wl,-dynamic-linker " + "-Wl," libc-native ,(glibc-dynamic-linker + (match (%current-system) + ("x86_64-linux" "i686-linux") + (_ (%current-system)))))))) + ((#:phases phases) + #~(modify-phases #$phases + (add-after 'unpack 'unpack-gmp&co + (lambda* (#:key inputs #:allow-other-keys) + (let ((gmp (assoc-ref %build-inputs "gmp-source")) + (mpfr (assoc-ref %build-inputs "mpfr-source")) + (mpc (assoc-ref %build-inputs "mpc-source"))) + + ;; To reduce the set of pre-built bootstrap inputs, build + ;; GMP & co. from GCC. + (for-each (lambda (source) + (invoke "tar" "xvf" source)) + (list gmp mpfr mpc)) + + ;; Create symlinks like `gmp' -> `gmp-x.y.z'. + #$@(map (lambda (lib) + ;; Drop trailing letters, as gmp-6.0.0a unpacks + ;; into gmp-6.0.0. + #~(symlink #$(string-trim-right + (package-full-name lib "-") + char-set:letter) + #$(package-name lib))) + (list gmp-6.0 mpfr mpc))))) + #$(match (%current-system) + ((or "i686-linux" "x86_64-linux") + #~(add-before 'configure 'fix-libcc1 (lambda* (#:key inputs #:allow-other-keys) ;; libcc1.so NEEDs libgcc_s.so, so provide one here ;; to placate the 'validate-runpath' phase. @@ -2423,18 +2424,18 @@ (define gcc-boot0 ;; XXX: "g++ -v" is broken (see also libstdc++ above). (substitute* "libcc1/configure" (("g\\+\\+ -v") "true"))))) - (_ '(add-before 'configure 'return-true + (_ #~(add-before 'configure 'return-true (lambda _ #t)))) - (add-after 'install 'symlink-libgcc_eh - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "lib"))) - ;; Glibc wants to link against libgcc_eh, so provide - ;; it. - (with-directory-excursion - (string-append out "/lib/gcc/" - ,(boot-triplet) - "/" ,(package-version gcc)) - (symlink "libgcc.a" "libgcc_eh.a")))))))))) + (add-after 'install 'symlink-libgcc_eh + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "lib"))) + ;; Glibc wants to link against libgcc_eh, so provide + ;; it. + (with-directory-excursion + (string-append out "/lib/gcc/" + #$(boot-triplet) + "/" #$(package-version gcc)) + (symlink "libgcc.a" "libgcc_eh.a")))))))))) (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0))) ("mpfr-source" ,(bootstrap-origin (package-source mpfr))) @@ -2888,41 +2889,42 @@ (define (cross-gcc-wrapper gcc binutils glibc bash) (build-system trivial-build-system) (outputs '("out")) (arguments - `(#:guile ,%bootstrap-guile - #:modules ((guix build utils)) - #:builder (begin - (use-modules (guix build utils)) - - (let* ((binutils (assoc-ref %build-inputs "binutils")) - (gcc (assoc-ref %build-inputs "gcc")) - (libc (assoc-ref %build-inputs "libc")) - (bash (assoc-ref %build-inputs "bash")) - (out (assoc-ref %outputs "out")) - (bindir (string-append out "/bin")) - (triplet ,(boot-triplet))) - (define (wrap-program program) - ;; GCC-BOOT0 is a libc-less cross-compiler, so it - ;; needs to be told where to find the crt files and - ;; the dynamic linker. - (call-with-output-file program - (lambda (p) - (format p "#!~a/bin/bash + (list + #:guile %bootstrap-guile + #:modules '((guix build utils)) + #:builder #~(begin + (use-modules (guix build utils)) + + (let* ((binutils (assoc-ref %build-inputs "binutils")) + (gcc (assoc-ref %build-inputs "gcc")) + (libc (assoc-ref %build-inputs "libc")) + (bash (assoc-ref %build-inputs "bash")) + (out (assoc-ref %outputs "out")) + (bindir (string-append out "/bin")) + (triplet #$(boot-triplet))) + (define (wrap-program program) + ;; GCC-BOOT0 is a libc-less cross-compiler, so it + ;; needs to be told where to find the crt files and + ;; the dynamic linker. + (call-with-output-file program + (lambda (p) + (format p "#!~a/bin/bash exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%" - bash - gcc triplet program - libc libc - ,(glibc-dynamic-linker)))) - - (chmod program #o555)) - - (mkdir-p bindir) - (with-directory-excursion bindir - (for-each (lambda (tool) - (symlink (string-append binutils "/bin/" - triplet "-" tool) - tool)) - '("ar" "ranlib")) - (for-each wrap-program '("gcc" "g++"))))))) + bash + gcc triplet program + libc libc + #$(glibc-dynamic-linker)))) + + (chmod program #o555)) + + (mkdir-p bindir) + (with-directory-excursion bindir + (for-each (lambda (tool) + (symlink (string-append binutils "/bin/" + triplet "-" tool) + tool)) + '("ar" "ranlib")) + (for-each wrap-program '("gcc" "g++"))))))) (native-inputs `(("binutils" ,binutils) ("gcc" ,gcc) @@ -3122,79 +3124,80 @@ (define gcc-final (outputs (delete "debug" (package-outputs gcc-boot0))) (arguments - `(#:guile ,%bootstrap-guile - #:implicit-inputs? #f + (cons* + #:guile %bootstrap-guile + #:implicit-inputs? #f - #:allowed-references ("out" "lib" ,zlib-final + #:allowed-references `("out" "lib" ,zlib-final ,glibc-final ,static-bash-for-glibc) - ;; Things like libasan.so and libstdc++.so NEED ld.so for some - ;; reason, but it is not in their RUNPATH. This is a false - ;; positive, so turn it off. - #:validate-runpath? #f + ;; Things like libasan.so and libstdc++.so NEED ld.so for some + ;; reason, but it is not in their RUNPATH. This is a false + ;; positive, so turn it off. + #:validate-runpath? #f - ;; Additional modules for the libstdc++ phase below. - #:modules ((srfi srfi-1) + ;; Additional modules for the libstdc++ phase below. + #:modules `((srfi srfi-1) (srfi srfi-26) ,@%gnu-build-system-modules) - ,@(substitute-keyword-arguments (package-arguments gcc) - ((#:make-flags flags) - ;; Since $LIBRARY_PATH is not honored, add the relevant flags. - `(let ((zlib (assoc-ref %build-inputs "zlib"))) - (map (lambda (flag) - (if (string-prefix? "LDFLAGS=" flag) - (string-append flag " -L" - (assoc-ref %build-inputs "libstdc++") - "/lib -L" zlib "/lib -Wl,-rpath=" - zlib "/lib") - flag)) - ,flags))) - ;; Build again GMP & co. within GCC's build process, because it's hard - ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus - ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) - ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'unpack-gmp&co - (lambda* (#:key inputs #:allow-other-keys) - (let ((gmp (assoc-ref %build-inputs "gmp-source")) - (mpfr (assoc-ref %build-inputs "mpfr-source")) - (mpc (assoc-ref %build-inputs "mpc-source"))) - - ;; To reduce the set of pre-built bootstrap inputs, build - ;; GMP & co. from GCC. - (for-each (lambda (source) - (invoke "tar" "xvf" source)) - (list gmp mpfr mpc)) - - ;; Create symlinks like `gmp' -> `gmp-x.y.z'. - ,@(map (lambda (lib) - ;; Drop trailing letters, as gmp-6.0.0a unpacks - ;; into gmp-6.0.0. - `(symlink ,(string-trim-right + (substitute-keyword-arguments (package-arguments gcc) + ((#:make-flags flags) + ;; Since $LIBRARY_PATH is not honored, add the relevant flags. + #~(let ((zlib (assoc-ref %build-inputs "zlib"))) + (map (lambda (flag) + (if (string-prefix? "LDFLAGS=" flag) + (string-append flag " -L" + (assoc-ref %build-inputs "libstdc++") + "/lib -L" zlib "/lib -Wl,-rpath=" + zlib "/lib") + flag)) + #$flags))) + ;; Build again GMP & co. within GCC's build process, because it's hard + ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus + ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) + ((#:phases phases) + #~(modify-phases #$phases + (add-after 'unpack 'unpack-gmp&co + (lambda* (#:key inputs #:allow-other-keys) + (let ((gmp (assoc-ref %build-inputs "gmp-source")) + (mpfr (assoc-ref %build-inputs "mpfr-source")) + (mpc (assoc-ref %build-inputs "mpc-source"))) + + ;; To reduce the set of pre-built bootstrap inputs, build + ;; GMP & co. from GCC. + (for-each (lambda (source) + (invoke "tar" "xvf" source)) + (list gmp mpfr mpc)) + + ;; Create symlinks like `gmp' -> `gmp-x.y.z'. + #$@(map (lambda (lib) + ;; Drop trailing letters, as gmp-6.0.0a unpacks + ;; into gmp-6.0.0. + #~(symlink #$(string-trim-right (package-full-name lib "-") char-set:letter) - ,(package-name lib))) - (list gmp-6.0 mpfr mpc))))) - (add-after 'unpack 'fix-build-with-external-libstdc++ - (lambda* (#:key inputs #:allow-other-keys) - (let ((libstdc++ (assoc-ref inputs "libstdc++"))) - ;; Fix a regression in GCC 11 where the libstc++ input - ;; 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 - ;; . - (substitute* "libstdc++-v3/src/c++17/Makefile.in" - (("AM_CXXFLAGS = ") - (string-append "CPLUS_INCLUDE_PATH = " - (string-join - (remove (cut string-prefix? libstdc++ <>) - (string-split - (getenv "CPLUS_INCLUDE_PATH") - #\:)) - ":") - "\nAM_CXXFLAGS = "))))))))))) + #$(package-name lib))) + (list gmp-6.0 mpfr mpc))))) + (add-after 'unpack 'fix-build-with-external-libstdc++ + (lambda* (#:key inputs #:allow-other-keys) + (let ((libstdc++ (assoc-ref inputs "libstdc++"))) + ;; Fix a regression in GCC 11 where the libstc++ input + ;; 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 + ;; . + (substitute* "libstdc++-v3/src/c++17/Makefile.in" + (("AM_CXXFLAGS = ") + (string-append "CPLUS_INCLUDE_PATH = " + (string-join + (remove (cut string-prefix? libstdc++ <>) + (string-split + (getenv "CPLUS_INCLUDE_PATH") + #\:)) + ":") + "\nAM_CXXFLAGS = "))))))))))) ;; This time we want Texinfo, so we get the manual. Add ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index fade5bb64b..d1c79b8dc2 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -864,62 +864,63 @@ (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 = "))))))) - '()) - ,@(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 _ - (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" + #: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 = "))))))) + '()) + #$@(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 _ + (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")))) base-commit: 40d6615ca2755605e8aab790fbbae0221ec1d827 -- 2.39.1 From unknown Sat Jun 21 03:28:33 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63329] [PATCH v2] gnu: Use gexps for gcc-boot0 and related packages. References: <54e8a32abd9f31253787d5997dbed172d794024f.1683379349.git.mail@cbaines.net> In-Reply-To: <54e8a32abd9f31253787d5997dbed172d794024f.1683379349.git.mail@cbaines.net> Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 06 May 2023 21:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63329 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63329@debbugs.gnu.org Received: via spool by 63329-submit@debbugs.gnu.org id=B63329.1683408757915 (code B ref 63329); Sat, 06 May 2023 21:33:01 +0000 Received: (at 63329) by debbugs.gnu.org; 6 May 2023 21:32:37 +0000 Received: from localhost ([127.0.0.1]:35867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvPW8-0000Ee-Eo for submit@debbugs.gnu.org; Sat, 06 May 2023 17:32:37 -0400 Received: from mira.cbaines.net ([212.71.252.8]:42498) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvPW5-0000EV-Ls for 63329@debbugs.gnu.org; Sat, 06 May 2023 17:32:35 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:3a91:a0a4:ecee:f157]) by mira.cbaines.net (Postfix) with ESMTPSA id C249427BBE2 for <63329@debbugs.gnu.org>; Sat, 6 May 2023 22:32:31 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 8f020309 for <63329@debbugs.gnu.org>; Sat, 6 May 2023 21:32:30 +0000 (UTC) From: Christopher Baines Date: Sat, 6 May 2023 22:32:30 +0100 Message-Id: <7c5922aed25834bcc4cfd248a5107960f3700ae2.1683408750.git.mail@cbaines.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) There are currently problems with native or cross building for i586-gnu, and one factor mixed up with this is that some of the gcc packages use sexp's for the phases, and thus introducing gexp's has caused problems. As part of the going in circles with this, this commit switches gcc-boot0 to use gexp's in it's arguments, and then also modifies libstdc++-boot0, libstdc++-boot0-gcc7, cross-gcc-wrapper, gcc-final and make-libstdc++ to handle this change. If done correctly, this change shouldn't affect any derivations. * gnu/packages/commencement.scm (libstdc++-boot0, libstdc++-boot0-gcc7, gcc-boot0, gcc-final)[arguments]: Use gexps. (cross-gcc-wrapper): Use gexps in the generated package. * gnu/packages/gcc.scm (make-libstdc++): Use gexps in the generated package. --- gnu/packages/commencement.scm | 421 +++++++++++++++++----------------- gnu/packages/gcc.scm | 109 ++++----- 2 files changed, 267 insertions(+), 263 deletions(-) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index fc1c508b38..c4b50ec2c4 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -2259,13 +2259,13 @@ (define libstdc++-boot0 ((or "i686-linux" "x86_64-linux") (substitute-keyword-arguments (package-arguments lib) ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'workaround-wrapper-bug - ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to - ;; fail, which in turn confuses the configure script. - (lambda _ - (substitute* "libstdc++-v3/configure" - (("g\\+\\+ -v") "true")))))))) + #~(modify-phases #$phases + (add-after 'unpack 'workaround-wrapper-bug + ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to + ;; fail, which in turn confuses the configure script. + (lambda _ + (substitute* "libstdc++-v3/configure" + (("g\\+\\+ -v") "true")))))))) (_ (package-arguments lib))) ;; Explicitly add #:modules so MAKE-LIBSTDC++ can be changed @@ -2292,28 +2292,28 @@ (define libstdc++-boot0-gcc7 ,@(substitute-keyword-arguments (package-arguments lib) ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'unpack-gmp&co - (lambda* (#:key inputs #:allow-other-keys) - (let ((gmp (assoc-ref %build-inputs "gmp-source")) - (mpfr (assoc-ref %build-inputs "mpfr-source")) - (mpc (assoc-ref %build-inputs "mpc-source"))) - - ;; To reduce the set of pre-built bootstrap inputs, build - ;; GMP & co. from GCC. - (for-each (lambda (source) - (invoke "tar" "xvf" source)) - (list gmp mpfr mpc)) - - ;; Create symlinks like `gmp' -> `gmp-x.y.z'. - ,@(map (lambda (lib) - ;; Drop trailing letters, as gmp-6.0.0a unpacks - ;; into gmp-6.0.0. - `(symlink ,(string-trim-right - (package-full-name lib "-") - char-set:letter) - ,(package-name lib))) - (list gmp-6.0 mpfr mpc)))))))))) + #~(modify-phases #$phases + (add-after 'unpack 'unpack-gmp&co + (lambda* (#:key inputs #:allow-other-keys) + (let ((gmp (assoc-ref %build-inputs "gmp-source")) + (mpfr (assoc-ref %build-inputs "mpfr-source")) + (mpc (assoc-ref %build-inputs "mpc-source"))) + + ;; To reduce the set of pre-built bootstrap inputs, build + ;; GMP & co. from GCC. + (for-each (lambda (source) + (invoke "tar" "xvf" source)) + (list gmp mpfr mpc)) + + ;; Create symlinks like `gmp' -> `gmp-x.y.z'. + #$@(map (lambda (lib) + ;; Drop trailing letters, as gmp-6.0.0a unpacks + ;; into gmp-6.0.0. + #~(symlink #$(string-trim-right + (package-full-name lib "-") + char-set:letter) + #$(package-name lib))) + (list gmp-6.0 mpfr mpc)))))))))) (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0))) ("mpfr-source" ,(bootstrap-origin (package-source mpfr))) ("mpc-source" ,(bootstrap-origin (package-source mpc))) @@ -2338,81 +2338,82 @@ (define gcc-boot0 (system* #$(file-append coreutils-boot0 "/bin/rm") "-rf" "gcc/testsuite/go.test/test/fixedbugs/issue27836.dir")))))) (arguments - `(#:guile ,%bootstrap-guile - #:implicit-inputs? #f - #:modules ((guix build gnu-build-system) + (cons* + #:guile %bootstrap-guile + #:implicit-inputs? #f + #:modules '((guix build gnu-build-system) (guix build utils) (ice-9 regex) (srfi srfi-1) (srfi srfi-26)) - ,@(substitute-keyword-arguments (package-arguments gcc) - ((#:configure-flags flags) - `(append (list ,(string-append "--target=" (boot-triplet)) - - ;; No libc yet. - "--without-headers" - - ;; Disable features not needed at this stage. - "--disable-shared" - "--enable-languages=c,c++" - - ;; libstdc++ cannot be built at this stage - ;; ("Link tests are not allowed after - ;; GCC_NO_EXECUTABLES."). - "--disable-libstdc++-v3" - - "--disable-threads" - "--disable-libmudflap" - "--disable-libatomic" - "--disable-libsanitizer" - "--disable-libitm" - "--disable-libgomp" - "--disable-libmpx" - "--disable-libcilkrts" - "--disable-libvtv" - "--disable-libssp" - "--disable-libquadmath" - "--disable-decimal-float") - (remove (cut string-match - "--(with-system-zlib|enable-languages.*)" <>) - ,flags))) - ((#:make-flags flags) - `(let* ((libc (assoc-ref %build-inputs "libc")) - (libc-native (or (assoc-ref %build-inputs "libc-native") - libc))) - `(,(string-append "LDFLAGS=" - "-Wl,-rpath=" libc-native "/lib " - "-Wl,-dynamic-linker " - "-Wl," libc-native ,(glibc-dynamic-linker - (match (%current-system) - ("x86_64-linux" "i686-linux") - (_ (%current-system)))))))) - ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'unpack-gmp&co - (lambda* (#:key inputs #:allow-other-keys) - (let ((gmp (assoc-ref %build-inputs "gmp-source")) - (mpfr (assoc-ref %build-inputs "mpfr-source")) - (mpc (assoc-ref %build-inputs "mpc-source"))) - - ;; To reduce the set of pre-built bootstrap inputs, build - ;; GMP & co. from GCC. - (for-each (lambda (source) - (invoke "tar" "xvf" source)) - (list gmp mpfr mpc)) - - ;; Create symlinks like `gmp' -> `gmp-x.y.z'. - ,@(map (lambda (lib) - ;; Drop trailing letters, as gmp-6.0.0a unpacks - ;; into gmp-6.0.0. - `(symlink ,(string-trim-right - (package-full-name lib "-") - char-set:letter) - ,(package-name lib))) - (list gmp-6.0 mpfr mpc))))) - ,(match (%current-system) - ((or "i686-linux" "x86_64-linux") - '(add-before 'configure 'fix-libcc1 + (substitute-keyword-arguments (package-arguments gcc) + ((#:configure-flags flags) + #~(append (list #$(string-append "--target=" (boot-triplet)) + + ;; No libc yet. + "--without-headers" + + ;; Disable features not needed at this stage. + "--disable-shared" + "--enable-languages=c,c++" + + ;; libstdc++ cannot be built at this stage + ;; ("Link tests are not allowed after + ;; GCC_NO_EXECUTABLES."). + "--disable-libstdc++-v3" + + "--disable-threads" + "--disable-libmudflap" + "--disable-libatomic" + "--disable-libsanitizer" + "--disable-libitm" + "--disable-libgomp" + "--disable-libmpx" + "--disable-libcilkrts" + "--disable-libvtv" + "--disable-libssp" + "--disable-libquadmath" + "--disable-decimal-float") + (remove (cut string-match + "--(with-system-zlib|enable-languages.*)" <>) + #$flags))) + ((#:make-flags flags) + `(let* ((libc (assoc-ref %build-inputs "libc")) + (libc-native (or (assoc-ref %build-inputs "libc-native") + libc))) + `(,(string-append "LDFLAGS=" + "-Wl,-rpath=" libc-native "/lib " + "-Wl,-dynamic-linker " + "-Wl," libc-native ,(glibc-dynamic-linker + (match (%current-system) + ("x86_64-linux" "i686-linux") + (_ (%current-system)))))))) + ((#:phases phases) + #~(modify-phases #$phases + (add-after 'unpack 'unpack-gmp&co + (lambda* (#:key inputs #:allow-other-keys) + (let ((gmp (assoc-ref %build-inputs "gmp-source")) + (mpfr (assoc-ref %build-inputs "mpfr-source")) + (mpc (assoc-ref %build-inputs "mpc-source"))) + + ;; To reduce the set of pre-built bootstrap inputs, build + ;; GMP & co. from GCC. + (for-each (lambda (source) + (invoke "tar" "xvf" source)) + (list gmp mpfr mpc)) + + ;; Create symlinks like `gmp' -> `gmp-x.y.z'. + #$@(map (lambda (lib) + ;; Drop trailing letters, as gmp-6.0.0a unpacks + ;; into gmp-6.0.0. + #~(symlink #$(string-trim-right + (package-full-name lib "-") + char-set:letter) + #$(package-name lib))) + (list gmp-6.0 mpfr mpc))))) + #$(match (%current-system) + ((or "i686-linux" "x86_64-linux") + #~(add-before 'configure 'fix-libcc1 (lambda* (#:key inputs #:allow-other-keys) ;; libcc1.so NEEDs libgcc_s.so, so provide one here ;; to placate the 'validate-runpath' phase. @@ -2423,18 +2424,18 @@ (define gcc-boot0 ;; XXX: "g++ -v" is broken (see also libstdc++ above). (substitute* "libcc1/configure" (("g\\+\\+ -v") "true"))))) - (_ '(add-before 'configure 'return-true + (_ #~(add-before 'configure 'return-true (lambda _ #t)))) - (add-after 'install 'symlink-libgcc_eh - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "lib"))) - ;; Glibc wants to link against libgcc_eh, so provide - ;; it. - (with-directory-excursion - (string-append out "/lib/gcc/" - ,(boot-triplet) - "/" ,(package-version gcc)) - (symlink "libgcc.a" "libgcc_eh.a")))))))))) + (add-after 'install 'symlink-libgcc_eh + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "lib"))) + ;; Glibc wants to link against libgcc_eh, so provide + ;; it. + (with-directory-excursion + (string-append out "/lib/gcc/" + #$(boot-triplet) + "/" #$(package-version gcc)) + (symlink "libgcc.a" "libgcc_eh.a")))))))))) (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0))) ("mpfr-source" ,(bootstrap-origin (package-source mpfr))) @@ -2888,41 +2889,42 @@ (define (cross-gcc-wrapper gcc binutils glibc bash) (build-system trivial-build-system) (outputs '("out")) (arguments - `(#:guile ,%bootstrap-guile - #:modules ((guix build utils)) - #:builder (begin - (use-modules (guix build utils)) - - (let* ((binutils (assoc-ref %build-inputs "binutils")) - (gcc (assoc-ref %build-inputs "gcc")) - (libc (assoc-ref %build-inputs "libc")) - (bash (assoc-ref %build-inputs "bash")) - (out (assoc-ref %outputs "out")) - (bindir (string-append out "/bin")) - (triplet ,(boot-triplet))) - (define (wrap-program program) - ;; GCC-BOOT0 is a libc-less cross-compiler, so it - ;; needs to be told where to find the crt files and - ;; the dynamic linker. - (call-with-output-file program - (lambda (p) - (format p "#!~a/bin/bash + (list + #:guile %bootstrap-guile + #:modules '((guix build utils)) + #:builder #~(begin + (use-modules (guix build utils)) + + (let* ((binutils (assoc-ref %build-inputs "binutils")) + (gcc (assoc-ref %build-inputs "gcc")) + (libc (assoc-ref %build-inputs "libc")) + (bash (assoc-ref %build-inputs "bash")) + (out (assoc-ref %outputs "out")) + (bindir (string-append out "/bin")) + (triplet #$(boot-triplet))) + (define (wrap-program program) + ;; GCC-BOOT0 is a libc-less cross-compiler, so it + ;; needs to be told where to find the crt files and + ;; the dynamic linker. + (call-with-output-file program + (lambda (p) + (format p "#!~a/bin/bash exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%" - bash - gcc triplet program - libc libc - ,(glibc-dynamic-linker)))) - - (chmod program #o555)) - - (mkdir-p bindir) - (with-directory-excursion bindir - (for-each (lambda (tool) - (symlink (string-append binutils "/bin/" - triplet "-" tool) - tool)) - '("ar" "ranlib")) - (for-each wrap-program '("gcc" "g++"))))))) + bash + gcc triplet program + libc libc + #$(glibc-dynamic-linker)))) + + (chmod program #o555)) + + (mkdir-p bindir) + (with-directory-excursion bindir + (for-each (lambda (tool) + (symlink (string-append binutils "/bin/" + triplet "-" tool) + tool)) + '("ar" "ranlib")) + (for-each wrap-program '("gcc" "g++"))))))) (native-inputs `(("binutils" ,binutils) ("gcc" ,gcc) @@ -3122,79 +3124,80 @@ (define gcc-final (outputs (delete "debug" (package-outputs gcc-boot0))) (arguments - `(#:guile ,%bootstrap-guile - #:implicit-inputs? #f + (cons* + #:guile %bootstrap-guile + #:implicit-inputs? #f - #:allowed-references ("out" "lib" ,zlib-final + #:allowed-references `("out" "lib" ,zlib-final ,glibc-final ,static-bash-for-glibc) - ;; Things like libasan.so and libstdc++.so NEED ld.so for some - ;; reason, but it is not in their RUNPATH. This is a false - ;; positive, so turn it off. - #:validate-runpath? #f + ;; Things like libasan.so and libstdc++.so NEED ld.so for some + ;; reason, but it is not in their RUNPATH. This is a false + ;; positive, so turn it off. + #:validate-runpath? #f - ;; Additional modules for the libstdc++ phase below. - #:modules ((srfi srfi-1) + ;; Additional modules for the libstdc++ phase below. + #:modules `((srfi srfi-1) (srfi srfi-26) ,@%gnu-build-system-modules) - ,@(substitute-keyword-arguments (package-arguments gcc) - ((#:make-flags flags) - ;; Since $LIBRARY_PATH is not honored, add the relevant flags. - `(let ((zlib (assoc-ref %build-inputs "zlib"))) - (map (lambda (flag) - (if (string-prefix? "LDFLAGS=" flag) - (string-append flag " -L" - (assoc-ref %build-inputs "libstdc++") - "/lib -L" zlib "/lib -Wl,-rpath=" - zlib "/lib") - flag)) - ,flags))) - ;; Build again GMP & co. within GCC's build process, because it's hard - ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus - ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) - ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'unpack-gmp&co - (lambda* (#:key inputs #:allow-other-keys) - (let ((gmp (assoc-ref %build-inputs "gmp-source")) - (mpfr (assoc-ref %build-inputs "mpfr-source")) - (mpc (assoc-ref %build-inputs "mpc-source"))) - - ;; To reduce the set of pre-built bootstrap inputs, build - ;; GMP & co. from GCC. - (for-each (lambda (source) - (invoke "tar" "xvf" source)) - (list gmp mpfr mpc)) - - ;; Create symlinks like `gmp' -> `gmp-x.y.z'. - ,@(map (lambda (lib) - ;; Drop trailing letters, as gmp-6.0.0a unpacks - ;; into gmp-6.0.0. - `(symlink ,(string-trim-right + (substitute-keyword-arguments (package-arguments gcc) + ((#:make-flags flags) + ;; Since $LIBRARY_PATH is not honored, add the relevant flags. + #~(let ((zlib (assoc-ref %build-inputs "zlib"))) + (map (lambda (flag) + (if (string-prefix? "LDFLAGS=" flag) + (string-append flag " -L" + (assoc-ref %build-inputs "libstdc++") + "/lib -L" zlib "/lib -Wl,-rpath=" + zlib "/lib") + flag)) + #$flags))) + ;; Build again GMP & co. within GCC's build process, because it's hard + ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus + ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) + ((#:phases phases) + #~(modify-phases #$phases + (add-after 'unpack 'unpack-gmp&co + (lambda* (#:key inputs #:allow-other-keys) + (let ((gmp (assoc-ref %build-inputs "gmp-source")) + (mpfr (assoc-ref %build-inputs "mpfr-source")) + (mpc (assoc-ref %build-inputs "mpc-source"))) + + ;; To reduce the set of pre-built bootstrap inputs, build + ;; GMP & co. from GCC. + (for-each (lambda (source) + (invoke "tar" "xvf" source)) + (list gmp mpfr mpc)) + + ;; Create symlinks like `gmp' -> `gmp-x.y.z'. + #$@(map (lambda (lib) + ;; Drop trailing letters, as gmp-6.0.0a unpacks + ;; into gmp-6.0.0. + #~(symlink #$(string-trim-right (package-full-name lib "-") char-set:letter) - ,(package-name lib))) - (list gmp-6.0 mpfr mpc))))) - (add-after 'unpack 'fix-build-with-external-libstdc++ - (lambda* (#:key inputs #:allow-other-keys) - (let ((libstdc++ (assoc-ref inputs "libstdc++"))) - ;; Fix a regression in GCC 11 where the libstc++ input - ;; 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 - ;; . - (substitute* "libstdc++-v3/src/c++17/Makefile.in" - (("AM_CXXFLAGS = ") - (string-append "CPLUS_INCLUDE_PATH = " - (string-join - (remove (cut string-prefix? libstdc++ <>) - (string-split - (getenv "CPLUS_INCLUDE_PATH") - #\:)) - ":") - "\nAM_CXXFLAGS = "))))))))))) + #$(package-name lib))) + (list gmp-6.0 mpfr mpc))))) + (add-after 'unpack 'fix-build-with-external-libstdc++ + (lambda* (#:key inputs #:allow-other-keys) + (let ((libstdc++ (assoc-ref inputs "libstdc++"))) + ;; Fix a regression in GCC 11 where the libstc++ input + ;; 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 + ;; . + (substitute* "libstdc++-v3/src/c++17/Makefile.in" + (("AM_CXXFLAGS = ") + (string-append "CPLUS_INCLUDE_PATH = " + (string-join + (remove (cut string-prefix? libstdc++ <>) + (string-split + (getenv "CPLUS_INCLUDE_PATH") + #\:)) + ":") + "\nAM_CXXFLAGS = "))))))))))) ;; This time we want Texinfo, so we get the manual. Add ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index fade5bb64b..d1c79b8dc2 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -864,62 +864,63 @@ (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 = "))))))) - '()) - ,@(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 _ - (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" + #: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 = "))))))) + '()) + #$@(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 _ + (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")))) base-commit: 40d6615ca2755605e8aab790fbbae0221ec1d827 -- 2.39.1 From unknown Sat Jun 21 03:28:33 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Christopher Baines Subject: bug#63329: closed (Re: [bug#63329] [PATCH v2] gnu: Use gexps for gcc-boot0 and related packages.) Message-ID: References: <878re01qk1.fsf@cbaines.net> <54e8a32abd9f31253787d5997dbed172d794024f.1683379349.git.mail@cbaines.net> X-Gnu-PR-Message: they-closed 63329 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 63329@debbugs.gnu.org Date: Sun, 07 May 2023 08:42:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1683448922-12082-1" This is a multi-part message in MIME format... ------------=_1683448922-12082-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #63329: [PATCH] gnu: Use gexps for gcc-boot0 and related packages. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 63329@debbugs.gnu.org. --=20 63329: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D63329 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1683448922-12082-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 63329-done) by debbugs.gnu.org; 7 May 2023 08:42:01 +0000 Received: from localhost ([127.0.0.1]:36380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvZxw-00038f-P8 for submit@debbugs.gnu.org; Sun, 07 May 2023 04:42:01 -0400 Received: from mira.cbaines.net ([212.71.252.8]:42500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvZxr-00038T-0I for 63329-done@debbugs.gnu.org; Sun, 07 May 2023 04:41:58 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id C65C427BBE2 for <63329-done@debbugs.gnu.org>; Sun, 7 May 2023 09:41:53 +0100 (BST) Received: from felis (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 81021e00 for <63329-done@debbugs.gnu.org>; Sun, 7 May 2023 08:41:53 +0000 (UTC) References: <54e8a32abd9f31253787d5997dbed172d794024f.1683379349.git.mail@cbaines.net> <7c5922aed25834bcc4cfd248a5107960f3700ae2.1683408750.git.mail@cbaines.net> User-agent: mu4e 1.8.13; emacs 28.2 From: Christopher Baines To: 63329-done@debbugs.gnu.org Subject: Re: [bug#63329] [PATCH v2] gnu: Use gexps for gcc-boot0 and related packages. Date: Sun, 07 May 2023 09:39:09 +0100 In-reply-to: <7c5922aed25834bcc4cfd248a5107960f3700ae2.1683408750.git.mail@cbaines.net> Message-ID: <878re01qk1.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 63329-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Christopher Baines writes: > There are currently problems with native or cross building for i586-gnu, and > one factor mixed up with this is that some of the gcc packages use sexp's for > the phases, and thus introducing gexp's has caused problems. > > As part of the going in circles with this, this commit switches gcc-boot0 to > use gexp's in it's arguments, and then also modifies libstdc++-boot0, > libstdc++-boot0-gcc7, cross-gcc-wrapper, gcc-final and make-libstdc++ to > handle this change. > > If done correctly, this change shouldn't affect any derivations. > > * gnu/packages/commencement.scm (libstdc++-boot0, libstdc++-boot0-gcc7, > gcc-boot0, gcc-final)[arguments]: Use gexps. > (cross-gcc-wrapper): Use gexps in the generated package. > * gnu/packages/gcc.scm (make-libstdc++): Use gexps in the generated package. > --- > gnu/packages/commencement.scm | 421 +++++++++++++++++----------------- > gnu/packages/gcc.scm | 109 ++++----- > 2 files changed, 267 insertions(+), 263 deletions(-) The data service didn't show any changes in derivations associated with this change, so I've gone ahead and pushed it to master as a795a02a9d988be5a762886620f7bb6a95e7ffdb. It did show some changes, but they related to gexp's in the builder script for icu4c-70 when built for riscv64. I fixed that in b1e9ae7f0e72bc3c8c7ab28362315fac5dfb65fe. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmRXZE5fFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh aW5lcy5uZXQACgkQXiijOwuE9Xc0eA//eRaKz1cdrwgqHGaMovSGReEToiaW2+1q 9JermCv86rC/UFxh00thnqVUGmhoey+WxplPHUa86Mtj6J/1ZShIQ5SE/7Znebh3 IbwypGF35tg4t7Gu4M+hcWh23/IAqI0Qe9BK8jURA0xJC1eJU/5a3JS7LSFwY5Nt IrdRqbN2ldVn7i34XtDRYUSBxfBFghugjtwWX+bDDZ/XRyh4jIHFdMlTB3Ku8c7l SKh8eniyDgjz6xic1rgNB1tWCdtKwDkNIWDJabXssLnv0/ofumL5WFSUpSuTfGMX npLC18V2foogEeEIu1c4KlmAQbpHw4btA5bcvdCX/pfFIVZ/g8acyv6aXpDnAo7G ZZVpM9zPBC5ua5qHIPkQVJbhJQRfeCLeVqTEiQI9ri+KY0h9ZfecVh9dxyFN0tsp yaaGOCbcsYtn3uthbgZpuYBbvo2esoWqFgmXmsRtIMCEzIwFEAAkKhF3+3PxbkiC Ve2Q98//WHJepXfcA1fAzaZDl5Gc6wFof+yqoEFiJceLXHP+ky8MO46zHtA2N4KL g3MvYvkABepu/JzRMpuDiwzcO2b0NKR6CSTTxxxI7JPjMkPzx9ga0YhKzyy7RUkT Hy6tnRotK5JYy2EtmR+vUHOQAg/k5oRRQ4k8LEz+OKBz931G8LHTtGzi+oU7nyrw PcVNAyQmALM= =qQG3 -----END PGP SIGNATURE----- --=-=-=-- ------------=_1683448922-12082-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 May 2023 13:22:49 +0000 Received: from localhost ([127.0.0.1]:59688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvHs8-0008Ey-1U for submit@debbugs.gnu.org; Sat, 06 May 2023 09:22:49 -0400 Received: from lists.gnu.org ([209.51.188.17]:55158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvHs2-0008Eh-0R for submit@debbugs.gnu.org; Sat, 06 May 2023 09:22:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pvHry-0001Nk-Fq for guix-patches@gnu.org; Sat, 06 May 2023 09:22:39 -0400 Received: from mira.cbaines.net ([212.71.252.8]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pvHrs-000533-QT for guix-patches@gnu.org; Sat, 06 May 2023 09:22:37 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id 8683E27BBE2 for ; Sat, 6 May 2023 14:22:30 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 8117863e for ; Sat, 6 May 2023 13:22:29 +0000 (UTC) From: Christopher Baines To: guix-patches@gnu.org Subject: [PATCH] gnu: Use gexps for gcc-boot0 and related packages. Date: Sat, 6 May 2023 14:22:29 +0100 Message-Id: <54e8a32abd9f31253787d5997dbed172d794024f.1683379349.git.mail@cbaines.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=212.71.252.8; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) There are currently problems with native or cross building for i586-gnu, and one factor mixed up with this is that some of the gcc packages use sexp's for the phases, and thus introducing gexp's has caused problems. As part of the going in circles with this, this commit switches gcc-boot0 to use gexp's in it's arguments, and then also modifies libstdc++-boot0, cross-gcc-wrapper, gcc-final and make-libstdc++ to handle this change. If done correctly, this change shouldn't affect any derivations. * gnu/packages/commencement.scm (libstdc++-boot0, gcc-boot0, gcc-final)[arguments]: Use gexps. (cross-gcc-wrapper): Use gexps in the generated package. * gnu/packages/gcc.scm (make-libstdc++): Use gexps in the generated package. --- gnu/packages/commencement.scm | 377 +++++++++++++++++----------------- gnu/packages/gcc.scm | 109 +++++----- 2 files changed, 245 insertions(+), 241 deletions(-) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index fc1c508b38..5e47b272e4 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -2259,13 +2259,13 @@ (define libstdc++-boot0 ((or "i686-linux" "x86_64-linux") (substitute-keyword-arguments (package-arguments lib) ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'workaround-wrapper-bug - ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to - ;; fail, which in turn confuses the configure script. - (lambda _ - (substitute* "libstdc++-v3/configure" - (("g\\+\\+ -v") "true")))))))) + #~(modify-phases #$phases + (add-after 'unpack 'workaround-wrapper-bug + ;; XXX: The crude gcc-cross-wrapper causes "g++ -v" to + ;; fail, which in turn confuses the configure script. + (lambda _ + (substitute* "libstdc++-v3/configure" + (("g\\+\\+ -v") "true")))))))) (_ (package-arguments lib))) ;; Explicitly add #:modules so MAKE-LIBSTDC++ can be changed @@ -2338,81 +2338,82 @@ (define gcc-boot0 (system* #$(file-append coreutils-boot0 "/bin/rm") "-rf" "gcc/testsuite/go.test/test/fixedbugs/issue27836.dir")))))) (arguments - `(#:guile ,%bootstrap-guile - #:implicit-inputs? #f - #:modules ((guix build gnu-build-system) + (cons* + #:guile %bootstrap-guile + #:implicit-inputs? #f + #:modules '((guix build gnu-build-system) (guix build utils) (ice-9 regex) (srfi srfi-1) (srfi srfi-26)) - ,@(substitute-keyword-arguments (package-arguments gcc) - ((#:configure-flags flags) - `(append (list ,(string-append "--target=" (boot-triplet)) - - ;; No libc yet. - "--without-headers" - - ;; Disable features not needed at this stage. - "--disable-shared" - "--enable-languages=c,c++" - - ;; libstdc++ cannot be built at this stage - ;; ("Link tests are not allowed after - ;; GCC_NO_EXECUTABLES."). - "--disable-libstdc++-v3" - - "--disable-threads" - "--disable-libmudflap" - "--disable-libatomic" - "--disable-libsanitizer" - "--disable-libitm" - "--disable-libgomp" - "--disable-libmpx" - "--disable-libcilkrts" - "--disable-libvtv" - "--disable-libssp" - "--disable-libquadmath" - "--disable-decimal-float") - (remove (cut string-match - "--(with-system-zlib|enable-languages.*)" <>) - ,flags))) - ((#:make-flags flags) - `(let* ((libc (assoc-ref %build-inputs "libc")) - (libc-native (or (assoc-ref %build-inputs "libc-native") - libc))) - `(,(string-append "LDFLAGS=" - "-Wl,-rpath=" libc-native "/lib " - "-Wl,-dynamic-linker " - "-Wl," libc-native ,(glibc-dynamic-linker - (match (%current-system) - ("x86_64-linux" "i686-linux") - (_ (%current-system)))))))) - ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'unpack-gmp&co - (lambda* (#:key inputs #:allow-other-keys) - (let ((gmp (assoc-ref %build-inputs "gmp-source")) - (mpfr (assoc-ref %build-inputs "mpfr-source")) - (mpc (assoc-ref %build-inputs "mpc-source"))) - - ;; To reduce the set of pre-built bootstrap inputs, build - ;; GMP & co. from GCC. - (for-each (lambda (source) - (invoke "tar" "xvf" source)) - (list gmp mpfr mpc)) - - ;; Create symlinks like `gmp' -> `gmp-x.y.z'. - ,@(map (lambda (lib) - ;; Drop trailing letters, as gmp-6.0.0a unpacks - ;; into gmp-6.0.0. - `(symlink ,(string-trim-right - (package-full-name lib "-") - char-set:letter) - ,(package-name lib))) - (list gmp-6.0 mpfr mpc))))) - ,(match (%current-system) - ((or "i686-linux" "x86_64-linux") - '(add-before 'configure 'fix-libcc1 + (substitute-keyword-arguments (package-arguments gcc) + ((#:configure-flags flags) + #~(append (list #$(string-append "--target=" (boot-triplet)) + + ;; No libc yet. + "--without-headers" + + ;; Disable features not needed at this stage. + "--disable-shared" + "--enable-languages=c,c++" + + ;; libstdc++ cannot be built at this stage + ;; ("Link tests are not allowed after + ;; GCC_NO_EXECUTABLES."). + "--disable-libstdc++-v3" + + "--disable-threads" + "--disable-libmudflap" + "--disable-libatomic" + "--disable-libsanitizer" + "--disable-libitm" + "--disable-libgomp" + "--disable-libmpx" + "--disable-libcilkrts" + "--disable-libvtv" + "--disable-libssp" + "--disable-libquadmath" + "--disable-decimal-float") + (remove (cut string-match + "--(with-system-zlib|enable-languages.*)" <>) + #$flags))) + ((#:make-flags flags) + `(let* ((libc (assoc-ref %build-inputs "libc")) + (libc-native (or (assoc-ref %build-inputs "libc-native") + libc))) + `(,(string-append "LDFLAGS=" + "-Wl,-rpath=" libc-native "/lib " + "-Wl,-dynamic-linker " + "-Wl," libc-native ,(glibc-dynamic-linker + (match (%current-system) + ("x86_64-linux" "i686-linux") + (_ (%current-system)))))))) + ((#:phases phases) + #~(modify-phases #$phases + (add-after 'unpack 'unpack-gmp&co + (lambda* (#:key inputs #:allow-other-keys) + (let ((gmp (assoc-ref %build-inputs "gmp-source")) + (mpfr (assoc-ref %build-inputs "mpfr-source")) + (mpc (assoc-ref %build-inputs "mpc-source"))) + + ;; To reduce the set of pre-built bootstrap inputs, build + ;; GMP & co. from GCC. + (for-each (lambda (source) + (invoke "tar" "xvf" source)) + (list gmp mpfr mpc)) + + ;; Create symlinks like `gmp' -> `gmp-x.y.z'. + #$@(map (lambda (lib) + ;; Drop trailing letters, as gmp-6.0.0a unpacks + ;; into gmp-6.0.0. + #~(symlink #$(string-trim-right + (package-full-name lib "-") + char-set:letter) + #$(package-name lib))) + (list gmp-6.0 mpfr mpc))))) + #$(match (%current-system) + ((or "i686-linux" "x86_64-linux") + #~(add-before 'configure 'fix-libcc1 (lambda* (#:key inputs #:allow-other-keys) ;; libcc1.so NEEDs libgcc_s.so, so provide one here ;; to placate the 'validate-runpath' phase. @@ -2423,18 +2424,18 @@ (define gcc-boot0 ;; XXX: "g++ -v" is broken (see also libstdc++ above). (substitute* "libcc1/configure" (("g\\+\\+ -v") "true"))))) - (_ '(add-before 'configure 'return-true + (_ #~(add-before 'configure 'return-true (lambda _ #t)))) - (add-after 'install 'symlink-libgcc_eh - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "lib"))) - ;; Glibc wants to link against libgcc_eh, so provide - ;; it. - (with-directory-excursion - (string-append out "/lib/gcc/" - ,(boot-triplet) - "/" ,(package-version gcc)) - (symlink "libgcc.a" "libgcc_eh.a")))))))))) + (add-after 'install 'symlink-libgcc_eh + (lambda* (#:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "lib"))) + ;; Glibc wants to link against libgcc_eh, so provide + ;; it. + (with-directory-excursion + (string-append out "/lib/gcc/" + #$(boot-triplet) + "/" #$(package-version gcc)) + (symlink "libgcc.a" "libgcc_eh.a")))))))))) (inputs `(("gmp-source" ,(bootstrap-origin (package-source gmp-6.0))) ("mpfr-source" ,(bootstrap-origin (package-source mpfr))) @@ -2888,41 +2889,42 @@ (define (cross-gcc-wrapper gcc binutils glibc bash) (build-system trivial-build-system) (outputs '("out")) (arguments - `(#:guile ,%bootstrap-guile - #:modules ((guix build utils)) - #:builder (begin - (use-modules (guix build utils)) - - (let* ((binutils (assoc-ref %build-inputs "binutils")) - (gcc (assoc-ref %build-inputs "gcc")) - (libc (assoc-ref %build-inputs "libc")) - (bash (assoc-ref %build-inputs "bash")) - (out (assoc-ref %outputs "out")) - (bindir (string-append out "/bin")) - (triplet ,(boot-triplet))) - (define (wrap-program program) - ;; GCC-BOOT0 is a libc-less cross-compiler, so it - ;; needs to be told where to find the crt files and - ;; the dynamic linker. - (call-with-output-file program - (lambda (p) - (format p "#!~a/bin/bash + (list + #:guile %bootstrap-guile + #:modules '((guix build utils)) + #:builder #~(begin + (use-modules (guix build utils)) + + (let* ((binutils (assoc-ref %build-inputs "binutils")) + (gcc (assoc-ref %build-inputs "gcc")) + (libc (assoc-ref %build-inputs "libc")) + (bash (assoc-ref %build-inputs "bash")) + (out (assoc-ref %outputs "out")) + (bindir (string-append out "/bin")) + (triplet #$(boot-triplet))) + (define (wrap-program program) + ;; GCC-BOOT0 is a libc-less cross-compiler, so it + ;; needs to be told where to find the crt files and + ;; the dynamic linker. + (call-with-output-file program + (lambda (p) + (format p "#!~a/bin/bash exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%" - bash - gcc triplet program - libc libc - ,(glibc-dynamic-linker)))) - - (chmod program #o555)) - - (mkdir-p bindir) - (with-directory-excursion bindir - (for-each (lambda (tool) - (symlink (string-append binutils "/bin/" - triplet "-" tool) - tool)) - '("ar" "ranlib")) - (for-each wrap-program '("gcc" "g++"))))))) + bash + gcc triplet program + libc libc + #$(glibc-dynamic-linker)))) + + (chmod program #o555)) + + (mkdir-p bindir) + (with-directory-excursion bindir + (for-each (lambda (tool) + (symlink (string-append binutils "/bin/" + triplet "-" tool) + tool)) + '("ar" "ranlib")) + (for-each wrap-program '("gcc" "g++"))))))) (native-inputs `(("binutils" ,binutils) ("gcc" ,gcc) @@ -3122,79 +3124,80 @@ (define gcc-final (outputs (delete "debug" (package-outputs gcc-boot0))) (arguments - `(#:guile ,%bootstrap-guile - #:implicit-inputs? #f + (cons* + #:guile %bootstrap-guile + #:implicit-inputs? #f - #:allowed-references ("out" "lib" ,zlib-final + #:allowed-references `("out" "lib" ,zlib-final ,glibc-final ,static-bash-for-glibc) - ;; Things like libasan.so and libstdc++.so NEED ld.so for some - ;; reason, but it is not in their RUNPATH. This is a false - ;; positive, so turn it off. - #:validate-runpath? #f + ;; Things like libasan.so and libstdc++.so NEED ld.so for some + ;; reason, but it is not in their RUNPATH. This is a false + ;; positive, so turn it off. + #:validate-runpath? #f - ;; Additional modules for the libstdc++ phase below. - #:modules ((srfi srfi-1) + ;; Additional modules for the libstdc++ phase below. + #:modules `((srfi srfi-1) (srfi srfi-26) ,@%gnu-build-system-modules) - ,@(substitute-keyword-arguments (package-arguments gcc) - ((#:make-flags flags) - ;; Since $LIBRARY_PATH is not honored, add the relevant flags. - `(let ((zlib (assoc-ref %build-inputs "zlib"))) - (map (lambda (flag) - (if (string-prefix? "LDFLAGS=" flag) - (string-append flag " -L" - (assoc-ref %build-inputs "libstdc++") - "/lib -L" zlib "/lib -Wl,-rpath=" - zlib "/lib") - flag)) - ,flags))) - ;; Build again GMP & co. within GCC's build process, because it's hard - ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus - ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) - ((#:phases phases) - `(modify-phases ,phases - (add-after 'unpack 'unpack-gmp&co - (lambda* (#:key inputs #:allow-other-keys) - (let ((gmp (assoc-ref %build-inputs "gmp-source")) - (mpfr (assoc-ref %build-inputs "mpfr-source")) - (mpc (assoc-ref %build-inputs "mpc-source"))) - - ;; To reduce the set of pre-built bootstrap inputs, build - ;; GMP & co. from GCC. - (for-each (lambda (source) - (invoke "tar" "xvf" source)) - (list gmp mpfr mpc)) - - ;; Create symlinks like `gmp' -> `gmp-x.y.z'. - ,@(map (lambda (lib) - ;; Drop trailing letters, as gmp-6.0.0a unpacks - ;; into gmp-6.0.0. - `(symlink ,(string-trim-right + (substitute-keyword-arguments (package-arguments gcc) + ((#:make-flags flags) + ;; Since $LIBRARY_PATH is not honored, add the relevant flags. + #~(let ((zlib (assoc-ref %build-inputs "zlib"))) + (map (lambda (flag) + (if (string-prefix? "LDFLAGS=" flag) + (string-append flag " -L" + (assoc-ref %build-inputs "libstdc++") + "/lib -L" zlib "/lib -Wl,-rpath=" + zlib "/lib") + flag)) + #$flags))) + ;; Build again GMP & co. within GCC's build process, because it's hard + ;; to do outside (because GCC-BOOT0 is a cross-compiler, and thus + ;; doesn't honor $LIBRARY_PATH, which breaks `gnu-build-system'.) + ((#:phases phases) + #~(modify-phases #$phases + (add-after 'unpack 'unpack-gmp&co + (lambda* (#:key inputs #:allow-other-keys) + (let ((gmp (assoc-ref %build-inputs "gmp-source")) + (mpfr (assoc-ref %build-inputs "mpfr-source")) + (mpc (assoc-ref %build-inputs "mpc-source"))) + + ;; To reduce the set of pre-built bootstrap inputs, build + ;; GMP & co. from GCC. + (for-each (lambda (source) + (invoke "tar" "xvf" source)) + (list gmp mpfr mpc)) + + ;; Create symlinks like `gmp' -> `gmp-x.y.z'. + #$@(map (lambda (lib) + ;; Drop trailing letters, as gmp-6.0.0a unpacks + ;; into gmp-6.0.0. + #~(symlink #$(string-trim-right (package-full-name lib "-") char-set:letter) - ,(package-name lib))) - (list gmp-6.0 mpfr mpc))))) - (add-after 'unpack 'fix-build-with-external-libstdc++ - (lambda* (#:key inputs #:allow-other-keys) - (let ((libstdc++ (assoc-ref inputs "libstdc++"))) - ;; Fix a regression in GCC 11 where the libstc++ input - ;; 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 - ;; . - (substitute* "libstdc++-v3/src/c++17/Makefile.in" - (("AM_CXXFLAGS = ") - (string-append "CPLUS_INCLUDE_PATH = " - (string-join - (remove (cut string-prefix? libstdc++ <>) - (string-split - (getenv "CPLUS_INCLUDE_PATH") - #\:)) - ":") - "\nAM_CXXFLAGS = "))))))))))) + #$(package-name lib))) + (list gmp-6.0 mpfr mpc))))) + (add-after 'unpack 'fix-build-with-external-libstdc++ + (lambda* (#:key inputs #:allow-other-keys) + (let ((libstdc++ (assoc-ref inputs "libstdc++"))) + ;; Fix a regression in GCC 11 where the libstc++ input + ;; 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 + ;; . + (substitute* "libstdc++-v3/src/c++17/Makefile.in" + (("AM_CXXFLAGS = ") + (string-append "CPLUS_INCLUDE_PATH = " + (string-join + (remove (cut string-prefix? libstdc++ <>) + (string-split + (getenv "CPLUS_INCLUDE_PATH") + #\:)) + ":") + "\nAM_CXXFLAGS = "))))))))))) ;; This time we want Texinfo, so we get the manual. Add ;; STATIC-BASH-FOR-GLIBC so that it's used in the final shebangs of diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index fade5bb64b..d1c79b8dc2 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -864,62 +864,63 @@ (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 = "))))))) - '()) - ,@(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 _ - (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" + #: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 = "))))))) + '()) + #$@(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 _ + (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")))) base-commit: 40d6615ca2755605e8aab790fbbae0221ec1d827 -- 2.39.1 ------------=_1683448922-12082-1-- From unknown Sat Jun 21 03:28:33 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#63329] [PATCH] gnu: Use gexps for gcc-boot0 and related packages. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 07 May 2023 21:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63329 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Christopher Baines Cc: 63329@debbugs.gnu.org Received: via spool by 63329-submit@debbugs.gnu.org id=B63329.168349486718552 (code B ref 63329); Sun, 07 May 2023 21:28:02 +0000 Received: (at 63329) by debbugs.gnu.org; 7 May 2023 21:27:47 +0000 Received: from localhost ([127.0.0.1]:38623 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvlv0-0004pA-RQ for submit@debbugs.gnu.org; Sun, 07 May 2023 17:27:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48408) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvluu-0004or-OJ for 63329@debbugs.gnu.org; Sun, 07 May 2023 17:27:45 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pvlup-0005f5-I7; Sun, 07 May 2023 17:27:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=hSUoR8BiAvIWzflPGdvlnl4klGuzMv+7kGyWkdPFTms=; b=BKL8e36de4J+8g6hjX3V s9CtdIOIoS+Y94TaPpihfDuRB1j7Lll1zO68RlgUCpUcd9O6coh471ztZ3gxaKwDkIRfLyafTPnSn OoXbhahLh7SRAW3vDmAtQ9XulrNPT+PEk+t5MBHO3DnjwDMZUXqLrV6qmhKvNGZos3ZTKFeHVgMsp RrvsbSmsLcc3oDYGAmLtDhERCeyYjoHSqcpbpcou/MfczY15wgaecWRB4gC8ZF9PQXYqDAJdvOoFj LgxAvzXNkkfTV3djy6SJqkjAQt2qY7a5coIINvX5DG4MSIVeJZsfT4duW0v+4iPPthp9Xkocz6IBp c+G1VBstb8yBuQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pvlup-0003aY-4g; Sun, 07 May 2023 17:27:35 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <54e8a32abd9f31253787d5997dbed172d794024f.1683379349.git.mail@cbaines.net> <7c5922aed25834bcc4cfd248a5107960f3700ae2.1683408750.git.mail@cbaines.net> Date: Sun, 07 May 2023 23:27:33 +0200 In-Reply-To: <7c5922aed25834bcc4cfd248a5107960f3700ae2.1683408750.git.mail@cbaines.net> (Christopher Baines's message of "Sat, 6 May 2023 22:32:30 +0100") Message-ID: <87y1lzg7cq.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Christopher Baines skribis: > There are currently problems with native or cross building for i586-gnu, = and > one factor mixed up with this is that some of the gcc packages use sexp's= for > the phases, and thus introducing gexp's has caused problems. > > As part of the going in circles with this, this commit switches gcc-boot0= to > use gexp's in it's arguments, and then also modifies libstdc++-boot0, > libstdc++-boot0-gcc7, cross-gcc-wrapper, gcc-final and make-libstdc++ to > handle this change. > > If done correctly, this change shouldn't affect any derivations. > > * gnu/packages/commencement.scm (libstdc++-boot0, libstdc++-boot0-gcc7, > gcc-boot0, gcc-final)[arguments]: Use gexps. > (cross-gcc-wrapper): Use gexps in the generated package. > * gnu/packages/gcc.scm (make-libstdc++): Use gexps in the generated packa= ge. I=E2=80=99m late to the party, but I think it goes in the right direction. Thank you! Ludo=E2=80=99.