guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

40/87: gnu: Add gcc-muslboot.


From: guix-commits
Subject: 40/87: gnu: Add gcc-muslboot.
Date: Mon, 13 Jan 2025 04:37:26 -0500 (EST)

efraim pushed a commit to branch wip-riscv-bootstrap
in repository guix.

commit 7b8921327676ca2110453244cfcc8446dde8a2f3
Author: Ekaitz Zarraga <ekaitz@elenq.tech>
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 <efraim@flashner.co.il>
    Change-Id: Ic31754a13fe81631bea8fbc61e6f4af82e105d11
---
 gnu/local.mk                                       |  1 +
 gnu/packages/commencement.scm                      | 58 ++++++++++++++++++++++
 .../gcc-boot-4.6.4-riscv64-libstdc++-support.patch | 31 ++++++++++++
 3 files changed, 90 insertions(+)

diff --git a/gnu/local.mk b/gnu/local.mk
index b8f85e3f80..e6dd56e9c3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1344,6 +1344,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 e1a48b5afb..11c806b750 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -1967,6 +1967,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"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]