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
This commit is contained in:
Ekaitz Zarraga 2024-10-09 19:58:14 +03:00 committed by Efraim Flashner
parent 8157a90e63
commit 7b89213276
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351
3 changed files with 90 additions and 0 deletions

View file

@ -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 \

View file

@ -1967,6 +1967,64 @@ (define musl-boot
(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))))

View file

@ -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"