guix_mirror_bot pushed a commit to branch wip-riscv-bootstrap in repository guix.
commit b76231de3869ec7b97b010e7b901d30c27709321 Author: Ekaitz Zarraga <[email protected]> AuthorDate: Wed Oct 9 19:58:14 2024 +0300 gnu: Add gcc-muslboot. * gnu/packages/commencement.scm (gcc-muslboot): New variable. * gnu/packages/patches/gcc-boot-4.6.4-riscv64-libstdc++-support.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. Co-authored-by: Efraim Flashner <[email protected]> Change-Id: Ic31754a13fe81631bea8fbc61e6f4af82e105d11 --- gnu/local.mk | 1 + gnu/packages/commencement.scm | 63 +++++++++++++++++++++- .../gcc-boot-4.6.4-riscv64-libstdc++-support.patch | 31 +++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/gnu/local.mk b/gnu/local.mk index a0705ca804..8019706866 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1356,6 +1356,7 @@ dist_patch_DATA = \ %D%/packages/patches/gcc-boot-2.95.3.patch \ %D%/packages/patches/gcc-boot-4.6.4.patch \ %D%/packages/patches/gcc-boot-4.6.4-riscv64-support.patch \ + %D%/packages/patches/gcc-boot-4.6.4-riscv64-libstdc++-support.patch \ %D%/packages/patches/gcc-cross-environment-variables.patch \ %D%/packages/patches/gcc-cross-gxx-include-dir.patch \ %D%/packages/patches/gcc-fix-texi2pod.patch \ diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index e47aecc475..455c894ffd 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -1898,7 +1898,10 @@ ac_cv_c_float_format='IEEE (little-endian)' (add-before 'configure 'setenv (lambda _ (setenv "CC" "tcc") - (setenv "CFLAGS" "-D HAVE_ALLOCA_H")))))) + (setenv "CFLAGS" "-D HAVE_ALLOCA_H") + ;; We don't have an existing C++ compiler so we need to set + ;; the search path manually. + (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH"))))))) (native-search-paths (list (search-path-specification (variable "C_INCLUDE_PATH") @@ -1989,6 +1992,64 @@ ac_cv_c_float_format='IEEE (little-endian)' (symlink "libc.so" (string-append #$output #$(glibc-dynamic-linker))))))))))) +(define gcc-muslboot + ;; GCC 4.6.4 is the latest modular distribution. We backported RISC-V support + ;; here. + (package + (inherit gcc-muslboot0) + (name "gcc-muslboot") + (version "4.6.4") + (native-inputs + `(("gcc-g++" + ,(origin + (method url-fetch) + (uri (string-append "mirror://gnu/gcc/gcc-" + version "/gcc-g++-" version ".tar.gz")) + (sha256 + (base32 + "1fqqk5zkmdg4vmqzdmip9i42q6b82i3f6yc0n86n9021cr7ms2k9")))) + ,@(modify-inputs (%boot-tcc-musl-inputs) + (replace "gcc" gcc-muslboot0) + (replace "libc" musl-boot)))) + (arguments + (substitute-keyword-arguments (package-arguments gcc-muslboot0) + ((#:configure-flags configure-flags) + #~(let ((out (assoc-ref %outputs "out"))) + `("--enable-languages=c,c++" + ,(string-append "--with-gmp=" (assoc-ref %build-inputs "gmp-boot")) + ,(string-append "--with-mpfr=" (assoc-ref %build-inputs "mpfr-boot")) + ,(string-append "--with-mpc=" (assoc-ref %build-inputs "mpc-boot")) + ,@(filter + (negate (lambda (x) (string-prefix? "--enable-languages=" x))) + #$configure-flags)))) + ((#:phases phases) + #~(modify-phases #$phases + (add-before 'unpack 'unpack-g++ + (lambda _ + (let ((source-g++ (assoc-ref %build-inputs "gcc-g++"))) + (invoke "tar" "xvf" source-g++)))) + (add-after 'apply-riscv64-patch 'apply-second-riscv64-patch + (lambda* (#:key inputs #:allow-other-keys) + (let ((patch-file + #$(local-file + (search-patch + "gcc-boot-4.6.4-riscv64-libstdc++-support.patch")))) + (invoke "patch" "--force" "-p1" "-i" patch-file)))) + (replace 'setenv + (lambda _ + (setenv "CC" "musl-gcc") + (setenv "CPLUS_INCLUDE_PATH" (getenv "C_INCLUDE_PATH")))))))) + (native-search-paths + (list (search-path-specification + (variable "C_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CPLUS_INCLUDE_PATH") + (files '("include/c++" "include"))) + (search-path-specification + (variable "LIBRARY_PATH") + (files '("lib"))))))) + (define (%boot-mesboot2-inputs) `(("gcc" ,gcc-mesboot1) ,@(alist-delete "gcc" (%boot-mesboot1-inputs)))) diff --git a/gnu/packages/patches/gcc-boot-4.6.4-riscv64-libstdc++-support.patch b/gnu/packages/patches/gcc-boot-4.6.4-riscv64-libstdc++-support.patch new file mode 100644 index 0000000000..b6637d8f5c --- /dev/null +++ b/gnu/packages/patches/gcc-boot-4.6.4-riscv64-libstdc++-support.patch @@ -0,0 +1,31 @@ +This is part 2 of the diff between Ekaitz's branch and upstream's releases/gcc-4.6.4 branch. +It only contains the libstdc++ diff. + +diff --git a/libstdc++-v3/config/os/generic/os_defines.h b/libstdc++-v3/config/os/generic/os_defines.h +index 3199bf30bb3..b8d7c16361e 100644 +--- a/libstdc++-v3/config/os/generic/os_defines.h ++++ b/libstdc++-v3/config/os/generic/os_defines.h +@@ -33,4 +33,9 @@ + // System-specific #define, typedefs, corrections, etc, go here. This + // file will come before all others. + ++// Disable the weak reference logic in gthr.h for os/generic because it ++// is broken on every platform unless there is implementation specific ++// workaround in gthr-posix.h and at link-time for static linking. ++#define _GLIBCXX_GTHREAD_USE_WEAK 0 ++ + #endif +diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host +index e29404c026f..5bbeb7f3763 100644 +--- a/libstdc++-v3/configure.host ++++ b/libstdc++-v3/configure.host +@@ -236,6 +236,9 @@ case "${host_os}" in + freebsd*) + os_include_dir="os/bsd/freebsd" + ;; ++ linux-musl*) ++ os_include_dir="os/generic" ++ ;; + gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) + if [ "$uclibc" = "yes" ]; then + os_include_dir="os/uclibc"
