Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] Ldc cross compile
@ 2023-09-08 14:44 sgn
  2023-09-09  3:56 ` [PR PATCH] [Updated] " sgn
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: sgn @ 2023-09-08 14:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->
[ci skip][skip ci]
#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 76272 bytes --]

From 0c764a26945b226c36da9788f6b9bfca49ea6af2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 1/8] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..695668bc3ec81
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+homepage="http://gcc.gnu.org"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From 87f7b90d78f92070e435683b0fe1a6e122844cf4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 2/8] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From a39e90220af5179c536177716ae30d95521fe106 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 3/8] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From 3148e56606909d6199d1b9d657265b240aef3d30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 4/8] ldc: update to 1.34.0.

---
 common/shlibs                            |   7 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/target-runtime.patch |  23 ++++
 srcpkgs/ldc/template                     | 145 +++++++++++++++++++++--
 5 files changed, 165 insertions(+), 12 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 531b3345e230f..403d6dd4d27df 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2180,9 +2180,10 @@ libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
 libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.104 ldc-runtime-1.34.0_1
+libphobos2-ldc-shared.so.104 ldc-runtime-1.34.0_1
+libdruntime-ldc-debug-shared.so.104 ldc-runtime-debug-1.34.0_1
+libphobos2-ldc-debug-shared.so.104 ldc-runtime-debug-1.34.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..321be796f62b9
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,23 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -863,7 +863,7 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if(BUILD_LDC_RUNTIME AND EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..3f49038a4e643 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.34.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,10 +11,10 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
 checkdepends="python3"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
@@ -22,19 +22,146 @@ license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=3005c6e9c79258538c83979766767a59e3d74f3cb90ac2cb0dce5d7573beb719
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
 make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
 
-post_install() {
-	vlicense LICENSE
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-DBUILD_LDC_RUNTIME=OFF \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	_major=$(sed -nE 's/set\(DMDFE_MAJOR_VERSION[[:space:]]*([0-9]*)\)/\1/p' CMakeLists.txt)
+	_minor=$(sed -nE 's/set\(DMDFE_MINOR_VERSION[[:space:]]*([0-9]*)\)/\1/p' CMakeLists.txt)
+	_pver=$(sed -nE 's/set\(DMDFE_PATCH_VERSION[[:space:]]*([0-9]*)\)/\1/p' CMakeLists.txt)
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DBUILD_LDC_RUNTIME=ON"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From f8cc99f75f272d0c874d52d5595a5844dbdd0e72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 5/8] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From 37c85167d49ab0ba48f501a2a3b2acb367e548b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 6/8] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch      | 11 ++++
 srcpkgs/gtkd/patches/pkg-config.patch | 89 +++++++++++++++++++++++++++
 srcpkgs/gtkd/template                 | 17 ++---
 3 files changed, 110 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..0db1f9baa5fe3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,7 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,11 +20,14 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {

From 79635760c1eabd05edb46b1df0561ff23924728a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 7/8] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index e15249cbd7e3c..d250493c1596a 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,7 +1,7 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.23
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2"
 hostmakedepends="ldc pkg-config"

From ef2360a3f7644e4da7e904e17696a5d3af0bf1de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 8/8] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..77da7f7940caf 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,7 +1,7 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
@ 2023-09-09  3:56 ` sgn
  2023-10-23  7:53 ` sgn
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-09-09  3:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->
[ci skip][skip ci]
#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 77943 bytes --]

From 261b27322d9ff05a9ea18c9fe78b828d4bbf4e94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 1/8] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From 627a66713d5b80ca387e0140bb2756b2e4e3ece1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 2/8] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From abee6146f16b77b2c75933d66f0b603f25bdb04b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 3/8] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From 17561c64fd164aadbf862e7c9fc7b9d23e74af02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 4/8] ldc: update to 1.34.0.

---
 common/shlibs                            |   7 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  17 +++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 148 +++++++++++++++++++++--
 6 files changed, 188 insertions(+), 11 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 531b3345e230f..403d6dd4d27df 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2180,9 +2180,10 @@ libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
 libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.104 ldc-runtime-1.34.0_1
+libphobos2-ldc-shared.so.104 ldc-runtime-1.34.0_1
+libdruntime-ldc-debug-shared.so.104 ldc-runtime-debug-1.34.0_1
+libphobos2-ldc-debug-shared.so.104 ldc-runtime-debug-1.34.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..0763f147432fd
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,17 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,14 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++	file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++	_major=${DMDFE_MAJOR_VERSION}
++	_minor=${DMDFE_MINOR_VERSION}
++	_pver=${DMDFE_PATCH_VERSION}
++	")
++endif()
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..0f1e02c84d162 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.34.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,10 +11,10 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
 checkdepends="python3"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
@@ -22,19 +22,151 @@ license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=3005c6e9c79258538c83979766767a59e3d74f3cb90ac2cb0dce5d7573beb719
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
 make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-DXBPS_LDC_BOOTSTRAP=Yes \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From cad77e63d923a754c96bf578fbc558b2c08321d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 5/8] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From f41f6f88c2dd72da60e8682a4f2967a379843994 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 6/8] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch      | 11 ++++
 srcpkgs/gtkd/patches/pkg-config.patch | 89 +++++++++++++++++++++++++++
 srcpkgs/gtkd/template                 | 17 ++---
 3 files changed, 110 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..0db1f9baa5fe3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,7 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,11 +20,14 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {

From 462f194c018c8fbd1a09f410831f67d4ab28ac99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 7/8] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index e15249cbd7e3c..fcff3bcd17b4e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,11 +1,11 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.23
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -13,7 +13,11 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=fb57b9683302a53958671d1c74eb9b8f89ac229055647adce093e8a49ad846e0
-nocross="uses host flags for cross compilations"
+# nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From b75475450f0361d652e58bfcabd8959c8b1c9515 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 8/8] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..77da7f7940caf 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,7 +1,7 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
  2023-09-09  3:56 ` [PR PATCH] [Updated] " sgn
@ 2023-10-23  7:53 ` sgn
  2023-10-23 23:43 ` sgn
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-23  7:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 78125 bytes --]

From 8ac5877fc7213081839636ff9c4b5bf14baeface Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 1/8] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From cd5e76618c5cfe9e2e127f6c8d35cfa5473a4b83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 2/8] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From ba9ea9f4dfe7435039c6f5b3fe38ddf4a8965f8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 3/8] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From b0cae0d9655ba5dd95d512f1ad37e1310c651841 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 4/8] ldc: update to 1.34.0.

---
 common/shlibs                            |   7 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  17 +++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 148 +++++++++++++++++++++--
 6 files changed, 188 insertions(+), 11 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 185ba856d7e6c..08442c252a220 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2153,9 +2153,10 @@ libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
 libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.104 ldc-runtime-1.34.0_1
+libphobos2-ldc-shared.so.104 ldc-runtime-1.34.0_1
+libdruntime-ldc-debug-shared.so.104 ldc-runtime-debug-1.34.0_1
+libphobos2-ldc-debug-shared.so.104 ldc-runtime-debug-1.34.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..0763f147432fd
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,17 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,14 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++	file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++	_major=${DMDFE_MAJOR_VERSION}
++	_minor=${DMDFE_MINOR_VERSION}
++	_pver=${DMDFE_PATCH_VERSION}
++	")
++endif()
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..0f1e02c84d162 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.34.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,10 +11,10 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
 checkdepends="python3"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
@@ -22,19 +22,151 @@ license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=3005c6e9c79258538c83979766767a59e3d74f3cb90ac2cb0dce5d7573beb719
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
 make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-DXBPS_LDC_BOOTSTRAP=Yes \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From 2d538992b329f00bd620f8d710a29ac891915a90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 5/8] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From d5b02c39eff9c2131131b34d1397fa77f8d7dce0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 6/8] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch      | 11 ++++
 srcpkgs/gtkd/patches/pkg-config.patch | 89 +++++++++++++++++++++++++++
 srcpkgs/gtkd/template                 | 17 ++---
 3 files changed, 110 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..0db1f9baa5fe3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,7 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,11 +20,14 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {

From 2aad3f29515fce363dc0d0b5bc6309af172fb519 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 7/8] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index 019a89325aace..39234b85b4e9e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,14 +1,14 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.25
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2 --enable-notifications --enable-completions
  --with-bash-completion-dir=/usr/share/bash-completion/completions
  --with-zsh-completion-dir=/usr/share/zsh/site-functions
  --with-fish-completion-dir=/usr/share/fish/vendor_completions.d"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -16,7 +16,10 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=e7d782ea7d1973b6b578899a84c4f90ba69302263b4be30d80a363ba8ba27eb3
-nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From c2cae69ef48e51cc3862456bb67fc31cbc5418db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 8/8] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..77da7f7940caf 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,7 +1,7 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
  2023-09-09  3:56 ` [PR PATCH] [Updated] " sgn
  2023-10-23  7:53 ` sgn
@ 2023-10-23 23:43 ` sgn
  2023-10-23 23:43 ` sgn
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-23 23:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 83440 bytes --]

From f019c464185a18a3c5ba86f603b79539ebb7be5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:10 +0700
Subject: [PATCH 01/10] meson: fix for cross compiling with ldc

---
 srcpkgs/meson/patches/ldc.patch | 12 ++++++++++++
 srcpkgs/meson/template          |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/meson/patches/ldc.patch

diff --git a/srcpkgs/meson/patches/ldc.patch b/srcpkgs/meson/patches/ldc.patch
new file mode 100644
index 0000000000000..680495ce2818e
--- /dev/null
+++ b/srcpkgs/meson/patches/ldc.patch
@@ -0,0 +1,12 @@
+diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
+index 0bfedd13..cfe6edfc 100644
+--- a/mesonbuild/compilers/detect.py
++++ b/mesonbuild/compilers/detect.py
+@@ -1151,6 +1151,7 @@ def detect_d_compiler(env: 'Environment', for_machine: MachineChoice) -> Compile
+ 
+             return cls(
+                 exelist, version, for_machine, info, arch,
++                exe_wrapper=exe_wrap, is_cross=is_cross,
+                 full_version=full_version, linker=linker, version_output=out)
+         elif 'gdc' in out:
+             cls = d.GnuDCompiler
diff --git a/srcpkgs/meson/template b/srcpkgs/meson/template
index 527cb6f710e54..f54360fcec254 100644
--- a/srcpkgs/meson/template
+++ b/srcpkgs/meson/template
@@ -1,7 +1,7 @@
 # Template file for 'meson'
 pkgname=meson
 version=1.2.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3-devel python3-setuptools"
 depends="ninja python3-setuptools"

From dacee04172569ea4593562a1b5a47ea9466a6784 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:48 +0700
Subject: [PATCH 02/10] build-helper: support cross compiling D with ldc

---
 common/build-helper/meson.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
index 5ac9d2fe1badc..a4830bb84233c 100644
--- a/common/build-helper/meson.sh
+++ b/common/build-helper/meson.sh
@@ -62,6 +62,7 @@ if [ -n "$CROSS_BUILD" ]; then
 		objcopy = '${OBJCOPY}'
 		pkgconfig = '${PKG_CONFIG}'
 		rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+		d = ['ldc2', '-mtriple=${XBPS_CROSS_TRIPLET}']
 		g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
 		g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
 		g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'

From 3b555aafc5632079382c8a8bb0c12de96d3503fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 03/10] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From 6754b0b2d2b731972598f5146d4f29c810e6e2b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 04/10] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From ea8eaa215a435ac38f81a835e6acfd4b6e4f8aac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 05/10] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From 194ce6dee05cdf459661897db2bd0ec071302587 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 06/10] ldc: update to 1.34.0.

---
 common/shlibs                            |   7 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  15 +++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 147 +++++++++++++++++++++--
 6 files changed, 185 insertions(+), 11 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 185ba856d7e6c..08442c252a220 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2153,9 +2153,10 @@ libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
 libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.104 ldc-runtime-1.34.0_1
+libphobos2-ldc-shared.so.104 ldc-runtime-1.34.0_1
+libdruntime-ldc-debug-shared.so.104 ldc-runtime-debug-1.34.0_1
+libphobos2-ldc-debug-shared.so.104 ldc-runtime-debug-1.34.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..9a4ef44994af9
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,12 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++_major=${DMDFE_MAJOR_VERSION}
++_minor=${DMDFE_MINOR_VERSION}
++_pver=${DMDFE_PATCH_VERSION}
++")
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..6b57640d60942 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.34.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,10 +11,10 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
 checkdepends="python3"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
@@ -22,19 +22,150 @@ license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=3005c6e9c79258538c83979766767a59e3d74f3cb90ac2cb0dce5d7573beb719
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
 make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From e1605f6c36e4067f7b78d1253c5ed7a9eb81160f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 07/10] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From b9f3a1c1f6779cc10d1a688db4943d081f648c03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 08/10] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch             | 11 +++
 srcpkgs/gtkd/patches/fix--L-pkg-config.patch | 51 +++++++++++
 srcpkgs/gtkd/patches/pkg-config.patch        | 89 ++++++++++++++++++++
 srcpkgs/gtkd/template                        | 17 ++--
 4 files changed, 161 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/fix--L-pkg-config.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/fix--L-pkg-config.patch b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
new file mode 100644
index 0000000000000..f6a6e6b7f2da4
--- /dev/null
+++ b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
@@ -0,0 +1,51 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -278,42 +278,42 @@ gtkd-$(MAJOR).pc:
+ 	echo Name: GtkD > $@
+ 	echo Description: A D binding and OO wrapper for GTK+. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-L$(prefix)/$(libdir)/ $(LINKERFLAG)-lgtkd-$(MAJOR) $(LINKERFLAG)-ldl >> $@
++	echo Libs: -L$(prefix)/$(libdir) -lgtkd-$(MAJOR) -ldl >> $@
+ 	echo Cflags: -I$(prefix)/include/d/gtkd-$(MAJOR)/ >> $@
+ 
+ gtkdgl-$(MAJOR).pc:
+ 	echo Name: GtkDGL > $@
+ 	echo Description: OpenGL capabilities for GtkD. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdgl-$(MAJOR) >> $@
++	echo Libs: -lgtkdgl-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gtkdsv-$(MAJOR).pc:
+ 	echo Name: GtkD SourceView > $@
+ 	echo Description: A D binding and OO wrapper for GtkSourceView. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdsv-$(MAJOR) >> $@
++	echo Libs: -lgtkdsv-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gstreamerd-$(MAJOR).pc:
+ 	echo Name: GstreamerD > $@
+ 	echo Description: A D binding and OO wrapper for Gstreamer. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgstreamerd-$(MAJOR) >> $@
++	echo Libs: -lgstreamerd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ vted-$(MAJOR).pc:
+ 	echo Name: VteD > $@
+ 	echo Description: A D binding and OO wrapper for Vte. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lvted-$(MAJOR) >> $@
++	echo Libs: -lvted-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ peasd-$(MAJOR).pc:
+ 	echo Name: PeasD > $@
+ 	echo Description: A D binding and OO wrapper for Peas. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lpeasd-$(MAJOR) >> $@
++	echo Libs: -lpeasd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ #######################################################################
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..0db1f9baa5fe3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,7 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,11 +20,14 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {

From 0f3778767b9d54e3fa5796baa70ed9eca6cfa534 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 09/10] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index 019a89325aace..39234b85b4e9e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,14 +1,14 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.25
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2 --enable-notifications --enable-completions
  --with-bash-completion-dir=/usr/share/bash-completion/completions
  --with-zsh-completion-dir=/usr/share/zsh/site-functions
  --with-fish-completion-dir=/usr/share/fish/vendor_completions.d"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -16,7 +16,10 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=e7d782ea7d1973b6b578899a84c4f90ba69302263b4be30d80a363ba8ba27eb3
-nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From 530830b5fd21f011379a4ddd146018ee15d4c45a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 10/10] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..f35eca5575806 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,14 +1,16 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson
+build_helper="qemu"
 configure_args="-Db_lto=false"
 hostmakedepends="automake gettext-devel gdk-pixbuf glib-devel ldc po4a pkg-config
  librsvg tar AppStream"
-makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel"
+makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel
+ vte3-devel ldc-runtime-devel"
 depends="gsettings-desktop-schemas vte3"
 checkdepends="$depends"
 short_desc="Tiling terminal emulator for Linux"

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (2 preceding siblings ...)
  2023-10-23 23:43 ` sgn
@ 2023-10-23 23:43 ` sgn
  2023-10-25 15:57 ` [PR PATCH] [Updated] " sgn
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-23 23:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 184 bytes --]

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/45973#issuecomment-1776225604

Comment:
https://github.com/mesonbuild/meson/pull/12415

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (3 preceding siblings ...)
  2023-10-23 23:43 ` sgn
@ 2023-10-25 15:57 ` sgn
  2023-10-25 16:42 ` sgn
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-25 15:57 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 85479 bytes --]

From c05d9849016b02b6cba6e8a757d546b2c42debff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:10 +0700
Subject: [PATCH 01/11] meson: fix for cross compiling with ldc

---
 srcpkgs/meson/patches/ldc.patch | 12 ++++++++++++
 srcpkgs/meson/template          |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/meson/patches/ldc.patch

diff --git a/srcpkgs/meson/patches/ldc.patch b/srcpkgs/meson/patches/ldc.patch
new file mode 100644
index 0000000000000..680495ce2818e
--- /dev/null
+++ b/srcpkgs/meson/patches/ldc.patch
@@ -0,0 +1,12 @@
+diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
+index 0bfedd13..cfe6edfc 100644
+--- a/mesonbuild/compilers/detect.py
++++ b/mesonbuild/compilers/detect.py
+@@ -1151,6 +1151,7 @@ def detect_d_compiler(env: 'Environment', for_machine: MachineChoice) -> Compile
+ 
+             return cls(
+                 exelist, version, for_machine, info, arch,
++                exe_wrapper=exe_wrap, is_cross=is_cross,
+                 full_version=full_version, linker=linker, version_output=out)
+         elif 'gdc' in out:
+             cls = d.GnuDCompiler
diff --git a/srcpkgs/meson/template b/srcpkgs/meson/template
index 527cb6f710e54..f54360fcec254 100644
--- a/srcpkgs/meson/template
+++ b/srcpkgs/meson/template
@@ -1,7 +1,7 @@
 # Template file for 'meson'
 pkgname=meson
 version=1.2.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3-devel python3-setuptools"
 depends="ninja python3-setuptools"

From 5d1e6814722cf1b6dce2dd0ba0bf40d67bf65f44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:48 +0700
Subject: [PATCH 02/11] build-helper: support cross compiling D with ldc

---
 common/build-helper/meson.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
index 5ac9d2fe1badc..a4830bb84233c 100644
--- a/common/build-helper/meson.sh
+++ b/common/build-helper/meson.sh
@@ -62,6 +62,7 @@ if [ -n "$CROSS_BUILD" ]; then
 		objcopy = '${OBJCOPY}'
 		pkgconfig = '${PKG_CONFIG}'
 		rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+		d = ['ldc2', '-mtriple=${XBPS_CROSS_TRIPLET}']
 		g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
 		g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
 		g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'

From d84d70b6e13fd8a9b3c571385e92a146589a023e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 03/11] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From 997aee2f7bbbfb826b34fd75f34f22b20e64aaf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 04/11] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From a533066c99c7f9937ad5ce6efff5d804db65dc30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 05/11] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From 38dbcf7a4d7be9cac2c17041ab0e5c138d7ec820 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 06/11] ldc: update to 1.35.0.

---
 common/shlibs                            |   8 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  15 +++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 147 +++++++++++++++++++++--
 6 files changed, 185 insertions(+), 12 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 67e0812c68e19..b9a5012250e19 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2152,10 +2152,10 @@ libFcitx5Config.so.6 libfcitx5-5.0.5_1
 libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
-libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libphobos2-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libdruntime-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
+libphobos2-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..9a4ef44994af9
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,12 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++_major=${DMDFE_MAJOR_VERSION}
++_minor=${DMDFE_MINOR_VERSION}
++_pver=${DMDFE_PATCH_VERSION}
++")
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..5443c4ebde94f 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.35.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,10 +11,10 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
 checkdepends="python3"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
@@ -22,19 +22,150 @@ license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=6e296993706c76c093e609139aa0b3f8704355fa0f3756f6758d78d44226dfa0
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
 make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;\"/usr/lib\",;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From 1d24e8b9c549f7fd3563ba52ad2e7a37cd0088a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 07/11] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From c843ed7956810aae533b04142a293529c1d0f8bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 08/11] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch             | 11 +++
 srcpkgs/gtkd/patches/fix--L-pkg-config.patch | 51 +++++++++++
 srcpkgs/gtkd/patches/pkg-config.patch        | 89 ++++++++++++++++++++
 srcpkgs/gtkd/template                        | 33 ++++++--
 4 files changed, 177 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/fix--L-pkg-config.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/fix--L-pkg-config.patch b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
new file mode 100644
index 0000000000000..f6a6e6b7f2da4
--- /dev/null
+++ b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
@@ -0,0 +1,51 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -278,42 +278,42 @@ gtkd-$(MAJOR).pc:
+ 	echo Name: GtkD > $@
+ 	echo Description: A D binding and OO wrapper for GTK+. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-L$(prefix)/$(libdir)/ $(LINKERFLAG)-lgtkd-$(MAJOR) $(LINKERFLAG)-ldl >> $@
++	echo Libs: -L$(prefix)/$(libdir) -lgtkd-$(MAJOR) -ldl >> $@
+ 	echo Cflags: -I$(prefix)/include/d/gtkd-$(MAJOR)/ >> $@
+ 
+ gtkdgl-$(MAJOR).pc:
+ 	echo Name: GtkDGL > $@
+ 	echo Description: OpenGL capabilities for GtkD. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdgl-$(MAJOR) >> $@
++	echo Libs: -lgtkdgl-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gtkdsv-$(MAJOR).pc:
+ 	echo Name: GtkD SourceView > $@
+ 	echo Description: A D binding and OO wrapper for GtkSourceView. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdsv-$(MAJOR) >> $@
++	echo Libs: -lgtkdsv-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gstreamerd-$(MAJOR).pc:
+ 	echo Name: GstreamerD > $@
+ 	echo Description: A D binding and OO wrapper for Gstreamer. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgstreamerd-$(MAJOR) >> $@
++	echo Libs: -lgstreamerd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ vted-$(MAJOR).pc:
+ 	echo Name: VteD > $@
+ 	echo Description: A D binding and OO wrapper for Vte. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lvted-$(MAJOR) >> $@
++	echo Libs: -lvted-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ peasd-$(MAJOR).pc:
+ 	echo Name: PeasD > $@
+ 	echo Description: A D binding and OO wrapper for Peas. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lpeasd-$(MAJOR) >> $@
++	echo Libs: -lpeasd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ #######################################################################
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..bb6128c7813d3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,8 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ atk-devel cairo-devel pango-devel gtk+3-devel libglib-devel
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,15 +21,29 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+shlib_requires="
+ libatk-1.0.so.0
+ libcairo.so.2
+ libgtk-3.so.0
+ libgdk-3.so.0
+ libgdk_pixbuf-2.0.so.0
+ libgio-2.0.so.0
+ libgobject-2.0.so.0
+ libpango-1.0.so.0 libpangocairo-1.0.so.0
+ libglib-2.0.so.0 libgmodule-2.0.so.0"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {
 	short_desc+=" - peasd library"
+	shlib_requires="libpeas-1.0.so.0 libpeas-gtk-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libpeasd-3.so.*"
 	}
@@ -66,6 +81,7 @@ libgtkdgl-devel_package() {
 
 libvted_package() {
 	short_desc+=" - vted library"
+	shlib_requires="libvte-2.91.so.0"
 	pkg_install() {
 		vmove "usr/lib/libvted-3.so.*"
 	}
@@ -84,6 +100,8 @@ libvted-devel_package() {
 
 libgstreamerd_package() {
 	short_desc+=" - gstreamerd library"
+	shlib_requires="libgstapp-1.0.so.0 libgstbase-1.0.so.0 libgstmpegts-1.0.so.0
+	 libgstvideo-1.0.so.0 libgstreamer-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgstreamerd-3.so.*"
 	}
@@ -104,6 +122,7 @@ libgstreamerd-devel_package() {
 
 libgtkdsv_package() {
 	short_desc+=" - gtkdsv library"
+	shlib_requires="libgtksourceview-4.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgtkdsv-3.so.*"
 	}

From 0125a58916581247493d3b4e2bfce836c44838fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 09/11] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index 019a89325aace..39234b85b4e9e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,14 +1,14 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.25
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2 --enable-notifications --enable-completions
  --with-bash-completion-dir=/usr/share/bash-completion/completions
  --with-zsh-completion-dir=/usr/share/zsh/site-functions
  --with-fish-completion-dir=/usr/share/fish/vendor_completions.d"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -16,7 +16,10 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=e7d782ea7d1973b6b578899a84c4f90ba69302263b4be30d80a363ba8ba27eb3
-nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From 70adf25dc696b9b48b0de3996736f466c1e3a5fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 10/11] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..0728d1688bd16 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,14 +1,15 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson
 configure_args="-Db_lto=false"
 hostmakedepends="automake gettext-devel gdk-pixbuf glib-devel ldc po4a pkg-config
  librsvg tar AppStream"
-makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel"
+makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel
+ vte3-devel ldc-runtime-devel"
 depends="gsettings-desktop-schemas vte3"
 checkdepends="$depends"
 short_desc="Tiling terminal emulator for Linux"

From bbadcd0f4829ed41972eeec985fba6ba608071b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 25 Oct 2023 16:20:37 +0700
Subject: [PATCH 11/11] shlibs: add libgstmpegts-1.0.so.0

---
 common/shlibs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/shlibs b/common/shlibs
index b9a5012250e19..b1988ccfe40e3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1136,6 +1136,7 @@ libgstcodecparsers-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstplayer-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstwebrtc-1.0.so.0 gst-plugins-bad1-1.18.4_2
 libgsttranscoder-1.0.so.0 gst-plugins-bad1-1.18.4_2
+libgstmpegts-1.0.so.0 gst-plugins-bad1-1.22.5_1
 libgstgl-1.0.so.0 gst-plugins-base1-1.14.0_1
 libgnome-desktop-3.so.20 gnome-desktop-43.0_1
 libgnome-desktop-4.so.2 gnome-desktop-43.0_1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (4 preceding siblings ...)
  2023-10-25 15:57 ` [PR PATCH] [Updated] " sgn
@ 2023-10-25 16:42 ` sgn
  2023-10-26  4:44 ` sgn
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-25 16:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 87356 bytes --]

From c05d9849016b02b6cba6e8a757d546b2c42debff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:10 +0700
Subject: [PATCH 01/12] meson: fix for cross compiling with ldc

---
 srcpkgs/meson/patches/ldc.patch | 12 ++++++++++++
 srcpkgs/meson/template          |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/meson/patches/ldc.patch

diff --git a/srcpkgs/meson/patches/ldc.patch b/srcpkgs/meson/patches/ldc.patch
new file mode 100644
index 0000000000000..680495ce2818e
--- /dev/null
+++ b/srcpkgs/meson/patches/ldc.patch
@@ -0,0 +1,12 @@
+diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
+index 0bfedd13..cfe6edfc 100644
+--- a/mesonbuild/compilers/detect.py
++++ b/mesonbuild/compilers/detect.py
+@@ -1151,6 +1151,7 @@ def detect_d_compiler(env: 'Environment', for_machine: MachineChoice) -> Compile
+ 
+             return cls(
+                 exelist, version, for_machine, info, arch,
++                exe_wrapper=exe_wrap, is_cross=is_cross,
+                 full_version=full_version, linker=linker, version_output=out)
+         elif 'gdc' in out:
+             cls = d.GnuDCompiler
diff --git a/srcpkgs/meson/template b/srcpkgs/meson/template
index 527cb6f710e54..f54360fcec254 100644
--- a/srcpkgs/meson/template
+++ b/srcpkgs/meson/template
@@ -1,7 +1,7 @@
 # Template file for 'meson'
 pkgname=meson
 version=1.2.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3-devel python3-setuptools"
 depends="ninja python3-setuptools"

From 5d1e6814722cf1b6dce2dd0ba0bf40d67bf65f44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:48 +0700
Subject: [PATCH 02/12] build-helper: support cross compiling D with ldc

---
 common/build-helper/meson.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
index 5ac9d2fe1badc..a4830bb84233c 100644
--- a/common/build-helper/meson.sh
+++ b/common/build-helper/meson.sh
@@ -62,6 +62,7 @@ if [ -n "$CROSS_BUILD" ]; then
 		objcopy = '${OBJCOPY}'
 		pkgconfig = '${PKG_CONFIG}'
 		rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+		d = ['ldc2', '-mtriple=${XBPS_CROSS_TRIPLET}']
 		g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
 		g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
 		g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'

From d84d70b6e13fd8a9b3c571385e92a146589a023e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 03/12] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From 997aee2f7bbbfb826b34fd75f34f22b20e64aaf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 04/12] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From a533066c99c7f9937ad5ce6efff5d804db65dc30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 05/12] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From 38dbcf7a4d7be9cac2c17041ab0e5c138d7ec820 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 06/12] ldc: update to 1.35.0.

---
 common/shlibs                            |   8 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  15 +++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 147 +++++++++++++++++++++--
 6 files changed, 185 insertions(+), 12 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 67e0812c68e19..b9a5012250e19 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2152,10 +2152,10 @@ libFcitx5Config.so.6 libfcitx5-5.0.5_1
 libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
-libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libphobos2-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libdruntime-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
+libphobos2-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..9a4ef44994af9
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,12 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++_major=${DMDFE_MAJOR_VERSION}
++_minor=${DMDFE_MINOR_VERSION}
++_pver=${DMDFE_PATCH_VERSION}
++")
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..5443c4ebde94f 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.35.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,10 +11,10 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
 checkdepends="python3"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
@@ -22,19 +22,150 @@ license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=6e296993706c76c093e609139aa0b3f8704355fa0f3756f6758d78d44226dfa0
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
 make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;\"/usr/lib\",;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From 1d24e8b9c549f7fd3563ba52ad2e7a37cd0088a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 07/12] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From c843ed7956810aae533b04142a293529c1d0f8bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 08/12] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch             | 11 +++
 srcpkgs/gtkd/patches/fix--L-pkg-config.patch | 51 +++++++++++
 srcpkgs/gtkd/patches/pkg-config.patch        | 89 ++++++++++++++++++++
 srcpkgs/gtkd/template                        | 33 ++++++--
 4 files changed, 177 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/fix--L-pkg-config.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/fix--L-pkg-config.patch b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
new file mode 100644
index 0000000000000..f6a6e6b7f2da4
--- /dev/null
+++ b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
@@ -0,0 +1,51 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -278,42 +278,42 @@ gtkd-$(MAJOR).pc:
+ 	echo Name: GtkD > $@
+ 	echo Description: A D binding and OO wrapper for GTK+. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-L$(prefix)/$(libdir)/ $(LINKERFLAG)-lgtkd-$(MAJOR) $(LINKERFLAG)-ldl >> $@
++	echo Libs: -L$(prefix)/$(libdir) -lgtkd-$(MAJOR) -ldl >> $@
+ 	echo Cflags: -I$(prefix)/include/d/gtkd-$(MAJOR)/ >> $@
+ 
+ gtkdgl-$(MAJOR).pc:
+ 	echo Name: GtkDGL > $@
+ 	echo Description: OpenGL capabilities for GtkD. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdgl-$(MAJOR) >> $@
++	echo Libs: -lgtkdgl-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gtkdsv-$(MAJOR).pc:
+ 	echo Name: GtkD SourceView > $@
+ 	echo Description: A D binding and OO wrapper for GtkSourceView. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdsv-$(MAJOR) >> $@
++	echo Libs: -lgtkdsv-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gstreamerd-$(MAJOR).pc:
+ 	echo Name: GstreamerD > $@
+ 	echo Description: A D binding and OO wrapper for Gstreamer. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgstreamerd-$(MAJOR) >> $@
++	echo Libs: -lgstreamerd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ vted-$(MAJOR).pc:
+ 	echo Name: VteD > $@
+ 	echo Description: A D binding and OO wrapper for Vte. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lvted-$(MAJOR) >> $@
++	echo Libs: -lvted-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ peasd-$(MAJOR).pc:
+ 	echo Name: PeasD > $@
+ 	echo Description: A D binding and OO wrapper for Peas. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lpeasd-$(MAJOR) >> $@
++	echo Libs: -lpeasd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ #######################################################################
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..bb6128c7813d3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,8 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ atk-devel cairo-devel pango-devel gtk+3-devel libglib-devel
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,15 +21,29 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+shlib_requires="
+ libatk-1.0.so.0
+ libcairo.so.2
+ libgtk-3.so.0
+ libgdk-3.so.0
+ libgdk_pixbuf-2.0.so.0
+ libgio-2.0.so.0
+ libgobject-2.0.so.0
+ libpango-1.0.so.0 libpangocairo-1.0.so.0
+ libglib-2.0.so.0 libgmodule-2.0.so.0"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {
 	short_desc+=" - peasd library"
+	shlib_requires="libpeas-1.0.so.0 libpeas-gtk-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libpeasd-3.so.*"
 	}
@@ -66,6 +81,7 @@ libgtkdgl-devel_package() {
 
 libvted_package() {
 	short_desc+=" - vted library"
+	shlib_requires="libvte-2.91.so.0"
 	pkg_install() {
 		vmove "usr/lib/libvted-3.so.*"
 	}
@@ -84,6 +100,8 @@ libvted-devel_package() {
 
 libgstreamerd_package() {
 	short_desc+=" - gstreamerd library"
+	shlib_requires="libgstapp-1.0.so.0 libgstbase-1.0.so.0 libgstmpegts-1.0.so.0
+	 libgstvideo-1.0.so.0 libgstreamer-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgstreamerd-3.so.*"
 	}
@@ -104,6 +122,7 @@ libgstreamerd-devel_package() {
 
 libgtkdsv_package() {
 	short_desc+=" - gtkdsv library"
+	shlib_requires="libgtksourceview-4.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgtkdsv-3.so.*"
 	}

From 0125a58916581247493d3b4e2bfce836c44838fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 09/12] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index 019a89325aace..39234b85b4e9e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,14 +1,14 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.25
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2 --enable-notifications --enable-completions
  --with-bash-completion-dir=/usr/share/bash-completion/completions
  --with-zsh-completion-dir=/usr/share/zsh/site-functions
  --with-fish-completion-dir=/usr/share/fish/vendor_completions.d"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -16,7 +16,10 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=e7d782ea7d1973b6b578899a84c4f90ba69302263b4be30d80a363ba8ba27eb3
-nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From 70adf25dc696b9b48b0de3996736f466c1e3a5fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 10/12] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..0728d1688bd16 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,14 +1,15 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson
 configure_args="-Db_lto=false"
 hostmakedepends="automake gettext-devel gdk-pixbuf glib-devel ldc po4a pkg-config
  librsvg tar AppStream"
-makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel"
+makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel
+ vte3-devel ldc-runtime-devel"
 depends="gsettings-desktop-schemas vte3"
 checkdepends="$depends"
 short_desc="Tiling terminal emulator for Linux"

From bbadcd0f4829ed41972eeec985fba6ba608071b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 25 Oct 2023 16:20:37 +0700
Subject: [PATCH 11/12] shlibs: add libgstmpegts-1.0.so.0

---
 common/shlibs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/shlibs b/common/shlibs
index b9a5012250e19..b1988ccfe40e3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1136,6 +1136,7 @@ libgstcodecparsers-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstplayer-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstwebrtc-1.0.so.0 gst-plugins-bad1-1.18.4_2
 libgsttranscoder-1.0.so.0 gst-plugins-bad1-1.18.4_2
+libgstmpegts-1.0.so.0 gst-plugins-bad1-1.22.5_1
 libgstgl-1.0.so.0 gst-plugins-base1-1.14.0_1
 libgnome-desktop-3.so.20 gnome-desktop-43.0_1
 libgnome-desktop-4.so.2 gnome-desktop-43.0_1

From 03b31b89a2c13174ae96caebfefc5864d9585f21 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 25 Oct 2023 23:42:05 +0700
Subject: [PATCH 12/12] fixup! ldc: update to 1.35.0.

---
 srcpkgs/ldc/patches/no-lit.patch | 11 +++++++++++
 srcpkgs/ldc/template             | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ldc/patches/no-lit.patch

diff --git a/srcpkgs/ldc/patches/no-lit.patch b/srcpkgs/ldc/patches/no-lit.patch
new file mode 100644
index 0000000000000..7290d39fdc21f
--- /dev/null
+++ b/srcpkgs/ldc/patches/no-lit.patch
@@ -0,0 +1,11 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -20,8 +20,3 @@ endif()
+ 
+ configure_file(lit.site.cfg.in lit.site.cfg )
+ configure_file(runlit.py       runlit.py    COPYONLY)
+-
+-add_test(NAME lit-tests
+-    COMMAND ${PYTHON_EXE} runlit.py -v .
+-)
+-
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index 5443c4ebde94f..039fe626ff73a 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -25,7 +25,7 @@ distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/l
 checksum=6e296993706c76c093e609139aa0b3f8704355fa0f3756f6758d78d44226dfa0
 nopie=yes
 # tests timeout on musl; also require unpackaged python3-lit
-make_check=no
+# make_check=no
 subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
 
 case "$XBPS_TARGET_MACHINE" in
@@ -137,6 +137,15 @@ pre_configure() {
 	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
 }
 
+pre_check() {
+	ninja -C build ${makejobs} ldc2-unittest \
+		druntime-test-runner-debug-shared \
+		druntime-test-runner-shared \
+		phobos2-test-runner-debug-shared \
+		phobos2-test-runner-shared \
+		build-run-dmd-testsuite
+}
+
 post_install() {
 	sed -i -e "
 	/rpath/ s,\"/usr/lib[36][24]\",\"\",

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (5 preceding siblings ...)
  2023-10-25 16:42 ` sgn
@ 2023-10-26  4:44 ` sgn
  2023-10-26 10:45 ` sgn
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-26  4:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 88528 bytes --]

From c05d9849016b02b6cba6e8a757d546b2c42debff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:10 +0700
Subject: [PATCH 01/13] meson: fix for cross compiling with ldc

---
 srcpkgs/meson/patches/ldc.patch | 12 ++++++++++++
 srcpkgs/meson/template          |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/meson/patches/ldc.patch

diff --git a/srcpkgs/meson/patches/ldc.patch b/srcpkgs/meson/patches/ldc.patch
new file mode 100644
index 0000000000000..680495ce2818e
--- /dev/null
+++ b/srcpkgs/meson/patches/ldc.patch
@@ -0,0 +1,12 @@
+diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
+index 0bfedd13..cfe6edfc 100644
+--- a/mesonbuild/compilers/detect.py
++++ b/mesonbuild/compilers/detect.py
+@@ -1151,6 +1151,7 @@ def detect_d_compiler(env: 'Environment', for_machine: MachineChoice) -> Compile
+ 
+             return cls(
+                 exelist, version, for_machine, info, arch,
++                exe_wrapper=exe_wrap, is_cross=is_cross,
+                 full_version=full_version, linker=linker, version_output=out)
+         elif 'gdc' in out:
+             cls = d.GnuDCompiler
diff --git a/srcpkgs/meson/template b/srcpkgs/meson/template
index 527cb6f710e54..f54360fcec254 100644
--- a/srcpkgs/meson/template
+++ b/srcpkgs/meson/template
@@ -1,7 +1,7 @@
 # Template file for 'meson'
 pkgname=meson
 version=1.2.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3-devel python3-setuptools"
 depends="ninja python3-setuptools"

From 5d1e6814722cf1b6dce2dd0ba0bf40d67bf65f44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:48 +0700
Subject: [PATCH 02/13] build-helper: support cross compiling D with ldc

---
 common/build-helper/meson.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
index 5ac9d2fe1badc..a4830bb84233c 100644
--- a/common/build-helper/meson.sh
+++ b/common/build-helper/meson.sh
@@ -62,6 +62,7 @@ if [ -n "$CROSS_BUILD" ]; then
 		objcopy = '${OBJCOPY}'
 		pkgconfig = '${PKG_CONFIG}'
 		rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+		d = ['ldc2', '-mtriple=${XBPS_CROSS_TRIPLET}']
 		g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
 		g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
 		g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'

From d84d70b6e13fd8a9b3c571385e92a146589a023e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 03/13] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From 997aee2f7bbbfb826b34fd75f34f22b20e64aaf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 04/13] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From a533066c99c7f9937ad5ce6efff5d804db65dc30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 05/13] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From 38dbcf7a4d7be9cac2c17041ab0e5c138d7ec820 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 06/13] ldc: update to 1.35.0.

---
 common/shlibs                            |   8 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  15 +++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 147 +++++++++++++++++++++--
 6 files changed, 185 insertions(+), 12 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 67e0812c68e19..b9a5012250e19 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2152,10 +2152,10 @@ libFcitx5Config.so.6 libfcitx5-5.0.5_1
 libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
-libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libphobos2-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libdruntime-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
+libphobos2-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..9a4ef44994af9
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,12 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++_major=${DMDFE_MAJOR_VERSION}
++_minor=${DMDFE_MINOR_VERSION}
++_pver=${DMDFE_PATCH_VERSION}
++")
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..5443c4ebde94f 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.35.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,10 +11,10 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
 checkdepends="python3"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
@@ -22,19 +22,150 @@ license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=6e296993706c76c093e609139aa0b3f8704355fa0f3756f6758d78d44226dfa0
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
 make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;\"/usr/lib\",;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From 1d24e8b9c549f7fd3563ba52ad2e7a37cd0088a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 07/13] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From c843ed7956810aae533b04142a293529c1d0f8bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 08/13] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch             | 11 +++
 srcpkgs/gtkd/patches/fix--L-pkg-config.patch | 51 +++++++++++
 srcpkgs/gtkd/patches/pkg-config.patch        | 89 ++++++++++++++++++++
 srcpkgs/gtkd/template                        | 33 ++++++--
 4 files changed, 177 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/fix--L-pkg-config.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/fix--L-pkg-config.patch b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
new file mode 100644
index 0000000000000..f6a6e6b7f2da4
--- /dev/null
+++ b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
@@ -0,0 +1,51 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -278,42 +278,42 @@ gtkd-$(MAJOR).pc:
+ 	echo Name: GtkD > $@
+ 	echo Description: A D binding and OO wrapper for GTK+. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-L$(prefix)/$(libdir)/ $(LINKERFLAG)-lgtkd-$(MAJOR) $(LINKERFLAG)-ldl >> $@
++	echo Libs: -L$(prefix)/$(libdir) -lgtkd-$(MAJOR) -ldl >> $@
+ 	echo Cflags: -I$(prefix)/include/d/gtkd-$(MAJOR)/ >> $@
+ 
+ gtkdgl-$(MAJOR).pc:
+ 	echo Name: GtkDGL > $@
+ 	echo Description: OpenGL capabilities for GtkD. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdgl-$(MAJOR) >> $@
++	echo Libs: -lgtkdgl-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gtkdsv-$(MAJOR).pc:
+ 	echo Name: GtkD SourceView > $@
+ 	echo Description: A D binding and OO wrapper for GtkSourceView. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdsv-$(MAJOR) >> $@
++	echo Libs: -lgtkdsv-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gstreamerd-$(MAJOR).pc:
+ 	echo Name: GstreamerD > $@
+ 	echo Description: A D binding and OO wrapper for Gstreamer. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgstreamerd-$(MAJOR) >> $@
++	echo Libs: -lgstreamerd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ vted-$(MAJOR).pc:
+ 	echo Name: VteD > $@
+ 	echo Description: A D binding and OO wrapper for Vte. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lvted-$(MAJOR) >> $@
++	echo Libs: -lvted-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ peasd-$(MAJOR).pc:
+ 	echo Name: PeasD > $@
+ 	echo Description: A D binding and OO wrapper for Peas. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lpeasd-$(MAJOR) >> $@
++	echo Libs: -lpeasd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ #######################################################################
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..bb6128c7813d3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,8 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ atk-devel cairo-devel pango-devel gtk+3-devel libglib-devel
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,15 +21,29 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+shlib_requires="
+ libatk-1.0.so.0
+ libcairo.so.2
+ libgtk-3.so.0
+ libgdk-3.so.0
+ libgdk_pixbuf-2.0.so.0
+ libgio-2.0.so.0
+ libgobject-2.0.so.0
+ libpango-1.0.so.0 libpangocairo-1.0.so.0
+ libglib-2.0.so.0 libgmodule-2.0.so.0"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {
 	short_desc+=" - peasd library"
+	shlib_requires="libpeas-1.0.so.0 libpeas-gtk-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libpeasd-3.so.*"
 	}
@@ -66,6 +81,7 @@ libgtkdgl-devel_package() {
 
 libvted_package() {
 	short_desc+=" - vted library"
+	shlib_requires="libvte-2.91.so.0"
 	pkg_install() {
 		vmove "usr/lib/libvted-3.so.*"
 	}
@@ -84,6 +100,8 @@ libvted-devel_package() {
 
 libgstreamerd_package() {
 	short_desc+=" - gstreamerd library"
+	shlib_requires="libgstapp-1.0.so.0 libgstbase-1.0.so.0 libgstmpegts-1.0.so.0
+	 libgstvideo-1.0.so.0 libgstreamer-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgstreamerd-3.so.*"
 	}
@@ -104,6 +122,7 @@ libgstreamerd-devel_package() {
 
 libgtkdsv_package() {
 	short_desc+=" - gtkdsv library"
+	shlib_requires="libgtksourceview-4.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgtkdsv-3.so.*"
 	}

From 0125a58916581247493d3b4e2bfce836c44838fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 09/13] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index 019a89325aace..39234b85b4e9e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,14 +1,14 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.25
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2 --enable-notifications --enable-completions
  --with-bash-completion-dir=/usr/share/bash-completion/completions
  --with-zsh-completion-dir=/usr/share/zsh/site-functions
  --with-fish-completion-dir=/usr/share/fish/vendor_completions.d"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -16,7 +16,10 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=e7d782ea7d1973b6b578899a84c4f90ba69302263b4be30d80a363ba8ba27eb3
-nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From 70adf25dc696b9b48b0de3996736f466c1e3a5fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 10/13] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..0728d1688bd16 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,14 +1,15 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson
 configure_args="-Db_lto=false"
 hostmakedepends="automake gettext-devel gdk-pixbuf glib-devel ldc po4a pkg-config
  librsvg tar AppStream"
-makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel"
+makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel
+ vte3-devel ldc-runtime-devel"
 depends="gsettings-desktop-schemas vte3"
 checkdepends="$depends"
 short_desc="Tiling terminal emulator for Linux"

From bbadcd0f4829ed41972eeec985fba6ba608071b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 25 Oct 2023 16:20:37 +0700
Subject: [PATCH 11/13] shlibs: add libgstmpegts-1.0.so.0

---
 common/shlibs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/shlibs b/common/shlibs
index b9a5012250e19..b1988ccfe40e3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1136,6 +1136,7 @@ libgstcodecparsers-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstplayer-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstwebrtc-1.0.so.0 gst-plugins-bad1-1.18.4_2
 libgsttranscoder-1.0.so.0 gst-plugins-bad1-1.18.4_2
+libgstmpegts-1.0.so.0 gst-plugins-bad1-1.22.5_1
 libgstgl-1.0.so.0 gst-plugins-base1-1.14.0_1
 libgnome-desktop-3.so.20 gnome-desktop-43.0_1
 libgnome-desktop-4.so.2 gnome-desktop-43.0_1

From 03b31b89a2c13174ae96caebfefc5864d9585f21 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 25 Oct 2023 23:42:05 +0700
Subject: [PATCH 12/13] fixup! ldc: update to 1.35.0.

---
 srcpkgs/ldc/patches/no-lit.patch | 11 +++++++++++
 srcpkgs/ldc/template             | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ldc/patches/no-lit.patch

diff --git a/srcpkgs/ldc/patches/no-lit.patch b/srcpkgs/ldc/patches/no-lit.patch
new file mode 100644
index 0000000000000..7290d39fdc21f
--- /dev/null
+++ b/srcpkgs/ldc/patches/no-lit.patch
@@ -0,0 +1,11 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -20,8 +20,3 @@ endif()
+ 
+ configure_file(lit.site.cfg.in lit.site.cfg )
+ configure_file(runlit.py       runlit.py    COPYONLY)
+-
+-add_test(NAME lit-tests
+-    COMMAND ${PYTHON_EXE} runlit.py -v .
+-)
+-
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index 5443c4ebde94f..039fe626ff73a 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -25,7 +25,7 @@ distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/l
 checksum=6e296993706c76c093e609139aa0b3f8704355fa0f3756f6758d78d44226dfa0
 nopie=yes
 # tests timeout on musl; also require unpackaged python3-lit
-make_check=no
+# make_check=no
 subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
 
 case "$XBPS_TARGET_MACHINE" in
@@ -137,6 +137,15 @@ pre_configure() {
 	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
 }
 
+pre_check() {
+	ninja -C build ${makejobs} ldc2-unittest \
+		druntime-test-runner-debug-shared \
+		druntime-test-runner-shared \
+		phobos2-test-runner-debug-shared \
+		phobos2-test-runner-shared \
+		build-run-dmd-testsuite
+}
+
 post_install() {
 	sed -i -e "
 	/rpath/ s,\"/usr/lib[36][24]\",\"\",

From 323696b26a828f627c6841b746523e4455da26df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Thu, 26 Oct 2023 11:44:12 +0700
Subject: [PATCH 13/13] fixup! fixup! ldc: update to 1.35.0.

---
 srcpkgs/ldc/template | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index 039fe626ff73a..769f82f8c4031 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -15,7 +15,7 @@ hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
  llvm-libunwind-devel llvm"
 depends="ldc-runtime-devel llvm-libunwind-devel"
-checkdepends="python3"
+checkdepends="python3 gdb"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
 license="BSD-3-Clause, BSL-1.0"
@@ -144,6 +144,9 @@ pre_check() {
 		phobos2-test-runner-debug-shared \
 		phobos2-test-runner-shared \
 		build-run-dmd-testsuite
+	# has unknown type; cast it to its declared type
+	rm -f tests/dmd/runnable/gdb14313.d \
+		tests/dmd/runnable/gdb4181.d
 }
 
 post_install() {

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (6 preceding siblings ...)
  2023-10-26  4:44 ` sgn
@ 2023-10-26 10:45 ` sgn
  2023-10-26 16:25 ` sgn
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-26 10:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 86442 bytes --]

From 2eaa4321c5217fe21513ac404e8805f63108d232 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:10 +0700
Subject: [PATCH 01/11] meson: fix for cross compiling with ldc

---
 srcpkgs/meson/patches/ldc.patch | 12 ++++++++++++
 srcpkgs/meson/template          |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/meson/patches/ldc.patch

diff --git a/srcpkgs/meson/patches/ldc.patch b/srcpkgs/meson/patches/ldc.patch
new file mode 100644
index 0000000000000..680495ce2818e
--- /dev/null
+++ b/srcpkgs/meson/patches/ldc.patch
@@ -0,0 +1,12 @@
+diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
+index 0bfedd13..cfe6edfc 100644
+--- a/mesonbuild/compilers/detect.py
++++ b/mesonbuild/compilers/detect.py
+@@ -1151,6 +1151,7 @@ def detect_d_compiler(env: 'Environment', for_machine: MachineChoice) -> Compile
+ 
+             return cls(
+                 exelist, version, for_machine, info, arch,
++                exe_wrapper=exe_wrap, is_cross=is_cross,
+                 full_version=full_version, linker=linker, version_output=out)
+         elif 'gdc' in out:
+             cls = d.GnuDCompiler
diff --git a/srcpkgs/meson/template b/srcpkgs/meson/template
index 527cb6f710e54..f54360fcec254 100644
--- a/srcpkgs/meson/template
+++ b/srcpkgs/meson/template
@@ -1,7 +1,7 @@
 # Template file for 'meson'
 pkgname=meson
 version=1.2.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3-devel python3-setuptools"
 depends="ninja python3-setuptools"

From 7280c68fd4b361d9c14d3efa8bf38b02f2ac56a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:48 +0700
Subject: [PATCH 02/11] build-helper: support cross compiling D with ldc

---
 common/build-helper/meson.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
index 5ac9d2fe1badc..a4830bb84233c 100644
--- a/common/build-helper/meson.sh
+++ b/common/build-helper/meson.sh
@@ -62,6 +62,7 @@ if [ -n "$CROSS_BUILD" ]; then
 		objcopy = '${OBJCOPY}'
 		pkgconfig = '${PKG_CONFIG}'
 		rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+		d = ['ldc2', '-mtriple=${XBPS_CROSS_TRIPLET}']
 		g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
 		g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
 		g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'

From 68b7729f908b15b33954f73c809187eadc6cb665 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 03/11] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From ef3fee79e9c0320f2f572f34f5173ebeaa073dca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 04/11] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From ab3798336b25ef2abf9ebfd1b2e31485e1abcf81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 05/11] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From c6df62075e5eeedcbf8d6f41ba400acdbee934c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 06/11] ldc: update to 1.35.0.

---
 common/shlibs                            |   8 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  15 +++
 srcpkgs/ldc/patches/no-lit.patch         |  11 ++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 163 +++++++++++++++++++++--
 7 files changed, 210 insertions(+), 14 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/no-lit.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 67e0812c68e19..b9a5012250e19 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2152,10 +2152,10 @@ libFcitx5Config.so.6 libfcitx5-5.0.5_1
 libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
-libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libphobos2-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libdruntime-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
+libphobos2-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..9a4ef44994af9
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,12 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++_major=${DMDFE_MAJOR_VERSION}
++_minor=${DMDFE_MINOR_VERSION}
++_pver=${DMDFE_PATCH_VERSION}
++")
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/no-lit.patch b/srcpkgs/ldc/patches/no-lit.patch
new file mode 100644
index 0000000000000..7290d39fdc21f
--- /dev/null
+++ b/srcpkgs/ldc/patches/no-lit.patch
@@ -0,0 +1,11 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -20,8 +20,3 @@ endif()
+ 
+ configure_file(lit.site.cfg.in lit.site.cfg )
+ configure_file(runlit.py       runlit.py    COPYONLY)
+-
+-add_test(NAME lit-tests
+-    COMMAND ${PYTHON_EXE} runlit.py -v .
+-)
+-
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..769f82f8c4031 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.35.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,30 +11,173 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
-checkdepends="python3"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
+checkdepends="python3 gdb"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
 license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=6e296993706c76c093e609139aa0b3f8704355fa0f3756f6758d78d44226dfa0
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
-make_check=no
+# make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
+
+pre_check() {
+	ninja -C build ${makejobs} ldc2-unittest \
+		druntime-test-runner-debug-shared \
+		druntime-test-runner-shared \
+		phobos2-test-runner-debug-shared \
+		phobos2-test-runner-shared \
+		build-run-dmd-testsuite
+	# has unknown type; cast it to its declared type
+	rm -f tests/dmd/runnable/gdb14313.d \
+		tests/dmd/runnable/gdb4181.d
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;\"/usr/lib\",;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From 086fbfa3dd0e010e2df26d3e89386ed15f92da2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 07/11] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From 702ceef33d5dda152b14a3b6fe25710112a60736 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 08/11] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch             | 11 +++
 srcpkgs/gtkd/patches/fix--L-pkg-config.patch | 51 +++++++++++
 srcpkgs/gtkd/patches/pkg-config.patch        | 89 ++++++++++++++++++++
 srcpkgs/gtkd/template                        | 33 ++++++--
 4 files changed, 177 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/fix--L-pkg-config.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/fix--L-pkg-config.patch b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
new file mode 100644
index 0000000000000..f6a6e6b7f2da4
--- /dev/null
+++ b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
@@ -0,0 +1,51 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -278,42 +278,42 @@ gtkd-$(MAJOR).pc:
+ 	echo Name: GtkD > $@
+ 	echo Description: A D binding and OO wrapper for GTK+. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-L$(prefix)/$(libdir)/ $(LINKERFLAG)-lgtkd-$(MAJOR) $(LINKERFLAG)-ldl >> $@
++	echo Libs: -L$(prefix)/$(libdir) -lgtkd-$(MAJOR) -ldl >> $@
+ 	echo Cflags: -I$(prefix)/include/d/gtkd-$(MAJOR)/ >> $@
+ 
+ gtkdgl-$(MAJOR).pc:
+ 	echo Name: GtkDGL > $@
+ 	echo Description: OpenGL capabilities for GtkD. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdgl-$(MAJOR) >> $@
++	echo Libs: -lgtkdgl-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gtkdsv-$(MAJOR).pc:
+ 	echo Name: GtkD SourceView > $@
+ 	echo Description: A D binding and OO wrapper for GtkSourceView. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdsv-$(MAJOR) >> $@
++	echo Libs: -lgtkdsv-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gstreamerd-$(MAJOR).pc:
+ 	echo Name: GstreamerD > $@
+ 	echo Description: A D binding and OO wrapper for Gstreamer. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgstreamerd-$(MAJOR) >> $@
++	echo Libs: -lgstreamerd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ vted-$(MAJOR).pc:
+ 	echo Name: VteD > $@
+ 	echo Description: A D binding and OO wrapper for Vte. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lvted-$(MAJOR) >> $@
++	echo Libs: -lvted-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ peasd-$(MAJOR).pc:
+ 	echo Name: PeasD > $@
+ 	echo Description: A D binding and OO wrapper for Peas. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lpeasd-$(MAJOR) >> $@
++	echo Libs: -lpeasd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ #######################################################################
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..bb6128c7813d3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,8 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ atk-devel cairo-devel pango-devel gtk+3-devel libglib-devel
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,15 +21,29 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+shlib_requires="
+ libatk-1.0.so.0
+ libcairo.so.2
+ libgtk-3.so.0
+ libgdk-3.so.0
+ libgdk_pixbuf-2.0.so.0
+ libgio-2.0.so.0
+ libgobject-2.0.so.0
+ libpango-1.0.so.0 libpangocairo-1.0.so.0
+ libglib-2.0.so.0 libgmodule-2.0.so.0"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {
 	short_desc+=" - peasd library"
+	shlib_requires="libpeas-1.0.so.0 libpeas-gtk-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libpeasd-3.so.*"
 	}
@@ -66,6 +81,7 @@ libgtkdgl-devel_package() {
 
 libvted_package() {
 	short_desc+=" - vted library"
+	shlib_requires="libvte-2.91.so.0"
 	pkg_install() {
 		vmove "usr/lib/libvted-3.so.*"
 	}
@@ -84,6 +100,8 @@ libvted-devel_package() {
 
 libgstreamerd_package() {
 	short_desc+=" - gstreamerd library"
+	shlib_requires="libgstapp-1.0.so.0 libgstbase-1.0.so.0 libgstmpegts-1.0.so.0
+	 libgstvideo-1.0.so.0 libgstreamer-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgstreamerd-3.so.*"
 	}
@@ -104,6 +122,7 @@ libgstreamerd-devel_package() {
 
 libgtkdsv_package() {
 	short_desc+=" - gtkdsv library"
+	shlib_requires="libgtksourceview-4.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgtkdsv-3.so.*"
 	}

From ca57ba6cf7598d1b40f67db8e3b6538c04e58169 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 09/11] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index 019a89325aace..39234b85b4e9e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,14 +1,14 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.25
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2 --enable-notifications --enable-completions
  --with-bash-completion-dir=/usr/share/bash-completion/completions
  --with-zsh-completion-dir=/usr/share/zsh/site-functions
  --with-fish-completion-dir=/usr/share/fish/vendor_completions.d"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -16,7 +16,10 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=e7d782ea7d1973b6b578899a84c4f90ba69302263b4be30d80a363ba8ba27eb3
-nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From 9246f028342d2521db47f3460996e7b4c121e2d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 10/11] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..0728d1688bd16 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,14 +1,15 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson
 configure_args="-Db_lto=false"
 hostmakedepends="automake gettext-devel gdk-pixbuf glib-devel ldc po4a pkg-config
  librsvg tar AppStream"
-makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel"
+makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel
+ vte3-devel ldc-runtime-devel"
 depends="gsettings-desktop-schemas vte3"
 checkdepends="$depends"
 short_desc="Tiling terminal emulator for Linux"

From ea1a4a15aed3038018f6e0157891e315d3cebe43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 25 Oct 2023 16:20:37 +0700
Subject: [PATCH 11/11] shlibs: add libgstmpegts-1.0.so.0

---
 common/shlibs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/shlibs b/common/shlibs
index b9a5012250e19..b1988ccfe40e3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1136,6 +1136,7 @@ libgstcodecparsers-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstplayer-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstwebrtc-1.0.so.0 gst-plugins-bad1-1.18.4_2
 libgsttranscoder-1.0.so.0 gst-plugins-bad1-1.18.4_2
+libgstmpegts-1.0.so.0 gst-plugins-bad1-1.22.5_1
 libgstgl-1.0.so.0 gst-plugins-base1-1.14.0_1
 libgnome-desktop-3.so.20 gnome-desktop-43.0_1
 libgnome-desktop-4.so.2 gnome-desktop-43.0_1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (7 preceding siblings ...)
  2023-10-26 10:45 ` sgn
@ 2023-10-26 16:25 ` sgn
  2023-10-26 17:01 ` sgn
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-26 16:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 95430 bytes --]

From 2eaa4321c5217fe21513ac404e8805f63108d232 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:10 +0700
Subject: [PATCH 01/13] meson: fix for cross compiling with ldc

---
 srcpkgs/meson/patches/ldc.patch | 12 ++++++++++++
 srcpkgs/meson/template          |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/meson/patches/ldc.patch

diff --git a/srcpkgs/meson/patches/ldc.patch b/srcpkgs/meson/patches/ldc.patch
new file mode 100644
index 0000000000000..680495ce2818e
--- /dev/null
+++ b/srcpkgs/meson/patches/ldc.patch
@@ -0,0 +1,12 @@
+diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
+index 0bfedd13..cfe6edfc 100644
+--- a/mesonbuild/compilers/detect.py
++++ b/mesonbuild/compilers/detect.py
+@@ -1151,6 +1151,7 @@ def detect_d_compiler(env: 'Environment', for_machine: MachineChoice) -> Compile
+ 
+             return cls(
+                 exelist, version, for_machine, info, arch,
++                exe_wrapper=exe_wrap, is_cross=is_cross,
+                 full_version=full_version, linker=linker, version_output=out)
+         elif 'gdc' in out:
+             cls = d.GnuDCompiler
diff --git a/srcpkgs/meson/template b/srcpkgs/meson/template
index 527cb6f710e54..f54360fcec254 100644
--- a/srcpkgs/meson/template
+++ b/srcpkgs/meson/template
@@ -1,7 +1,7 @@
 # Template file for 'meson'
 pkgname=meson
 version=1.2.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3-devel python3-setuptools"
 depends="ninja python3-setuptools"

From 7280c68fd4b361d9c14d3efa8bf38b02f2ac56a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:48 +0700
Subject: [PATCH 02/13] build-helper: support cross compiling D with ldc

---
 common/build-helper/meson.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
index 5ac9d2fe1badc..a4830bb84233c 100644
--- a/common/build-helper/meson.sh
+++ b/common/build-helper/meson.sh
@@ -62,6 +62,7 @@ if [ -n "$CROSS_BUILD" ]; then
 		objcopy = '${OBJCOPY}'
 		pkgconfig = '${PKG_CONFIG}'
 		rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+		d = ['ldc2', '-mtriple=${XBPS_CROSS_TRIPLET}']
 		g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
 		g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
 		g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'

From 68b7729f908b15b33954f73c809187eadc6cb665 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 03/13] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From ef3fee79e9c0320f2f572f34f5173ebeaa073dca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 04/13] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From ab3798336b25ef2abf9ebfd1b2e31485e1abcf81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 05/13] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From c6df62075e5eeedcbf8d6f41ba400acdbee934c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 06/13] ldc: update to 1.35.0.

---
 common/shlibs                            |   8 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  15 +++
 srcpkgs/ldc/patches/no-lit.patch         |  11 ++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 163 +++++++++++++++++++++--
 7 files changed, 210 insertions(+), 14 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/no-lit.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 67e0812c68e19..b9a5012250e19 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2152,10 +2152,10 @@ libFcitx5Config.so.6 libfcitx5-5.0.5_1
 libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
-libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libphobos2-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libdruntime-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
+libphobos2-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..9a4ef44994af9
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,12 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++_major=${DMDFE_MAJOR_VERSION}
++_minor=${DMDFE_MINOR_VERSION}
++_pver=${DMDFE_PATCH_VERSION}
++")
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/no-lit.patch b/srcpkgs/ldc/patches/no-lit.patch
new file mode 100644
index 0000000000000..7290d39fdc21f
--- /dev/null
+++ b/srcpkgs/ldc/patches/no-lit.patch
@@ -0,0 +1,11 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -20,8 +20,3 @@ endif()
+ 
+ configure_file(lit.site.cfg.in lit.site.cfg )
+ configure_file(runlit.py       runlit.py    COPYONLY)
+-
+-add_test(NAME lit-tests
+-    COMMAND ${PYTHON_EXE} runlit.py -v .
+-)
+-
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..769f82f8c4031 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.35.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,30 +11,173 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
-checkdepends="python3"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
+checkdepends="python3 gdb"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
 license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=6e296993706c76c093e609139aa0b3f8704355fa0f3756f6758d78d44226dfa0
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
-make_check=no
+# make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
+
+pre_check() {
+	ninja -C build ${makejobs} ldc2-unittest \
+		druntime-test-runner-debug-shared \
+		druntime-test-runner-shared \
+		phobos2-test-runner-debug-shared \
+		phobos2-test-runner-shared \
+		build-run-dmd-testsuite
+	# has unknown type; cast it to its declared type
+	rm -f tests/dmd/runnable/gdb14313.d \
+		tests/dmd/runnable/gdb4181.d
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;\"/usr/lib\",;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From 086fbfa3dd0e010e2df26d3e89386ed15f92da2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 07/13] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From 702ceef33d5dda152b14a3b6fe25710112a60736 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 08/13] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch             | 11 +++
 srcpkgs/gtkd/patches/fix--L-pkg-config.patch | 51 +++++++++++
 srcpkgs/gtkd/patches/pkg-config.patch        | 89 ++++++++++++++++++++
 srcpkgs/gtkd/template                        | 33 ++++++--
 4 files changed, 177 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/fix--L-pkg-config.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/fix--L-pkg-config.patch b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
new file mode 100644
index 0000000000000..f6a6e6b7f2da4
--- /dev/null
+++ b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
@@ -0,0 +1,51 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -278,42 +278,42 @@ gtkd-$(MAJOR).pc:
+ 	echo Name: GtkD > $@
+ 	echo Description: A D binding and OO wrapper for GTK+. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-L$(prefix)/$(libdir)/ $(LINKERFLAG)-lgtkd-$(MAJOR) $(LINKERFLAG)-ldl >> $@
++	echo Libs: -L$(prefix)/$(libdir) -lgtkd-$(MAJOR) -ldl >> $@
+ 	echo Cflags: -I$(prefix)/include/d/gtkd-$(MAJOR)/ >> $@
+ 
+ gtkdgl-$(MAJOR).pc:
+ 	echo Name: GtkDGL > $@
+ 	echo Description: OpenGL capabilities for GtkD. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdgl-$(MAJOR) >> $@
++	echo Libs: -lgtkdgl-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gtkdsv-$(MAJOR).pc:
+ 	echo Name: GtkD SourceView > $@
+ 	echo Description: A D binding and OO wrapper for GtkSourceView. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdsv-$(MAJOR) >> $@
++	echo Libs: -lgtkdsv-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gstreamerd-$(MAJOR).pc:
+ 	echo Name: GstreamerD > $@
+ 	echo Description: A D binding and OO wrapper for Gstreamer. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgstreamerd-$(MAJOR) >> $@
++	echo Libs: -lgstreamerd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ vted-$(MAJOR).pc:
+ 	echo Name: VteD > $@
+ 	echo Description: A D binding and OO wrapper for Vte. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lvted-$(MAJOR) >> $@
++	echo Libs: -lvted-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ peasd-$(MAJOR).pc:
+ 	echo Name: PeasD > $@
+ 	echo Description: A D binding and OO wrapper for Peas. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lpeasd-$(MAJOR) >> $@
++	echo Libs: -lpeasd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ #######################################################################
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..bb6128c7813d3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,8 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ atk-devel cairo-devel pango-devel gtk+3-devel libglib-devel
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,15 +21,29 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+shlib_requires="
+ libatk-1.0.so.0
+ libcairo.so.2
+ libgtk-3.so.0
+ libgdk-3.so.0
+ libgdk_pixbuf-2.0.so.0
+ libgio-2.0.so.0
+ libgobject-2.0.so.0
+ libpango-1.0.so.0 libpangocairo-1.0.so.0
+ libglib-2.0.so.0 libgmodule-2.0.so.0"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {
 	short_desc+=" - peasd library"
+	shlib_requires="libpeas-1.0.so.0 libpeas-gtk-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libpeasd-3.so.*"
 	}
@@ -66,6 +81,7 @@ libgtkdgl-devel_package() {
 
 libvted_package() {
 	short_desc+=" - vted library"
+	shlib_requires="libvte-2.91.so.0"
 	pkg_install() {
 		vmove "usr/lib/libvted-3.so.*"
 	}
@@ -84,6 +100,8 @@ libvted-devel_package() {
 
 libgstreamerd_package() {
 	short_desc+=" - gstreamerd library"
+	shlib_requires="libgstapp-1.0.so.0 libgstbase-1.0.so.0 libgstmpegts-1.0.so.0
+	 libgstvideo-1.0.so.0 libgstreamer-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgstreamerd-3.so.*"
 	}
@@ -104,6 +122,7 @@ libgstreamerd-devel_package() {
 
 libgtkdsv_package() {
 	short_desc+=" - gtkdsv library"
+	shlib_requires="libgtksourceview-4.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgtkdsv-3.so.*"
 	}

From ca57ba6cf7598d1b40f67db8e3b6538c04e58169 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 09/13] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index 019a89325aace..39234b85b4e9e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,14 +1,14 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.25
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2 --enable-notifications --enable-completions
  --with-bash-completion-dir=/usr/share/bash-completion/completions
  --with-zsh-completion-dir=/usr/share/zsh/site-functions
  --with-fish-completion-dir=/usr/share/fish/vendor_completions.d"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -16,7 +16,10 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=e7d782ea7d1973b6b578899a84c4f90ba69302263b4be30d80a363ba8ba27eb3
-nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From 9246f028342d2521db47f3460996e7b4c121e2d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 10/13] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..0728d1688bd16 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,14 +1,15 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson
 configure_args="-Db_lto=false"
 hostmakedepends="automake gettext-devel gdk-pixbuf glib-devel ldc po4a pkg-config
  librsvg tar AppStream"
-makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel"
+makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel
+ vte3-devel ldc-runtime-devel"
 depends="gsettings-desktop-schemas vte3"
 checkdepends="$depends"
 short_desc="Tiling terminal emulator for Linux"

From ea1a4a15aed3038018f6e0157891e315d3cebe43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 25 Oct 2023 16:20:37 +0700
Subject: [PATCH 11/13] shlibs: add libgstmpegts-1.0.so.0

---
 common/shlibs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/shlibs b/common/shlibs
index b9a5012250e19..b1988ccfe40e3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1136,6 +1136,7 @@ libgstcodecparsers-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstplayer-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstwebrtc-1.0.so.0 gst-plugins-bad1-1.18.4_2
 libgsttranscoder-1.0.so.0 gst-plugins-bad1-1.18.4_2
+libgstmpegts-1.0.so.0 gst-plugins-bad1-1.22.5_1
 libgstgl-1.0.so.0 gst-plugins-base1-1.14.0_1
 libgnome-desktop-3.so.20 gnome-desktop-43.0_1
 libgnome-desktop-4.so.2 gnome-desktop-43.0_1

From 87ca5af3fe9eed7cabdbd73570debcc6b2e5b093 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Thu, 26 Oct 2023 23:24:46 +0700
Subject: [PATCH 12/13] fixup! New package: gcc11-11.3.0

---
 ...se-poisoned-calloc-error-in-libgccji.patch | 19 +++------
 .../patches/fix-poisoned-calloc-cp.patch      | 30 ++++++++++++++
 srcpkgs/gcc11/patches/musl-libucontext.patch  | 39 +++++++++++++++++++
 srcpkgs/gcc11/template                        |  2 +
 4 files changed, 76 insertions(+), 14 deletions(-)
 create mode 100644 srcpkgs/gcc11/patches/fix-poisoned-calloc-cp.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-libucontext.patch

diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
index 7975e6339acaa..516f88a23ed1c 100644
--- a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -11,11 +11,9 @@ included #pragma GCC poison calloc
  gcc/jit/libgccjit.c     | 3 ++-
  3 files changed, 6 insertions(+), 5 deletions(-)
 
-diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
-index cee9daa8220..a5600084933 100644
 --- a/gcc/jit/jit-playback.c
 +++ b/gcc/jit/jit-playback.c
-@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+@@ -18,6 +18,8 @@ You should have received a copy of the G
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
@@ -24,7 +22,7 @@ index cee9daa8220..a5600084933 100644
  #include "config.h"
  #include "system.h"
  #include "coretypes.h"
-@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.
  #include "diagnostic.h"
  #include "stmt.h"
  
@@ -33,11 +31,9 @@ index cee9daa8220..a5600084933 100644
  #include "jit-playback.h"
  #include "jit-result.h"
  #include "jit-builtins.h"
-diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
-index 117ff70114c..d2634a546b1 100644
 --- a/gcc/jit/jit-recording.c
 +++ b/gcc/jit/jit-recording.c
-@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+@@ -18,6 +18,8 @@ You should have received a copy of the G
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
@@ -46,7 +42,7 @@ index 117ff70114c..d2634a546b1 100644
  #include "config.h"
  #include "system.h"
  #include "coretypes.h"
-@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.
  #include "pretty-print.h"
  #include "toplev.h"
  
@@ -55,11 +51,9 @@ index 117ff70114c..d2634a546b1 100644
  #include "jit-builtins.h"
  #include "jit-recording.h"
  #include "jit-playback.h"
-diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
-index 0cc650f9810..2f44481eeb0 100644
 --- a/gcc/jit/libgccjit.c
 +++ b/gcc/jit/libgccjit.c
-@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+@@ -18,13 +18,14 @@ You should have received a copy of the G
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
@@ -75,6 +69,3 @@ index 0cc650f9810..2f44481eeb0 100644
  
  #include "libgccjit.h"
  #include "jit-recording.h"
--- 
-2.35.1
-
diff --git a/srcpkgs/gcc11/patches/fix-poisoned-calloc-cp.patch b/srcpkgs/gcc11/patches/fix-poisoned-calloc-cp.patch
new file mode 100644
index 0000000000000..5ea0f0682c02e
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-poisoned-calloc-cp.patch
@@ -0,0 +1,30 @@
+--- a/gcc/cp/mapper-client.cc
++++ b/gcc/cp/mapper-client.cc
+@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
+ #define INCLUDE_STRING
+ #define INCLUDE_VECTOR
+ #define INCLUDE_MAP
++#include <pthread.h>
+ #include "system.h"
+ 
+ #include "line-map.h"
+--- a/gcc/cp/mapper-resolver.cc
++++ b/gcc/cp/mapper-resolver.cc
+@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.
+ #define INCLUDE_VECTOR
+ #define INCLUDE_ALGORITHM
+ #define INCLUDE_MAP
++#include <pthread.h>
+ #include "system.h"
+ 
+ // We don't want or need to be aware of networking
+--- a/gcc/cp/module.cc
++++ b/gcc/cp/module.cc
+@@ -204,6 +204,7 @@ Classes used:
+ #include "config.h"
+ #define INCLUDE_STRING
+ #define INCLUDE_VECTOR
++#include <pthread.h>
+ #include "system.h"
+ #include "coretypes.h"
+ #include "cp-tree.h"
diff --git a/srcpkgs/gcc11/patches/musl-libucontext.patch b/srcpkgs/gcc11/patches/musl-libucontext.patch
new file mode 100644
index 0000000000000..db8780bf4758e
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-libucontext.patch
@@ -0,0 +1,39 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -51260,7 +51260,7 @@ configure-target-libphobos:
+ 	esac; \
+ 	module_srcdir=libphobos; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="$$LIBS $(LIBUCONTEXT)" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libphobos/configure
++++ b/libphobos/configure
+@@ -15200,6 +15200,11 @@ fi
+       druntime_fiber_asm_external=yes
+       ;;
+   esac
++  case "$target" in
++    *-musl)
++      druntime_fiber_asm_external=no
++      ;;
++  esac
+   if test "$druntime_fiber_asm_external" = no; then
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing swapcontext" >&5
+ $as_echo_n "checking for library containing swapcontext... " >&6; }
+--- a/libphobos/m4/druntime/libraries.m4
++++ b/libphobos/m4/druntime/libraries.m4
+@@ -228,6 +228,11 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT],
+       druntime_fiber_asm_external=yes
+       ;;
+   esac
++  case "$target" in
++    *-musl)
++      druntime_fiber_asm_external=no
++      ;;
++  esac
+   if test "$druntime_fiber_asm_external" = no; then
+     AC_SEARCH_LIBS([swapcontext], [c ucontext], [],
+       AC_MSG_ERROR([swapcontext required but not found]))
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
index ed9afc988370d..1dc6bc81d19b7 100644
--- a/srcpkgs/gcc11/template
+++ b/srcpkgs/gcc11/template
@@ -41,7 +41,9 @@ skip_extraction="
  "
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	makedepends+=" libucontext-devel"
 	depends+=" musl-devel"
+	export LIBUCONTEXT=-lucontext
 else
 	depends+=" glibc-devel"
 fi

From e7a60a8fced2f5baf0f8f5483e6f97a9fd00da46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Thu, 26 Oct 2023 23:24:57 +0700
Subject: [PATCH 13/13] fixup! gcc: add D frontend

---
 srcpkgs/gcc/patches/libucontext.patch | 39 +++++++++++++++++++++++++++
 srcpkgs/gcc/template                  |  4 +++
 2 files changed, 43 insertions(+)
 create mode 100644 srcpkgs/gcc/patches/libucontext.patch

diff --git a/srcpkgs/gcc/patches/libucontext.patch b/srcpkgs/gcc/patches/libucontext.patch
new file mode 100644
index 0000000000000..b755232105f11
--- /dev/null
+++ b/srcpkgs/gcc/patches/libucontext.patch
@@ -0,0 +1,39 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -53287,7 +53287,7 @@ configure-target-libphobos:
+ 	esac; \
+ 	module_srcdir=libphobos; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="$(LIBUCONTEXT) $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libphobos/configure
++++ b/libphobos/configure
+@@ -15200,6 +15200,11 @@ fi
+       druntime_fiber_asm_external=yes
+       ;;
+   esac
++  case "$target" in
++    *-musl)
++      druntime_fiber_asm_external=no
++      ;;
++  esac
+   if test "$druntime_fiber_asm_external" = no; then
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing swapcontext" >&5
+ $as_echo_n "checking for library containing swapcontext... " >&6; }
+--- a/libphobos/m4/druntime/libraries.m4
++++ b/libphobos/m4/druntime/libraries.m4
+@@ -228,6 +228,11 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT],
+       druntime_fiber_asm_external=yes
+       ;;
+   esac
++  case "$target" in
++    *-musl)
++      druntime_fiber_asm_external=no
++      ;;
++  esac
+   if test "$druntime_fiber_asm_external" = no; then
+     AC_SEARCH_LIBS([swapcontext], [c ucontext], [],
+       AC_MSG_ERROR([swapcontext required but not found]))
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index a818b0cdacf57..9e6244f58d16f 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -98,6 +98,10 @@ if [ "$_have_gccgo" = "yes" ]; then
 fi
 
 if [ "$_have_gdc" = yes ]; then
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		makedepends+=" libucontext-devel"
+		export LIBUCONTEXT=-lucontext
+	fi
 	if [ "$CROSS_BUILD" ]; then
 		hostmakedepends+=" gcc-gdc"
 	else

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PR PATCH] [Updated] Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (8 preceding siblings ...)
  2023-10-26 16:25 ` sgn
@ 2023-10-26 17:01 ` sgn
  2024-01-25  1:48 ` github-actions
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sgn @ 2023-10-26 17:01 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages ldc-cross-compile
https://github.com/void-linux/void-packages/pull/45973

Ldc cross compile
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/45973.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ldc-cross-compile-45973.patch --]
[-- Type: text/x-diff, Size: 129904 bytes --]

From 2eaa4321c5217fe21513ac404e8805f63108d232 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:10 +0700
Subject: [PATCH 01/15] meson: fix for cross compiling with ldc

---
 srcpkgs/meson/patches/ldc.patch | 12 ++++++++++++
 srcpkgs/meson/template          |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/meson/patches/ldc.patch

diff --git a/srcpkgs/meson/patches/ldc.patch b/srcpkgs/meson/patches/ldc.patch
new file mode 100644
index 0000000000000..680495ce2818e
--- /dev/null
+++ b/srcpkgs/meson/patches/ldc.patch
@@ -0,0 +1,12 @@
+diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
+index 0bfedd13..cfe6edfc 100644
+--- a/mesonbuild/compilers/detect.py
++++ b/mesonbuild/compilers/detect.py
+@@ -1151,6 +1151,7 @@ def detect_d_compiler(env: 'Environment', for_machine: MachineChoice) -> Compile
+ 
+             return cls(
+                 exelist, version, for_machine, info, arch,
++                exe_wrapper=exe_wrap, is_cross=is_cross,
+                 full_version=full_version, linker=linker, version_output=out)
+         elif 'gdc' in out:
+             cls = d.GnuDCompiler
diff --git a/srcpkgs/meson/template b/srcpkgs/meson/template
index 527cb6f710e54..f54360fcec254 100644
--- a/srcpkgs/meson/template
+++ b/srcpkgs/meson/template
@@ -1,7 +1,7 @@
 # Template file for 'meson'
 pkgname=meson
 version=1.2.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3-devel python3-setuptools"
 depends="ninja python3-setuptools"

From 7280c68fd4b361d9c14d3efa8bf38b02f2ac56a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 23 Oct 2023 22:10:48 +0700
Subject: [PATCH 02/15] build-helper: support cross compiling D with ldc

---
 common/build-helper/meson.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
index 5ac9d2fe1badc..a4830bb84233c 100644
--- a/common/build-helper/meson.sh
+++ b/common/build-helper/meson.sh
@@ -62,6 +62,7 @@ if [ -n "$CROSS_BUILD" ]; then
 		objcopy = '${OBJCOPY}'
 		pkgconfig = '${PKG_CONFIG}'
 		rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+		d = ['ldc2', '-mtriple=${XBPS_CROSS_TRIPLET}']
 		g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
 		g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
 		g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'

From 68b7729f908b15b33954f73c809187eadc6cb665 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 23:59:22 +0700
Subject: [PATCH 03/15] New package: gcc11-11.3.0

---
 srcpkgs/gcc11-gdc                             |   1 +
 srcpkgs/gcc11/files/gccgo-musl.patch          | 162 +++++++++++
 srcpkgs/gcc11/files/libgnarl-musl.patch       | 122 ++++++++
 srcpkgs/gcc11/files/libssp-musl.patch         |  70 +++++
 ...se-poisoned-calloc-error-in-libgccji.patch |  80 ++++++
 srcpkgs/gcc11/patches/ada-shared.patch        |  28 ++
 .../patches/consistent-library-paths.patch    | 107 +++++++
 .../gcc11/patches/fix-cxxflags-passing.patch  |  10 +
 srcpkgs/gcc11/patches/fix-musl-execinfo.patch |  33 +++
 .../gcc11/patches/fix-vtv-link-order.patch    |  20 ++
 .../patches/force-override-clocale.patch      |  21 ++
 .../gcc11/patches/libgcc-ibm128-no-tag.patch  |  35 +++
 srcpkgs/gcc11/patches/mips-soft-float.patch   |  18 ++
 srcpkgs/gcc11/patches/musl-ada.patch          | 200 ++++++++++++++
 .../gcc11/patches/musl-generic-locale.patch   |  15 +
 srcpkgs/gcc11/template                        | 261 ++++++++++++++++++
 16 files changed, 1183 insertions(+)
 create mode 120000 srcpkgs/gcc11-gdc
 create mode 100644 srcpkgs/gcc11/files/gccgo-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libgnarl-musl.patch
 create mode 100644 srcpkgs/gcc11/files/libssp-musl.patch
 create mode 100644 srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
 create mode 100644 srcpkgs/gcc11/patches/ada-shared.patch
 create mode 100644 srcpkgs/gcc11/patches/consistent-library-paths.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-musl-execinfo.patch
 create mode 100644 srcpkgs/gcc11/patches/fix-vtv-link-order.patch
 create mode 100644 srcpkgs/gcc11/patches/force-override-clocale.patch
 create mode 100644 srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
 create mode 100644 srcpkgs/gcc11/patches/mips-soft-float.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-ada.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-generic-locale.patch
 create mode 100644 srcpkgs/gcc11/template

diff --git a/srcpkgs/gcc11-gdc b/srcpkgs/gcc11-gdc
new file mode 120000
index 0000000000000..7ab0b751796f2
--- /dev/null
+++ b/srcpkgs/gcc11-gdc
@@ -0,0 +1 @@
+gcc11
\ No newline at end of file
diff --git a/srcpkgs/gcc11/files/gccgo-musl.patch b/srcpkgs/gcc11/files/gccgo-musl.patch
new file mode 100644
index 0000000000000..35c6e3b3ceea3
--- /dev/null
+++ b/srcpkgs/gcc11/files/gccgo-musl.patch
@@ -0,0 +1,162 @@
+This is not among the normal patches as these changes are musl specific and
+there is no way to easily conditionalize it in source for some of the changes.
+
+Added by q66: runtime.h now uses libucontext_ prefixed APIs to allow build
+with freestanding versions of libucontext
+
+Souurce: Adélie Linux, q66
+URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -50344,7 +50344,7 @@ configure-target-libgo:
+ 	esac; \
+ 	module_srcdir=libgo; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libgo/mksysinfo.sh
++++ b/libgo/mksysinfo.sh
+@@ -403,11 +403,7 @@ fi
+ # Some basic types.
+ echo 'type Size_t _size_t' >> ${OUT}
+ echo "type Ssize_t _ssize_t" >> ${OUT}
+-if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
+-  echo "type Offset_t _off64_t" >> ${OUT}
+-else
+-  echo "type Offset_t _off_t" >> ${OUT}
+-fi
++echo "type Offset_t _off_t" >> ${OUT}
+ echo "type Mode_t _mode_t" >> ${OUT}
+ echo "type Pid_t _pid_t" >> ${OUT}
+ echo "type Uid_t _uid_t" >> ${OUT}
+--- a/libgo/go/runtime/mem_gccgo.go
++++ b/libgo/go/runtime/mem_gccgo.go
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
+ 
+ //extern mmap
+-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer
+ 
+ //extern munmap
+ func munmap(addr unsafe.Pointer, length uintptr) int32
+@@ -37,7 +37,7 @@ func init() {
+ 	}
+ }
+ 
+-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) {
++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) {
+ 	p := sysMmap(addr, n, prot, flags, fd, off)
+ 	if uintptr(p) == _MAP_FAILED {
+ 		return nil, errno()
+--- a/libgo/go/syscall/errstr.go
++++ b/libgo/go/syscall/errstr.go
+@@ -5,7 +5,6 @@
+ // license that can be found in the LICENSE file.
+ 
+ // +build !hurd
+-// +build !linux
+ 
+ package syscall
+ 
+--- a/libgo/go/syscall/errstr_glibc.go
++++ /dev/null
+@@ -1,33 +0,0 @@
+-// errstr_glibc.go -- GNU/Linux and GNU/Hurd specific error strings.
+-
+-// Copyright 2010 The Go Authors. All rights reserved.
+-// Use of this source code is governed by a BSD-style
+-// license that can be found in the LICENSE file.
+-
+-// We use this rather than errstr.go because on GNU/Linux sterror_r
+-// returns a pointer to the error message, and may not use buf at all.
+-
+-// +build hurd linux
+-
+-package syscall
+-
+-import "unsafe"
+-
+-//sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
+-//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
+-
+-func Errstr(errnum int) string {
+-	a := make([]byte, 128)
+-	p := strerror_r(errnum, a)
+-	b := (*[1000]byte)(unsafe.Pointer(p))
+-	i := 0
+-	for b[i] != 0 {
+-		i++
+-	}
+-	// Lowercase first letter: Bad -> bad, but STREAM -> STREAM.
+-	if i > 1 && 'A' <= b[0] && b[0] <= 'Z' && 'a' <= b[1] && b[1] <= 'z' {
+-		c := b[0] + 'a' - 'A'
+-		return string(c) + string(b[1:i])
+-	}
+-	return string(b[:i])
+-}
+--- a/libgo/go/syscall/libcall_linux.go
++++ b/libgo/go/syscall/libcall_linux.go
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
+ //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
+ //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
+ 
+-//sys	splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error)
+-//splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t
++//sys	splice(rfd int, roff *_off_t, wfd int, woff *_off_t, len int, flags int) (n int64, err error)
++//splice(rfd _C_int, roff *_off_t, wfd _C_int, woff *_off_t, len Size_t, flags _C_uint) Ssize_t
+ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
+-	var lroff _loff_t
+-	var plroff *_loff_t
++	var lroff _off_t
++	var plroff *_off_t
+ 	if roff != nil {
+-		lroff = _loff_t(*roff)
++		lroff = _off_t(*roff)
+ 		plroff = &lroff
+ 	}
+-	var lwoff _loff_t
+-	var plwoff *_loff_t
++	var lwoff _off_t
++	var plwoff *_off_t
+ 	if woff != nil {
+-		lwoff = _loff_t(*woff)
++		lwoff = _off_t(*woff)
+ 		plwoff = &lwoff
+ 	}
+ 	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
+--- a/libgo/runtime/runtime.h
++++ b/libgo/runtime/runtime.h
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
+ void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
+ #else
+ #define __go_context_t	ucontext_t
+-#define __go_getcontext(c)	getcontext(c)
+-#define __go_setcontext(c)	setcontext(c)
++int  libucontext_getcontext(__go_context_t *);
++void libucontext_makecontext(__go_context_t *, void (*)(), int, ...);
++int  libucontext_setcontext(const __go_context_t *);
++#define __go_getcontext(c)	libucontext_getcontext(c)
++#define __go_setcontext(c)	libucontext_setcontext(c)
+ #define __go_makecontext(c, fn, sp, size) \
+-	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, makecontext(c, fn, 0))
++	((c)->uc_stack.ss_sp = sp, (c)->uc_stack.ss_size = size, libucontext_makecontext(c, fn, 0))
+ #endif
+ 
+ // Symbols defined by the linker.
+--- a/libgo/sysinfo.c
++++ b/libgo/sysinfo.c
+@@ -78,9 +78,6 @@
+ #include <sys/times.h>
+ #include <sys/wait.h>
+ #include <sys/un.h>
+-#if defined(HAVE_SYS_USER_H)
+-#include <sys/user.h>
+-#endif
+ #if defined(HAVE_SYS_UTSNAME_H)
+ #include <sys/utsname.h>
+ #endif
diff --git a/srcpkgs/gcc11/files/libgnarl-musl.patch b/srcpkgs/gcc11/files/libgnarl-musl.patch
new file mode 100644
index 0000000000000..5db06d337a229
--- /dev/null
+++ b/srcpkgs/gcc11/files/libgnarl-musl.patch
@@ -0,0 +1,122 @@
+Source: Alpine Linux
+Upstream: Unknown
+Reason: Patch libgnarl to not use function missing from musl.
+
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
+@@ -401,12 +401,6 @@ package System.OS_Interface is
+    PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
+    PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
+ 
+-   function pthread_rwlockattr_setkind_np
+-     (attr : access pthread_rwlockattr_t;
+-      pref : int) return int;
+-   pragma Import
+-     (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
+-
+    function pthread_rwlock_init
+      (mutex : access pthread_rwlock_t;
+       attr  : access pthread_rwlockattr_t) return int;
+@@ -468,11 +462,6 @@ package System.OS_Interface is
+       protocol : int) return int;
+    pragma Import (C, pthread_mutexattr_setprotocol);
+ 
+-   function pthread_mutexattr_setprioceiling
+-     (attr        : access pthread_mutexattr_t;
+-      prioceiling : int) return int;
+-   pragma Import (C, pthread_mutexattr_setprioceiling);
+-
+    type struct_sched_param is record
+       sched_priority : int;  --  scheduling priority
+    end record;
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
+@@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
+    pragma Import
+      (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
+ 
+-   function GNAT_has_cap_sys_nice return C.int;
+-   pragma Import
+-     (C, GNAT_has_cap_sys_nice, "__gnat_has_cap_sys_nice");
+    --  We do not have pragma Linker_Options ("-lcap"); here, because this
+    --  library is not present on many Linux systems. 'libcap' is the Linux
+    --  "capabilities" library, called by __gnat_has_cap_sys_nice.
+@@ -210,38 +207,6 @@ package body System.Task_Primitives.Oper
+    --  Convert Ada priority to Linux priority. Priorities are 1 .. 99 on
+    --  GNU/Linux, so we map 0 .. 98 to 1 .. 99.
+ 
+-   function Get_Ceiling_Support return Boolean;
+-   --  Get the value of the Ceiling_Support constant (see below).
+-   --  Note well: If this function or related code is modified, it should be
+-   --  tested by hand, because automated testing doesn't exercise it.
+-
+-   -------------------------
+-   -- Get_Ceiling_Support --
+-   -------------------------
+-
+-   function Get_Ceiling_Support return Boolean is
+-      Ceiling_Support : Boolean := False;
+-   begin
+-      if Locking_Policy /= 'C' then
+-         return False;
+-      end if;
+-
+-      declare
+-         function geteuid return Integer;
+-         pragma Import (C, geteuid, "geteuid");
+-         Superuser : constant Boolean := geteuid = 0;
+-         Has_Cap : constant C.int := GNAT_has_cap_sys_nice;
+-         pragma Assert (Has_Cap in 0 | 1);
+-      begin
+-         Ceiling_Support := Superuser or else Has_Cap = 1;
+-      end;
+-
+-      return Ceiling_Support;
+-   end Get_Ceiling_Support;
+-
+-   pragma Warnings (Off, "non-preelaborable call not allowed*");
+-   Ceiling_Support : constant Boolean := Get_Ceiling_Support;
+-   pragma Warnings (On, "non-preelaborable call not allowed*");
+    --  True if the locking policy is Ceiling_Locking, and the current process
+    --  has permission to use this policy. The process has permission if it is
+    --  running as 'root', or if the capability was set by the setcap command,
+@@ -344,7 +309,9 @@ package body System.Task_Primitives.Oper
+    -- Init_Mutex --
+    ----------------
+ 
++   pragma Warnings (Off, "formal parameter * is not referenced");
+    function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is
++   pragma Warnings (On, "formal parameter * is not referenced");
+       Mutex_Attr : aliased pthread_mutexattr_t;
+       Result, Result_2 : C.int;
+ 
+@@ -356,16 +323,7 @@ package body System.Task_Primitives.Oper
+          return Result;
+       end if;
+ 
+-      if Ceiling_Support then
+-         Result := pthread_mutexattr_setprotocol
+-           (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT);
+-         pragma Assert (Result = 0);
+-
+-         Result := pthread_mutexattr_setprioceiling
+-           (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio));
+-         pragma Assert (Result = 0);
+-
+-      elsif Locking_Policy = 'I' then
++      if Locking_Policy = 'I' then
+          Result := pthread_mutexattr_setprotocol
+            (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT);
+          pragma Assert (Result = 0);
+@@ -405,11 +363,6 @@ package body System.Task_Primitives.Oper
+             Result := pthread_rwlockattr_init (RWlock_Attr'Access);
+             pragma Assert (Result = 0);
+ 
+-            Result := pthread_rwlockattr_setkind_np
+-              (RWlock_Attr'Access,
+-               PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+-            pragma Assert (Result = 0);
+-
+             Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
+ 
+             pragma Assert (Result in 0 | ENOMEM);
diff --git a/srcpkgs/gcc11/files/libssp-musl.patch b/srcpkgs/gcc11/files/libssp-musl.patch
new file mode 100644
index 0000000000000..c1c22699571e1
--- /dev/null
+++ b/srcpkgs/gcc11/files/libssp-musl.patch
@@ -0,0 +1,70 @@
+First part taken from Alpine.
+
+Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
+
+--- a/gcc/gcc.c
++++ b/gcc/gcc.c
+@@ -977,10 +977,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+ 
++#ifdef ENABLE_DEFAULT_SSP
++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
++#else
++#define NO_SSP_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+-		       "|fstack-protector-strong|fstack-protector-explicit:}"
++#define LINK_SSP_SPEC "-lssp_nonshared"
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ 		       "|fstack-protector-strong|fstack-protector-explicit" \
+@@ -1273,7 +1278,7 @@ static const char *cc1_options =
+  %{-version:--version}\
+  %{-help=*:--help=%*}\
+  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
+- %{fsyntax-only:-o %j} %{-param*}\
++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+--- a/gcc/params.opt
++++ b/gcc/params.opt
+@@ -950,7 +950,7 @@ Common Joined UInteger Var(param_ssa_nam
+ The maximum number of SSA_NAME assignments to follow in determining a value.
+ 
+ -param=ssp-buffer-size=
+-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
+ The lower bound for a buffer to be considered for stack smashing protection.
+ 
+ -param=stack-clash-protection-guard-size=
+--- a/gcc/config/i386/gnu-user-common.h
++++ b/gcc/config/i386/gnu-user-common.h
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
+ 
+ /* Static stack checking is supported by means of probes.  */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+-
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+--- a/gcc/config/i386/gnu.h
++++ b/gcc/config/i386/gnu.h
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
+ /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+ #define TARGET_THREAD_SSP_OFFSET        0x14
+ 
+-/* We only build the -fsplit-stack support in libgcc if the
+-   assembler has full support for the CFI directives.  */
+-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+-#define TARGET_CAN_SPLIT_STACK
+-#endif
+ /* We steal the last transactional memory word.  */
+ #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+ #endif
diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
new file mode 100644
index 0000000000000..7975e6339acaa
--- /dev/null
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -0,0 +1,80 @@
+From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001
+From: Alex McGrath <amk@amk.ie>
+Date: Wed, 13 Oct 2021 23:24:27 +0100
+Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit
+
+This moves usages of pthread.h to above any usage of system.h as it
+included #pragma GCC poison calloc
+---
+ gcc/jit/jit-playback.c  | 4 ++--
+ gcc/jit/jit-recording.c | 4 ++--
+ gcc/jit/libgccjit.c     | 3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
+index cee9daa8220..a5600084933 100644
+--- a/gcc/jit/jit-playback.c
++++ b/gcc/jit/jit-playback.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "diagnostic.h"
+ #include "stmt.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-playback.h"
+ #include "jit-result.h"
+ #include "jit-builtins.h"
+diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
+index 117ff70114c..d2634a546b1 100644
+--- a/gcc/jit/jit-recording.c
++++ b/gcc/jit/jit-recording.c
+@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+ #include "pretty-print.h"
+ #include "toplev.h"
+ 
+-#include <pthread.h>
+-
+ #include "jit-builtins.h"
+ #include "jit-recording.h"
+ #include "jit-playback.h"
+diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
+index 0cc650f9810..2f44481eeb0 100644
+--- a/gcc/jit/libgccjit.c
++++ b/gcc/jit/libgccjit.c
+@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
++#include <pthread.h>
++
+ #include "config.h"
+ #include "system.h"
+ #include "coretypes.h"
+ #include "timevar.h"
+ #include "typed-splay-tree.h"
+ #include "cppbuiltin.h"
+-#include <pthread.h>
+ 
+ #include "libgccjit.h"
+ #include "jit-recording.h"
+-- 
+2.35.1
+
diff --git a/srcpkgs/gcc11/patches/ada-shared.patch b/srcpkgs/gcc11/patches/ada-shared.patch
new file mode 100644
index 0000000000000..dba5fb1d7deee
--- /dev/null
+++ b/srcpkgs/gcc11/patches/ada-shared.patch
@@ -0,0 +1,28 @@
+--- a/gcc/ada/link.c
++++ b/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+ 
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
diff --git a/srcpkgs/gcc11/patches/consistent-library-paths.patch b/srcpkgs/gcc11/patches/consistent-library-paths.patch
new file mode 100644
index 0000000000000..8ea6f17f3e752
--- /dev/null
+++ b/srcpkgs/gcc11/patches/consistent-library-paths.patch
@@ -0,0 +1,107 @@
+Always use lib64 for 64-bit and lib32 for 32-bit.
+
+Do not change the dynamic linkers in any way, though.
+
+When adding a new platform, fix this up too.
+
+--- a/gcc/config/aarch64/t-aarch64-linux
++++ b/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+ 
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib64
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+ 
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/gcc/config/i386/t-linux64
++++ b/gcc/config/i386/t-linux64
+@@ -33,6 +33,6 @@
+ comma=,
+ MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
+-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
+--- a/gcc/config/mips/t-linux64
++++ b/gcc/config/mips/t-linux64
+@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
+ MULTILIB_OSDIRNAMES = \
+-	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+-	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+-	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++	../lib32 \
++	../lib \
++	../lib64
+--- a/gcc/config/rs6000/t-linux
++++ b/gcc/config/rs6000/t-linux
+@@ -2,7 +2,8 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
+ MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
+ endif
+ ifneq (,$(findstring powerpc64le,$(target)))
+-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ endif
+ endif
+ 
+--- a/gcc/config/rs6000/t-linux64
++++ b/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,8 @@
+ MULTILIB_OPTIONS    := m64/m32
+ MULTILIB_DIRNAMES   := 64 32
+ MULTILIB_EXTRA_OPTS := 
+-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ 
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ 	$(COMPILE) $<
+--- a/gcc/config/rs6000/t-linux64bele
++++ b/gcc/config/rs6000/t-linux64bele
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mlittle
+ MULTILIB_DIRNAMES   += le
+-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/rs6000/t-linux64lebe
++++ b/gcc/config/rs6000/t-linux64lebe
+@@ -2,6 +2,6 @@
+ 
+ MULTILIB_OPTIONS    += mbig
+ MULTILIB_DIRNAMES   += be
+-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES))))))
+-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES)))
++MULTILIB_OSDIRNAMES := m64=../lib64
++MULTILIB_OSDIRNAMES += m32=../lib32
+ MULTILIB_MATCHES    := ${MULTILIB_MATCHES_ENDIAN}
+--- a/gcc/config/s390/t-linux64
++++ b/gcc/config/s390/t-linux64
+@@ -7,5 +7,5 @@
+ 
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES = m64=../lib64
++MULTILIB_OSDIRNAMES+= m32=../lib32
diff --git a/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
new file mode 100644
index 0000000000000..d6c65aaafa827
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-cxxflags-passing.patch
@@ -0,0 +1,10 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -174,6 +174,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
+ EXTRA_BUILD_FLAGS = \
+ 	CFLAGS="$(CFLAGS_FOR_BUILD)" \
++	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
+ 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"
+ 
+ # This is the list of directories to built for the host system.
diff --git a/srcpkgs/gcc11/patches/fix-musl-execinfo.patch b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
new file mode 100644
index 0000000000000..2d9d181204741
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-musl-execinfo.patch
@@ -0,0 +1,33 @@
+There is no <execinfo.h> in musl libc
+
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -124,7 +124,7 @@
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -34,7 +34,7 @@
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
+ #include <windows.h>
+-#else
++#elif defined (__GLIBC__)
+ #include <execinfo.h>
+ #endif
+ 
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
+ 
+   __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
+ 
+-#if !defined (__CYGWIN__) && !defined (__MINGW32__)
++#if !defined (__CYGWIN__) && !defined (__MINGW32__) && defined(__GLIBC__)
+   if (generate_backtrace)
+     {
+ #define STACK_DEPTH 20
diff --git a/srcpkgs/gcc11/patches/fix-vtv-link-order.patch b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
new file mode 100644
index 0000000000000..1bb0ef277bb60
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-vtv-link-order.patch
@@ -0,0 +1,20 @@
+put vtv_end.o in front of postdep_objects_CXX
+having it after crtendS.o leads to missing zero termination in eh_frame section
+
+This is in line with comment in libgcc/vtv_end.c:
+
+   When the GCC driver inserts vtv_start.o into the link line (just
+   after crtbegin.o) it also inserts vtv_end.o into the link line,
+   just before crtend.o.
+
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -15566,7 +15566,7 @@ esac
+ 
+ if test "$enable_vtable_verify" = yes; then
+   predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
+-  postdep_objects_CXX="${postdep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_end.o"
++  postdep_objects_CXX="${glibcxx_builddir}/../libgcc/vtv_end.o ${postdep_objects_CXX}" 
+ fi
+ 
+ 
diff --git a/srcpkgs/gcc11/patches/force-override-clocale.patch b/srcpkgs/gcc11/patches/force-override-clocale.patch
new file mode 100644
index 0000000000000..457ec3849e498
--- /dev/null
+++ b/srcpkgs/gcc11/patches/force-override-clocale.patch
@@ -0,0 +1,21 @@
+This is necessary when building a gnu cross compiler for a musl target.
+Otherwise, even if clocale manually is set to gnu, it will be reset to generic
+when the test is performed using AC_EGREP_CPP().
+--- a/libstdc++-v3/configure
++++ b/libstdc++-v3/configure
+@@ -16504,6 +16504,7 @@ fi
+ 
+   # Sanity check model, and test for special functionality.
+   if test $enable_clocale_flag = gnu; then
++    if test $enable_clocale = auto; then
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -16520,6 +16521,7 @@ else
+   enable_clocale_flag=generic
+ fi
+ rm -f conftest*
++    fi
+ 
+ 
+     # Set it to scream when it hurts.
diff --git a/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
new file mode 100644
index 0000000000000..b38cab8ddffae
--- /dev/null
+++ b/srcpkgs/gcc11/patches/libgcc-ibm128-no-tag.patch
@@ -0,0 +1,35 @@
+From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
+From: q66 <daniel@octaforge.org>
+Date: Thu, 12 Dec 2019 04:03:56 +0100
+Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
+ support code
+
+Doing this will allow libgcc to emit the appropriate symbols without actually
+emitting the FP ABI tag for them, which allows 64-bit long double environments
+to function and even link statically while still allowing usage of
+explicit __ibm128.
+---
+ libgcc/config/rs6000/t-ibm-ldouble | 2 +-
+ libgcc/config/rs6000/t-linux       | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libgcc/config/rs6000/t-ibm-ldouble
++++ b/libgcc/config/rs6000/t-ibm-ldouble
+@@ -1,6 +1,6 @@
+ # GCC 128-bit long double support routines.
+ LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
+--- a/libgcc/config/rs6000/t-linux
++++ b/libgcc/config/rs6000/t-linux
+@@ -1,6 +1,6 @@
+ SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
+ 
+-HOST_LIBGCC2_CFLAGS += -mlong-double-128
++HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
+ 
+ # This is a way of selecting -mcmodel=small for ppc64, which gives
+ # smaller and faster libgcc code.  Directly specifying -mcmodel=small
diff --git a/srcpkgs/gcc11/patches/mips-soft-float.patch b/srcpkgs/gcc11/patches/mips-soft-float.patch
new file mode 100644
index 0000000000000..5e966ff313d18
--- /dev/null
+++ b/srcpkgs/gcc11/patches/mips-soft-float.patch
@@ -0,0 +1,18 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -278,6 +278,7 @@ $LCFI7:
+ 	li	$9, FFI_TYPE_VOID
+ 	beq	$8, $9, closure_done
+ 
++#ifndef __mips_soft_float
+ 	li	$13, 1		# FFI_O32
+ 	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
+ 
+@@ -289,6 +290,7 @@ $LCFI7:
+ 	l.d	$f0, V0_OFF2($fp)
+ 	beq	$8, $9, closure_done
+ 1:	
++#endif
+ 	REG_L	$3, V1_OFF2($fp)
+ 	REG_L	$2, V0_OFF2($fp)
+ 
diff --git a/srcpkgs/gcc11/patches/musl-ada.patch b/srcpkgs/gcc11/patches/musl-ada.patch
new file mode 100644
index 0000000000000..c640741e9ab95
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-ada.patch
@@ -0,0 +1,200 @@
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -91,6 +91,11 @@
+ #include <sys/param.h>
+ #include <sys/pstat.h>
+ #endif
++ 
++#if defined (linux)
++#define _GNU_SOURCE 1
++#include <sched.h>
++#endif
+ 
+ #ifdef __PikeOS__
+ #define __BSD_VISIBLE 1
+@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void)
+ #endif
+ 
+ #if defined (__linux__)
+-#include <sched.h>
+ 
+ /* glibc versions earlier than 2.7 do not define the routines to handle
+    dynamically allocated CPU sets. For these targets, we use the static
+@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void)
+ 
+ /* Dynamic cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count)
+ {
+   return CPU_ALLOC (count);
+@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count)
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+-  CPU_FREE (set);
++  CPU_FREE ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count, cpu_set_t *set)
++__gnat_cpu_zero (size_t count, void *set)
+ {
+-  CPU_ZERO_S (count, set);
++  CPU_ZERO_S (count, (cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET_S (cpu - 1, count, set);
++  CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
+ }
+ 
+ #else /* !CPU_ALLOC */
+ 
+ /* Static cpu sets */
+ 
+-cpu_set_t *
++void *
+ __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
+ {
+-  return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
++  return xmalloc (sizeof (cpu_set_t));
+ }
+ 
+ size_t
+@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
+ }
+ 
+ void
+-__gnat_cpu_free (cpu_set_t *set)
++__gnat_cpu_free (void *set)
+ {
+   free (set);
+ }
+ 
+ void
+-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+-  CPU_ZERO (set);
++  CPU_ZERO ((cpu_set_t *) set);
+ }
+ 
+ void
+-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
+ {
+   /* Ada handles CPU numbers starting from 1, while C identifies the first
+      CPU by a 0, so we need to adjust. */
+-  CPU_SET (cpu - 1, set);
++  CPU_SET (cpu - 1, (cpu_set_t *) set);
+ }
+ #endif /* !CPU_ALLOC */
+ #endif /* __linux__ */
+--- a/gcc/ada/adaint.h
++++ b/gcc/ada/adaint.h
+@@ -325,13 +325,11 @@ extern void   *__gnat_lwp_self			   (voi
+ 
+ /* Routines for interface to required CPU set primitives */
+ 
+-#include <sched.h>
+-
+-extern cpu_set_t *__gnat_cpu_alloc                 (size_t);
++extern void * __gnat_cpu_alloc                 (size_t);
+ extern size_t __gnat_cpu_alloc_size                (size_t);
+-extern void   __gnat_cpu_free                  (cpu_set_t *);
+-extern void   __gnat_cpu_zero                      (size_t, cpu_set_t *);
+-extern void   __gnat_cpu_set                       (int, size_t, cpu_set_t *);
++extern void   __gnat_cpu_free                  (void *);
++extern void   __gnat_cpu_zero                      (size_t, void *);
++extern void   __gnat_cpu_set                       (int, size_t, void *);
+ #endif
+ 
+ #if defined (_WIN32)
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
+   s-intman.adb<libgnarl/s-intman__posix.adb \
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   a-exetim.adb<libgnarl/a-exetim__posix.adb \
+   a-exetim.ads<libgnarl/a-exetim__default.ads \
+   s-linux.ads<libgnarl/s-linux.ads \
+@@ -2355,7 +2355,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   system.ads<libgnat/system-linux-ppc.ads
+@@ -2386,7 +2386,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+ endif
+ 
+ # ARM linux, GNU eabi
+-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
+   LIBGNAT_TARGET_PAIRS = \
+   a-intnam.ads<libgnarl/a-intnam__linux.ads \
+   s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+@@ -2597,7 +2597,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(ATOMICS_BUILTINS_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2700,7 +2700,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
+   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
+   $(TRASYM_DWARF_UNIX_PAIRS) \
+-  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
++  s-tsmona.adb<libgnat/s-tsmona.adb \
+   $(ATOMICS_TARGET_PAIRS) \
+   $(X86_64_TARGET_PAIRS) \
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ /* POSIX does not specify how to open the master side of a terminal.Several
+    methods are available (system specific):
+       1- using a cloning device (USE_CLONE_DEVICE)
+-      2- getpt                  (USE_GETPT)
++      2- posix_openpt           (USE_POSIX_OPENPT)
+       3- openpty                (USE_OPENPTY)
+ 
+    When using the cloning device method, the macro USE_CLONE_DEVICE should
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
+ #if defined (__APPLE__) || defined (BSD)
+ #define USE_OPENPTY
+ #elif defined (__linux__)
+-#define USE_GETPT
++#define USE_POSIX_OPENPT
+ #elif defined (__sun__)
+ #define USE_CLONE_DEVICE "/dev/ptmx"
+ #elif defined (_AIX)
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
+    int  master_fd   = -1;
+    char *slave_name = NULL;
+ 
+-#ifdef USE_GETPT
+-  master_fd = getpt ();
++#if defined(USE_POSIX_OPENPT)
++  master_fd = posix_openpt(O_RDWR | O_NOCTTY);
+ #elif defined (USE_OPENPTY)
+   status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
+ #elif defined (USE_CLONE_DEVICE)
diff --git a/srcpkgs/gcc11/patches/musl-generic-locale.patch b/srcpkgs/gcc11/patches/musl-generic-locale.patch
new file mode 100644
index 0000000000000..db8d96b71df89
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-generic-locale.patch
@@ -0,0 +1,15 @@
+See
+https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
+
+--- a/libstdc++-v3/config/locale/generic/c_locale.cc
++++ b/libstdc++-v3/config/locale/generic/c_locale.cc
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
+     __cloc = 0;
+-    if (strcmp(__s, "C"))
+-      __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
+-			    "name not valid"));
+   }
+ 
+   void
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
new file mode 100644
index 0000000000000..ed9afc988370d
--- /dev/null
+++ b/srcpkgs/gcc11/template
@@ -0,0 +1,261 @@
+# Template file for 'gcc11'
+# for gdc
+pkgname=gcc11
+version=11.4.0
+revision=1
+_majorver="${version%%.*}"
+_minorver="${version%.*}"
+build_style=gnu-configure
+hostmakedepends="tar texinfo perl flex"
+makedepends="zlib-devel libzstd-devel"
+depends="binutils"
+checkdepends="dejagnu"
+short_desc="GNU Compiler Collection - version ${_majorver}"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
+homepage="http://gcc.gnu.org"
+_gmp_version=6.2.1
+_mpfr_version=4.1.0
+_mpc_version=1.2.1
+_isl_version=0.24
+distfiles="
+ ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
+ https://gmplib.org/download/gmp/gmp-${_gmp_version}.tar.xz
+ ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
+ ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
+ ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
+checksum="
+ 3f2db222b007e8a4a23cd5ba56726ef08e8b1f1eb2055ee72c1402cea73a8dd9
+ fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
+ 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f
+ 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
+ fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0"
+nopie=yes
+lib32disabled=yes
+repository=bootstrap
+skip_extraction="
+ gmp-${_gmp_version}.tar.xz
+ mpfr-${_mpfr_version}.tar.xz
+ mpc-${_mpc_version}.tar.gz
+ isl-${_isl_version}.tar.bz2
+ "
+
+if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	depends+=" musl-devel"
+else
+	depends+=" glibc-devel"
+fi
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+
+if [ "$CROSS_BUILD" ]; then
+	hostmakedepends+=" cross-${_triplet}"
+fi
+
+post_extract() {
+	vsrcextract -C gmp gmp-${_gmp_version}.tar.xz
+	vsrcextract -C mpfr mpfr-${_mpfr_version}.tar.xz
+	vsrcextract -C mpc mpc-${_mpc_version}.tar.gz
+	vsrcextract -C isl isl-${_isl_version}.tar.bz2
+}
+
+post_patch() {
+	# _FORTIFY_SOURCE needs an optimization level.
+	vsed -i '/ac_cpp=/s/[$]CPPFLAGS/$CPPFLAGS -O2/' {gcc,libiberty}/configure
+
+	# Do not run fixincludes
+	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -Np1 -i $p
+		done
+	fi
+}
+
+do_configure() {
+	local _args _hash
+	_hash=gnu
+	case "$XBPS_TARGET_MACHINE" in
+		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard"; _hash=sysv;;
+		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft"; _hash=sysv;;
+		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard";;
+		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft";;
+		armv5*) _args+=" --with-arch=armv5te --with-float=soft";;
+		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard";;
+		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
+		aarch64*) _args+=" --with-arch=armv8-a";;
+		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
+		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
+		ppc*) _args+=" --enable-secureplt";;
+	esac
+
+	# on ppc64le-musl and all big endian ppc64
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le) ;;
+		ppc64*) _args+=" --disable-libquadmath" ;;
+	esac
+
+	# fix: unknown long double size, cannot define BFP_FMT
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*-musl) _args+=" --disable-decimal-float";;
+	esac
+
+
+	if [ "$CROSS_BUILD" ]; then
+		export CC_FOR_TARGET="$CC"
+		export GCC_FOR_TARGET="$CC"
+		export CXX_FOR_TARGET="$CXX"
+
+		_args+=" --host=$XBPS_CROSS_TRIPLET"
+		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
+	else
+		_args+=" --build=${_triplet}"
+	fi
+
+	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
+		_args+=" --disable-gnu-unique-object"
+		_args+=" --disable-libsanitizer"
+		_args+=" --disable-symvers"
+		_args+=" libat_cv_have_ifunc=no"
+	else
+		_args+=" --enable-gnu-unique-object"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc*) _args+=" --disable-vtable-verify";;
+		*) _args+=" --enable-vtable-verify";;
+	esac
+
+	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
+	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"
+
+	# Disable explicit -fno-PIE, gcc will figure this out itself.
+	export CFLAGS="${CFLAGS//-fno-PIE/}"
+	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
+	export LDFLAGS="${LDFLAGS//-no-pie/}"
+
+	_args+=" --prefix=/usr"
+	_args+=" --program-suffix=-${_majorver}"
+	_args+=" --enable-version-specific-runtime-libs"
+	_args+=" --mandir=/usr/share/man"
+	_args+=" --infodir=/usr/share/info"
+	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
+	_args+=" --with-gxx-include-dir=/usr/include/c++/${version}"
+	_args+=" --enable-threads=posix"
+	_args+=" --enable-__cxa_atexit"
+	_args+=" --disable-multilib"
+	_args+=" --with-system-zlib"
+	_args+=" --enable-shared"
+	_args+=" --enable-lto"
+	_args+=" --enable-plugins"
+	_args+=" --enable-linker-build-id"
+	_args+=" --disable-werror"
+	_args+=" --disable-nls"
+	_args+=" --enable-default-pie"
+	_args+=" --enable-default-ssp"
+	_args+=" --enable-checking=release"
+	_args+=" --disable-libstdcxx-pch"
+	_args+=" --with-isl"
+	_args+=" --with-linker-hash-style=$_hash"
+	_args+=" --disable-sjlj-exceptions"
+	_args+=" --disable-target-libiberty"
+	_args+=" --disable-libssp"
+
+	mkdir -p build
+	cd build
+	_args+=" --enable-languages=c,c++,d,lto"
+	CONFIG_SHELL=/bin/bash \
+		${wrksrc}/configure ${_args}
+}
+
+do_build() {
+	make -C build ${makejobs}
+}
+
+do_install() {
+	local _f
+	vmkdir "usr/include/c++/${version}"
+	make -C build DESTDIR="${DESTDIR}" install
+
+	# Make version a symlink of major version to make all versions
+	# from the same series work automagically.
+	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}
+
+	# Ditto for c++ headers.
+	mv ${DESTDIR}/usr/include/c++/${version} \
+		${DESTDIR}/usr/include/c++/${_minorver}
+	ln -sf ${_minorver} ${DESTDIR}/usr/include/c++/${version}
+
+	# Avoid conflict with gcc
+	mv ${DESTDIR}/usr/lib/libcc1* ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
+
+	# Remove python stuff
+	rm -rf ${DESTDIR}/usr/share/gcc-${version}/python
+
+	# Conflicting manpages, provided by gcc
+	rm -rf ${DESTDIR}/usr/share/man/man7
+
+	# Version info files to avoid conflicts with gcc
+	for f in cpp cppinternals gcc gccinstall gccint gdc \
+		libgomp libitm libquadmath; do
+		if [ -f ${DESTDIR}/usr/share/info/${f}.info ]; then
+			mv ${DESTDIR}/usr/share/info/${f}.info \
+			   ${DESTDIR}/usr/share/info/${f}-${_majorver}.info
+		fi
+	done
+
+	# Provided by main libgcc
+	rm -f ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib64/libgcc_s.so* \
+		${DESTDIR}/usr/lib/gcc/${_triplet}/lib32/libgcc_s.so*
+
+	# Move pkg-config file into a path pkg-config knows about
+	# mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/pkgconfig \
+	#   ${DESTDIR}/usr/lib/
+}
+
+gcc11-gdc_package() {
+	lib32disabled=yes
+	repository=bootstrap
+	depends="${sourcepkg}>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgphobos.*"
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/libgdruntime.*"
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}

From ef3fee79e9c0320f2f572f34f5173ebeaa073dca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 14:12:54 +0700
Subject: [PATCH 04/15] gcc: add D frontend

---
 srcpkgs/gcc-gdc            |   1 +
 srcpkgs/gcc/template       | 110 +++++++++++++++++++++++++++++++------
 srcpkgs/libgdruntime       |   1 +
 srcpkgs/libgdruntime-devel |   1 +
 srcpkgs/libgphobos         |   1 +
 srcpkgs/libgphobos-devel   |   1 +
 6 files changed, 98 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/gcc-gdc
 create mode 120000 srcpkgs/libgdruntime
 create mode 120000 srcpkgs/libgdruntime-devel
 create mode 120000 srcpkgs/libgphobos
 create mode 120000 srcpkgs/libgphobos-devel

diff --git a/srcpkgs/gcc-gdc b/srcpkgs/gcc-gdc
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/gcc-gdc
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 34a3fa62d31b5..a818b0cdacf57 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -4,7 +4,7 @@
 
 pkgname=gcc
 version=12.2.0
-revision=3
+revision=4
 _minorver="${version%.*}"
 _majorver="${_minorver%.*}"
 _gmp_version=6.2.1
@@ -36,6 +36,7 @@ replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
  libssp>=0 libssp-devel>=0"
 
 _have_gccgo=yes
+_have_gdc=yes
 
 # MIPS is untested and does not have go in crosstoolchains
 # 32-bit PowerPC seems weirdly broken since the 10.x release
@@ -49,6 +50,7 @@ if [ "$CHROOT_READY" ]; then
 	hostmakedepends="tar texinfo perl flex"
 else
 	_have_gccgo=no
+	_have_gdc=no
 	# libzstd fails to link in bootstrap with glibc 2.36
 	# when zlib has been compiled with glibc 2.32.
 	LDFLAGS="-lzstd -pthread"
@@ -95,6 +97,17 @@ if [ "$_have_gccgo" = "yes" ]; then
 	fi
 fi
 
+if [ "$_have_gdc" = yes ]; then
+	if [ "$CROSS_BUILD" ]; then
+		hostmakedepends+=" gcc-gdc"
+	else
+		hostmakedepends+=" gcc11-gdc"
+	fi
+	subpackages+=" gcc-gdc"
+	subpackages+=" libgdruntime-devel libgdruntime"
+	subpackages+=" libgphobos-devel libgphobos"
+fi
+
 subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
 if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
 	subpackages+=" gcc-ada libada-devel libada"
@@ -180,7 +193,7 @@ post_extract() {
 	fi
 }
 
-pre_configure() {
+post_patch() {
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
@@ -193,9 +206,9 @@ pre_configure() {
 		done
 	fi
 }
+
 do_configure() {
 	local _langs _args _hash
-
 	_hash=gnu
 	case "$XBPS_TARGET_MACHINE" in
 		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
@@ -222,10 +235,6 @@ do_configure() {
 		ppc*-musl) _args+=" --disable-decimal-float";;
 	esac
 
-	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
-		_langs="c,c++,lto"
-	fi
-
 	if [ "$CROSS_BUILD" ]; then
 		export CC_FOR_TARGET="$CC"
 		export GCC_FOR_TARGET="$CC"
@@ -235,10 +244,11 @@ do_configure() {
 
 		_args+=" --host=$XBPS_CROSS_TRIPLET"
 		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
-		_langs+=",objc,obj-c++,fortran"
+		_langs="c,c++,lto,objc,obj-c++,fortran"
 	elif [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 		_args+=" --build=${_triplet}"
+		_langs="c,c++,lto"
 	else
 		_langs="c,c++,objc,obj-c++,fortran,lto"
 		_args+=" --build=${_triplet}"
@@ -248,6 +258,26 @@ do_configure() {
 		_langs+=",go"
 	fi
 
+	if [ "$_have_gdc" = yes ]; then
+		_langs+=",d"
+		mkdir -p ${wrksrc}/gdc-bt
+		PATH="$PATH:${wrksrc}/gdc-bt"
+		ln -fs /usr/bin/gdc-11 ${wrksrc}/gdc-bt/gdc
+		case "$XBPS_TARGET_MACHINE" in
+		x86_64)
+			ln -fs /usr/bin/x86_64-linux-gnu-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		*)
+			ln -fs /usr/bin/${_triplet}-gdc-11 \
+				${wrksrc}/gdc-bt/${_triplet}-gdc
+			;;
+		esac
+		export GDC=gdc
+		export GDC_FOR_TARGET="${_triplet}-gdc"
+
+	fi
+
 	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
 		_args+=" --disable-gnu-unique-object"
 		_args+=" --disable-libsanitizer"
@@ -320,29 +350,27 @@ do_build() {
 	if [ -z "$CHROOT_READY" ]; then
 		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
 	fi
-	cd build
+	if [ "$_have_gdc" = yes ]; then
+		PATH="$PATH:${wrksrc}/gdc-bt"
+	fi
 	if [ "$build_option_gnatboot" ]; then
 		CC="${wrksrc}/gnat/bin/gcc" \
 		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
 		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
 		PATH="${wrksrc}/gnat/bin:$PATH" \
-		make ${makejobs}
+		make -C build ${makejobs}
 	else
-		make ${makejobs}
+		make -C build ${makejobs}
 	fi
 }
-pre_install() {
+do_install() {
 	if [ "$CROSS_BUILD" ]; then
 		# XXX otherwise links to host libpthread
 		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
 			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
 		done
 	fi
-}
-do_install() {
-	cd build
-
-	make DESTDIR=${DESTDIR} install
+	make -C build DESTDIR=${DESTDIR} install
 
 	# Make version a symlink of major version to make all versions
 	# from the same series work automagically.
@@ -402,6 +430,19 @@ gcc-ada_package() {
 	}
 }
 
+gcc-gdc_package() {
+	lib32disabled=yes
+	depends="${sourcepkg}>=${_minorver}
+	 libgdruntime-devel>=${_minorver} libgphobos-devel>=${_minorver}"
+	short_desc+=" - D compiler frontend"
+	pkg_install() {
+		vmove "usr/bin/*gdc*"
+		vmove usr/lib/gcc/${_triplet}/${_minorver}/d21
+		vmove "usr/share/info/gdc*"
+		vmove "usr/share/man/man1/gdc*"
+	}
+}
+
 gcc-go_package() {
 	lib32disabled=yes
 	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
@@ -499,6 +540,41 @@ libada_package() {
 	}
 }
 
+libgdruntime-devel_package() {
+	depends="libgdruntime>=${_minorver}"
+	short_desc+=" - D library - development files"
+	pkg_install() {
+		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
+		vmove "usr/lib/libgdruntime.a"
+		vmove "usr/lib/libgdruntime.la"
+		vmove "usr/lib/libgdruntime.so"
+	}
+}
+
+libgdruntime_package() {
+	short_desc+=" - D library"
+	pkg_install() {
+		vmove "usr/lib/libgdruntime*.so.*"
+	}
+}
+
+libgphobos-devel_package() {
+	depends="libgphobos>=${_minorver}"
+	short_desc+=" - GNU Phobos library - development files"
+	pkg_install() {
+		vmove usr/lib/libgphobos.spec
+		vmove usr/lib/libgphobos.a
+		vmove usr/lib/libgphobos.so
+	}
+}
+
+libgphobos_package() {
+	short_desc+=" - GNU Phobos library"
+	pkg_install() {
+		vmove "usr/lib/libgphobos.so.*"
+	}
+}
+
 libgfortran-devel_package() {
 	depends="libgfortran>=${_minorver}"
 	short_desc+=" - Fortran library - development files"
diff --git a/srcpkgs/libgdruntime b/srcpkgs/libgdruntime
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgdruntime-devel b/srcpkgs/libgdruntime-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgdruntime-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos b/srcpkgs/libgphobos
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos
@@ -0,0 +1 @@
+gcc
\ No newline at end of file
diff --git a/srcpkgs/libgphobos-devel b/srcpkgs/libgphobos-devel
new file mode 120000
index 0000000000000..b08d5af5795c6
--- /dev/null
+++ b/srcpkgs/libgphobos-devel
@@ -0,0 +1 @@
+gcc
\ No newline at end of file

From ab3798336b25ef2abf9ebfd1b2e31485e1abcf81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 16:03:36 +0700
Subject: [PATCH 05/15] New package: gdmd-0.1.0

---
 srcpkgs/gdmd/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/gdmd/template

diff --git a/srcpkgs/gdmd/template b/srcpkgs/gdmd/template
new file mode 100644
index 0000000000000..af8e1a3cc007d
--- /dev/null
+++ b/srcpkgs/gdmd/template
@@ -0,0 +1,17 @@
+# Template file for 'gdmd'
+pkgname=gdmd
+version=0.1.0
+revision=1
+depends="perl gcc-gdc"
+short_desc="DMD-like CLI interface for gdc"
+maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
+license="GPL-3.0-or-later"
+homepage="https://github.com/D-Programming-GDC/gdmd"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/script-$version.tar.gz"
+distfiles="https://github.com/D-Programming-GDC/gdmd/archive/refs/tags/script-${version}.tar.gz"
+checksum=6c9891b7f2e41d8b6c0e89fab3ad32fb77bb3617760b33a4c23bca49197a026b
+
+do_install() {
+	vbin dmd-script gdmd
+	vman dmd-script.1 gdmd.1
+}

From c6df62075e5eeedcbf8d6f41ba400acdbee934c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Tue, 14 Mar 2023 21:23:40 +0700
Subject: [PATCH 06/15] ldc: update to 1.35.0.

---
 common/shlibs                            |   8 +-
 srcpkgs/ldc-runtime-debug                |   1 +
 srcpkgs/ldc-runtime-devel                |   1 +
 srcpkgs/ldc/patches/dmd-fe-version.patch |  15 +++
 srcpkgs/ldc/patches/no-lit.patch         |  11 ++
 srcpkgs/ldc/patches/target-runtime.patch |  25 ++++
 srcpkgs/ldc/template                     | 163 +++++++++++++++++++++--
 7 files changed, 210 insertions(+), 14 deletions(-)
 create mode 120000 srcpkgs/ldc-runtime-debug
 create mode 120000 srcpkgs/ldc-runtime-devel
 create mode 100644 srcpkgs/ldc/patches/dmd-fe-version.patch
 create mode 100644 srcpkgs/ldc/patches/no-lit.patch
 create mode 100644 srcpkgs/ldc/patches/target-runtime.patch

diff --git a/common/shlibs b/common/shlibs
index 67e0812c68e19..b9a5012250e19 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2152,10 +2152,10 @@ libFcitx5Config.so.6 libfcitx5-5.0.5_1
 libFcitx5GClient.so.2 fcitx5-gtk-5.0.4_1
 libFcitx5Qt5DBusAddons.so.1 fcitx5-qt5-5.0.3_1
 libFcitx5Qt5WidgetsAddons.so.2 fcitx5-qt5-5.0.3_1
-libdruntime-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
-libdruntime-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-shared.so.101 ldc-runtime-1.31.0_1
-libphobos2-ldc-debug-shared.so.101 ldc-runtime-1.31.0_1
+libdruntime-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libphobos2-ldc-shared.so.105 ldc-runtime-1.35.0_1
+libdruntime-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
+libphobos2-ldc-debug-shared.so.105 ldc-runtime-debug-1.35.0_1
 libmarblewidget-qt5.so.28 marble5-17.12.2_1
 libastro.so.2 marble5-17.12.2_1
 libparrot.so.6.9.0 parrot-6.9.0_1
diff --git a/srcpkgs/ldc-runtime-debug b/srcpkgs/ldc-runtime-debug
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-debug
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc-runtime-devel b/srcpkgs/ldc-runtime-devel
new file mode 120000
index 0000000000000..12f0b1bf64f06
--- /dev/null
+++ b/srcpkgs/ldc-runtime-devel
@@ -0,0 +1 @@
+ldc
\ No newline at end of file
diff --git a/srcpkgs/ldc/patches/dmd-fe-version.patch b/srcpkgs/ldc/patches/dmd-fe-version.patch
new file mode 100644
index 0000000000000..9a4ef44994af9
--- /dev/null
+++ b/srcpkgs/ldc/patches/dmd-fe-version.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -134,6 +134,12 @@ if(NOT DEFINED SYSCONF_INSTALL_DIR)
+     endif()
+ endif()
+ 
++file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dmd.version "
++_major=${DMDFE_MAJOR_VERSION}
++_minor=${DMDFE_MINOR_VERSION}
++_pver=${DMDFE_PATCH_VERSION}
++")
++
+ set(D_VERSION ${DMDFE_MAJOR_VERSION} CACHE STRING "D language version")
+ set(PROGRAM_PREFIX "" CACHE STRING "Prepended to ldc/ldmd binary names")
+ set(PROGRAM_SUFFIX "" CACHE STRING "Appended to ldc/ldmd binary names")
diff --git a/srcpkgs/ldc/patches/no-lit.patch b/srcpkgs/ldc/patches/no-lit.patch
new file mode 100644
index 0000000000000..7290d39fdc21f
--- /dev/null
+++ b/srcpkgs/ldc/patches/no-lit.patch
@@ -0,0 +1,11 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -20,8 +20,3 @@ endif()
+ 
+ configure_file(lit.site.cfg.in lit.site.cfg )
+ configure_file(runlit.py       runlit.py    COPYONLY)
+-
+-add_test(NAME lit-tests
+-    COMMAND ${PYTHON_EXE} runlit.py -v .
+-)
+-
diff --git a/srcpkgs/ldc/patches/target-runtime.patch b/srcpkgs/ldc/patches/target-runtime.patch
new file mode 100644
index 0000000000000..c85795a4606ee
--- /dev/null
+++ b/srcpkgs/ldc/patches/target-runtime.patch
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -906,7 +906,9 @@ add_test(NAME build-ldc2-unittest COMMAN
+ add_test(NAME ldc2-unittest COMMAND ${LDC_UNITTEST_EXE_FULL} --version)
+ set_tests_properties(ldc2-unittest PROPERTIES DEPENDS build-ldc2-unittest)
+ 
+-if(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
++if (DEFINED XBPS_LDC_BOOTSTRAP)
++    message(STATUS "Bootstrapping, skip building runtime")
++elseif(EXISTS "${PROJECT_SOURCE_DIR}/runtime/druntime/src/object.d")
+     add_subdirectory(runtime)
+ else()
+     message(STATUS "Runtime file runtime/druntime/src/object.d not found, will build ldc binaries but not the standard library.")
+--- a/runtime/CMakeLists.txt
++++ b/runtime/CMakeLists.txt
+@@ -7,6 +7,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PAT
+ include(CheckIncludeFile)
+ 
+ # Verify required variables if this CMake project is NOT embedded in the LDC CMake project.
++if(DEFINED XLDC_EXE_FULL)
++   set(LDC_EXE_FULL "${XLDC_EXE_FULL}")
++endif()
+ if(NOT LDC_EXE)
+     if(NOT LDC_EXE_FULL)
+         message(FATAL_ERROR "Please define the path to the LDC executable via -DLDC_EXE_FULL=...")
diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index f6d8b7ffbe985..769f82f8c4031 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -1,6 +1,6 @@
 # Template file for 'ldc'
 pkgname=ldc
-version=1.31.0
+version=1.35.0
 revision=1
 build_style=cmake
 configure_args="
@@ -11,30 +11,173 @@ configure_args="
  -DCOMPILE_D_MODULES_SEPARATELY=ON
  -DC_SYSTEM_LIBS='unwind;m;pthread;rt;dl'"
 conf_files="/etc/ldc2.conf"
-hostmakedepends="dmd llvm15 perl pkg-config"
+hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel"
-depends="ldc-runtime llvm-libunwind-devel"
-checkdepends="python3"
+ llvm-libunwind-devel llvm"
+depends="ldc-runtime-devel llvm-libunwind-devel"
+checkdepends="python3 gdb"
 short_desc="Portable D programming language compiler based on LLVM"
 maintainer="Auri <me@aurieh.me>"
 license="BSD-3-Clause, BSL-1.0"
 homepage="https://wiki.dlang.org/LDC"
 changelog="https://raw.githubusercontent.com/ldc-developers/ldc/master/CHANGELOG.md"
 distfiles="https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"
-checksum=f1c8ece9e1e35806c3441bf24fbe666cddd8eef375592c19cd8fee4701cd5458
+checksum=6e296993706c76c093e609139aa0b3f8704355fa0f3756f6758d78d44226dfa0
 nopie=yes
-nocross="dmd compilation fails on cross"
 # tests timeout on musl; also require unpackaged python3-lit
-make_check=no
+# make_check=no
+subpackages="ldc-runtime-debug ldc-runtime ldc-runtime-devel"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686) _triplet="i686-pc-linux-gnu";;
+	i686-musl) _triplet="i686-linux-musl";;
+	x86_64) _triplet="x86_64-linux-gnu";;
+	x86_64-musl) _triplet="x86_64-linux-musl";;
+	armv5tel) _triplet="arm-linux-gnueabi";;
+	armv5tel-musl) _triplet="arm-linux-musleabi";;
+	armv6l) _triplet="arm-linux-gnueabihf";;
+	armv7l) _triplet="armv7l-linux-gnueabihf";;
+	armv6l-musl) _triplet="arm-linux-musleabihf";;
+	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
+	aarch64) _triplet="aarch64-linux-gnu";;
+	aarch64-musl) _triplet="aarch64-linux-musl";;
+	ppc) _triplet="powerpc-linux-gnu";;
+	ppc-musl) _triplet="powerpc-linux-musl";;
+	ppcle) _triplet="powerpcle-linux-gnu";;
+	ppcle-musl) _triplet="powerpcle-linux-musl";;
+	ppc64le) _triplet="powerpc64le-linux-gnu";;
+	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
+	ppc64) _triplet="powerpc64-linux-gnu";;
+	ppc64-musl) _triplet="powerpc64-linux-musl";;
+	mips-musl) _triplet="mips-linux-musl";;
+	mipshf-musl) _triplet="mips-linux-muslhf";;
+	mipsel-musl) _triplet="mipsel-linux-musl";;
+	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
+esac
+export DFLAGS="-mtriple=${_triplet}"
+
+pre_configure() {
+	local _ldc _major _minor _pver
+
+	unset DFLAGS
+	# First build ldc by gdc
+	mkdir -p build-stage1
+	CC=$CC_FOR_BUILD CFLAGS="$CFLAGS_FOR_BUILD" \
+	CXX=$CXX_FOR_BUILD CXXFLAGS="$CXXFLAGS_FOR_BUILD" \
+	LD=$LD_FOR_BUILD LDFLAGS="$LDFLAGS_FOR_BUILD" \
+	cmake -GNinja -DD_COMPILER=gdmd \
+		-S $PWD -B $PWD/build-stage1
+	ninja -C build-stage1
+
+	# Then build ldc-runtime for stage1 ldc
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldmd2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldmd2" -mtriple="$_triplet" "\$@"
+	EOF
+	cat <<-EOF >"${XBPS_WRAPPERDIR}/ldc2"
+	#!/bin/sh
+	exec "$wrksrc/build-stage1/bin/ldc2" -mtriple="$_triplet" "\$@"
+	EOF
+	_ldmd="${XBPS_WRAPPERDIR}/ldmd2"
+	_ldc="${XBPS_WRAPPERDIR}/ldc2"
+	chmod +x "${_ldmd}"
+	chmod +x "${_ldc}"
+
+	export DFLAGS=-mtriple=${_triplet}
+	# get _major _minor and _pver
+	source build-stage1/dmd.version
+	mkdir -p build-stage2
+	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
+	CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
+	cmake -GNinja \
+		-DD_COMPILER="$_ldmd" -DLDC_EXE_FULL="$_ldc" \
+		-DDMDFE_MAJOR_VERSION=$_major \
+		-DDMDFE_MINOR_VERSION=$_minor \
+		-DDMDFE_PATCH_VERSION=$_pver \
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+		-DCMAKE_INSTALL_LIBDIR="lib${XBPS_TARGET_WORDSIZE}" \
+		-DLIB_SUFFIX="${XBPS_TARGET_WORDSIZE}" \
+		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
+		-S $PWD/runtime -B $PWD/build-stage2
+	ninja -C build-stage2
+
+	cat <<-EOF >build-stage1/bin/ldc2.conf
+	default:
+	{
+	    switches = [
+		"-defaultlib=phobos2-ldc,druntime-ldc",
+	    ];
+	    post-switches = [
+		"-I$PWD/runtime/druntime/src",
+		"-I$PWD/build-stage2/runtime/import",
+		"-I$PWD/runtime/jit-rt/d",
+		"-I$PWD/runtime/phobos",
+	    ];
+	    lib-dirs = [
+		"$PWD/build-stage2/lib${XBPS_TARGET_WORDSIZE}",
+	    ];
+	    rpath = "";
+	};
+
+	"^wasm(32|64)-":
+	{
+	    switches = [
+		"-defaultlib=",
+		"-L-z", "-Lstack-size=1048576",
+		"-L--stack-first",
+		"-L--export-dynamic",
+	    ];
+	    lib-dirs = [];
+	};
+	EOF
+
+	configure_args+=" -DD_COMPILER=${_ldmd}"
+	configure_args+=" -DXLDC_EXE_FULL=${_ldc}"
+	configure_args+=" -DLIB_SUFFIX=${XBPS_TARGET_WORDSIZE}"
+}
+
+pre_check() {
+	ninja -C build ${makejobs} ldc2-unittest \
+		druntime-test-runner-debug-shared \
+		druntime-test-runner-shared \
+		phobos2-test-runner-debug-shared \
+		phobos2-test-runner-shared \
+		build-run-dmd-testsuite
+	# has unknown type; cast it to its declared type
+	rm -f tests/dmd/runnable/gdb14313.d \
+		tests/dmd/runnable/gdb4181.d
+}
 
 post_install() {
-	vlicense LICENSE
+	sed -i -e "
+	/rpath/ s,\"/usr/lib[36][24]\",\"\",
+	s;\"/usr/lib[36][24]\",;\"/usr/lib\",;
+	" "$DESTDIR/etc/ldc2.conf"
 }
 
 ldc-runtime_package() {
 	short_desc+=" - D runtime"
 	pkg_install() {
-		vmove "usr/lib/*.so*"
+		vlicense LICENSE
+		vmove "usr/lib/*.so.*"
+	}
+}
+
+ldc-runtime-debug_package() {
+	short_desc+=" - D runtime - debug version"
+	pkg_install() {
+		vlicense LICENSE
+		vmove "usr/lib/*-debug-*.so.*"
+	}
+}
+
+ldc-runtime-devel_package() {
+	short_desc+=" - D runtime - development files"
+	depends="ldc-runtime ldc-runtime-debug llvm-libunwind-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove "usr/lib/*.o"
+		vmove "usr/lib/*.so"
 	}
 }

From 086fbfa3dd0e010e2df26d3e89386ed15f92da2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:47 +0700
Subject: [PATCH 07/15] btdu: rebuild for ldc 1.34.0

---
 srcpkgs/btdu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/btdu/template b/srcpkgs/btdu/template
index a42917b4f665b..eb2a33360b3f6 100644
--- a/srcpkgs/btdu/template
+++ b/srcpkgs/btdu/template
@@ -1,7 +1,7 @@
 # Template file for 'btdu'
 pkgname=btdu
 version=0.5.1
-revision=1
+revision=2
 hostmakedepends="ldc dub"
 makedepends="zlib-devel ncurses-devel"
 short_desc="Sampling disk usage profiler for btrfs"

From 702ceef33d5dda152b14a3b6fe25710112a60736 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:51 +0700
Subject: [PATCH 08/15] gtkd: rebuild for ldc 1.34.0

---
 srcpkgs/gtkd/patches/cross.patch             | 11 +++
 srcpkgs/gtkd/patches/fix--L-pkg-config.patch | 51 +++++++++++
 srcpkgs/gtkd/patches/pkg-config.patch        | 89 ++++++++++++++++++++
 srcpkgs/gtkd/template                        | 33 ++++++--
 4 files changed, 177 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/gtkd/patches/cross.patch
 create mode 100644 srcpkgs/gtkd/patches/fix--L-pkg-config.patch
 create mode 100644 srcpkgs/gtkd/patches/pkg-config.patch

diff --git a/srcpkgs/gtkd/patches/cross.patch b/srcpkgs/gtkd/patches/cross.patch
new file mode 100644
index 0000000000000..d56f5efe8d222
--- /dev/null
+++ b/srcpkgs/gtkd/patches/cross.patch
@@ -0,0 +1,11 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -38,7 +38,7 @@ ifeq ("$(DC)","gdc")
+     DDOCINC=-fdoc-inc=
+     output=-o $@
+ else
+-    DCFLAGS=-O
++    DCFLAGS+=-O
+     LINKERFLAG=-L
+     DDOCFLAGS=-o- -Df$@
+     output=-of$@
diff --git a/srcpkgs/gtkd/patches/fix--L-pkg-config.patch b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
new file mode 100644
index 0000000000000..f6a6e6b7f2da4
--- /dev/null
+++ b/srcpkgs/gtkd/patches/fix--L-pkg-config.patch
@@ -0,0 +1,51 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -278,42 +278,42 @@ gtkd-$(MAJOR).pc:
+ 	echo Name: GtkD > $@
+ 	echo Description: A D binding and OO wrapper for GTK+. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-L$(prefix)/$(libdir)/ $(LINKERFLAG)-lgtkd-$(MAJOR) $(LINKERFLAG)-ldl >> $@
++	echo Libs: -L$(prefix)/$(libdir) -lgtkd-$(MAJOR) -ldl >> $@
+ 	echo Cflags: -I$(prefix)/include/d/gtkd-$(MAJOR)/ >> $@
+ 
+ gtkdgl-$(MAJOR).pc:
+ 	echo Name: GtkDGL > $@
+ 	echo Description: OpenGL capabilities for GtkD. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdgl-$(MAJOR) >> $@
++	echo Libs: -lgtkdgl-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gtkdsv-$(MAJOR).pc:
+ 	echo Name: GtkD SourceView > $@
+ 	echo Description: A D binding and OO wrapper for GtkSourceView. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgtkdsv-$(MAJOR) >> $@
++	echo Libs: -lgtkdsv-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ gstreamerd-$(MAJOR).pc:
+ 	echo Name: GstreamerD > $@
+ 	echo Description: A D binding and OO wrapper for Gstreamer. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lgstreamerd-$(MAJOR) >> $@
++	echo Libs: -lgstreamerd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ vted-$(MAJOR).pc:
+ 	echo Name: VteD > $@
+ 	echo Description: A D binding and OO wrapper for Vte. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lvted-$(MAJOR) >> $@
++	echo Libs: -lvted-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ peasd-$(MAJOR).pc:
+ 	echo Name: PeasD > $@
+ 	echo Description: A D binding and OO wrapper for Peas. >> $@
+ 	echo Version: $(GTKD_VERSION) >> $@
+-	echo Libs: $(LINKERFLAG)-lpeasd-$(MAJOR) >> $@
++	echo Libs: -lpeasd-$(MAJOR) >> $@
+ 	echo Requires: gtkd-$(MAJOR) >> $@
+ 
+ #######################################################################
diff --git a/srcpkgs/gtkd/patches/pkg-config.patch b/srcpkgs/gtkd/patches/pkg-config.patch
new file mode 100644
index 0000000000000..e3f5fccc65c6c
--- /dev/null
+++ b/srcpkgs/gtkd/patches/pkg-config.patch
@@ -0,0 +1,89 @@
+--- a/GNUmakefile
++++ b/GNUmakefile
+@@ -368,33 +368,33 @@ install-shared-peas: $(SONAME_PEASD) ins
+ 
+ install-headers-gtkd: gtkd-$(MAJOR).pc
+ 	install -d $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)
+-	install -d $(DESTDIR)$(libdir)/pkgconfig
++	install -d $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 	(cd generated/gtkd;   echo $(SOURCES_GTKD)   | sed -e s,generated/gtkd/,,g   | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdgl: gtkdgl-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gtkdgl; echo $(SOURCES_GTKDGL) | sed -e s,generated/gtkdgl/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdgl-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gtkdsv: gtkdsv-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/sourceview; echo $(SOURCES_GTKDSV) | sed -e s,generated/sourceview/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gtkdsv-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-gstreamer: gstreamerd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/gstreamer; echo $(SOURCES_GSTREAMERD) | sed -e s,generated/gstreamer/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 gstreamerd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-vte: vted-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/vte; echo $(SOURCES_VTED) | sed -e s,generated/vte/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 vted-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ install-headers-peas: peasd-$(MAJOR).pc install-headers-gtkd
+ 	(cd generated/peas; echo $(SOURCES_PEASD) | sed -e s,generated/peas/,,g | xargs tar cf -) | (cd $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR); tar xvf -)
+-	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(libdir)/pkgconfig
++	install -m 644 peasd-$(MAJOR).pc $(DESTDIR)$(prefix)/$(libdir)/pkgconfig
+ 
+ uninstall: uninstall-gtkdgl uninstall-gtkdsv uninstall-gstreamer uninstall-vte uninstall-peas
+ 	$(foreach dir,$(shell ls generated/gtkd)  , rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKD).$(SO_VERSION)
+@@ -402,7 +402,7 @@ uninstall: uninstall-gtkdgl uninstall-gt
+ 
+ uninstall-gtkdgl:
+ 	$(foreach dir,$(shell ls generated/gtkdgl), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdgl-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDGL).$(SO_VERSION)
+@@ -410,7 +410,7 @@ uninstall-gtkdgl:
+ 
+ uninstall-gtkdsv:
+ 	$(foreach dir,$(shell ls generated/sourceview), rm -rf $(DESTDIR)$(prefix)/include/d/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gtkdsv-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GTKDSV).$(SO_VERSION)
+@@ -418,7 +418,7 @@ uninstall-gtkdsv:
+ 
+ uninstall-gstreamer:
+ 	$(foreach dir,$(shell ls generated/gstreamer), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/gstreamerd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_GSTREAMERD).$(SO_VERSION)
+@@ -426,7 +426,7 @@ uninstall-gstreamer:
+ 
+ uninstall-vte:
+ 	$(foreach dir,$(shell ls generated/vte), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/vted-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/vted-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_VTED).$(SO_VERSION)
+@@ -434,7 +434,7 @@ uninstall-vte:
+ 
+ uninstall-peas:
+ 	$(foreach dir,$(shell ls generated/peas), rm -rf $(DESTDIR)$(prefix)/include/d/gtkd-$(MAJOR)/$(dir))
+-	rm -f $(DESTDIR)$(libdir)/pkgconfig/peasd-$(MAJOR).pc
++	rm -f $(DESTDIR)$(prefix)/$(libdir)/pkgconfig/peasd-$(MAJOR).pc
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(LIBNAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD)
+ 	rm -f $(DESTDIR)$(prefix)/$(libdir)/$(SONAME_PEASD).$(SO_VERSION)
diff --git a/srcpkgs/gtkd/template b/srcpkgs/gtkd/template
index 6a75d69e19cec..bb6128c7813d3 100644
--- a/srcpkgs/gtkd/template
+++ b/srcpkgs/gtkd/template
@@ -1,9 +1,9 @@
 # Template file for 'gtkd'
 pkgname=gtkd
 version=3.9.0
-revision=10
+revision=11
 build_style=gnu-makefile
-make_build_args="LDFLAGS='-linker=bfd' DC=ldc2"
+make_build_args="DC=ldc2"
 make_build_target="shared-libs shared-gstreamer shared-vte shared-peas shared-gtkdgl"
 make_check_args="$make_build_args"
 make_install_target="install-shared-gstreamer install-headers-gstreamer
@@ -12,7 +12,8 @@ make_install_target="install-shared-gstreamer install-headers-gstreamer
  install-headers-vte"
 hostmakedepends="ldc pkg-config tar which"
 makedepends="gstreamer1-devel gtksourceview-devel libpeas-devel librsvg-devel
- vte3-devel"
+ atk-devel cairo-devel pango-devel gtk+3-devel libglib-devel
+ vte3-devel ldc-runtime-devel"
 short_desc="D bindings for GTK+3 and related libraries"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="LGPL-3.0-or-later"
@@ -20,15 +21,29 @@ homepage="https://gtkd.org"
 #changelog="https://gtkd.org/changelog.html"
 distfiles="https://github.com/gtkd-developers/GtkD/archive/v${version}.tar.gz"
 checksum=02a5d84b120e66011d6595f92679780f5782e8fe733c5517de1629c397a0d7d9
-nocross="Uses host flags for cross compilations"
+shlib_requires="
+ libatk-1.0.so.0
+ libcairo.so.2
+ libgtk-3.so.0
+ libgdk-3.so.0
+ libgdk_pixbuf-2.0.so.0
+ libgio-2.0.so.0
+ libgobject-2.0.so.0
+ libpango-1.0.so.0 libpangocairo-1.0.so.0
+ libglib-2.0.so.0 libgmodule-2.0.so.0"
+# nocross="Uses host flags for cross compilations"
 
-do_patch() {
-	# Makefile wants to install pkgconfig in /lib by default
-	vsed -e 's@$(DESTDIR)$(libdir)@$(DESTDIR)$(prefix)/$(libdir)@g' -i GNUmakefile
+if [ "$CROSS_BUILD" ]; then
+	export DCFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
+
+pre_build() {
+	LDFLAGS="-linker=bfd ${DCFLAGS}"
 }
 
 libpeasd_package() {
 	short_desc+=" - peasd library"
+	shlib_requires="libpeas-1.0.so.0 libpeas-gtk-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libpeasd-3.so.*"
 	}
@@ -66,6 +81,7 @@ libgtkdgl-devel_package() {
 
 libvted_package() {
 	short_desc+=" - vted library"
+	shlib_requires="libvte-2.91.so.0"
 	pkg_install() {
 		vmove "usr/lib/libvted-3.so.*"
 	}
@@ -84,6 +100,8 @@ libvted-devel_package() {
 
 libgstreamerd_package() {
 	short_desc+=" - gstreamerd library"
+	shlib_requires="libgstapp-1.0.so.0 libgstbase-1.0.so.0 libgstmpegts-1.0.so.0
+	 libgstvideo-1.0.so.0 libgstreamer-1.0.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgstreamerd-3.so.*"
 	}
@@ -104,6 +122,7 @@ libgstreamerd-devel_package() {
 
 libgtkdsv_package() {
 	short_desc+=" - gtkdsv library"
+	shlib_requires="libgtksourceview-4.so.0"
 	pkg_install() {
 		vmove "usr/lib/libgtkdsv-3.so.*"
 	}

From ca57ba6cf7598d1b40f67db8e3b6538c04e58169 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:56 +0700
Subject: [PATCH 09/15] onedrive: rebuild for ldc 1.34.0

---
 srcpkgs/onedrive/template | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/onedrive/template b/srcpkgs/onedrive/template
index 019a89325aace..39234b85b4e9e 100644
--- a/srcpkgs/onedrive/template
+++ b/srcpkgs/onedrive/template
@@ -1,14 +1,14 @@
 # Template file for 'onedrive'
 pkgname=onedrive
 version=2.4.25
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="DC=ldc2 --enable-notifications --enable-completions
  --with-bash-completion-dir=/usr/share/bash-completion/completions
  --with-zsh-completion-dir=/usr/share/zsh/site-functions
  --with-fish-completion-dir=/usr/share/fish/vendor_completions.d"
 hostmakedepends="ldc pkg-config"
-makedepends="libcurl-devel sqlite-devel libnotify-devel"
+makedepends="libcurl-devel sqlite-devel libnotify-devel ldc-runtime-devel"
 short_desc="OneDrive Client for Linux"
 maintainer="selfisekai <laura@selfisekai.rocks>"
 license="GPL-3.0-or-later"
@@ -16,7 +16,10 @@ homepage="https://github.com/abraunegg/onedrive"
 changelog="https://raw.githubusercontent.com/abraunegg/onedrive/master/CHANGELOG.md"
 distfiles="https://github.com/abraunegg/onedrive/archive/v${version}.tar.gz"
 checksum=e7d782ea7d1973b6b578899a84c4f90ba69302263b4be30d80a363ba8ba27eb3
-nocross="uses host flags for cross compilations"
+
+if [ "$CROSS_BUILD" ]; then
+	DFLAGS="-mtriple=$XBPS_CROSS_TRIPLET"
+fi
 
 post_install() {
 	vinstall config 644 usr/share/onedrive config.default

From 9246f028342d2521db47f3460996e7b4c121e2d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 8 Sep 2023 20:04:59 +0700
Subject: [PATCH 10/15] tilix: rebuild for ldc 1.34.0

---
 srcpkgs/tilix/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tilix/template b/srcpkgs/tilix/template
index 74ccb4dd4592d..0728d1688bd16 100644
--- a/srcpkgs/tilix/template
+++ b/srcpkgs/tilix/template
@@ -1,14 +1,15 @@
 # Template file for 'tilix'
 pkgname=tilix
 version=1.9.4
-revision=7
+revision=8
 _undead_version=1.1.8
 build_wrksrc="${pkgname}-${version}"
 build_style=meson
 configure_args="-Db_lto=false"
 hostmakedepends="automake gettext-devel gdk-pixbuf glib-devel ldc po4a pkg-config
  librsvg tar AppStream"
-makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel"
+makedepends="dconf-devel gtkd-devel libglib-devel libvted-devel libX11-devel
+ vte3-devel ldc-runtime-devel"
 depends="gsettings-desktop-schemas vte3"
 checkdepends="$depends"
 short_desc="Tiling terminal emulator for Linux"

From ea1a4a15aed3038018f6e0157891e315d3cebe43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 25 Oct 2023 16:20:37 +0700
Subject: [PATCH 11/15] shlibs: add libgstmpegts-1.0.so.0

---
 common/shlibs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/shlibs b/common/shlibs
index b9a5012250e19..b1988ccfe40e3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1136,6 +1136,7 @@ libgstcodecparsers-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstplayer-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstwebrtc-1.0.so.0 gst-plugins-bad1-1.18.4_2
 libgsttranscoder-1.0.so.0 gst-plugins-bad1-1.18.4_2
+libgstmpegts-1.0.so.0 gst-plugins-bad1-1.22.5_1
 libgstgl-1.0.so.0 gst-plugins-base1-1.14.0_1
 libgnome-desktop-3.so.20 gnome-desktop-43.0_1
 libgnome-desktop-4.so.2 gnome-desktop-43.0_1

From 87ca5af3fe9eed7cabdbd73570debcc6b2e5b093 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Thu, 26 Oct 2023 23:24:46 +0700
Subject: [PATCH 12/15] fixup! New package: gcc11-11.3.0

---
 ...se-poisoned-calloc-error-in-libgccji.patch | 19 +++------
 .../patches/fix-poisoned-calloc-cp.patch      | 30 ++++++++++++++
 srcpkgs/gcc11/patches/musl-libucontext.patch  | 39 +++++++++++++++++++
 srcpkgs/gcc11/template                        |  2 +
 4 files changed, 76 insertions(+), 14 deletions(-)
 create mode 100644 srcpkgs/gcc11/patches/fix-poisoned-calloc-cp.patch
 create mode 100644 srcpkgs/gcc11/patches/musl-libucontext.patch

diff --git a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
index 7975e6339acaa..516f88a23ed1c 100644
--- a/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
+++ b/srcpkgs/gcc11/patches/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch
@@ -11,11 +11,9 @@ included #pragma GCC poison calloc
  gcc/jit/libgccjit.c     | 3 ++-
  3 files changed, 6 insertions(+), 5 deletions(-)
 
-diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
-index cee9daa8220..a5600084933 100644
 --- a/gcc/jit/jit-playback.c
 +++ b/gcc/jit/jit-playback.c
-@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+@@ -18,6 +18,8 @@ You should have received a copy of the G
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
@@ -24,7 +22,7 @@ index cee9daa8220..a5600084933 100644
  #include "config.h"
  #include "system.h"
  #include "coretypes.h"
-@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.  If not see
+@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3.
  #include "diagnostic.h"
  #include "stmt.h"
  
@@ -33,11 +31,9 @@ index cee9daa8220..a5600084933 100644
  #include "jit-playback.h"
  #include "jit-result.h"
  #include "jit-builtins.h"
-diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
-index 117ff70114c..d2634a546b1 100644
 --- a/gcc/jit/jit-recording.c
 +++ b/gcc/jit/jit-recording.c
-@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
+@@ -18,6 +18,8 @@ You should have received a copy of the G
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
@@ -46,7 +42,7 @@ index 117ff70114c..d2634a546b1 100644
  #include "config.h"
  #include "system.h"
  #include "coretypes.h"
-@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.  If not see
+@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3.
  #include "pretty-print.h"
  #include "toplev.h"
  
@@ -55,11 +51,9 @@ index 117ff70114c..d2634a546b1 100644
  #include "jit-builtins.h"
  #include "jit-recording.h"
  #include "jit-playback.h"
-diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
-index 0cc650f9810..2f44481eeb0 100644
 --- a/gcc/jit/libgccjit.c
 +++ b/gcc/jit/libgccjit.c
-@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License
+@@ -18,13 +18,14 @@ You should have received a copy of the G
  along with GCC; see the file COPYING3.  If not see
  <http://www.gnu.org/licenses/>.  */
  
@@ -75,6 +69,3 @@ index 0cc650f9810..2f44481eeb0 100644
  
  #include "libgccjit.h"
  #include "jit-recording.h"
--- 
-2.35.1
-
diff --git a/srcpkgs/gcc11/patches/fix-poisoned-calloc-cp.patch b/srcpkgs/gcc11/patches/fix-poisoned-calloc-cp.patch
new file mode 100644
index 0000000000000..5ea0f0682c02e
--- /dev/null
+++ b/srcpkgs/gcc11/patches/fix-poisoned-calloc-cp.patch
@@ -0,0 +1,30 @@
+--- a/gcc/cp/mapper-client.cc
++++ b/gcc/cp/mapper-client.cc
+@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
+ #define INCLUDE_STRING
+ #define INCLUDE_VECTOR
+ #define INCLUDE_MAP
++#include <pthread.h>
+ #include "system.h"
+ 
+ #include "line-map.h"
+--- a/gcc/cp/mapper-resolver.cc
++++ b/gcc/cp/mapper-resolver.cc
+@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.
+ #define INCLUDE_VECTOR
+ #define INCLUDE_ALGORITHM
+ #define INCLUDE_MAP
++#include <pthread.h>
+ #include "system.h"
+ 
+ // We don't want or need to be aware of networking
+--- a/gcc/cp/module.cc
++++ b/gcc/cp/module.cc
+@@ -204,6 +204,7 @@ Classes used:
+ #include "config.h"
+ #define INCLUDE_STRING
+ #define INCLUDE_VECTOR
++#include <pthread.h>
+ #include "system.h"
+ #include "coretypes.h"
+ #include "cp-tree.h"
diff --git a/srcpkgs/gcc11/patches/musl-libucontext.patch b/srcpkgs/gcc11/patches/musl-libucontext.patch
new file mode 100644
index 0000000000000..db8780bf4758e
--- /dev/null
+++ b/srcpkgs/gcc11/patches/musl-libucontext.patch
@@ -0,0 +1,39 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -51260,7 +51260,7 @@ configure-target-libphobos:
+ 	esac; \
+ 	module_srcdir=libphobos; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="$$LIBS $(LIBUCONTEXT)" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libphobos/configure
++++ b/libphobos/configure
+@@ -15200,6 +15200,11 @@ fi
+       druntime_fiber_asm_external=yes
+       ;;
+   esac
++  case "$target" in
++    *-musl)
++      druntime_fiber_asm_external=no
++      ;;
++  esac
+   if test "$druntime_fiber_asm_external" = no; then
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing swapcontext" >&5
+ $as_echo_n "checking for library containing swapcontext... " >&6; }
+--- a/libphobos/m4/druntime/libraries.m4
++++ b/libphobos/m4/druntime/libraries.m4
+@@ -228,6 +228,11 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT],
+       druntime_fiber_asm_external=yes
+       ;;
+   esac
++  case "$target" in
++    *-musl)
++      druntime_fiber_asm_external=no
++      ;;
++  esac
+   if test "$druntime_fiber_asm_external" = no; then
+     AC_SEARCH_LIBS([swapcontext], [c ucontext], [],
+       AC_MSG_ERROR([swapcontext required but not found]))
diff --git a/srcpkgs/gcc11/template b/srcpkgs/gcc11/template
index ed9afc988370d..1dc6bc81d19b7 100644
--- a/srcpkgs/gcc11/template
+++ b/srcpkgs/gcc11/template
@@ -41,7 +41,9 @@ skip_extraction="
  "
 
 if [ "$XBPS_TARGET_LIBC" = musl ]; then
+	makedepends+=" libucontext-devel"
 	depends+=" musl-devel"
+	export LIBUCONTEXT=-lucontext
 else
 	depends+=" glibc-devel"
 fi

From e7a60a8fced2f5baf0f8f5483e6f97a9fd00da46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Thu, 26 Oct 2023 23:24:57 +0700
Subject: [PATCH 13/15] fixup! gcc: add D frontend

---
 srcpkgs/gcc/patches/libucontext.patch | 39 +++++++++++++++++++++++++++
 srcpkgs/gcc/template                  |  4 +++
 2 files changed, 43 insertions(+)
 create mode 100644 srcpkgs/gcc/patches/libucontext.patch

diff --git a/srcpkgs/gcc/patches/libucontext.patch b/srcpkgs/gcc/patches/libucontext.patch
new file mode 100644
index 0000000000000..b755232105f11
--- /dev/null
+++ b/srcpkgs/gcc/patches/libucontext.patch
@@ -0,0 +1,39 @@
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -53287,7 +53287,7 @@ configure-target-libphobos:
+ 	esac; \
+ 	module_srcdir=libphobos; \
+ 	rm -f no-such-file || : ; \
+-	CONFIG_SITE=no-such-file $(SHELL) \
++	CONFIG_SITE=no-such-file LIBS="$(LIBUCONTEXT) $$LIBS" $(SHELL) \
+ 	  $$s/$$module_srcdir/configure \
+ 	  --srcdir=$${topdir}/$$module_srcdir \
+ 	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+--- a/libphobos/configure
++++ b/libphobos/configure
+@@ -15200,6 +15200,11 @@ fi
+       druntime_fiber_asm_external=yes
+       ;;
+   esac
++  case "$target" in
++    *-musl)
++      druntime_fiber_asm_external=no
++      ;;
++  esac
+   if test "$druntime_fiber_asm_external" = no; then
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing swapcontext" >&5
+ $as_echo_n "checking for library containing swapcontext... " >&6; }
+--- a/libphobos/m4/druntime/libraries.m4
++++ b/libphobos/m4/druntime/libraries.m4
+@@ -228,6 +228,11 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT],
+       druntime_fiber_asm_external=yes
+       ;;
+   esac
++  case "$target" in
++    *-musl)
++      druntime_fiber_asm_external=no
++      ;;
++  esac
+   if test "$druntime_fiber_asm_external" = no; then
+     AC_SEARCH_LIBS([swapcontext], [c ucontext], [],
+       AC_MSG_ERROR([swapcontext required but not found]))
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index a818b0cdacf57..9e6244f58d16f 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -98,6 +98,10 @@ if [ "$_have_gccgo" = "yes" ]; then
 fi
 
 if [ "$_have_gdc" = yes ]; then
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		makedepends+=" libucontext-devel"
+		export LIBUCONTEXT=-lucontext
+	fi
 	if [ "$CROSS_BUILD" ]; then
 		hostmakedepends+=" gcc-gdc"
 	else

From 7d011c2c2cd6cfb932d54933fd0553bea8219eaa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 27 Oct 2023 00:01:19 +0700
Subject: [PATCH 14/15] fixup! fixup! gcc: add D frontend

---
 srcpkgs/gcc/files/gccgo-musl.patch            | 16 ++---
 srcpkgs/gcc/files/libgnarl-musl.patch         | 11 ++--
 srcpkgs/gcc/files/libssp-musl.patch           | 12 ++--
 ...-go-fix-build-error-with-SYS_SECCOMP.patch |  4 +-
 ...defined-reference-to-__cmsg_nxthdr-w.patch | 60 +++++++++++++++++++
 srcpkgs/gcc/patches/ada-shared.patch          | 10 ++--
 .../patches/consistent-library-paths.patch    |  7 +--
 .../gcc/patches/fix-cxxflags-passing.patch    |  4 +-
 srcpkgs/gcc/patches/fix-musl-execinfo.patch   | 10 ++--
 srcpkgs/gcc/patches/fix-vtv-link-order.patch  |  2 +-
 srcpkgs/gcc/patches/libatomic-autolink.patch  | 40 ++++---------
 srcpkgs/gcc/patches/libatomic-configure.patch |  2 -
 .../gcc/patches/libgcc-ibm128-no-tag.patch    |  7 ---
 srcpkgs/gcc/patches/mips-sgidefs_h.patch      |  4 +-
 srcpkgs/gcc/patches/mips-soft-float.patch     | 10 ++--
 srcpkgs/gcc/patches/musl-ada.patch            | 48 +++++++--------
 srcpkgs/gcc/patches/musl-generic-locale.patch |  3 +-
 srcpkgs/gcc/template                          | 18 ++++--
 18 files changed, 147 insertions(+), 121 deletions(-)
 create mode 100644 srcpkgs/gcc/patches/0054-libphobos-fix-undefined-reference-to-__cmsg_nxthdr-w.patch

diff --git a/srcpkgs/gcc/files/gccgo-musl.patch b/srcpkgs/gcc/files/gccgo-musl.patch
index 12ec68dd8aa30..22148490adb17 100644
--- a/srcpkgs/gcc/files/gccgo-musl.patch
+++ b/srcpkgs/gcc/files/gccgo-musl.patch
@@ -9,7 +9,7 @@ URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
 
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -46325,7 +46325,7 @@ configure-target-libgo:
+@@ -52803,7 +52803,7 @@ configure-target-libgo:
  	esac; \
  	module_srcdir=libgo; \
  	rm -f no-such-file || : ; \
@@ -20,7 +20,7 @@ URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
  	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
 --- a/libgo/mksysinfo.sh
 +++ b/libgo/mksysinfo.sh
-@@ -379,11 +379,7 @@ fi
+@@ -404,11 +404,7 @@ fi
  # Some basic types.
  echo 'type Size_t _size_t' >> ${OUT}
  echo "type Ssize_t _ssize_t" >> ${OUT}
@@ -35,8 +35,8 @@ URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
  echo "type Uid_t _uid_t" >> ${OUT}
 --- a/libgo/go/runtime/mem_gccgo.go
 +++ b/libgo/go/runtime/mem_gccgo.go
-@@ -16,7 +16,7 @@ import (
- //go:linkname sysFree runtime.sysFree
+@@ -15,7 +15,7 @@ import (
+ //go:linkname sysFree
  
  //extern mmap
 -func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer
@@ -44,7 +44,7 @@ URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
  
  //extern munmap
  func munmap(addr unsafe.Pointer, length uintptr) int32
-@@ -38,7 +38,7 @@ func init() {
+@@ -37,7 +37,7 @@ func init() {
  	}
  }
  
@@ -101,7 +101,7 @@ URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
 -}
 --- a/libgo/go/syscall/libcall_linux.go
 +++ b/libgo/go/syscall/libcall_linux.go
-@@ -206,19 +206,19 @@ func Gettid() (tid int) {
+@@ -209,19 +209,19 @@ func Gettid() (tid int) {
  //sys	Setxattr(path string, attr string, data []byte, flags int) (err error)
  //setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int
  
@@ -131,7 +131,7 @@ URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
  	n, err = splice(rfd, plroff, wfd, plwoff, len, flags)
 --- a/libgo/runtime/runtime.h
 +++ b/libgo/runtime/runtime.h
-@@ -500,10 +500,13 @@ int __go_setcontext(__go_context_t*);
+@@ -501,10 +501,13 @@ int __go_setcontext(__go_context_t*);
  void __go_makecontext(__go_context_t*, void (*)(), void*, size_t);
  #else
  #define __go_context_t	ucontext_t
@@ -150,7 +150,7 @@ URL: https://code.foxkit.us/adelie/packages/tree/master/system/gcc
  // Symbols defined by the linker.
 --- a/libgo/sysinfo.c
 +++ b/libgo/sysinfo.c
-@@ -73,9 +73,6 @@
+@@ -78,9 +78,6 @@
  #include <sys/times.h>
  #include <sys/wait.h>
  #include <sys/un.h>
diff --git a/srcpkgs/gcc/files/libgnarl-musl.patch b/srcpkgs/gcc/files/libgnarl-musl.patch
index 91c95949e0e91..d8e45cd7105c0 100644
--- a/srcpkgs/gcc/files/libgnarl-musl.patch
+++ b/srcpkgs/gcc/files/libgnarl-musl.patch
@@ -2,9 +2,8 @@ Source: Alpine Linux
 Upstream: Unknown
 Reason: Patch libgnarl to not use function missing from musl.
 
-diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-osinte__linux.ads gcc-8.2.0-new/gcc/ada/libgnarl/s-osinte__linux.ads
---- a/gcc/ada/libgnarl/s-osinte__linux.ads	2018-01-11 00:55:25.000000000 -0800
-+++ b/gcc/ada/libgnarl/s-osinte__linux.ads	2018-11-01 16:16:23.372452951 -0700
+--- a/gcc/ada/libgnarl/s-osinte__linux.ads
++++ b/gcc/ada/libgnarl/s-osinte__linux.ads
 @@ -403,12 +403,6 @@ package System.OS_Interface is
     PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
     PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
@@ -30,9 +29,8 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-osinte__linux.ads gcc-8.2.0-new/gcc/ada/l
     type struct_sched_param is record
        sched_priority : int;  --  scheduling priority
     end record;
-diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb gcc-8.2.0-new/gcc/ada/libgnarl/s-taprop__linux.adb
---- a/gcc/ada/libgnarl/s-taprop__linux.adb	2018-01-11 00:55:25.000000000 -0800
-+++ b/gcc/ada/libgnarl/s-taprop__linux.adb	2018-11-13 11:28:36.433964449 -0800
+--- a/gcc/ada/libgnarl/s-taprop__linux.adb
++++ b/gcc/ada/libgnarl/s-taprop__linux.adb
 @@ -198,9 +198,6 @@ package body System.Task_Primitives.Oper
     pragma Import
       (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup");
@@ -122,4 +120,3 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb gcc-8.2.0-new/gcc/ada/l
              Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access);
  
              pragma Assert (Result in 0 | ENOMEM);
-
diff --git a/srcpkgs/gcc/files/libssp-musl.patch b/srcpkgs/gcc/files/libssp-musl.patch
index 99f248401a1cc..6c7206f27a1f6 100644
--- a/srcpkgs/gcc/files/libssp-musl.patch
+++ b/srcpkgs/gcc/files/libssp-musl.patch
@@ -4,8 +4,8 @@ Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
 
 --- a/gcc/gcc.cc
 +++ b/gcc/gcc.cc
-@@ -984,10 +984,15 @@ proper position among the other output f
- #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+@@ -994,10 +994,15 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L %G}"
  #endif
  
 +#ifdef ENABLE_DEFAULT_SSP
@@ -22,7 +22,7 @@ Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
  #else
  #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
  		       "|fstack-protector-strong|fstack-protector-explicit" \
-@@ -1280,7 +1285,7 @@ static const char *cc1_options =
+@@ -1290,7 +1295,7 @@ static const char *cc1_options =
   %{-version:--version}\
   %{-help=*:--help=%*}\
   %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
@@ -33,7 +33,7 @@ Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
     %{!fprofile-update=single:\
 --- a/gcc/params.opt
 +++ b/gcc/params.opt
-@@ -853,7 +853,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
+@@ -1012,7 +1012,7 @@ Common Joined UInteger Var(param_ssa_nam
  The maximum number of SSA_NAME assignments to follow in determining a value.
  
  -param=ssp-buffer-size=
@@ -44,7 +44,7 @@ Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
  -param=stack-clash-protection-guard-size=
 --- a/gcc/config/i386/gnu-user-common.h
 +++ b/gcc/config/i386/gnu-user-common.h
-@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.  If not see
+@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3.
  
  /* Static stack checking is supported by means of probes.  */
  #define STACK_CHECK_STATIC_BUILTIN 1
@@ -56,7 +56,7 @@ Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
 -#endif
 --- a/gcc/config/i386/gnu.h
 +++ b/gcc/config/i386/gnu.h
-@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www.gnu.org/licenses/>.
+@@ -40,11 +40,6 @@ along with GCC.  If not, see <http://www
  /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
  #define TARGET_THREAD_SSP_OFFSET        0x14
  
diff --git a/srcpkgs/gcc/patches/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch b/srcpkgs/gcc/patches/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch
index db38df3b010ab..1c3b8340da59f 100644
--- a/srcpkgs/gcc/patches/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch
+++ b/srcpkgs/gcc/patches/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch
@@ -18,8 +18,6 @@ Reviewed-by: Ian Lance Taylor <iant@google.com>
  libgo/mksysinfo.sh | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
-diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
-index 5aa30915..ea1fa17d 100755
 --- a/libgo/mksysinfo.sh
 +++ b/libgo/mksysinfo.sh
 @@ -127,6 +127,7 @@ fi
@@ -30,7 +28,7 @@ index 5aa30915..ea1fa17d 100755
    sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
    while read sys; do
      sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
-@@ -506,7 +507,7 @@ fi
+@@ -510,7 +511,7 @@ fi
  
  # For historical reasons Go uses the suffix "timespec" instead of "tim" for
  # stat_t's time fields on NetBSD.
diff --git a/srcpkgs/gcc/patches/0054-libphobos-fix-undefined-reference-to-__cmsg_nxthdr-w.patch b/srcpkgs/gcc/patches/0054-libphobos-fix-undefined-reference-to-__cmsg_nxthdr-w.patch
new file mode 100644
index 0000000000000..b57d0e922da0d
--- /dev/null
+++ b/srcpkgs/gcc/patches/0054-libphobos-fix-undefined-reference-to-__cmsg_nxthdr-w.patch
@@ -0,0 +1,60 @@
+From 7b8400f902ef25ea71ed460716c1afedca357a61 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 2 Nov 2022 12:31:36 +0100
+Subject: [PATCH] libphobos: fix undefined reference to `__cmsg_nxthdr' with
+ musl
+
+Ported fix from upstream.
+
+Upstream: https://github.com/dlang/dmd/commit/54544260a848c8ebad5582e27ac1e09627cdfb17
+Bug-URL: https://issues.dlang.org/show_bug.cgi?id=23157
+---
+ .../libdruntime/core/sys/posix/sys/socket.d   | 36 +++++++++++++++++--
+ 1 file changed, 33 insertions(+), 3 deletions(-)
+
+--- a/libphobos/libdruntime/core/sys/posix/sys/socket.d
++++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d
+@@ -188,10 +188,40 @@ version (linux)
+ 
+     extern (D) inout(ubyte)*   CMSG_DATA( return scope inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
+ 
+-    private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc;
+-    extern (D)  inout(cmsghdr)* CMSG_NXTHDR(inout(msghdr)* msg, inout(cmsghdr)* cmsg) pure nothrow @nogc
++    version (CRuntime_Musl)
+     {
+-        return __cmsg_nxthdr(msg, cmsg);
++        extern (D)
++        {
++            private size_t __CMSG_LEN(inout(cmsghdr)* cmsg) pure nothrow @nogc
++            {
++                return (cmsg.cmsg_len + size_t.sizeof -1) & cast(size_t)(~(size_t.sizeof - 1));
++            }
++
++            private inout(cmsghdr)* __CMSG_NEXT(inout(cmsghdr)* cmsg) pure nothrow @nogc
++            {
++                return cmsg + __CMSG_LEN(cmsg);
++            }
++
++            private inout(msghdr)* __MHDR_END(inout(msghdr)* mhdr) pure nothrow @nogc
++            {
++                return cast(inout(msghdr)*)(mhdr.msg_control + mhdr.msg_controllen);
++            }
++
++            inout(cmsghdr)* CMSG_NXTHDR(inout(msghdr)* msg, inout(cmsghdr)* cmsg) pure nothrow @nogc
++            {
++                return cmsg.cmsg_len < cmsghdr.sizeof ||
++                    __CMSG_LEN(cmsg) + cmsghdr.sizeof >= __MHDR_END(msg) - cast(inout(msghdr)*)(cmsg)
++                        ? cast(inout(cmsghdr)*) null : cast(inout(cmsghdr)*) __CMSG_NEXT(cmsg);
++            }
++        }
++    }
++    else
++    {
++        private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc;
++        extern (D)  inout(cmsghdr)* CMSG_NXTHDR(inout(msghdr)* msg, inout(cmsghdr)* cmsg) pure nothrow @nogc
++        {
++            return __cmsg_nxthdr(msg, cmsg);
++        }
+     }
+ 
+     extern (D) inout(cmsghdr)* CMSG_FIRSTHDR( inout(msghdr)* mhdr ) pure nothrow @nogc
diff --git a/srcpkgs/gcc/patches/ada-shared.patch b/srcpkgs/gcc/patches/ada-shared.patch
index 01b23d3228f82..dba5fb1d7deee 100644
--- a/srcpkgs/gcc/patches/ada-shared.patch
+++ b/srcpkgs/gcc/patches/ada-shared.patch
@@ -1,8 +1,8 @@
 --- a/gcc/ada/link.c
 +++ b/gcc/ada/link.c
-@@ -105,9 +105,9 @@
- 
- #elif defined (__FreeBSD__)
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+    || defined (__NetBSD__) || defined (__OpenBSD__) \
+    || defined (__QNX__)
  const char *__gnat_object_file_option = "-Wl,@";
 -const char *__gnat_run_path_option = "-Wl,-rpath,";
 -char __gnat_shared_libgnat_default = STATIC;
@@ -13,9 +13,9 @@
  int __gnat_link_max = 8192;
  unsigned char __gnat_objlist_file_supported = 1;
  const char *__gnat_object_library_extension = ".a";
-@@ -127,9 +127,9 @@
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
  
- #elif defined (linux) || defined(__GLIBC__)
+ #elif defined (__linux__) || defined (__GLIBC__)
  const char *__gnat_object_file_option = "-Wl,@";
 -const char *__gnat_run_path_option = "-Wl,-rpath,";
 -char __gnat_shared_libgnat_default = STATIC;
diff --git a/srcpkgs/gcc/patches/consistent-library-paths.patch b/srcpkgs/gcc/patches/consistent-library-paths.patch
index 333dc53a4eca3..4b8c513d1c7e0 100644
--- a/srcpkgs/gcc/patches/consistent-library-paths.patch
+++ b/srcpkgs/gcc/patches/consistent-library-paths.patch
@@ -50,7 +50,7 @@ When adding a new platform, fix this up too.
  else
  MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
  endif
-@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)))
+@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target)
  MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME))
  endif
  ifneq (,$(findstring powerpc64le,$(target)))
@@ -71,7 +71,7 @@ When adding a new platform, fix this up too.
 +MULTILIB_OSDIRNAMES := m64=../lib64
 +MULTILIB_OSDIRNAMES += m32=../lib32
  
- rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.cc
  	$(COMPILE) $<
 --- a/gcc/config/rs6000/t-linux64bele
 +++ b/gcc/config/rs6000/t-linux64bele
@@ -105,6 +105,3 @@ When adding a new platform, fix this up too.
 -MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
 +MULTILIB_OSDIRNAMES = m64=../lib64
 +MULTILIB_OSDIRNAMES+= m32=../lib32
--- 
-2.29.2
-
diff --git a/srcpkgs/gcc/patches/fix-cxxflags-passing.patch b/srcpkgs/gcc/patches/fix-cxxflags-passing.patch
index d03974013f122..49d85352ae9a8 100644
--- a/srcpkgs/gcc/patches/fix-cxxflags-passing.patch
+++ b/srcpkgs/gcc/patches/fix-cxxflags-passing.patch
@@ -1,7 +1,7 @@
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -169,6 +169,7 @@
- # built for the build system to override those in BASE_FLAGS_TO_PASSS.
+@@ -176,6 +176,7 @@ BUILD_EXPORTS = \
+ # built for the build system to override those in BASE_FLAGS_TO_PASS.
  EXTRA_BUILD_FLAGS = \
  	CFLAGS="$(CFLAGS_FOR_BUILD)" \
 +	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
diff --git a/srcpkgs/gcc/patches/fix-musl-execinfo.patch b/srcpkgs/gcc/patches/fix-musl-execinfo.patch
index 543316638b996..2d9d181204741 100644
--- a/srcpkgs/gcc/patches/fix-musl-execinfo.patch
+++ b/srcpkgs/gcc/patches/fix-musl-execinfo.patch
@@ -1,7 +1,7 @@
 There is no <execinfo.h> in musl libc
 
---- a/libvtv/vtv_rts.cc	2016-09-23 16:17:11.000000000 +0200
-+++ b/libvtc/vtv_rts.cc	2016-09-25 15:08:57.896000000 +0200
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
 @@ -124,7 +124,7 @@
  #include <windows.h>
  #include <winternl.h>
@@ -11,8 +11,8 @@ There is no <execinfo.h> in musl libc
  #include <execinfo.h>
  #endif
  
---- a/libvtv/vtv_utils.cc	2016-09-23 16:17:11.000000000 +0200
-+++ b/libvtv/vtv_utils.cc	2016-09-25 15:15:35.529000000 +0200
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
 @@ -34,7 +34,7 @@
  #include <string.h>
  #if defined (__CYGWIN__) || defined (__MINGW32__)
@@ -22,7 +22,7 @@ There is no <execinfo.h> in musl libc
  #include <execinfo.h>
  #endif
  
-@@ -178,7 +178,7 @@
+@@ -178,7 +178,7 @@ __vtv_log_verification_failure (const ch
  
    __vtv_add_to_log (vtv_failures_log_fd, "%s", log_msg);
  
diff --git a/srcpkgs/gcc/patches/fix-vtv-link-order.patch b/srcpkgs/gcc/patches/fix-vtv-link-order.patch
index 4925ed5aa60fb..a513ca5a72f6a 100644
--- a/srcpkgs/gcc/patches/fix-vtv-link-order.patch
+++ b/srcpkgs/gcc/patches/fix-vtv-link-order.patch
@@ -9,7 +9,7 @@ This is in line with comment in libgcc/vtv_end.c:
 
 --- a/libstdc++-v3/configure
 +++ b/libstdc++-v3/configure
-@@ -15443,7 +15443,7 @@
+@@ -15581,7 +15581,7 @@ esac
  
  if test "$enable_vtable_verify" = yes; then
    predep_objects_CXX="${predep_objects_CXX} ${glibcxx_builddir}/../libgcc/vtv_start.o"
diff --git a/srcpkgs/gcc/patches/libatomic-autolink.patch b/srcpkgs/gcc/patches/libatomic-autolink.patch
index 20cdc42308dc5..7b256cbcaeb0b 100644
--- a/srcpkgs/gcc/patches/libatomic-autolink.patch
+++ b/srcpkgs/gcc/patches/libatomic-autolink.patch
@@ -21,8 +21,6 @@ This fixes issues with RISC-V.
  gcc/gcc.cc            | 12 +++++++++++-
  9 files changed, 102 insertions(+), 7 deletions(-)
 
-diff --git a/Makefile.in b/Makefile.in
-index b564ddbf792..a95c7407d16 100644
 --- a/Makefile.in
 +++ b/Makefile.in
 @@ -232,6 +232,7 @@ HOST_EXPORTS = \
@@ -33,8 +31,6 @@ index b564ddbf792..a95c7407d16 100644
  	HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \
  	GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
  	GMPINC="$(HOST_GMPINC)"; export GMPINC; \
-diff --git a/gcc/config.in b/gcc/config.in
-index f0fbf123aa8..af84efc4f9e 100644
 --- a/gcc/config.in
 +++ b/gcc/config.in
 @@ -118,6 +118,12 @@
@@ -50,11 +46,9 @@ index f0fbf123aa8..af84efc4f9e 100644
  /* Define to 1 to specify that we are using the BID decimal floating point
     format instead of DPD */
  #ifndef USED_FOR_TARGET
-diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
-index 8433e56c3e1..0347f10da8b 100644
 --- a/gcc/config/gnu-user.h
 +++ b/gcc/config/gnu-user.h
-@@ -109,8 +109,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+@@ -109,8 +109,18 @@ see the files COPYING3 and COPYING.RUNTI
  #define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
  #endif
  
@@ -74,8 +68,6 @@ index 8433e56c3e1..0347f10da8b 100644
     %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"
  
  #undef LINK_GCC_C_SEQUENCE_SPEC
-diff --git a/gcc/configure b/gcc/configure
-index 2f6b3265a6c..6dc65bf4ccb 100755
 --- a/gcc/configure
 +++ b/gcc/configure
 @@ -981,6 +981,7 @@ with_changes_root_url
@@ -86,7 +78,7 @@ index 2f6b3265a6c..6dc65bf4ccb 100755
  with_zstd
  with_zstd_include
  with_zstd_lib
-@@ -1710,6 +1711,9 @@ Optional Features:
+@@ -1709,6 +1710,9 @@ Optional Features:
    --disable-shared        don't provide a shared libgcc
    --disable-gcov          don't provide libgcov and related host tools
    --enable-languages=LIST specify which front-ends to build
@@ -96,7 +88,7 @@ index 2f6b3265a6c..6dc65bf4ccb 100755
    --disable-rpath         do not hardcode runtime library paths
    --enable-sjlj-exceptions
                            arrange to use setjmp/longjmp exception handling
-@@ -8324,7 +8328,6 @@ else
+@@ -8321,7 +8325,6 @@ else
  fi
  
  
@@ -104,7 +96,7 @@ index 2f6b3265a6c..6dc65bf4ccb 100755
  # Check whether --with-multilib-generator was given.
  if test "${with_multilib_generator+set}" = set; then :
    withval=$with_multilib_generator; :
-@@ -8332,6 +8335,32 @@ else
+@@ -8329,6 +8332,32 @@ else
    with_multilib_generator=default
  fi
  
@@ -137,13 +129,11 @@ index 2f6b3265a6c..6dc65bf4ccb 100755
  
  # -------------------------
  # Checks for other programs
-@@ -34296,4 +34325,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+@@ -34253,4 +34282,3 @@ if test -n "$ac_unrecognized_opts" && te
  $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
  fi
  
 -
-diff --git a/gcc/configure.ac b/gcc/configure.ac
-index e683d3a7a5f..07c81c78336 100644
 --- a/gcc/configure.ac
 +++ b/gcc/configure.ac
 @@ -1205,6 +1205,27 @@ AC_ARG_WITH(multilib-generator,
@@ -174,16 +164,14 @@ index e683d3a7a5f..07c81c78336 100644
  # -------------------------
  # Checks for other programs
  # -------------------------
-@@ -7839,4 +7860,3 @@ done
+@@ -7816,4 +7837,3 @@ done
  ], 
  [subdirs='$subdirs'])
  AC_OUTPUT
 -
-diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
-index 48408d842db..c90be0ee750 100644
 --- a/gcc/doc/install.texi
 +++ b/gcc/doc/install.texi
-@@ -2295,6 +2295,14 @@ files, but these changed header paths may conflict with some compilation
+@@ -2295,6 +2295,14 @@ files, but these changed header paths ma
  environments.  Enabled by default, and may be disabled using
  @option{--disable-canonical-system-headers}.
  
@@ -198,11 +186,9 @@ index 48408d842db..c90be0ee750 100644
  @item --with-glibc-version=@var{major}.@var{minor}
  Tell GCC that when the GNU C Library (glibc) is used on the target it
  will be version @var{major}.@var{minor} or later.  Normally this can
-diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
-index c5006afc00d..56b62c69ae8 100644
 --- a/gcc/doc/tm.texi
 +++ b/gcc/doc/tm.texi
-@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search.
+@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the
  
  @defmac LINK_GCC_C_SEQUENCE_SPEC
  The sequence in which libgcc and libc are specified to the linker.
@@ -217,11 +203,9 @@ index c5006afc00d..56b62c69ae8 100644
  @end defmac
  
  @defmac POST_LINK_SPEC
-diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
-index f869ddd5e5b..57c93f24ac3 100644
 --- a/gcc/doc/tm.texi.in
 +++ b/gcc/doc/tm.texi.in
-@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search.
+@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the
  
  @defmac LINK_GCC_C_SEQUENCE_SPEC
  The sequence in which libgcc and libc are specified to the linker.
@@ -236,11 +220,9 @@ index f869ddd5e5b..57c93f24ac3 100644
  @end defmac
  
  @defmac POST_LINK_SPEC
-diff --git a/gcc/gcc.cc b/gcc/gcc.cc
-index 735b2b1bba1..f10f3c91aa7 100644
 --- a/gcc/gcc.cc
 +++ b/gcc/gcc.cc
-@@ -987,13 +987,23 @@ proper position among the other output files.  */
+@@ -975,13 +975,23 @@ proper position among the other output f
  # define ASM_DEBUG_OPTION_SPEC ""
  #endif
  
@@ -264,4 +246,4 @@ index 735b2b1bba1..f10f3c91aa7 100644
 +#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L %G}"
  #endif
  
- #ifdef ENABLE_DEFAULT_SSP
+ #ifndef LINK_SSP_SPEC
diff --git a/srcpkgs/gcc/patches/libatomic-configure.patch b/srcpkgs/gcc/patches/libatomic-configure.patch
index 232de555155fe..10e64b8f22972 100644
--- a/srcpkgs/gcc/patches/libatomic-configure.patch
+++ b/srcpkgs/gcc/patches/libatomic-configure.patch
@@ -25,8 +25,6 @@ See:
  libatomic/configure.tgt | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
 
-diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
-index 33f8c91ce77..3999db2cf8a 100644
 --- a/libatomic/configure.tgt
 +++ b/libatomic/configure.tgt
 @@ -30,6 +30,26 @@
diff --git a/srcpkgs/gcc/patches/libgcc-ibm128-no-tag.patch b/srcpkgs/gcc/patches/libgcc-ibm128-no-tag.patch
index 26d80356ad0d8..b38cab8ddffae 100644
--- a/srcpkgs/gcc/patches/libgcc-ibm128-no-tag.patch
+++ b/srcpkgs/gcc/patches/libgcc-ibm128-no-tag.patch
@@ -13,8 +13,6 @@ explicit __ibm128.
  libgcc/config/rs6000/t-linux       | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
-diff --git a/libgcc/config/rs6000/t-ibm-ldouble b/libgcc/config/rs6000/t-ibm-ldouble
-index b132784..fb5eca8 100644
 --- a/libgcc/config/rs6000/t-ibm-ldouble
 +++ b/libgcc/config/rs6000/t-ibm-ldouble
 @@ -1,6 +1,6 @@
@@ -25,8 +23,6 @@ index b132784..fb5eca8 100644
 +HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
  
  SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
-diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux
-index 4f6d4c4..fa93bb6 100644
 --- a/libgcc/config/rs6000/t-linux
 +++ b/libgcc/config/rs6000/t-linux
 @@ -1,6 +1,6 @@
@@ -37,6 +33,3 @@ index 4f6d4c4..fa93bb6 100644
  
  # This is a way of selecting -mcmodel=small for ppc64, which gives
  # smaller and faster libgcc code.  Directly specifying -mcmodel=small
-
--- 
-2.24.0
diff --git a/srcpkgs/gcc/patches/mips-sgidefs_h.patch b/srcpkgs/gcc/patches/mips-sgidefs_h.patch
index cd0ae7a380dfb..3d72f55927dec 100644
--- a/srcpkgs/gcc/patches/mips-sgidefs_h.patch
+++ b/srcpkgs/gcc/patches/mips-sgidefs_h.patch
@@ -1,5 +1,5 @@
---- a/libffi/src/mips/ffitarget.h	2014-11-08 13:47:24.000000000 +0100
-+++ b/libffi/src/mips/ffitarget.h	2017-11-09 16:51:11.866848444 +0100
+--- a/libffi/src/mips/ffitarget.h
++++ b/libffi/src/mips/ffitarget.h
 @@ -42,7 +42,7 @@
  #define _MIPS_SIM_NABI32	2
  #define _MIPS_SIM_ABI64		3
diff --git a/srcpkgs/gcc/patches/mips-soft-float.patch b/srcpkgs/gcc/patches/mips-soft-float.patch
index a954e3df73a16..9d0ffecf235fc 100644
--- a/srcpkgs/gcc/patches/mips-soft-float.patch
+++ b/srcpkgs/gcc/patches/mips-soft-float.patch
@@ -1,6 +1,6 @@
---- a/libffi/src/mips/o32.S	2020-03-12 12:07:23.000000000 +0100
-+++ b/libffi/src/mips/o32.S	2020-05-14 20:52:45.701809054 +0200
-@@ -278,6 +278,7 @@
+--- a/libffi/src/mips/o32.S
++++ b/libffi/src/mips/o32.S
+@@ -367,6 +367,7 @@ $do_closure:
  	li	$9, FFI_TYPE_VOID
  	beq	$8, $9, closure_done
  
@@ -8,9 +8,9 @@
  	li	$13, 1		# FFI_O32
  	bne	$16, $13, 1f	# Skip fp restore if FFI_O32_SOFT_FLOAT
  
-@@ -289,6 +290,7 @@
- 	l.d	$f0, V0_OFF2($fp)
+@@ -380,6 +381,7 @@ $do_closure:
  	beq	$8, $9, closure_done
+ #endif
  1:	
 +#endif
  	REG_L	$3, V1_OFF2($fp)
diff --git a/srcpkgs/gcc/patches/musl-ada.patch b/srcpkgs/gcc/patches/musl-ada.patch
index c2c79df0adb7d..db113048744d7 100644
--- a/srcpkgs/gcc/patches/musl-ada.patch
+++ b/srcpkgs/gcc/patches/musl-ada.patch
@@ -1,8 +1,6 @@
-diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
-index 3b0aea9..ee0bb69 100644
 --- a/gcc/ada/adaint.c
 +++ b/gcc/ada/adaint.c
-@@ -76,6 +76,11 @@
+@@ -91,6 +91,11 @@
  #include <sys/param.h>
  #include <sys/pstat.h>
  #endif
@@ -14,7 +12,7 @@ index 3b0aea9..ee0bb69 100644
  
  #ifdef __PikeOS__
  #define __BSD_VISIBLE 1
-@@ -3255,7 +3260,6 @@ __gnat_lwp_self (void)
+@@ -3446,7 +3451,6 @@ __gnat_lwp_self (void)
  #endif
  
  #if defined (__linux__)
@@ -22,7 +20,7 @@ index 3b0aea9..ee0bb69 100644
  
  /* glibc versions earlier than 2.7 do not define the routines to handle
     dynamically allocated CPU sets. For these targets, we use the static
-@@ -3265,7 +3269,7 @@ __gnat_lwp_self (void)
+@@ -3456,7 +3460,7 @@ __gnat_lwp_self (void)
  
  /* Dynamic cpu sets */
  
@@ -31,7 +29,7 @@ index 3b0aea9..ee0bb69 100644
  __gnat_cpu_alloc (size_t count)
  {
    return CPU_ALLOC (count);
-@@ -3278,33 +3282,33 @@ __gnat_cpu_alloc_size (size_t count)
+@@ -3469,33 +3473,33 @@ __gnat_cpu_alloc_size (size_t count)
  }
  
  void
@@ -73,7 +71,7 @@ index 3b0aea9..ee0bb69 100644
  }
  
  size_t
-@@ -3314,23 +3318,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED)
+@@ -3505,23 +3509,23 @@ __gnat_cpu_alloc_size (size_t count ATTR
  }
  
  void
@@ -102,11 +100,9 @@ index 3b0aea9..ee0bb69 100644
  }
  #endif /* !CPU_ALLOC */
  #endif /* __linux__ */
-diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h
-index 0d12f7e..a063b47 100644
 --- a/gcc/ada/adaint.h
 +++ b/gcc/ada/adaint.h
-@@ -316,13 +316,11 @@ extern void   *__gnat_lwp_self			   (void);
+@@ -321,13 +321,11 @@ extern void   *__gnat_lwp_self			   (voi
  
  /* Routines for interface to required CPU set primitives */
  
@@ -124,9 +120,9 @@ index 0d12f7e..a063b47 100644
  #endif
  
  #if defined (_WIN32)
---- a/gcc/ada/Makefile.rtl	2020-07-23 08:35:17.052381336 +0200
-+++ b/gcc/ada/Makefile.rtl	2020-07-23 08:35:17.052381336 +0200
-@@ -1533,7 +1533,7 @@
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1633,7 +1633,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(
    s-intman.adb<libgnarl/s-intman__posix.adb \
    s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
    $(TRASYM_DWARF_UNIX_PAIRS) \
@@ -135,16 +131,16 @@ index 0d12f7e..a063b47 100644
    a-exetim.adb<libgnarl/a-exetim__posix.adb \
    a-exetim.ads<libgnarl/a-exetim__default.ads \
    s-linux.ads<libgnarl/s-linux.ads \
-@@ -2083,7 +2083,7 @@
-   s-osinte.adb<libgnarl/s-osinte__posix.adb \
-   s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
+@@ -2258,7 +2258,7 @@ ifeq ($(strip $(filter-out powerpc% linu
+   s-tasinf.adb<libgnarl/s-tasinf__linux.adb \
+   s-taspri.ads<libgnarl/s-taspri__posix.ads \
    $(TRASYM_DWARF_UNIX_PAIRS) \
 -  s-tsmona.adb<libgnat/s-tsmona__linux.adb \
 +  s-tsmona.adb<libgnat/s-tsmona.adb \
    $(ATOMICS_TARGET_PAIRS) \
    $(ATOMICS_BUILTINS_TARGET_PAIRS) \
    system.ads<libgnat/system-linux-ppc.ads
-@@ -2112,7 +2112,7 @@
+@@ -2289,7 +2289,7 @@ ifeq ($(strip $(filter-out powerpc% linu
  endif
  
  # ARM linux, GNU eabi
@@ -153,7 +149,7 @@ index 0d12f7e..a063b47 100644
    LIBGNAT_TARGET_PAIRS = \
    a-intnam.ads<libgnarl/a-intnam__linux.ads \
    s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
-@@ -2305,7 +2305,7 @@
+@@ -2504,7 +2504,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,
    s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
    s-taspri.ads<libgnarl/s-taspri__posix-noaltstack.ads \
    $(TRASYM_DWARF_UNIX_PAIRS) \
@@ -161,8 +157,8 @@ index 0d12f7e..a063b47 100644
 +  s-tsmona.adb<libgnat/s-tsmona.adb \
    $(ATOMICS_TARGET_PAIRS) \
    $(ATOMICS_BUILTINS_TARGET_PAIRS) \
-   system.ads<libgnat/system-linux-ia64.ads
-@@ -2401,7 +2401,7 @@
+   $(GNATRTL_128BIT_PAIRS) \
+@@ -2608,7 +2608,7 @@ ifeq ($(strip $(filter-out %x86_64 linux
    s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
    s-taspri.ads<libgnarl/s-taspri__posix.ads \
    $(TRASYM_DWARF_UNIX_PAIRS) \
@@ -170,10 +166,10 @@ index 0d12f7e..a063b47 100644
 +  s-tsmona.adb<libgnat/s-tsmona.adb \
    $(ATOMICS_TARGET_PAIRS) \
    $(X86_64_TARGET_PAIRS) \
-   system.ads<libgnat/system-linux-x86.ads
---- a/gcc/ada/terminals.c	2019-01-08 10:54:04.000000000 +0100
-+++ b/gcc/ada/terminals.c	2019-05-15 13:14:09.935742526 +0200
-@@ -1136,7 +1136,7 @@
+   $(GNATRTL_128BIT_PAIRS) \
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -1132,7 +1132,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
  /* POSIX does not specify how to open the master side of a terminal.Several
     methods are available (system specific):
        1- using a cloning device (USE_CLONE_DEVICE)
@@ -182,7 +178,7 @@ index 0d12f7e..a063b47 100644
        3- openpty                (USE_OPENPTY)
  
     When using the cloning device method, the macro USE_CLONE_DEVICE should
-@@ -1150,7 +1150,7 @@
+@@ -1146,7 +1146,7 @@ __gnat_setup_winsize (void *desc ATTRIBU
  #if defined (__APPLE__) || defined (BSD)
  #define USE_OPENPTY
  #elif defined (__linux__)
@@ -191,7 +187,7 @@ index 0d12f7e..a063b47 100644
  #elif defined (__sun__)
  #define USE_CLONE_DEVICE "/dev/ptmx"
  #elif defined (_AIX)
-@@ -1199,8 +1199,8 @@
+@@ -1195,8 +1195,8 @@ allocate_pty_desc (pty_desc **desc) {
     int  master_fd   = -1;
     char *slave_name = NULL;
  
diff --git a/srcpkgs/gcc/patches/musl-generic-locale.patch b/srcpkgs/gcc/patches/musl-generic-locale.patch
index 96742c4457610..db8d96b71df89 100644
--- a/srcpkgs/gcc/patches/musl-generic-locale.patch
+++ b/srcpkgs/gcc/patches/musl-generic-locale.patch
@@ -1,10 +1,9 @@
 See
 https://inbox.vuxu.org/musl/551d3310-039f-23c4-608e-5e15e625f638@sholland.org/
 
-diff --git gcc-5.4.0/libstdc++-v3/config/locale/generic/c_locale.cc.orig gcc-5.4.0/libstdc++-v3/config/locale/generic/c_locale.cc
 --- a/libstdc++-v3/config/locale/generic/c_locale.cc
 +++ b/libstdc++-v3/config/locale/generic/c_locale.cc
-@@ -213,9 +213,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+@@ -242,9 +242,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
      // Currently, the generic model only supports the "C" locale.
      // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
      __cloc = 0;
diff --git a/srcpkgs/gcc/template b/srcpkgs/gcc/template
index 9e6244f58d16f..ac5a7d3b5d726 100644
--- a/srcpkgs/gcc/template
+++ b/srcpkgs/gcc/template
@@ -198,17 +198,17 @@ post_extract() {
 }
 
 post_patch() {
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		for p in ${FILESDIR}/*-musl.patch; do
+			patch -sNp1 -i $p
+		done
+	fi
+
 	# _FORTIFY_SOURCE needs an optimization level.
 	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure
 
 	# Do not run fixincludes
 	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
-
-	if [ "$XBPS_TARGET_LIBC" = musl ]; then
-		for p in ${FILESDIR}/*-musl.patch; do
-			patch -p1 -i $p
-		done
-	fi
 }
 
 do_configure() {
@@ -546,6 +546,9 @@ libada_package() {
 
 libgdruntime-devel_package() {
 	depends="libgdruntime>=${_minorver}"
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		depends+=" libucontext-devel"
+	fi
 	short_desc+=" - D library - development files"
 	pkg_install() {
 		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/d"
@@ -564,6 +567,9 @@ libgdruntime_package() {
 
 libgphobos-devel_package() {
 	depends="libgphobos>=${_minorver}"
+	if [ "$XBPS_TARGET_LIBC" = musl ]; then
+		depends+=" libucontext-devel"
+	fi
 	short_desc+=" - GNU Phobos library - development files"
 	pkg_install() {
 		vmove usr/lib/libgphobos.spec

From 42acff7c3de2fa067bb55462d1517e196f8c1792 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 27 Oct 2023 00:01:40 +0700
Subject: [PATCH 15/15] fixup! ldc: update to 1.35.0.

---
 srcpkgs/ldc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ldc/template b/srcpkgs/ldc/template
index 769f82f8c4031..c7762f22ee8ca 100644
--- a/srcpkgs/ldc/template
+++ b/srcpkgs/ldc/template
@@ -13,7 +13,7 @@ configure_args="
 conf_files="/etc/ldc2.conf"
 hostmakedepends="gdmd llvm perl pkg-config"
 makedepends="libcurl-devel libffi-devel ncurses-devel zlib-devel
- llvm-libunwind-devel llvm"
+ llvm-libunwind-devel llvm libgphobos-devel libgdruntime-devel"
 depends="ldc-runtime-devel llvm-libunwind-devel"
 checkdepends="python3 gdb"
 short_desc="Portable D programming language compiler based on LLVM"

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (9 preceding siblings ...)
  2023-10-26 17:01 ` sgn
@ 2024-01-25  1:48 ` github-actions
  2024-01-26  6:52 ` jtbx
  2024-04-26  1:45 ` github-actions
  12 siblings, 0 replies; 14+ messages in thread
From: github-actions @ 2024-01-25  1:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/45973#issuecomment-1909211009

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (10 preceding siblings ...)
  2024-01-25  1:48 ` github-actions
@ 2024-01-26  6:52 ` jtbx
  2024-04-26  1:45 ` github-actions
  12 siblings, 0 replies; 14+ messages in thread
From: jtbx @ 2024-01-26  6:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1295 bytes --]

New comment by jtbx on void-packages repository

https://github.com/void-linux/void-packages/pull/45973#issuecomment-1911572368

Comment:
Is this still active? Building libcurl on your branch fails:
```
  CC       vssh/libcurl_la-libssh2.lo
  CC       vssh/libcurl_la-libssh.lo
  CC       vssh/libcurl_la-wolfssh.lo
  CCLD     libcurl.la
/usr/bin/ld: /usr/lib64/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../lib64/libnghttp2.a(nghttp2_map.o): warning: relocation against `stderr@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: /usr/lib64/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../lib64/libnghttp2.a(nghttp2_map.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:1696: libcurl.la] Error 1
make[2]: Leaving directory '/builddir/curl-8.4.0/lib'
make[1]: *** [Makefile:1503: all] Error 2
make[1]: Leaving directory '/builddir/curl-8.4.0/lib'
make: *** [Makefile:1273: all-recursive] Error 1
=> ERROR: curl-8.4.0_1: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 2
=> ERROR:   in do_build() at common/build-style/gnu-configure.sh:15
```

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Ldc cross compile
  2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
                   ` (11 preceding siblings ...)
  2024-01-26  6:52 ` jtbx
@ 2024-04-26  1:45 ` github-actions
  12 siblings, 0 replies; 14+ messages in thread
From: github-actions @ 2024-04-26  1:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/45973#issuecomment-2078483252

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-04-26  1:45 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-08 14:44 [PR PATCH] Ldc cross compile sgn
2023-09-09  3:56 ` [PR PATCH] [Updated] " sgn
2023-10-23  7:53 ` sgn
2023-10-23 23:43 ` sgn
2023-10-23 23:43 ` sgn
2023-10-25 15:57 ` [PR PATCH] [Updated] " sgn
2023-10-25 16:42 ` sgn
2023-10-26  4:44 ` sgn
2023-10-26 10:45 ` sgn
2023-10-26 16:25 ` sgn
2023-10-26 17:01 ` sgn
2024-01-25  1:48 ` github-actions
2024-01-26  6:52 ` jtbx
2024-04-26  1:45 ` github-actions

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).