From 2447cb00e0c2f7ae9efcb23a74f176122c457d58 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Fri, 30 Sep 2022 17:30:53 -0700 Subject: [PATCH] cross/gcc-*: upgrade to 12.2.1-r1 --- ...go-Fix-handling-of-signal-34-on-musl.patch | 26 --- ...han-one-st_-a-m-c-tim-fields-in-stru.patch | 24 -- ...ef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch | 24 -- .../0033-gcc-go-link-to-libucontext.patch | 36 ++- ...off64_t-and-loff_t-definitions-of-mu.patch | 214 ++++++++++++++---- ...t64-type-as-offset-argument-for-mmap.patch | 57 ++--- ...m-ptrace.h-for-pt_regs-definition-on.patch | 55 ----- ...orcibly-disable-fsplit-stack-support.patch | 87 +++++-- ...-go-fix-build-error-with-SYS_SECCOMP.patch | 48 ++-- ...id-memory-poisoning-on-musl-PR106102.patch | 107 --------- ...id-calloc-poisoning-on-musl-PR106102.patch | 117 ---------- ...ust-name-of-union-in-sigevent-struct.patch | 104 ++++++++- ...-define-SYS_timer_settime-for-32-bit.patch | 46 ++-- ...make-match.sh-POSIX-shell-compatible.patch | 50 ++-- cross/gcc-aarch64/APKBUILD | 46 ++-- ...go-Fix-handling-of-signal-34-on-musl.patch | 26 --- ...han-one-st_-a-m-c-tim-fields-in-stru.patch | 24 -- ...ef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch | 24 -- .../0033-gcc-go-link-to-libucontext.patch | 36 ++- ...off64_t-and-loff_t-definitions-of-mu.patch | 214 ++++++++++++++---- ...t64-type-as-offset-argument-for-mmap.patch | 57 ++--- ...m-ptrace.h-for-pt_regs-definition-on.patch | 55 ----- ...orcibly-disable-fsplit-stack-support.patch | 87 +++++-- ...-go-fix-build-error-with-SYS_SECCOMP.patch | 48 ++-- ...id-memory-poisoning-on-musl-PR106102.patch | 107 --------- ...id-calloc-poisoning-on-musl-PR106102.patch | 117 ---------- ...ust-name-of-union-in-sigevent-struct.patch | 104 ++++++++- ...-define-SYS_timer_settime-for-32-bit.patch | 46 ++-- ...make-match.sh-POSIX-shell-compatible.patch | 50 ++-- cross/gcc-armhf/APKBUILD | 46 ++-- ...go-Fix-handling-of-signal-34-on-musl.patch | 26 --- ...han-one-st_-a-m-c-tim-fields-in-stru.patch | 24 -- ...ef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch | 24 -- .../0033-gcc-go-link-to-libucontext.patch | 36 ++- ...off64_t-and-loff_t-definitions-of-mu.patch | 214 ++++++++++++++---- ...t64-type-as-offset-argument-for-mmap.patch | 57 ++--- ...m-ptrace.h-for-pt_regs-definition-on.patch | 55 ----- ...orcibly-disable-fsplit-stack-support.patch | 87 +++++-- ...-go-fix-build-error-with-SYS_SECCOMP.patch | 48 ++-- ...id-memory-poisoning-on-musl-PR106102.patch | 107 --------- ...id-calloc-poisoning-on-musl-PR106102.patch | 117 ---------- ...ust-name-of-union-in-sigevent-struct.patch | 104 ++++++++- ...-define-SYS_timer_settime-for-32-bit.patch | 46 ++-- ...make-match.sh-POSIX-shell-compatible.patch | 50 ++-- cross/gcc-armv7/APKBUILD | 46 ++-- 45 files changed, 1425 insertions(+), 1698 deletions(-) delete mode 100644 cross/gcc-aarch64/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch delete mode 100644 cross/gcc-aarch64/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch delete mode 100644 cross/gcc-aarch64/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch delete mode 100644 cross/gcc-aarch64/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch delete mode 100644 cross/gcc-aarch64/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch delete mode 100644 cross/gcc-aarch64/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch delete mode 100644 cross/gcc-armhf/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch delete mode 100644 cross/gcc-armhf/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch delete mode 100644 cross/gcc-armhf/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch delete mode 100644 cross/gcc-armhf/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch delete mode 100644 cross/gcc-armhf/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch delete mode 100644 cross/gcc-armhf/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch delete mode 100644 cross/gcc-armv7/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch delete mode 100644 cross/gcc-armv7/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch delete mode 100644 cross/gcc-armv7/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch delete mode 100644 cross/gcc-armv7/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch delete mode 100644 cross/gcc-armv7/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch delete mode 100644 cross/gcc-armv7/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch diff --git a/cross/gcc-aarch64/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch b/cross/gcc-aarch64/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch deleted file mode 100644 index c032ba7e1..000000000 --- a/cross/gcc-aarch64/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 7feb681596c4cfa34c769505058aa5bdf31c5131 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 17:59:45 +0200 -Subject: [PATCH] gcc-go: Fix handling of signal 34 on musl -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/mksigtab.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/mksigtab.sh b/libgo/mksigtab.sh -index bea8739957e..3876002efab 100644 ---- a/libgo/mksigtab.sh -+++ b/libgo/mksigtab.sh -@@ -86,7 +86,7 @@ checksig _SIGPWR '{_SigNotify, "SIGPWR: power failure restart"}' - checksig _SIGEMT '{_SigThrow, "SIGEMT: emulate instruction executed"}' - checksig _SIGINFO '{_SigNotify, "SIGINFO: status request from keyboard"}' - checksig _SIGTHR '{_SigNotify, "SIGTHR: reserved"}' --checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' -+#checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' - checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}' - checksig _SIGLWP '{_SigNotify, "SIGLWP: reserved signal no longer used by"}' - checksig _SIGFREEZE '{_SigNotify, "SIGFREEZE: special signal used by CPR"}' diff --git a/cross/gcc-aarch64/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch b/cross/gcc-aarch64/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch deleted file mode 100644 index 4f6967977..000000000 --- a/cross/gcc-aarch64/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch +++ /dev/null @@ -1,24 +0,0 @@ -From b6885cf73989161b1b6893b5ae0dafed006d5f13 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Thu, 25 Nov 2021 01:47:03 +0000 -Subject: [PATCH] There are more than one st_{a,m,c}tim fields in struct stat - on time64 machines. - -Run the Go-isation on all of them. ---- - libgo/mksysinfo.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh -index 0c52ea5d71a..6fef104cc1c 100755 ---- a/libgo/mksysinfo.sh -+++ b/libgo/mksysinfo.sh -@@ -510,7 +510,7 @@ fi - - # For historical reasons Go uses the suffix "timespec" instead of "tim" for - # stat_t's time fields on NetBSD. --st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' -+st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' - if test "${GOOS}" = "netbsd"; then - st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' - fi diff --git a/cross/gcc-aarch64/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch b/cross/gcc-aarch64/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch deleted file mode 100644 index d85d2dbef..000000000 --- a/cross/gcc-aarch64/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch +++ /dev/null @@ -1,24 +0,0 @@ -From c7a22e42ae403154a0c0158495b04b0205102041 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 30 Aug 2020 19:27:51 +0200 -Subject: [PATCH] gcc-go: undef SETCONTEXT_CLOBBERS_TLS in proc.c - ---- - libgo/runtime/proc.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c -index 3a30748d329..a987678fa84 100644 ---- a/libgo/runtime/proc.c -+++ b/libgo/runtime/proc.c -@@ -66,6 +66,10 @@ static void gscanstack(G*); - - __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); - -+/* libucontext does not seem to support tlsbase, undef the macro -+ * here to make sure we define initcontext and fixcontext as dummies. */ -+#undef SETCONTEXT_CLOBBERS_TLS -+ - #ifndef SETCONTEXT_CLOBBERS_TLS - - static inline void diff --git a/cross/gcc-aarch64/0033-gcc-go-link-to-libucontext.patch b/cross/gcc-aarch64/0033-gcc-go-link-to-libucontext.patch index 86c806d12..802295d3a 100644 --- a/cross/gcc-aarch64/0033-gcc-go-link-to-libucontext.patch +++ b/cross/gcc-aarch64/0033-gcc-go-link-to-libucontext.patch @@ -1,17 +1,22 @@ -From ef9df74e0c1059e51bb76b1f6d9d4746949d4d34 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Mon, 31 Aug 2020 08:59:40 +0200 -Subject: [PATCH] gcc-go: link to libucontext +From 0631e2b9453b33c42e12a14c11e8257d470016c5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 30 Aug 2020 19:17:42 +0200 +Subject: [PATCH] gcc-go: support libucontext +This patch allows using gcc-go with libucontext. For this purpose, +it unconditionally links gcc-go against -lucontext. Furthermore, +it undefines SETCONTEXT_CLOBBERS_TLS in proc.c to prevent usage +of makecontext/swapcontext feature that are not support by libucontext. --- - Makefile.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Makefile.in | 2 +- + libgo/runtime/proc.c | 4 ++++ + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in -index b96f60e33e2..b564ddbf792 100644 +index 593495e1650..c3e5d489bc0 100644 --- a/Makefile.in +++ b/Makefile.in -@@ -52802,7 +52802,7 @@ configure-target-libgo: +@@ -52801,7 +52801,7 @@ configure-target-libgo: esac; \ module_srcdir=libgo; \ rm -f no-such-file || : ; \ @@ -20,3 +25,18 @@ index b96f60e33e2..b564ddbf792 100644 $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ +diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c +index 3a30748d329..a987678fa84 100644 +--- a/libgo/runtime/proc.c ++++ b/libgo/runtime/proc.c +@@ -66,6 +66,10 @@ static void gscanstack(G*); + + __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); + ++/* libucontext does not seem to support tlsbase, undef the macro ++ * here to make sure we define initcontext and fixcontext as dummies. */ ++#undef SETCONTEXT_CLOBBERS_TLS ++ + #ifndef SETCONTEXT_CLOBBERS_TLS + + static inline void diff --git a/cross/gcc-aarch64/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch b/cross/gcc-aarch64/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch index 2259716b8..e0423d47b 100644 --- a/cross/gcc-aarch64/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch +++ b/cross/gcc-aarch64/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch @@ -1,81 +1,199 @@ -From 4655244d80aa67904a88d620361f2d37ea4c8576 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 28 Nov 2021 00:54:37 +0100 -Subject: [PATCH] libgo: Recognize off64_t and loff_t definitions of musl libc +From 3b9243b891cc06373639a23ed5717b0d1c2d8ea6 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Tue, 14 Jun 2022 06:13:43 -0700 +Subject: [PATCH] libgo: permit loff_t and off_t to be macros +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -Without this patch, both off64_t and loff_t are not recognized by --fdump-go-spec which causes a variety Go-related compilation errors on -musl libc since the gcc-go frontend expects both off64_t and loff_t to -be present. +They are macros in musl libc, rather than typedefs, and -fgo-dump-spec +doesn't handle that case. -Also make sure that autoconf recognizes support for loff_t on musl, by -compiling the relevant feature test code with -D_GNU_SOURCE and making -it include fcntl.h which defines loff_t on musl. +Based on patch by Sören Tempel. + +Change-Id: Ic9a608fd964a6f78e754aa8e3100aff06ab3dade +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/412075 +Reviewed-by: Ian Lance Taylor +Reviewed-by: Cherry Mui + +libgo: #include when checking for loff_t + +Fixes https://gcc.gnu.org/PR106033 +Fixes golang/go#53469 + +Change-Id: I060021b7bb9334949b567442448abb6822fd6d35 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413214 +Reviewed-by: Cherry Mui +Reviewed-by: Than McIntosh --- - libgo/configure | 4 +++- - libgo/configure.ac | 4 +++- - libgo/sysinfo.c | 21 +++++++++++++++++++++ - 3 files changed, 27 insertions(+), 2 deletions(-) + libgo/config.h.in | 3 +++ + libgo/configure | 12 ++++++++++-- + libgo/configure.ac | 11 +++++++++-- + libgo/go/syscall/libcall_linux.go | 17 +++++++++-------- + libgo/mksysinfo.sh | 6 +----- + libgo/sysinfo.c | 15 ++++++++++++++- + 6 files changed, 46 insertions(+), 18 deletions(-) +diff --git a/libgo/config.h.in b/libgo/config.h.in +index 25b8ab8f9ee..2c3c7469675 100644 +--- a/libgo/config.h.in ++++ b/libgo/config.h.in +@@ -70,6 +70,9 @@ + /* Define to 1 if you have the `fchownat' function. */ + #undef HAVE_FCHOWNAT + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_FCNTL_H ++ + /* Define to 1 if you have the `futimesat' function. */ + #undef HAVE_FUTIMESAT + diff --git a/libgo/configure b/libgo/configure -index ffe17c9be55..c2dbecef98c 100755 +index ffe17c9be55..61a49947eb9 100755 --- a/libgo/configure +++ b/libgo/configure -@@ -15546,7 +15546,9 @@ _ACEOF +@@ -15249,7 +15249,7 @@ $as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h + fi + + +-for ac_header in port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h ++for ac_header in fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h + do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` + ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +@@ -15546,7 +15546,14 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default" -+CFLAGS_hold=$CFLAGS -+CFLAGS="$CFLAGS -D_GNU_SOURCE" -+ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include " ++ ++CFLAGS_hold="$CFLAGS" ++CFLAGS="$OSCFLAGS $CFLAGS" ++ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" " ++#include ++#include ++ ++" if test "x$ac_cv_type_loff_t" = xyes; then : cat >>confdefs.h <<_ACEOF +@@ -15556,6 +15563,7 @@ _ACEOF + + fi + ++CFLAGS="$CFLAGS_hold" + + LIBS_hold="$LIBS" + LIBS="$LIBS -lm" diff --git a/libgo/configure.ac b/libgo/configure.ac -index 7e2b98ba67c..667feae3c03 100644 +index 7e2b98ba67c..274fcfc35c7 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac -@@ -601,7 +601,9 @@ AC_STRUCT_DIRENT_D_TYPE +@@ -579,7 +579,7 @@ AC_C_BIGENDIAN + + GCC_CHECK_UNWIND_GETIPINFO + +-AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h) ++AC_CHECK_HEADERS(fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h) + + AC_CHECK_HEADERS([netinet/icmp6.h], [], [], + [#include +@@ -601,7 +601,14 @@ AC_STRUCT_DIRENT_D_TYPE AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat) AC_TYPE_OFF_T -AC_CHECK_TYPES([loff_t]) -+CFLAGS_hold=$CFLAGS -+CFLAGS="$CFLAGS -D_GNU_SOURCE" # musl does not define loff_t without this -+AC_CHECK_TYPES([loff_t], [], [], [[#include ]]) ++ ++CFLAGS_hold="$CFLAGS" ++CFLAGS="$OSCFLAGS $CFLAGS" ++AC_CHECK_TYPES([loff_t], [], [], [[ ++#include ++#include ++]]) ++CFLAGS="$CFLAGS_hold" LIBS_hold="$LIBS" LIBS="$LIBS -lm" +diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go +index 96974bd3269..65eb1a745f7 100644 +--- a/libgo/go/syscall/libcall_linux.go ++++ b/libgo/go/syscall/libcall_linux.go +@@ -209,19 +209,20 @@ 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 *_libgo_loff_t_type, wfd int, woff *_libgo_loff_t_type, len int, flags int) (n int64, err error) ++//splice(rfd _C_int, roff *_libgo_loff_t_type, wfd _C_int, woff *_libgo_loff_t_type, 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 _libgo_loff_t_type ++ var plroff *_libgo_loff_t_type + if roff != nil { +- lroff = _loff_t(*roff) ++ lroff = _libgo_loff_t_type(*roff) + plroff = &lroff + } +- var lwoff _loff_t +- var plwoff *_loff_t ++ var lwoff _libgo_loff_t_type ++ var plwoff *_libgo_loff_t_type + if woff != nil { +- lwoff = _loff_t(*woff) ++ lwoff = _libgo_loff_t_type(*woff) + plwoff = &lwoff + } + n, err = splice(rfd, plroff, wfd, plwoff, len, flags) +diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh +index 0c52ea5d71a..5aa309155c3 100755 +--- 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 _libgo_off_t_type" >> ${OUT} + echo "type Mode_t _mode_t" >> ${OUT} + echo "type Pid_t _pid_t" >> ${OUT} + echo "type Uid_t _uid_t" >> ${OUT} diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c -index 8ce061e2f5f..b85add15a7b 100644 +index 336a5983750..fc0210992fa 100644 --- a/libgo/sysinfo.c +++ b/libgo/sysinfo.c -@@ -343,6 +343,27 @@ enum { - #endif +@@ -354,6 +354,18 @@ enum { }; + #endif -+// musl libc has both off64_t and loff_t. However, both of these types -+// are defined as CPP macros, not as C typedefs. Unfortunately, the GCC -+// -fdump-go-spec option, which is responsible for generating type -+// definitions for Go based on this file, only recognizes types defined -+// through typedefs. -+// -+// For this reason, we check here if either off64_t or loff_t are -+// defined as CPP macros and if so, we redefine them using a C typedef. -+#if defined(HAVE_OFF64_T) && defined(off64_t) -+typedef off64_t __musl_off64_t; -+#undef off64_t -+typedef __musl_off64_t off64_t; ++#if defined(HAVE_LOFF_T) ++// loff_t can be defined as a macro; for -fgo-dump-spec make sure we ++// see a typedef. ++typedef loff_t libgo_loff_t_type; +#endif + -+// See comment regarding musl libc above. -+#if defined(HAVE_LOFF_T) && defined(loff_t) -+typedef loff_t __musl_loff_t; -+#undef loff_t -+typedef __musl_loff_t loff_t; ++#if defined(HAVE_OFF64_T) ++typedef off64_t libgo_off_t_type; ++#else ++typedef off_t libgo_off_t_type; +#endif + - // SIOCGIFMTU can't be added in the above enum as it might - // be signed in some OSes. - #ifdef SIOCGIFMTU + // The following section introduces explicit references to types and + // constants of interest to support bootstrapping libgo using a + // compiler that doesn't support -fdump-go-spec (e.g., clang), via +@@ -534,7 +546,8 @@ SREF(timex); + // From sys/types.h + TREF(pid_t); + TREF(off_t); +-TREF(loff_t); ++TREF(libgo_loff_t_type); ++TREF(libgo_off_t_type); + TREF(size_t); + TREF(ssize_t); + TREF(mode_t); diff --git a/cross/gcc-aarch64/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch b/cross/gcc-aarch64/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch index 14836f27c..4867ab090 100644 --- a/cross/gcc-aarch64/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch +++ b/cross/gcc-aarch64/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch @@ -1,43 +1,22 @@ -From 76c13560bba3534bff335e5bb571a8b95d50d4ba Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 18:33:49 +0200 -Subject: [PATCH] gcc-go: Use int64 type as offset argument for mmap -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +From 4b6240d5301ce04b8bbc3e2152915cbc7da80584 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Wed, 28 Sep 2022 17:30:14 +0200 +Subject: [PATCH] libgo: use _off_t for mmap offset argument -Without this patch, Go run-time memory allocation fails on 32-bit architectures: +On glibc-based systems, off_t is a 32-bit type on 32-bit systems and a +64-bit type on 64-bit systems by default. However, on systems using musl +libc off_t is unconditionally a 64-bit type. As such, it is insufficient +to use a uintptr type for the mmap offset parameter. - fatal error: runtime: cannot allocate memory - runtime stack: - runtime.dopanic__m - :0 - runtime.throw - :0 - :0 - :0 - runtime.systemstack - :0 - runtime.addrRanges.init - :0 - runtime.pageAlloc.init - :0 - runtime.mheap.init - :0 - runtime.schedinit - :0 - :0 - :0 - -Taken from Adélie Linux [1]. - -[1]: https://git.adelielinux.org/adelie/packages/-/commit/63b5fb12c3d75e460799c672bbbdd5d29c3cc33c +Presently, the (incorrect) mmap declaration causes a libgo run-time +failure on 32-bit musl systems (fatal error: runtime: cannot allocate +memory). This commit fixes this run-time error. --- libgo/go/runtime/mem_gccgo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go -index fa3389d857e..57bed97c710 100644 +index fa3389d8..07bf325a 100644 --- a/libgo/go/runtime/mem_gccgo.go +++ b/libgo/go/runtime/mem_gccgo.go @@ -15,7 +15,7 @@ import ( @@ -45,16 +24,16 @@ index fa3389d857e..57bed97c710 100644 //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 ++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off _off_t) unsafe.Pointer //extern munmap func munmap(addr unsafe.Pointer, length uintptr) int32 -@@ -37,7 +37,7 @@ func init() { - } +@@ -38,7 +38,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) + func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) { +- p := sysMmap(addr, n, prot, flags, fd, off) ++ p := sysMmap(addr, n, prot, flags, fd, _off_t(off)) if uintptr(p) == _MAP_FAILED { return nil, errno() + } diff --git a/cross/gcc-aarch64/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch b/cross/gcc-aarch64/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch deleted file mode 100644 index 7ca25c3df..000000000 --- a/cross/gcc-aarch64/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch +++ /dev/null @@ -1,55 +0,0 @@ -From cf41d579088e1c0b5c33c93657ad041e797b5905 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 2 Jan 2022 01:07:03 +0100 -Subject: [PATCH] libgo: include asm/ptrace.h for pt_regs definition on PowerPC -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Both glibc and musl libc declare pt_regs as an incomplete type. This -type has to be completed by inclusion of another header. On Linux, the -asm/ptrace.h header file provides this type definition. Without -including this header file, it is not possible to access the regs member -of the mcontext_t struct as done in libgo/runtime/go-signal.c. On glibc, -other headers (e.g. sys/user.h) include asm/ptrace.h but on musl -asm/ptrace.h is not included by other headers and thus the -aforementioned files do not compile without an explicit include of -asm/ptrace.h: - - libgo/runtime/go-signal.c: In function 'getSiginfo': - libgo/runtime/go-signal.c:227:63: error: invalid use of undefined type 'struct pt_regs' - 227 | ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip; - | - -Instead of including the asm/ptrace.h header conditionally on PowerPC -only it would alternatively also be possible to include it -unconditionally. - -See also: - -* https://git.musl-libc.org/cgit/musl/commit/?id=c2518a8efb6507f1b41c3b12e03b06f8f2317a1f -* https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d57cb31910ca5c200e4172276749a7f8bd17ae3c -* https://github.com/kaniini/libucontext/issues/36 - -Signed-off-by: Sören Tempel ---- - libgo/runtime/go-signal.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c -index 528d9b6d9fe..c67503f0a79 100644 ---- a/libgo/runtime/go-signal.c -+++ b/libgo/runtime/go-signal.c -@@ -10,6 +10,12 @@ - #include - #include - -+// On PowerPC, ucontext.h uses a pt_regs struct as an incomplete -+// type. This type must be completed by including asm/ptrace.h. -+#ifdef __PPC__ -+#include -+#endif -+ - #include "runtime.h" - - #ifndef SA_RESTART diff --git a/cross/gcc-aarch64/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch b/cross/gcc-aarch64/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch index cb1cd527a..5cebe745b 100644 --- a/cross/gcc-aarch64/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch +++ b/cross/gcc-aarch64/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch @@ -1,30 +1,71 @@ -From fbc8240ac15225ede8416a27c9978559b85d6877 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Mon, 21 Feb 2022 10:04:47 +0000 -Subject: [PATCH] go/gospec: forcibly disable -fsplit-stack support +From c86b726c048eddc1be320c0bf64a897658bee13d Mon Sep 17 00:00:00 2001 +From: Uros Bizjak +Date: Wed, 18 May 2022 20:03:26 +0200 +Subject: [PATCH] x86: Fix -fsplit-stack feature detection via + TARGET_CAN_SPLIT_STACK +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -for some reason, TARGET_CAN_SPLIT_STACK still gets defined on 32-bit x86, -so hackfix it for now +Since commit c163647ffbc9a20c8feb6e079dbecccfe016c82e -fsplit-stack +is only supported on glibc targets. However, this original commit +required some fixups. As part of the fixup, the changes to the +gnu-user-common.h and gnu.h were partially reverted in commit +60953a23d57b13a672f751bec0c6eefc059eb1ab thus causing TARGET_CAN_SPLIT_STACK +to be defined for non-glibc targets even though -fsplit-stack is +actually not supported and attempting to use it causes a runtime error. + +This causes gcc internal code, such as ./gcc/go/gospec.c to not +correctly detect that -fsplit-stack is not supported and thus causes +gccgo to fail compilation on non-glibc targets. + +This commit ensures that TARGET_CAN_SPLIT_STACK is only set if the +default libc is glibc. It is presently unclear to me if there is a +better way to detect glibc at pre-processor time. + +The proposed changes have been tested on x86 and x86_64 Alpine Linux +(which uses musl libc) and fix compilation of gccgo for this target. + +Signed-off-by: Sören Tempel + +gcc/ChangeLog: + + * config/i386/gnu-user-common.h (defined): Only define + TARGET_CAN_SPLIT_STACK for glibc targets. + * config/i386/gnu.h (defined): Ditto. --- - gcc/go/gospec.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) + gcc/config/i386/gnu-user-common.h | 5 +++-- + gcc/config/i386/gnu.h | 5 +++-- + 2 files changed, 6 insertions(+), 4 deletions(-) -diff --git a/gcc/go/gospec.cc b/gcc/go/gospec.cc -index df92b62d8e6..cf168beb4cf 100644 ---- a/gcc/go/gospec.cc -+++ b/gcc/go/gospec.cc -@@ -269,11 +269,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, - /* Copy the 0th argument, i.e., the name of the program itself. */ - new_decoded_options[j++] = decoded_options[i++]; +diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h +index 23b54c5be52..cab9be2bfb7 100644 +--- a/gcc/config/i386/gnu-user-common.h ++++ b/gcc/config/i386/gnu-user-common.h +@@ -66,7 +66,8 @@ along with GCC; see the file COPYING3. If not see + #define STACK_CHECK_STATIC_BUILTIN 1 --#ifdef TARGET_CAN_SPLIT_STACK -+ /* Hackfix: we never support split stack on Alpine GCC */ -+#if 0 - supports_split_stack = 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 ++ assembler has full support for the CFI directives. Also ++ we only support -fsplit-stack on glibc targets. */ ++#if (DEFAULT_LIBC == LIBC_GLIBC) && HAVE_GAS_CFI_PERSONALITY_DIRECTIVE + #define TARGET_CAN_SPLIT_STACK #endif +diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h +index 401e60c9a02..fb8d69a97d8 100644 +--- a/gcc/config/i386/gnu.h ++++ b/gcc/config/i386/gnu.h +@@ -41,8 +41,9 @@ along with GCC. If not, see . + #define TARGET_THREAD_SSP_OFFSET 0x14 --#ifdef TARGET_CAN_SPLIT_STACK_64BIT -+#if 0 - if (is_m64) - supports_split_stack = 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 ++ assembler has full support for the CFI directives. Also ++ we only support -fsplit-stack on glibc targets. */ ++#if (DEFAULT_LIBC == LIBC_GLIBC) && HAVE_GAS_CFI_PERSONALITY_DIRECTIVE + #define TARGET_CAN_SPLIT_STACK #endif + /* We steal the last transactional memory word. */ diff --git a/cross/gcc-aarch64/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch b/cross/gcc-aarch64/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch index 0ce960966..db38df3b0 100644 --- a/cross/gcc-aarch64/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch +++ b/cross/gcc-aarch64/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch @@ -1,31 +1,41 @@ -From 38270192ea355d8035d9f1b5fe50e36ca3fa3708 Mon Sep 17 00:00:00 2001 -From: Natanael Copa -Date: Thu, 30 Jun 2022 17:04:23 +0000 -Subject: [PATCH] gcc-go: fix build error with SYS_SECCOMP +From 548720bca6bff21ebc9aba22249d9ce45bbd90c7 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Wed, 29 Jun 2022 15:32:04 -0700 +Subject: [PATCH] libgo: handle stat st_atim32 field and SYS_SECCOMP +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -fix the build error: - sysinfo.go:6606:7: error: redefinition of 'SYS_SECCOMP' - 6606 | const SYS_SECCOMP = _SYS_SECCOMP - | ^ - sysinfo.go:6600:7: note: previous definition of 'SYS_SECCOMP' was here - 6600 | const SYS_SECCOMP = _SYS_seccomp - | ^ +Patches for musl support, from Sören Tempel. -Upstream report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105225 +Fixes https://gcc.gnu.org/PR105225 + +Change-Id: If396877d4a4c7d27962226d7a6e3bb91b1344413 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415294 +Reviewed-by: Than McIntosh +Reviewed-by: Ian Lance Taylor --- - libgo/mksysinfo.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/mksysinfo.sh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh -index 6fef104cc1c..06289a43bdf 100755 +index 5aa30915..ea1fa17d 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh -@@ -126,7 +126,7 @@ if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then - fi +@@ -127,6 +127,7 @@ fi # The syscall numbers. We force the names to upper case. --grep '^const _SYS_' gen-sysinfo.go | \ -+grep '^const _SYS_[a-z]' gen-sysinfo.go | \ + grep '^const _SYS_' gen-sysinfo.go | \ ++ grep -v '^const _SYS_SECCOMP = ' | \ sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \ while read sys; do sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` +@@ -506,7 +507,7 @@ fi + + # For historical reasons Go uses the suffix "timespec" instead of "tim" for + # stat_t's time fields on NetBSD. +-st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' ++st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' + if test "${GOOS}" = "netbsd"; then + st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' + fi diff --git a/cross/gcc-aarch64/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch b/cross/gcc-aarch64/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch deleted file mode 100644 index 09504f1e9..000000000 --- a/cross/gcc-aarch64/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 9cef407678b40c20ecc39850c7e43346ad92a60b Mon Sep 17 00:00:00 2001 -From: Sergei Trofimovich -Date: Mon, 27 Jun 2022 03:31:45 +0100 -Subject: [PATCH] c++: avoid poisoning on musl [PR106102] - -On musl uses calloc() (via ). includes -it indirectly and exposes use of poisoned calloc() when module code -is built: - - /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc - In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, - from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35, - .... - from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77, - from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24, - from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25, - from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23, - from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32: - /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" - 84 | void *calloc(size_t, size_t); - | ^ - /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" - 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) - | ^ - -gcc/cp/ - - PR c++/106102 - * mapper-client.cc: Include via "system.h". - * mapper-resolver.cc: Ditto. - * module.cc: Ditto. - -libcc1/ - - PR c++/106102 - * libcc1plugin.cc: Include via "system.h". - * libcp1plugin.cc: Ditto. - -(cherry picked from commit 3b21c21f3f5726823e19728fdd1571a14aae0fb3) ---- - gcc/cp/mapper-client.cc | 1 + - gcc/cp/mapper-resolver.cc | 1 + - gcc/cp/module.cc | 1 + - libcc1/libcc1plugin.cc | 1 + - libcc1/libcp1plugin.cc | 1 + - 5 files changed, 5 insertions(+) - -diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc -index 8603a886a09..fe9544b5ba4 100644 ---- a/gcc/cp/mapper-client.cc -+++ b/gcc/cp/mapper-client.cc -@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see - #define INCLUDE_STRING - #define INCLUDE_VECTOR - #define INCLUDE_MAP -+#define INCLUDE_MEMORY - #include "system.h" - - #include "line-map.h" -diff --git a/gcc/cp/mapper-resolver.cc b/gcc/cp/mapper-resolver.cc -index e3d29fb5ada..e70d1b4ae2c 100644 ---- a/gcc/cp/mapper-resolver.cc -+++ b/gcc/cp/mapper-resolver.cc -@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see - #define INCLUDE_VECTOR - #define INCLUDE_ALGORITHM - #define INCLUDE_MAP -+#define INCLUDE_MEMORY - #include "system.h" - - // We don't want or need to be aware of networking -diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc -index cebf9c35c1d..5c5d02bb523 100644 ---- a/gcc/cp/module.cc -+++ b/gcc/cp/module.cc -@@ -202,6 +202,7 @@ Classes used: - - #define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available. */ - #include "config.h" -+#define INCLUDE_MEMORY - #define INCLUDE_STRING - #define INCLUDE_VECTOR - #include "system.h" -diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc -index 12ab5a57c8d..bdd0bdabe77 100644 ---- a/libcc1/libcc1plugin.cc -+++ b/libcc1/libcc1plugin.cc -@@ -31,6 +31,7 @@ - #undef PACKAGE_TARNAME - #undef PACKAGE_VERSION - -+#define INCLUDE_MEMORY - #include "gcc-plugin.h" - #include "system.h" - #include "coretypes.h" -diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc -index 83dab7f58b1..e2d5039a0a1 100644 ---- a/libcc1/libcp1plugin.cc -+++ b/libcc1/libcp1plugin.cc -@@ -32,6 +32,7 @@ - #undef PACKAGE_TARNAME - #undef PACKAGE_VERSION - -+#define INCLUDE_MEMORY - #include "gcc-plugin.h" - #include "system.h" - #include "coretypes.h" diff --git a/cross/gcc-aarch64/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch b/cross/gcc-aarch64/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch deleted file mode 100644 index 4cc457f53..000000000 --- a/cross/gcc-aarch64/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch +++ /dev/null @@ -1,117 +0,0 @@ -From f982c816d8f52a65231544b838160484b5ed4c71 Mon Sep 17 00:00:00 2001 -From: Sergei Trofimovich -Date: Mon, 27 Jun 2022 14:44:48 +0100 -Subject: [PATCH] jit: avoid calloc() poisoning on musl [PR106102] - -On musl uses calloc() (via ). jit/ includes -it directly and exposes use of poisoned calloc(): - - /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/jit/jit-playback.cc - make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1 - make[3]: *** Waiting for unfinished jobs.... - In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, - from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44: - /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" - 84 | void *calloc(size_t, size_t); - | ^ - /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" - 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) - | ^ - -The change moves inclusion to "system.h" under new -INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit. - -gcc/ - - PR c++/106102 - * system.h: Introduce INCLUDE_PTHREAD_H macros to include . - -gcc/jit/ - - PR c++/106102 - * jit-playback.cc: Include via "system.h" to avoid calloc() - poisoning. - * jit-recording.cc: Ditto. - * libgccjit.cc: Ditto. - -(cherry picked from commit 49d508065bdd36fb1a9b6aad9666b1edb5e06474) ---- - gcc/jit/jit-playback.cc | 3 +-- - gcc/jit/jit-recording.cc | 2 +- - gcc/jit/libgccjit.cc | 2 +- - gcc/system.h | 4 ++++ - 4 files changed, 7 insertions(+), 4 deletions(-) - -diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc -index 6be6bdf8dea..79714132b91 100644 ---- a/gcc/jit/jit-playback.cc -+++ b/gcc/jit/jit-playback.cc -@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "target.h" -@@ -41,8 +42,6 @@ along with GCC; see the file COPYING3. If not see - #include "diagnostic.h" - #include "stmt.h" - --#include -- - #include "jit-playback.h" - #include "jit-result.h" - #include "jit-builtins.h" -diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc -index a31720f043e..5556b9c4905 100644 ---- a/gcc/jit/jit-recording.cc -+++ b/gcc/jit/jit-recording.cc -@@ -19,13 +19,13 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "tm.h" - #include "pretty-print.h" - #include "toplev.h" - --#include - - #include "jit-builtins.h" - #include "jit-recording.h" -diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc -index cc6486c9cad..4c991e5436b 100644 ---- a/gcc/jit/libgccjit.cc -+++ b/gcc/jit/libgccjit.cc -@@ -19,12 +19,12 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "timevar.h" - #include "typed-splay-tree.h" - #include "cppbuiltin.h" --#include - - #include "libgccjit.h" - #include "jit-recording.h" -diff --git a/gcc/system.h b/gcc/system.h -index c5562cc49a3..e10c34f70ec 100644 ---- a/gcc/system.h -+++ b/gcc/system.h -@@ -750,6 +750,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); - #endif - #endif - -+#ifdef INCLUDE_PTHREAD_H -+#include -+#endif -+ - #ifdef INCLUDE_ISL - #ifdef HAVE_isl - #include diff --git a/cross/gcc-aarch64/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch b/cross/gcc-aarch64/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch index 4de9ea2b7..0f949be3a 100644 --- a/cross/gcc-aarch64/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch +++ b/cross/gcc-aarch64/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch @@ -1,28 +1,108 @@ -From d54419ddcc14f52517017147201560da5353c436 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 17 Jul 2022 02:52:13 +0200 -Subject: [PATCH] libgo: adjust name of union in sigevent struct +From 8f1a91aeff400d572857895b7f5e863ec5a4d93e Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Mon, 26 Sep 2022 15:03:53 -0400 +Subject: [PATCH] runtime: portable access to sigev_notify_thread_id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -The union in struct sigevent is named __sev_fields on musl but -_sigev_un on glibc. Not sure what this code actually does and -how this works if the union layout is different… +Previously, libgo relied on the _sigev_un implementation-specific +field in struct sigevent, which is only available on glibc. +This patch uses the sigev_notify_thread_id macro instead which is +mandated by timer_create(2). In theory, this should work with any libc +implementation for Linux. Unfortunately, there is an open glibc bug +as glibc does not define this macro. For this reason, a glibc-specific +workaround is required. Other libcs (such as musl) define the macro +and don't require the workaround. + +See https://sourceware.org/bugzilla/show_bug.cgi?id=27417 + +This makes libgo compatible with musl libc. + +Based on patch by Sören Tempel. + +Change-Id: I0924a53d5212730ebc395ecf9199f85967be8cc6 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/434755 +Reviewed-by: Cherry Mui +Reviewed-by: Than McIntosh --- - libgo/go/runtime/os_linux.go | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/go/runtime/os_linux.go | 12 +++++++++++- + libgo/runtime/go-signal.c | 18 ++++++++++++++++++ + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libgo/go/runtime/os_linux.go b/libgo/go/runtime/os_linux.go -index 96fb178870e..a75a2dd703f 100644 +index 96fb1788..2b2d827c 100644 --- a/libgo/go/runtime/os_linux.go +++ b/libgo/go/runtime/os_linux.go -@@ -365,7 +365,7 @@ func setThreadCPUProfiler(hz int32) { +@@ -22,6 +22,12 @@ type mOS struct { + profileTimerValid uint32 + } + ++// setSigeventTID is written in C to set the sigev_notify_thread_id ++// field of a sigevent struct. ++// ++//go:noescape ++func setSigeventTID(*_sigevent, int32) ++ + func getProcID() uint64 { + return uint64(gettid()) + } +@@ -52,9 +58,12 @@ const ( + ) + + // Atomically, ++// + // if(*addr == val) sleep ++// + // Might be woken up spuriously; that's allowed. + // Don't sleep longer than ns; ns < 0 means forever. ++// + //go:nosplit + func futexsleep(addr *uint32, val uint32, ns int64) { + // Some Linux kernels have a bug where futex of +@@ -73,6 +82,7 @@ func futexsleep(addr *uint32, val uint32, ns int64) { + } + + // If any procs are sleeping on addr, wake up at most cnt. ++// + //go:nosplit + func futexwakeup(addr *uint32, cnt uint32) { + ret := futex(unsafe.Pointer(addr), _FUTEX_WAKE_PRIVATE, cnt, nil, nil, 0) +@@ -365,7 +375,7 @@ func setThreadCPUProfiler(hz int32) { var sevp _sigevent sevp.sigev_notify = _SIGEV_THREAD_ID sevp.sigev_signo = _SIGPROF - *((*int32)(unsafe.Pointer(&sevp._sigev_un))) = int32(mp.procid) -+ *((*int32)(unsafe.Pointer(&sevp.__sev_fields))) = int32(mp.procid) ++ setSigeventTID(&sevp, int32(mp.procid)) ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, &sevp, &timerid) if ret != 0 { // If we cannot create a timer for this M, leave profileTimerValid false +diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c +index 528d9b6d..aa1b6305 100644 +--- a/libgo/runtime/go-signal.c ++++ b/libgo/runtime/go-signal.c +@@ -183,6 +183,24 @@ setSigactionHandler(struct sigaction* sa, uintptr handler) + sa->sa_sigaction = (void*)(handler); + } + ++#ifdef __linux__ ++ ++// Workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=27417 ++#ifndef sigev_notify_thread_id ++ #define sigev_notify_thread_id _sigev_un._tid ++#endif ++ ++void setSigeventTID(struct sigevent*, int32_t) ++ __asm__ (GOSYM_PREFIX "runtime.setSigeventTID"); ++ ++void ++setSigeventTID(struct sigevent *sev, int32_t v) ++{ ++ sev->sigev_notify_thread_id = v; ++} ++ ++#endif // defined(__linux__) ++ + // C code to fetch values from the siginfo_t and ucontext_t pointers + // passed to a signal handler. + diff --git a/cross/gcc-aarch64/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch b/cross/gcc-aarch64/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch index 10f82014a..f2f019119 100644 --- a/cross/gcc-aarch64/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch +++ b/cross/gcc-aarch64/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch @@ -1,36 +1,36 @@ -From 3825632cf4007ac93d8e44705a6da042c496318b Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Mon, 18 Jul 2022 20:34:39 +0200 -Subject: [PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl - arches +From d53e8a0e94e34dc609e34dd5e404debda2640cfb Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Sat, 30 Jul 2022 07:29:28 -0700 +Subject: [PATCH] libgo: use SYS_timer_settime32 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -On 32-bit systems musl only defines SYS_timer_settime32 not -SYS_timer_settime. This causes the following compilation error: +Musl defines SYS_timer_settime32, not SYS_timer_settime, on 32-bit systems. - os_linux.go:251:30: error: reference to undefined name '_SYS_timer_settime' - 251 | return int32(syscall(_SYS_timer_settime, uintptr(timerid), uintptr(flags), uintptr(unsafe.Pointer(new)), uintptr(unsafe.Pointer(old)), 0, 0)) - | ^ +Based on patch by Sören Tempel. -This commit fixes this error by defining SYS_timer_settime to -SYS_timer_settime32 if the latter is defined. +Change-Id: I1f3485028d132ceca1aba595325af24b4d72b894 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/420222 +Reviewed-by: Ian Lance Taylor +Reviewed-by: Cherry Mui --- - libgo/sysinfo.c | 6 ++++++ - 1 file changed, 6 insertions(+) + libgo/sysinfo.c | 5 +++++ + 1 file changed, 5 insertions(+) diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c -index b85add15a7b..ff04706a993 100644 +index fc021099..180f5c31 100644 --- a/libgo/sysinfo.c +++ b/libgo/sysinfo.c -@@ -343,6 +343,12 @@ enum { - #endif +@@ -354,6 +354,11 @@ enum { }; + #endif -+// musl libc does not have SYS_timer_settime on 32-bit platforms -+// but defines SYS_timer_settime32 instead, alias accordingly. -+#ifdef SYS_timer_settime32 ++#if !defined(SYS_timer_settime) && defined(SYS_timer_settime32) ++// musl defines SYS_timer_settim32 on 32-bit systems. +#define SYS_timer_settime SYS_timer_settime32 +#endif + - // musl libc has both off64_t and loff_t. However, both of these types - // are defined as CPP macros, not as C typedefs. Unfortunately, the GCC - // -fdump-go-spec option, which is responsible for generating type + #if defined(HAVE_LOFF_T) + // loff_t can be defined as a macro; for -fgo-dump-spec make sure we + // see a typedef. diff --git a/cross/gcc-aarch64/0053-libgo-make-match.sh-POSIX-shell-compatible.patch b/cross/gcc-aarch64/0053-libgo-make-match.sh-POSIX-shell-compatible.patch index cbfaca9aa..8758cb837 100644 --- a/cross/gcc-aarch64/0053-libgo-make-match.sh-POSIX-shell-compatible.patch +++ b/cross/gcc-aarch64/0053-libgo-make-match.sh-POSIX-shell-compatible.patch @@ -1,20 +1,29 @@ -From 75a430f66760802bf1ac5afcd716613e3cf8c77d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Tue, 19 Jul 2022 07:15:25 +0200 -Subject: [PATCH] libgo: make match.sh POSIX-shell compatible +From a62f20ae78ddd41be682dde8cab075ca4f5dbb2a Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Fri, 22 Jul 2022 11:38:20 -0700 +Subject: [PATCH] libgo: use POSIX shell arithmetic expansion +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -The `(( expression ))` syntax is a Bash extension. However, the -arithmetic expressions used by the gobuild() function can also -be expressed using Arithmetic POSIX Expansion with `$(( expression ))`. -Contrary to the Bash expression, the Arithmetic Expansion doesn't set -the return value if the expression is non-zero but instead just prints -the expression result. Hence, the expression also needs to be negated. +Avoid bash-specific ((expression)) syntax. As the bash syntax +converts a non-zero value to a zero status (and a zero value to a 1 +status), and POSIX arithmetic expansion does not, we have to negate +the result. + +Based on patch by Sören Tempel. + +Change-Id: I4c64fa15de3994a1a5c7c5ec0de6a82ddd858917 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/419154 +Reviewed-by: Than McIntosh +Reviewed-by: Ian Lance Taylor --- - libgo/match.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/match.sh | 2 +- + libgo/testsuite/gotest | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libgo/match.sh b/libgo/match.sh -index 7ed587ff794..b355d47429a 100755 +index 7ed587ff..e5ed98de 100755 --- a/libgo/match.sh +++ b/libgo/match.sh @@ -111,7 +111,7 @@ gobuild() { @@ -22,7 +31,20 @@ index 7ed587ff794..b355d47429a 100755 line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") fi - (($line)) -+ return $((! ( line ))) ++ return $((!($line))) } matched= +diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest +index 04e4267f..0a0a7e14 100755 +--- a/libgo/testsuite/gotest ++++ b/libgo/testsuite/gotest +@@ -302,7 +302,7 @@ gobuild() { + if test "$goarch" != "386"; then + line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") + fi +- (($line)) ++ return $((!($line))) + } + + case "x$gofiles" in diff --git a/cross/gcc-aarch64/APKBUILD b/cross/gcc-aarch64/APKBUILD index 0cfacf756..7b549f2d5 100644 --- a/cross/gcc-aarch64/APKBUILD +++ b/cross/gcc-aarch64/APKBUILD @@ -24,14 +24,15 @@ CBUILDROOT="/" _cross_configure="--disable-bootstrap --with-sysroot=/usr/$CTARGET" pkgname=gcc-aarch64 -_pkgbase=12.1.1 -pkgver=12.1.1_git20220630 +_pkgbase=12.2.1 # must match gcc/BASE-VER +_pkgsnap=20220924 +pkgver=${_pkgbase}_git${_pkgsnap} [ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2" [ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross="" [ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" pkgname=gcc-aarch64 -pkgrel=6 +pkgrel=1 pkgdesc="Stage2 cross-compiler for aarch64" url="https://gcc.gnu.org" arch="x86_64" @@ -204,11 +205,14 @@ makedepends="$makedepends_build $makedepends_host" # when using upstream releases, use this URI template # https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz # -# right now, we are using a git snapshot. +# right now, we are using a git snapshot. snapshots are taken from gcc.gnu.org/pub/gcc/snapshots. +# However, since they are periodically deleted from the GCC mirrors the utilized snapshots are +# mirrored on dev.alpinelinux.org. Please ensure that the snapshot Git commit (as stated in the +# README) matches the base commit on the version-specific branch in the Git repository below. # # PLEASE submit all patches to gcc to https://gitlab.alpinelinux.org/kaniini/alpine-gcc-patches, # so that they can be properly tracked and easily rebased if needed. -source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz +source="https://dev.alpinelinux.org/archive/gcc/${_pkgbase%%.*}-${_pkgsnap}/gcc-${_pkgbase%%.*}-${_pkgsnap}.tar.xz 0001-posix_memalign.patch 0002-gcc-poison-system-directories.patch 0003-specs-turn-on-Wl-z-now-by-default.patch @@ -238,23 +242,17 @@ source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz 0027-always-build-libgcc_eh.a.patch 0028-ada-libgnarl-compatibility-for-musl.patch 0029-ada-musl-support-fixes.patch - 0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch - 0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch - 0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch 0033-gcc-go-link-to-libucontext.patch 0034-Use-generic-errstr.go-implementation-on-musl.patch 0035-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch 0036-configure-fix-detection-of-atomic-builtins-in-libato.patch 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch - 0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch 0043-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch 0044-gdc-unconditionally-link-libgphobos-against-libucont.patch 0045-druntime-link-against-libucontext-on-all-platforms.patch - 0046-c-avoid-memory-poisoning-on-musl-PR106102.patch - 0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch 0050-libphobos-don-t-define-__mode_t-twice-on-musl-target.patch 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch @@ -263,7 +261,7 @@ source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz " # we build out-of-tree -_gccdir="$srcdir"/gcc-$pkgver +_gccdir="$srcdir"/gcc-${_pkgbase%%.*}-${_pkgsnap} _gcclibdir="/usr/lib/gcc/$CTARGET/${_pkgbase:-$pkgver}" _gcclibexec="/usr/libexec/gcc/$CTARGET/${_pkgbase:-$pkgver}" @@ -763,7 +761,7 @@ gnat() { } sha512sums=" -43de66dfed7b5351bb543f7f2e8253e63d1e544e5bd293829e8ec7bffe60925cabcf8f6972fe8825100b1f1d7839e41d9314ec650c1320150c09317e2be24aa9 gcc-12.1.1_git20220630.tar.xz +ba4d9e73d108088da26fbefe18d9b245b76771ffe752c2b4b31bdf38a2d0b638fbc115c377526c27311d4d7ffd4e0d236a5af5016bd364ccaa11a4989d1401e8 gcc-12-20220924.tar.xz 41cbb4d69218006cf9e0cdb6c86212ef451f8decd52a50a7dbb4d34726009da7a4e0261c852b46cb584db253a4bae2f31dc485c506cb545e64a7d26e0ba6c2b6 0001-posix_memalign.patch 531155055cda7f119bcac6479bcae73af9201cd596af9cf1616850bbcf4393b91c5de9f2fbbc1cde6e158fb4df7237b033146f662dff5fa0ea12151cc514adb8 0002-gcc-poison-system-directories.patch c1275d77b5269386a2ec683933570810f5a2ba1208c161ed887797eb9aee3cb82ef08a8964635902614e6a6e83f3065ba0801c9355d85dd8d60cb1fa20bdf687 0003-specs-turn-on-Wl-z-now-by-default.patch @@ -793,26 +791,20 @@ b40d7e4712c035674c993bbb55475290ec14523b3f0fd05493514bac4e9adaa6641faf815fc40ffc 674360ce2ee9f704d0632cc98756f9fe8dd8ca30064fb9d3423b437f7e679c1c51e765b15e535dcb278cd2769583690acb3395b91e4fd5f6f4e3b97879fcc313 0027-always-build-libgcc_eh.a.patch f060687adcd5297124e4000f1ba1e3fd5d7d124da04d948cbd0d4a6c69a90a2b29a4a0dbbe13a83ab6950724f434de012b681bdbcdf53c0100b40fe3d00f2f2f 0028-ada-libgnarl-compatibility-for-musl.patch 5160bae68e20a1966c1f6d655ee98af759e9b9ee842718ae6007d467b418e1cf3b307528a0841477b5259671ce868521b06c0f2e947b7b8f3a398c53dd978252 0029-ada-musl-support-fixes.patch -74c70a752ff24f231b45c69ca1d86ebf261bca643334cb6ba518ac204986ccd7fa84f4df4fdb38bbc0bb61832514b0100b2d2ba069fb1842929369d073220f24 0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch -9786711f308d5f93f2f5a45862f340d4741e1d8aef116d696b85a6debb6149d3772b0cfab4d9ef8782172b102664d9acdd27021af433b504c5918f379b1dd978 0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch -4ffd2f279fbcf5abb1ac8cc6435204e48a776e7ef3742f2120eef1a1bdca2d0a01d30c481fd1495926c9166daaf127f9013fda0efefe3ed7bf6e660915cc1b49 0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch -0ad15e78806031cef68da6577f7ce9be178533b3768ca42fff7f12816d61fa745acc77be2e047ac1c5bfdbc04e999202e5cefd04042bca798177197236b79954 0033-gcc-go-link-to-libucontext.patch +3c04b26554a78096296ca9542c77a91219bd26044dd2cb2006db4c1944889a97c215900b3828ba7e8c675162406db543605a815bdfbd915bf810663b1b253bdd 0033-gcc-go-link-to-libucontext.patch 699dc3641099da6136dd3689f06c6553c03b3a85acf83a3fce1beb5425065b3e378535ca9e9100a120fdbafc34871d61c063fd5328a49cd87a15a989ed51706d 0034-Use-generic-errstr.go-implementation-on-musl.patch d9ba710f770e053c8f212e821817c188091a829658050b9ab5906388553ec60fec37943ea43c270e92a9014902949f3c98fc4639032d92b8145b375bb29e193e 0035-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch ab90d8fdd977d6cd3da096a1c76d77be3e89a020b2127247771711a32eb608cceed21834ef488ab4b69bb0f408b098fdfb61630819e3d1a1e57d5af67800ee74 0036-configure-fix-detection-of-atomic-builtins-in-libato.patch -7b356e11f66877bee864e2b1f81ae4be6c6c586040afb3ac220ff902f694efd60dcb4647cc7a37890c91dd539535b9992d463b785d3158205dbf9369b17c8ab7 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch -5905e4309670cfa4a5883aa21f744391ee2107731795817e0ffcccfaa22b0c21df883038c86362b091e7b35730aa4de6dce827c908ea398a161add851df5c31e 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch -570e084d223671fa29cb460b1b536a216920a7bcdfcdad21fe8cd7610e13f6942c1b1dd34ec861e9e3d830b9fe1f0e02e305c50c54d83aaf20526be09ca2256c 0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch -a8b53c7d6e0d6d19c655844cab074f49b8f14c54a7af920b5792303f73713fdc69b723a0a6041548d227dfaa98ef63641460ea355487619eb29f9fec4a1e301b 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch -15c93c9f2d68b19d00c6e82748e5f14470a120a3996f64d1ce91f17a65a5334cca478b4a6eba7d2d0a1d6d22206407ac3b1b5255987cc1144f5177bbb68153c8 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch +8bc6823f0b3c66f7b73d7ddb64ffa6930463285c2e9a14a2bc1882bcc4271144eaa1107d713294699caf9481648163cbf43921a2b8e4ac0d55c78a804bae8a3d 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch +e9699f4721778869eb3a8fef2c679208ef5b98584892f30b0e1cb5dc1669f8158198d7792659b1b56c381baf62247d21990dcced9178547affd5d6bfb2d12548 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch +d6dc1bfb881a313d167aaa5658790b0f55eea4336c408cfc6613dd5783440dafd0d37c43031a5f3e69be40f632e38371cd4fb6e5f0494ac4ea4d7d5025d2ae02 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch +684c6a6d52512b973429b6e709966439ac1e174f9e79a33d4a638b452245b457b34752b4b4034ba983f6a712f86522e7adf715bab00a6603f64a12139c5b1e39 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch 25014dfa99d96ee70ce0ad22e9f7974f0a51cc50b3b9c2db49df50774c8cd29e497ceed120486bee50be83bfb07f2009ed310eb9b0543f2795bd7359b87eadd2 0043-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch 75fd83ac05ab0a08d5f48547b08810f9934209bc78b5db59d65f33887b382af7ec24d8a29d40f86325c05af40c1ae1ec6466c839f646af90afc895a13073d07b 0044-gdc-unconditionally-link-libgphobos-against-libucont.patch 13e047153076d6e1fc40c9f5b6bfe5699c0e5460248f3d2b35ae36677cb960525af7b0b025997e5000a8492cec5e77a86828d66b4058c0d7f89fde0ab3890142 0045-druntime-link-against-libucontext-on-all-platforms.patch -ba87d4b4433e5f018071ce933ae523c62334574be2e46881a8945c9dc7ecc0fadfed3aaf837f13f93fd4c0d6d33feb24cb67c77d9c0adb40b62637991fed4374 0046-c-avoid-memory-poisoning-on-musl-PR106102.patch -03e7c0caf59ee7c7d13a840178befb378b734f18a5c36ec4bbfad3f78253f0afab80864ea0905b58454178c8c31b2441622dd38668dd54e6550e30e6249e882b 0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch -be7688a44707991c31337bff24245394aa385e7b4ba151f18e21e734a4bbb151348458f413965e5cba50185ab8e0aba8b793eba04c0802dc563b148ed490f26d 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch +c33ca2553642c2dbd1c65cd97046548f08775785a3db06d761e3bbe61398c37bc382fe132c0c3fa2101dfd4eea2a6d48bf4fae899a0ddb811c81abd7be35c122 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch 179cd15d629884a66e954fd76066675efa594686b970facbb12ad50769e5d70b5530d7f61e77120e26d1c3dfc701cfc5295f341f635db998df73c41bc8e62172 0050-libphobos-don-t-define-__mode_t-twice-on-musl-target.patch -d7592589cbf982f4518cb07572f96131278c7d2fd8fbbcd7fcb47f6628529ae9a5fc22b2dfe929be06845d137e1c5d2efeb6f63b1c2fb9c36cd6bdb97d41c65f 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch +c82d7c8d340a76df3d796565a79b0ccc04ddffef39927620e1f3719bf2dc1db101ba13aef24b46c5bc95b7bf1e31c8bda4ab0936ba4c9c5e5047ba08826c982c 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch eb403d8ea665fd5dc2c11faf43b055e6a3bf480a397ceee3e0ca1e38ec7d2392315f2694ed9a34ffbc99e464f2873fbbf91be8646ea4dea5d3636e3ea22fefa0 0052-libgnat-time_t-is-always-64-bit-on-musl-libc.patch -29c4fe28e5bf232e01b44106b2f8a3e50b5e00fc4302a69d3f5f90695e43ef07721a917b51d49dc40ae0543d8d97d432cb475834059c92176b73d326af9496e3 0053-libgo-make-match.sh-POSIX-shell-compatible.patch +22fb6edf1ed0387e2b93839ffe6e82a7fee420950af90e91199c3488d966702fdeb1a3396d22be0c73a4051525da9349c93d070a0d83b724c83f2b268da6483f 0053-libgo-make-match.sh-POSIX-shell-compatible.patch " diff --git a/cross/gcc-armhf/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch b/cross/gcc-armhf/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch deleted file mode 100644 index c032ba7e1..000000000 --- a/cross/gcc-armhf/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 7feb681596c4cfa34c769505058aa5bdf31c5131 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 17:59:45 +0200 -Subject: [PATCH] gcc-go: Fix handling of signal 34 on musl -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/mksigtab.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/mksigtab.sh b/libgo/mksigtab.sh -index bea8739957e..3876002efab 100644 ---- a/libgo/mksigtab.sh -+++ b/libgo/mksigtab.sh -@@ -86,7 +86,7 @@ checksig _SIGPWR '{_SigNotify, "SIGPWR: power failure restart"}' - checksig _SIGEMT '{_SigThrow, "SIGEMT: emulate instruction executed"}' - checksig _SIGINFO '{_SigNotify, "SIGINFO: status request from keyboard"}' - checksig _SIGTHR '{_SigNotify, "SIGTHR: reserved"}' --checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' -+#checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' - checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}' - checksig _SIGLWP '{_SigNotify, "SIGLWP: reserved signal no longer used by"}' - checksig _SIGFREEZE '{_SigNotify, "SIGFREEZE: special signal used by CPR"}' diff --git a/cross/gcc-armhf/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch b/cross/gcc-armhf/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch deleted file mode 100644 index 4f6967977..000000000 --- a/cross/gcc-armhf/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch +++ /dev/null @@ -1,24 +0,0 @@ -From b6885cf73989161b1b6893b5ae0dafed006d5f13 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Thu, 25 Nov 2021 01:47:03 +0000 -Subject: [PATCH] There are more than one st_{a,m,c}tim fields in struct stat - on time64 machines. - -Run the Go-isation on all of them. ---- - libgo/mksysinfo.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh -index 0c52ea5d71a..6fef104cc1c 100755 ---- a/libgo/mksysinfo.sh -+++ b/libgo/mksysinfo.sh -@@ -510,7 +510,7 @@ fi - - # For historical reasons Go uses the suffix "timespec" instead of "tim" for - # stat_t's time fields on NetBSD. --st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' -+st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' - if test "${GOOS}" = "netbsd"; then - st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' - fi diff --git a/cross/gcc-armhf/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch b/cross/gcc-armhf/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch deleted file mode 100644 index d85d2dbef..000000000 --- a/cross/gcc-armhf/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch +++ /dev/null @@ -1,24 +0,0 @@ -From c7a22e42ae403154a0c0158495b04b0205102041 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 30 Aug 2020 19:27:51 +0200 -Subject: [PATCH] gcc-go: undef SETCONTEXT_CLOBBERS_TLS in proc.c - ---- - libgo/runtime/proc.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c -index 3a30748d329..a987678fa84 100644 ---- a/libgo/runtime/proc.c -+++ b/libgo/runtime/proc.c -@@ -66,6 +66,10 @@ static void gscanstack(G*); - - __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); - -+/* libucontext does not seem to support tlsbase, undef the macro -+ * here to make sure we define initcontext and fixcontext as dummies. */ -+#undef SETCONTEXT_CLOBBERS_TLS -+ - #ifndef SETCONTEXT_CLOBBERS_TLS - - static inline void diff --git a/cross/gcc-armhf/0033-gcc-go-link-to-libucontext.patch b/cross/gcc-armhf/0033-gcc-go-link-to-libucontext.patch index 86c806d12..802295d3a 100644 --- a/cross/gcc-armhf/0033-gcc-go-link-to-libucontext.patch +++ b/cross/gcc-armhf/0033-gcc-go-link-to-libucontext.patch @@ -1,17 +1,22 @@ -From ef9df74e0c1059e51bb76b1f6d9d4746949d4d34 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Mon, 31 Aug 2020 08:59:40 +0200 -Subject: [PATCH] gcc-go: link to libucontext +From 0631e2b9453b33c42e12a14c11e8257d470016c5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 30 Aug 2020 19:17:42 +0200 +Subject: [PATCH] gcc-go: support libucontext +This patch allows using gcc-go with libucontext. For this purpose, +it unconditionally links gcc-go against -lucontext. Furthermore, +it undefines SETCONTEXT_CLOBBERS_TLS in proc.c to prevent usage +of makecontext/swapcontext feature that are not support by libucontext. --- - Makefile.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Makefile.in | 2 +- + libgo/runtime/proc.c | 4 ++++ + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in -index b96f60e33e2..b564ddbf792 100644 +index 593495e1650..c3e5d489bc0 100644 --- a/Makefile.in +++ b/Makefile.in -@@ -52802,7 +52802,7 @@ configure-target-libgo: +@@ -52801,7 +52801,7 @@ configure-target-libgo: esac; \ module_srcdir=libgo; \ rm -f no-such-file || : ; \ @@ -20,3 +25,18 @@ index b96f60e33e2..b564ddbf792 100644 $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ +diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c +index 3a30748d329..a987678fa84 100644 +--- a/libgo/runtime/proc.c ++++ b/libgo/runtime/proc.c +@@ -66,6 +66,10 @@ static void gscanstack(G*); + + __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); + ++/* libucontext does not seem to support tlsbase, undef the macro ++ * here to make sure we define initcontext and fixcontext as dummies. */ ++#undef SETCONTEXT_CLOBBERS_TLS ++ + #ifndef SETCONTEXT_CLOBBERS_TLS + + static inline void diff --git a/cross/gcc-armhf/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch b/cross/gcc-armhf/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch index 2259716b8..e0423d47b 100644 --- a/cross/gcc-armhf/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch +++ b/cross/gcc-armhf/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch @@ -1,81 +1,199 @@ -From 4655244d80aa67904a88d620361f2d37ea4c8576 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 28 Nov 2021 00:54:37 +0100 -Subject: [PATCH] libgo: Recognize off64_t and loff_t definitions of musl libc +From 3b9243b891cc06373639a23ed5717b0d1c2d8ea6 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Tue, 14 Jun 2022 06:13:43 -0700 +Subject: [PATCH] libgo: permit loff_t and off_t to be macros +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -Without this patch, both off64_t and loff_t are not recognized by --fdump-go-spec which causes a variety Go-related compilation errors on -musl libc since the gcc-go frontend expects both off64_t and loff_t to -be present. +They are macros in musl libc, rather than typedefs, and -fgo-dump-spec +doesn't handle that case. -Also make sure that autoconf recognizes support for loff_t on musl, by -compiling the relevant feature test code with -D_GNU_SOURCE and making -it include fcntl.h which defines loff_t on musl. +Based on patch by Sören Tempel. + +Change-Id: Ic9a608fd964a6f78e754aa8e3100aff06ab3dade +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/412075 +Reviewed-by: Ian Lance Taylor +Reviewed-by: Cherry Mui + +libgo: #include when checking for loff_t + +Fixes https://gcc.gnu.org/PR106033 +Fixes golang/go#53469 + +Change-Id: I060021b7bb9334949b567442448abb6822fd6d35 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413214 +Reviewed-by: Cherry Mui +Reviewed-by: Than McIntosh --- - libgo/configure | 4 +++- - libgo/configure.ac | 4 +++- - libgo/sysinfo.c | 21 +++++++++++++++++++++ - 3 files changed, 27 insertions(+), 2 deletions(-) + libgo/config.h.in | 3 +++ + libgo/configure | 12 ++++++++++-- + libgo/configure.ac | 11 +++++++++-- + libgo/go/syscall/libcall_linux.go | 17 +++++++++-------- + libgo/mksysinfo.sh | 6 +----- + libgo/sysinfo.c | 15 ++++++++++++++- + 6 files changed, 46 insertions(+), 18 deletions(-) +diff --git a/libgo/config.h.in b/libgo/config.h.in +index 25b8ab8f9ee..2c3c7469675 100644 +--- a/libgo/config.h.in ++++ b/libgo/config.h.in +@@ -70,6 +70,9 @@ + /* Define to 1 if you have the `fchownat' function. */ + #undef HAVE_FCHOWNAT + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_FCNTL_H ++ + /* Define to 1 if you have the `futimesat' function. */ + #undef HAVE_FUTIMESAT + diff --git a/libgo/configure b/libgo/configure -index ffe17c9be55..c2dbecef98c 100755 +index ffe17c9be55..61a49947eb9 100755 --- a/libgo/configure +++ b/libgo/configure -@@ -15546,7 +15546,9 @@ _ACEOF +@@ -15249,7 +15249,7 @@ $as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h + fi + + +-for ac_header in port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h ++for ac_header in fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h + do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` + ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +@@ -15546,7 +15546,14 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default" -+CFLAGS_hold=$CFLAGS -+CFLAGS="$CFLAGS -D_GNU_SOURCE" -+ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include " ++ ++CFLAGS_hold="$CFLAGS" ++CFLAGS="$OSCFLAGS $CFLAGS" ++ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" " ++#include ++#include ++ ++" if test "x$ac_cv_type_loff_t" = xyes; then : cat >>confdefs.h <<_ACEOF +@@ -15556,6 +15563,7 @@ _ACEOF + + fi + ++CFLAGS="$CFLAGS_hold" + + LIBS_hold="$LIBS" + LIBS="$LIBS -lm" diff --git a/libgo/configure.ac b/libgo/configure.ac -index 7e2b98ba67c..667feae3c03 100644 +index 7e2b98ba67c..274fcfc35c7 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac -@@ -601,7 +601,9 @@ AC_STRUCT_DIRENT_D_TYPE +@@ -579,7 +579,7 @@ AC_C_BIGENDIAN + + GCC_CHECK_UNWIND_GETIPINFO + +-AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h) ++AC_CHECK_HEADERS(fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h) + + AC_CHECK_HEADERS([netinet/icmp6.h], [], [], + [#include +@@ -601,7 +601,14 @@ AC_STRUCT_DIRENT_D_TYPE AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat) AC_TYPE_OFF_T -AC_CHECK_TYPES([loff_t]) -+CFLAGS_hold=$CFLAGS -+CFLAGS="$CFLAGS -D_GNU_SOURCE" # musl does not define loff_t without this -+AC_CHECK_TYPES([loff_t], [], [], [[#include ]]) ++ ++CFLAGS_hold="$CFLAGS" ++CFLAGS="$OSCFLAGS $CFLAGS" ++AC_CHECK_TYPES([loff_t], [], [], [[ ++#include ++#include ++]]) ++CFLAGS="$CFLAGS_hold" LIBS_hold="$LIBS" LIBS="$LIBS -lm" +diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go +index 96974bd3269..65eb1a745f7 100644 +--- a/libgo/go/syscall/libcall_linux.go ++++ b/libgo/go/syscall/libcall_linux.go +@@ -209,19 +209,20 @@ 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 *_libgo_loff_t_type, wfd int, woff *_libgo_loff_t_type, len int, flags int) (n int64, err error) ++//splice(rfd _C_int, roff *_libgo_loff_t_type, wfd _C_int, woff *_libgo_loff_t_type, 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 _libgo_loff_t_type ++ var plroff *_libgo_loff_t_type + if roff != nil { +- lroff = _loff_t(*roff) ++ lroff = _libgo_loff_t_type(*roff) + plroff = &lroff + } +- var lwoff _loff_t +- var plwoff *_loff_t ++ var lwoff _libgo_loff_t_type ++ var plwoff *_libgo_loff_t_type + if woff != nil { +- lwoff = _loff_t(*woff) ++ lwoff = _libgo_loff_t_type(*woff) + plwoff = &lwoff + } + n, err = splice(rfd, plroff, wfd, plwoff, len, flags) +diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh +index 0c52ea5d71a..5aa309155c3 100755 +--- 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 _libgo_off_t_type" >> ${OUT} + echo "type Mode_t _mode_t" >> ${OUT} + echo "type Pid_t _pid_t" >> ${OUT} + echo "type Uid_t _uid_t" >> ${OUT} diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c -index 8ce061e2f5f..b85add15a7b 100644 +index 336a5983750..fc0210992fa 100644 --- a/libgo/sysinfo.c +++ b/libgo/sysinfo.c -@@ -343,6 +343,27 @@ enum { - #endif +@@ -354,6 +354,18 @@ enum { }; + #endif -+// musl libc has both off64_t and loff_t. However, both of these types -+// are defined as CPP macros, not as C typedefs. Unfortunately, the GCC -+// -fdump-go-spec option, which is responsible for generating type -+// definitions for Go based on this file, only recognizes types defined -+// through typedefs. -+// -+// For this reason, we check here if either off64_t or loff_t are -+// defined as CPP macros and if so, we redefine them using a C typedef. -+#if defined(HAVE_OFF64_T) && defined(off64_t) -+typedef off64_t __musl_off64_t; -+#undef off64_t -+typedef __musl_off64_t off64_t; ++#if defined(HAVE_LOFF_T) ++// loff_t can be defined as a macro; for -fgo-dump-spec make sure we ++// see a typedef. ++typedef loff_t libgo_loff_t_type; +#endif + -+// See comment regarding musl libc above. -+#if defined(HAVE_LOFF_T) && defined(loff_t) -+typedef loff_t __musl_loff_t; -+#undef loff_t -+typedef __musl_loff_t loff_t; ++#if defined(HAVE_OFF64_T) ++typedef off64_t libgo_off_t_type; ++#else ++typedef off_t libgo_off_t_type; +#endif + - // SIOCGIFMTU can't be added in the above enum as it might - // be signed in some OSes. - #ifdef SIOCGIFMTU + // The following section introduces explicit references to types and + // constants of interest to support bootstrapping libgo using a + // compiler that doesn't support -fdump-go-spec (e.g., clang), via +@@ -534,7 +546,8 @@ SREF(timex); + // From sys/types.h + TREF(pid_t); + TREF(off_t); +-TREF(loff_t); ++TREF(libgo_loff_t_type); ++TREF(libgo_off_t_type); + TREF(size_t); + TREF(ssize_t); + TREF(mode_t); diff --git a/cross/gcc-armhf/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch b/cross/gcc-armhf/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch index 14836f27c..4867ab090 100644 --- a/cross/gcc-armhf/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch +++ b/cross/gcc-armhf/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch @@ -1,43 +1,22 @@ -From 76c13560bba3534bff335e5bb571a8b95d50d4ba Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 18:33:49 +0200 -Subject: [PATCH] gcc-go: Use int64 type as offset argument for mmap -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +From 4b6240d5301ce04b8bbc3e2152915cbc7da80584 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Wed, 28 Sep 2022 17:30:14 +0200 +Subject: [PATCH] libgo: use _off_t for mmap offset argument -Without this patch, Go run-time memory allocation fails on 32-bit architectures: +On glibc-based systems, off_t is a 32-bit type on 32-bit systems and a +64-bit type on 64-bit systems by default. However, on systems using musl +libc off_t is unconditionally a 64-bit type. As such, it is insufficient +to use a uintptr type for the mmap offset parameter. - fatal error: runtime: cannot allocate memory - runtime stack: - runtime.dopanic__m - :0 - runtime.throw - :0 - :0 - :0 - runtime.systemstack - :0 - runtime.addrRanges.init - :0 - runtime.pageAlloc.init - :0 - runtime.mheap.init - :0 - runtime.schedinit - :0 - :0 - :0 - -Taken from Adélie Linux [1]. - -[1]: https://git.adelielinux.org/adelie/packages/-/commit/63b5fb12c3d75e460799c672bbbdd5d29c3cc33c +Presently, the (incorrect) mmap declaration causes a libgo run-time +failure on 32-bit musl systems (fatal error: runtime: cannot allocate +memory). This commit fixes this run-time error. --- libgo/go/runtime/mem_gccgo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go -index fa3389d857e..57bed97c710 100644 +index fa3389d8..07bf325a 100644 --- a/libgo/go/runtime/mem_gccgo.go +++ b/libgo/go/runtime/mem_gccgo.go @@ -15,7 +15,7 @@ import ( @@ -45,16 +24,16 @@ index fa3389d857e..57bed97c710 100644 //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 ++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off _off_t) unsafe.Pointer //extern munmap func munmap(addr unsafe.Pointer, length uintptr) int32 -@@ -37,7 +37,7 @@ func init() { - } +@@ -38,7 +38,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) + func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) { +- p := sysMmap(addr, n, prot, flags, fd, off) ++ p := sysMmap(addr, n, prot, flags, fd, _off_t(off)) if uintptr(p) == _MAP_FAILED { return nil, errno() + } diff --git a/cross/gcc-armhf/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch b/cross/gcc-armhf/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch deleted file mode 100644 index 7ca25c3df..000000000 --- a/cross/gcc-armhf/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch +++ /dev/null @@ -1,55 +0,0 @@ -From cf41d579088e1c0b5c33c93657ad041e797b5905 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 2 Jan 2022 01:07:03 +0100 -Subject: [PATCH] libgo: include asm/ptrace.h for pt_regs definition on PowerPC -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Both glibc and musl libc declare pt_regs as an incomplete type. This -type has to be completed by inclusion of another header. On Linux, the -asm/ptrace.h header file provides this type definition. Without -including this header file, it is not possible to access the regs member -of the mcontext_t struct as done in libgo/runtime/go-signal.c. On glibc, -other headers (e.g. sys/user.h) include asm/ptrace.h but on musl -asm/ptrace.h is not included by other headers and thus the -aforementioned files do not compile without an explicit include of -asm/ptrace.h: - - libgo/runtime/go-signal.c: In function 'getSiginfo': - libgo/runtime/go-signal.c:227:63: error: invalid use of undefined type 'struct pt_regs' - 227 | ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip; - | - -Instead of including the asm/ptrace.h header conditionally on PowerPC -only it would alternatively also be possible to include it -unconditionally. - -See also: - -* https://git.musl-libc.org/cgit/musl/commit/?id=c2518a8efb6507f1b41c3b12e03b06f8f2317a1f -* https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d57cb31910ca5c200e4172276749a7f8bd17ae3c -* https://github.com/kaniini/libucontext/issues/36 - -Signed-off-by: Sören Tempel ---- - libgo/runtime/go-signal.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c -index 528d9b6d9fe..c67503f0a79 100644 ---- a/libgo/runtime/go-signal.c -+++ b/libgo/runtime/go-signal.c -@@ -10,6 +10,12 @@ - #include - #include - -+// On PowerPC, ucontext.h uses a pt_regs struct as an incomplete -+// type. This type must be completed by including asm/ptrace.h. -+#ifdef __PPC__ -+#include -+#endif -+ - #include "runtime.h" - - #ifndef SA_RESTART diff --git a/cross/gcc-armhf/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch b/cross/gcc-armhf/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch index cb1cd527a..5cebe745b 100644 --- a/cross/gcc-armhf/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch +++ b/cross/gcc-armhf/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch @@ -1,30 +1,71 @@ -From fbc8240ac15225ede8416a27c9978559b85d6877 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Mon, 21 Feb 2022 10:04:47 +0000 -Subject: [PATCH] go/gospec: forcibly disable -fsplit-stack support +From c86b726c048eddc1be320c0bf64a897658bee13d Mon Sep 17 00:00:00 2001 +From: Uros Bizjak +Date: Wed, 18 May 2022 20:03:26 +0200 +Subject: [PATCH] x86: Fix -fsplit-stack feature detection via + TARGET_CAN_SPLIT_STACK +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -for some reason, TARGET_CAN_SPLIT_STACK still gets defined on 32-bit x86, -so hackfix it for now +Since commit c163647ffbc9a20c8feb6e079dbecccfe016c82e -fsplit-stack +is only supported on glibc targets. However, this original commit +required some fixups. As part of the fixup, the changes to the +gnu-user-common.h and gnu.h were partially reverted in commit +60953a23d57b13a672f751bec0c6eefc059eb1ab thus causing TARGET_CAN_SPLIT_STACK +to be defined for non-glibc targets even though -fsplit-stack is +actually not supported and attempting to use it causes a runtime error. + +This causes gcc internal code, such as ./gcc/go/gospec.c to not +correctly detect that -fsplit-stack is not supported and thus causes +gccgo to fail compilation on non-glibc targets. + +This commit ensures that TARGET_CAN_SPLIT_STACK is only set if the +default libc is glibc. It is presently unclear to me if there is a +better way to detect glibc at pre-processor time. + +The proposed changes have been tested on x86 and x86_64 Alpine Linux +(which uses musl libc) and fix compilation of gccgo for this target. + +Signed-off-by: Sören Tempel + +gcc/ChangeLog: + + * config/i386/gnu-user-common.h (defined): Only define + TARGET_CAN_SPLIT_STACK for glibc targets. + * config/i386/gnu.h (defined): Ditto. --- - gcc/go/gospec.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) + gcc/config/i386/gnu-user-common.h | 5 +++-- + gcc/config/i386/gnu.h | 5 +++-- + 2 files changed, 6 insertions(+), 4 deletions(-) -diff --git a/gcc/go/gospec.cc b/gcc/go/gospec.cc -index df92b62d8e6..cf168beb4cf 100644 ---- a/gcc/go/gospec.cc -+++ b/gcc/go/gospec.cc -@@ -269,11 +269,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, - /* Copy the 0th argument, i.e., the name of the program itself. */ - new_decoded_options[j++] = decoded_options[i++]; +diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h +index 23b54c5be52..cab9be2bfb7 100644 +--- a/gcc/config/i386/gnu-user-common.h ++++ b/gcc/config/i386/gnu-user-common.h +@@ -66,7 +66,8 @@ along with GCC; see the file COPYING3. If not see + #define STACK_CHECK_STATIC_BUILTIN 1 --#ifdef TARGET_CAN_SPLIT_STACK -+ /* Hackfix: we never support split stack on Alpine GCC */ -+#if 0 - supports_split_stack = 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 ++ assembler has full support for the CFI directives. Also ++ we only support -fsplit-stack on glibc targets. */ ++#if (DEFAULT_LIBC == LIBC_GLIBC) && HAVE_GAS_CFI_PERSONALITY_DIRECTIVE + #define TARGET_CAN_SPLIT_STACK #endif +diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h +index 401e60c9a02..fb8d69a97d8 100644 +--- a/gcc/config/i386/gnu.h ++++ b/gcc/config/i386/gnu.h +@@ -41,8 +41,9 @@ along with GCC. If not, see . + #define TARGET_THREAD_SSP_OFFSET 0x14 --#ifdef TARGET_CAN_SPLIT_STACK_64BIT -+#if 0 - if (is_m64) - supports_split_stack = 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 ++ assembler has full support for the CFI directives. Also ++ we only support -fsplit-stack on glibc targets. */ ++#if (DEFAULT_LIBC == LIBC_GLIBC) && HAVE_GAS_CFI_PERSONALITY_DIRECTIVE + #define TARGET_CAN_SPLIT_STACK #endif + /* We steal the last transactional memory word. */ diff --git a/cross/gcc-armhf/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch b/cross/gcc-armhf/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch index 0ce960966..db38df3b0 100644 --- a/cross/gcc-armhf/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch +++ b/cross/gcc-armhf/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch @@ -1,31 +1,41 @@ -From 38270192ea355d8035d9f1b5fe50e36ca3fa3708 Mon Sep 17 00:00:00 2001 -From: Natanael Copa -Date: Thu, 30 Jun 2022 17:04:23 +0000 -Subject: [PATCH] gcc-go: fix build error with SYS_SECCOMP +From 548720bca6bff21ebc9aba22249d9ce45bbd90c7 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Wed, 29 Jun 2022 15:32:04 -0700 +Subject: [PATCH] libgo: handle stat st_atim32 field and SYS_SECCOMP +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -fix the build error: - sysinfo.go:6606:7: error: redefinition of 'SYS_SECCOMP' - 6606 | const SYS_SECCOMP = _SYS_SECCOMP - | ^ - sysinfo.go:6600:7: note: previous definition of 'SYS_SECCOMP' was here - 6600 | const SYS_SECCOMP = _SYS_seccomp - | ^ +Patches for musl support, from Sören Tempel. -Upstream report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105225 +Fixes https://gcc.gnu.org/PR105225 + +Change-Id: If396877d4a4c7d27962226d7a6e3bb91b1344413 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415294 +Reviewed-by: Than McIntosh +Reviewed-by: Ian Lance Taylor --- - libgo/mksysinfo.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/mksysinfo.sh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh -index 6fef104cc1c..06289a43bdf 100755 +index 5aa30915..ea1fa17d 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh -@@ -126,7 +126,7 @@ if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then - fi +@@ -127,6 +127,7 @@ fi # The syscall numbers. We force the names to upper case. --grep '^const _SYS_' gen-sysinfo.go | \ -+grep '^const _SYS_[a-z]' gen-sysinfo.go | \ + grep '^const _SYS_' gen-sysinfo.go | \ ++ grep -v '^const _SYS_SECCOMP = ' | \ sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \ while read sys; do sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` +@@ -506,7 +507,7 @@ fi + + # For historical reasons Go uses the suffix "timespec" instead of "tim" for + # stat_t's time fields on NetBSD. +-st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' ++st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' + if test "${GOOS}" = "netbsd"; then + st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' + fi diff --git a/cross/gcc-armhf/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch b/cross/gcc-armhf/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch deleted file mode 100644 index 09504f1e9..000000000 --- a/cross/gcc-armhf/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 9cef407678b40c20ecc39850c7e43346ad92a60b Mon Sep 17 00:00:00 2001 -From: Sergei Trofimovich -Date: Mon, 27 Jun 2022 03:31:45 +0100 -Subject: [PATCH] c++: avoid poisoning on musl [PR106102] - -On musl uses calloc() (via ). includes -it indirectly and exposes use of poisoned calloc() when module code -is built: - - /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc - In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, - from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35, - .... - from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77, - from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24, - from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25, - from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23, - from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32: - /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" - 84 | void *calloc(size_t, size_t); - | ^ - /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" - 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) - | ^ - -gcc/cp/ - - PR c++/106102 - * mapper-client.cc: Include via "system.h". - * mapper-resolver.cc: Ditto. - * module.cc: Ditto. - -libcc1/ - - PR c++/106102 - * libcc1plugin.cc: Include via "system.h". - * libcp1plugin.cc: Ditto. - -(cherry picked from commit 3b21c21f3f5726823e19728fdd1571a14aae0fb3) ---- - gcc/cp/mapper-client.cc | 1 + - gcc/cp/mapper-resolver.cc | 1 + - gcc/cp/module.cc | 1 + - libcc1/libcc1plugin.cc | 1 + - libcc1/libcp1plugin.cc | 1 + - 5 files changed, 5 insertions(+) - -diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc -index 8603a886a09..fe9544b5ba4 100644 ---- a/gcc/cp/mapper-client.cc -+++ b/gcc/cp/mapper-client.cc -@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see - #define INCLUDE_STRING - #define INCLUDE_VECTOR - #define INCLUDE_MAP -+#define INCLUDE_MEMORY - #include "system.h" - - #include "line-map.h" -diff --git a/gcc/cp/mapper-resolver.cc b/gcc/cp/mapper-resolver.cc -index e3d29fb5ada..e70d1b4ae2c 100644 ---- a/gcc/cp/mapper-resolver.cc -+++ b/gcc/cp/mapper-resolver.cc -@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see - #define INCLUDE_VECTOR - #define INCLUDE_ALGORITHM - #define INCLUDE_MAP -+#define INCLUDE_MEMORY - #include "system.h" - - // We don't want or need to be aware of networking -diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc -index cebf9c35c1d..5c5d02bb523 100644 ---- a/gcc/cp/module.cc -+++ b/gcc/cp/module.cc -@@ -202,6 +202,7 @@ Classes used: - - #define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available. */ - #include "config.h" -+#define INCLUDE_MEMORY - #define INCLUDE_STRING - #define INCLUDE_VECTOR - #include "system.h" -diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc -index 12ab5a57c8d..bdd0bdabe77 100644 ---- a/libcc1/libcc1plugin.cc -+++ b/libcc1/libcc1plugin.cc -@@ -31,6 +31,7 @@ - #undef PACKAGE_TARNAME - #undef PACKAGE_VERSION - -+#define INCLUDE_MEMORY - #include "gcc-plugin.h" - #include "system.h" - #include "coretypes.h" -diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc -index 83dab7f58b1..e2d5039a0a1 100644 ---- a/libcc1/libcp1plugin.cc -+++ b/libcc1/libcp1plugin.cc -@@ -32,6 +32,7 @@ - #undef PACKAGE_TARNAME - #undef PACKAGE_VERSION - -+#define INCLUDE_MEMORY - #include "gcc-plugin.h" - #include "system.h" - #include "coretypes.h" diff --git a/cross/gcc-armhf/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch b/cross/gcc-armhf/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch deleted file mode 100644 index 4cc457f53..000000000 --- a/cross/gcc-armhf/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch +++ /dev/null @@ -1,117 +0,0 @@ -From f982c816d8f52a65231544b838160484b5ed4c71 Mon Sep 17 00:00:00 2001 -From: Sergei Trofimovich -Date: Mon, 27 Jun 2022 14:44:48 +0100 -Subject: [PATCH] jit: avoid calloc() poisoning on musl [PR106102] - -On musl uses calloc() (via ). jit/ includes -it directly and exposes use of poisoned calloc(): - - /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/jit/jit-playback.cc - make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1 - make[3]: *** Waiting for unfinished jobs.... - In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, - from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44: - /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" - 84 | void *calloc(size_t, size_t); - | ^ - /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" - 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) - | ^ - -The change moves inclusion to "system.h" under new -INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit. - -gcc/ - - PR c++/106102 - * system.h: Introduce INCLUDE_PTHREAD_H macros to include . - -gcc/jit/ - - PR c++/106102 - * jit-playback.cc: Include via "system.h" to avoid calloc() - poisoning. - * jit-recording.cc: Ditto. - * libgccjit.cc: Ditto. - -(cherry picked from commit 49d508065bdd36fb1a9b6aad9666b1edb5e06474) ---- - gcc/jit/jit-playback.cc | 3 +-- - gcc/jit/jit-recording.cc | 2 +- - gcc/jit/libgccjit.cc | 2 +- - gcc/system.h | 4 ++++ - 4 files changed, 7 insertions(+), 4 deletions(-) - -diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc -index 6be6bdf8dea..79714132b91 100644 ---- a/gcc/jit/jit-playback.cc -+++ b/gcc/jit/jit-playback.cc -@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "target.h" -@@ -41,8 +42,6 @@ along with GCC; see the file COPYING3. If not see - #include "diagnostic.h" - #include "stmt.h" - --#include -- - #include "jit-playback.h" - #include "jit-result.h" - #include "jit-builtins.h" -diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc -index a31720f043e..5556b9c4905 100644 ---- a/gcc/jit/jit-recording.cc -+++ b/gcc/jit/jit-recording.cc -@@ -19,13 +19,13 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "tm.h" - #include "pretty-print.h" - #include "toplev.h" - --#include - - #include "jit-builtins.h" - #include "jit-recording.h" -diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc -index cc6486c9cad..4c991e5436b 100644 ---- a/gcc/jit/libgccjit.cc -+++ b/gcc/jit/libgccjit.cc -@@ -19,12 +19,12 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "timevar.h" - #include "typed-splay-tree.h" - #include "cppbuiltin.h" --#include - - #include "libgccjit.h" - #include "jit-recording.h" -diff --git a/gcc/system.h b/gcc/system.h -index c5562cc49a3..e10c34f70ec 100644 ---- a/gcc/system.h -+++ b/gcc/system.h -@@ -750,6 +750,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); - #endif - #endif - -+#ifdef INCLUDE_PTHREAD_H -+#include -+#endif -+ - #ifdef INCLUDE_ISL - #ifdef HAVE_isl - #include diff --git a/cross/gcc-armhf/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch b/cross/gcc-armhf/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch index 4de9ea2b7..0f949be3a 100644 --- a/cross/gcc-armhf/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch +++ b/cross/gcc-armhf/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch @@ -1,28 +1,108 @@ -From d54419ddcc14f52517017147201560da5353c436 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 17 Jul 2022 02:52:13 +0200 -Subject: [PATCH] libgo: adjust name of union in sigevent struct +From 8f1a91aeff400d572857895b7f5e863ec5a4d93e Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Mon, 26 Sep 2022 15:03:53 -0400 +Subject: [PATCH] runtime: portable access to sigev_notify_thread_id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -The union in struct sigevent is named __sev_fields on musl but -_sigev_un on glibc. Not sure what this code actually does and -how this works if the union layout is different… +Previously, libgo relied on the _sigev_un implementation-specific +field in struct sigevent, which is only available on glibc. +This patch uses the sigev_notify_thread_id macro instead which is +mandated by timer_create(2). In theory, this should work with any libc +implementation for Linux. Unfortunately, there is an open glibc bug +as glibc does not define this macro. For this reason, a glibc-specific +workaround is required. Other libcs (such as musl) define the macro +and don't require the workaround. + +See https://sourceware.org/bugzilla/show_bug.cgi?id=27417 + +This makes libgo compatible with musl libc. + +Based on patch by Sören Tempel. + +Change-Id: I0924a53d5212730ebc395ecf9199f85967be8cc6 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/434755 +Reviewed-by: Cherry Mui +Reviewed-by: Than McIntosh --- - libgo/go/runtime/os_linux.go | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/go/runtime/os_linux.go | 12 +++++++++++- + libgo/runtime/go-signal.c | 18 ++++++++++++++++++ + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libgo/go/runtime/os_linux.go b/libgo/go/runtime/os_linux.go -index 96fb178870e..a75a2dd703f 100644 +index 96fb1788..2b2d827c 100644 --- a/libgo/go/runtime/os_linux.go +++ b/libgo/go/runtime/os_linux.go -@@ -365,7 +365,7 @@ func setThreadCPUProfiler(hz int32) { +@@ -22,6 +22,12 @@ type mOS struct { + profileTimerValid uint32 + } + ++// setSigeventTID is written in C to set the sigev_notify_thread_id ++// field of a sigevent struct. ++// ++//go:noescape ++func setSigeventTID(*_sigevent, int32) ++ + func getProcID() uint64 { + return uint64(gettid()) + } +@@ -52,9 +58,12 @@ const ( + ) + + // Atomically, ++// + // if(*addr == val) sleep ++// + // Might be woken up spuriously; that's allowed. + // Don't sleep longer than ns; ns < 0 means forever. ++// + //go:nosplit + func futexsleep(addr *uint32, val uint32, ns int64) { + // Some Linux kernels have a bug where futex of +@@ -73,6 +82,7 @@ func futexsleep(addr *uint32, val uint32, ns int64) { + } + + // If any procs are sleeping on addr, wake up at most cnt. ++// + //go:nosplit + func futexwakeup(addr *uint32, cnt uint32) { + ret := futex(unsafe.Pointer(addr), _FUTEX_WAKE_PRIVATE, cnt, nil, nil, 0) +@@ -365,7 +375,7 @@ func setThreadCPUProfiler(hz int32) { var sevp _sigevent sevp.sigev_notify = _SIGEV_THREAD_ID sevp.sigev_signo = _SIGPROF - *((*int32)(unsafe.Pointer(&sevp._sigev_un))) = int32(mp.procid) -+ *((*int32)(unsafe.Pointer(&sevp.__sev_fields))) = int32(mp.procid) ++ setSigeventTID(&sevp, int32(mp.procid)) ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, &sevp, &timerid) if ret != 0 { // If we cannot create a timer for this M, leave profileTimerValid false +diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c +index 528d9b6d..aa1b6305 100644 +--- a/libgo/runtime/go-signal.c ++++ b/libgo/runtime/go-signal.c +@@ -183,6 +183,24 @@ setSigactionHandler(struct sigaction* sa, uintptr handler) + sa->sa_sigaction = (void*)(handler); + } + ++#ifdef __linux__ ++ ++// Workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=27417 ++#ifndef sigev_notify_thread_id ++ #define sigev_notify_thread_id _sigev_un._tid ++#endif ++ ++void setSigeventTID(struct sigevent*, int32_t) ++ __asm__ (GOSYM_PREFIX "runtime.setSigeventTID"); ++ ++void ++setSigeventTID(struct sigevent *sev, int32_t v) ++{ ++ sev->sigev_notify_thread_id = v; ++} ++ ++#endif // defined(__linux__) ++ + // C code to fetch values from the siginfo_t and ucontext_t pointers + // passed to a signal handler. + diff --git a/cross/gcc-armhf/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch b/cross/gcc-armhf/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch index 10f82014a..f2f019119 100644 --- a/cross/gcc-armhf/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch +++ b/cross/gcc-armhf/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch @@ -1,36 +1,36 @@ -From 3825632cf4007ac93d8e44705a6da042c496318b Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Mon, 18 Jul 2022 20:34:39 +0200 -Subject: [PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl - arches +From d53e8a0e94e34dc609e34dd5e404debda2640cfb Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Sat, 30 Jul 2022 07:29:28 -0700 +Subject: [PATCH] libgo: use SYS_timer_settime32 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -On 32-bit systems musl only defines SYS_timer_settime32 not -SYS_timer_settime. This causes the following compilation error: +Musl defines SYS_timer_settime32, not SYS_timer_settime, on 32-bit systems. - os_linux.go:251:30: error: reference to undefined name '_SYS_timer_settime' - 251 | return int32(syscall(_SYS_timer_settime, uintptr(timerid), uintptr(flags), uintptr(unsafe.Pointer(new)), uintptr(unsafe.Pointer(old)), 0, 0)) - | ^ +Based on patch by Sören Tempel. -This commit fixes this error by defining SYS_timer_settime to -SYS_timer_settime32 if the latter is defined. +Change-Id: I1f3485028d132ceca1aba595325af24b4d72b894 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/420222 +Reviewed-by: Ian Lance Taylor +Reviewed-by: Cherry Mui --- - libgo/sysinfo.c | 6 ++++++ - 1 file changed, 6 insertions(+) + libgo/sysinfo.c | 5 +++++ + 1 file changed, 5 insertions(+) diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c -index b85add15a7b..ff04706a993 100644 +index fc021099..180f5c31 100644 --- a/libgo/sysinfo.c +++ b/libgo/sysinfo.c -@@ -343,6 +343,12 @@ enum { - #endif +@@ -354,6 +354,11 @@ enum { }; + #endif -+// musl libc does not have SYS_timer_settime on 32-bit platforms -+// but defines SYS_timer_settime32 instead, alias accordingly. -+#ifdef SYS_timer_settime32 ++#if !defined(SYS_timer_settime) && defined(SYS_timer_settime32) ++// musl defines SYS_timer_settim32 on 32-bit systems. +#define SYS_timer_settime SYS_timer_settime32 +#endif + - // musl libc has both off64_t and loff_t. However, both of these types - // are defined as CPP macros, not as C typedefs. Unfortunately, the GCC - // -fdump-go-spec option, which is responsible for generating type + #if defined(HAVE_LOFF_T) + // loff_t can be defined as a macro; for -fgo-dump-spec make sure we + // see a typedef. diff --git a/cross/gcc-armhf/0053-libgo-make-match.sh-POSIX-shell-compatible.patch b/cross/gcc-armhf/0053-libgo-make-match.sh-POSIX-shell-compatible.patch index cbfaca9aa..8758cb837 100644 --- a/cross/gcc-armhf/0053-libgo-make-match.sh-POSIX-shell-compatible.patch +++ b/cross/gcc-armhf/0053-libgo-make-match.sh-POSIX-shell-compatible.patch @@ -1,20 +1,29 @@ -From 75a430f66760802bf1ac5afcd716613e3cf8c77d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Tue, 19 Jul 2022 07:15:25 +0200 -Subject: [PATCH] libgo: make match.sh POSIX-shell compatible +From a62f20ae78ddd41be682dde8cab075ca4f5dbb2a Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Fri, 22 Jul 2022 11:38:20 -0700 +Subject: [PATCH] libgo: use POSIX shell arithmetic expansion +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -The `(( expression ))` syntax is a Bash extension. However, the -arithmetic expressions used by the gobuild() function can also -be expressed using Arithmetic POSIX Expansion with `$(( expression ))`. -Contrary to the Bash expression, the Arithmetic Expansion doesn't set -the return value if the expression is non-zero but instead just prints -the expression result. Hence, the expression also needs to be negated. +Avoid bash-specific ((expression)) syntax. As the bash syntax +converts a non-zero value to a zero status (and a zero value to a 1 +status), and POSIX arithmetic expansion does not, we have to negate +the result. + +Based on patch by Sören Tempel. + +Change-Id: I4c64fa15de3994a1a5c7c5ec0de6a82ddd858917 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/419154 +Reviewed-by: Than McIntosh +Reviewed-by: Ian Lance Taylor --- - libgo/match.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/match.sh | 2 +- + libgo/testsuite/gotest | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libgo/match.sh b/libgo/match.sh -index 7ed587ff794..b355d47429a 100755 +index 7ed587ff..e5ed98de 100755 --- a/libgo/match.sh +++ b/libgo/match.sh @@ -111,7 +111,7 @@ gobuild() { @@ -22,7 +31,20 @@ index 7ed587ff794..b355d47429a 100755 line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") fi - (($line)) -+ return $((! ( line ))) ++ return $((!($line))) } matched= +diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest +index 04e4267f..0a0a7e14 100755 +--- a/libgo/testsuite/gotest ++++ b/libgo/testsuite/gotest +@@ -302,7 +302,7 @@ gobuild() { + if test "$goarch" != "386"; then + line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") + fi +- (($line)) ++ return $((!($line))) + } + + case "x$gofiles" in diff --git a/cross/gcc-armhf/APKBUILD b/cross/gcc-armhf/APKBUILD index a72f39846..2eaf84025 100644 --- a/cross/gcc-armhf/APKBUILD +++ b/cross/gcc-armhf/APKBUILD @@ -24,14 +24,15 @@ CBUILDROOT="/" _cross_configure="--disable-bootstrap --with-sysroot=/usr/$CTARGET" pkgname=gcc-armhf -_pkgbase=12.1.1 -pkgver=12.1.1_git20220630 +_pkgbase=12.2.1 # must match gcc/BASE-VER +_pkgsnap=20220924 +pkgver=${_pkgbase}_git${_pkgsnap} [ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2" [ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross="" [ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" pkgname=gcc-armhf -pkgrel=6 +pkgrel=1 pkgdesc="Stage2 cross-compiler for armhf" url="https://gcc.gnu.org" arch="x86_64" @@ -204,11 +205,14 @@ makedepends="$makedepends_build $makedepends_host" # when using upstream releases, use this URI template # https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz # -# right now, we are using a git snapshot. +# right now, we are using a git snapshot. snapshots are taken from gcc.gnu.org/pub/gcc/snapshots. +# However, since they are periodically deleted from the GCC mirrors the utilized snapshots are +# mirrored on dev.alpinelinux.org. Please ensure that the snapshot Git commit (as stated in the +# README) matches the base commit on the version-specific branch in the Git repository below. # # PLEASE submit all patches to gcc to https://gitlab.alpinelinux.org/kaniini/alpine-gcc-patches, # so that they can be properly tracked and easily rebased if needed. -source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz +source="https://dev.alpinelinux.org/archive/gcc/${_pkgbase%%.*}-${_pkgsnap}/gcc-${_pkgbase%%.*}-${_pkgsnap}.tar.xz 0001-posix_memalign.patch 0002-gcc-poison-system-directories.patch 0003-specs-turn-on-Wl-z-now-by-default.patch @@ -238,23 +242,17 @@ source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz 0027-always-build-libgcc_eh.a.patch 0028-ada-libgnarl-compatibility-for-musl.patch 0029-ada-musl-support-fixes.patch - 0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch - 0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch - 0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch 0033-gcc-go-link-to-libucontext.patch 0034-Use-generic-errstr.go-implementation-on-musl.patch 0035-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch 0036-configure-fix-detection-of-atomic-builtins-in-libato.patch 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch - 0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch 0043-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch 0044-gdc-unconditionally-link-libgphobos-against-libucont.patch 0045-druntime-link-against-libucontext-on-all-platforms.patch - 0046-c-avoid-memory-poisoning-on-musl-PR106102.patch - 0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch 0050-libphobos-don-t-define-__mode_t-twice-on-musl-target.patch 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch @@ -263,7 +261,7 @@ source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz " # we build out-of-tree -_gccdir="$srcdir"/gcc-$pkgver +_gccdir="$srcdir"/gcc-${_pkgbase%%.*}-${_pkgsnap} _gcclibdir="/usr/lib/gcc/$CTARGET/${_pkgbase:-$pkgver}" _gcclibexec="/usr/libexec/gcc/$CTARGET/${_pkgbase:-$pkgver}" @@ -763,7 +761,7 @@ gnat() { } sha512sums=" -43de66dfed7b5351bb543f7f2e8253e63d1e544e5bd293829e8ec7bffe60925cabcf8f6972fe8825100b1f1d7839e41d9314ec650c1320150c09317e2be24aa9 gcc-12.1.1_git20220630.tar.xz +ba4d9e73d108088da26fbefe18d9b245b76771ffe752c2b4b31bdf38a2d0b638fbc115c377526c27311d4d7ffd4e0d236a5af5016bd364ccaa11a4989d1401e8 gcc-12-20220924.tar.xz 41cbb4d69218006cf9e0cdb6c86212ef451f8decd52a50a7dbb4d34726009da7a4e0261c852b46cb584db253a4bae2f31dc485c506cb545e64a7d26e0ba6c2b6 0001-posix_memalign.patch 531155055cda7f119bcac6479bcae73af9201cd596af9cf1616850bbcf4393b91c5de9f2fbbc1cde6e158fb4df7237b033146f662dff5fa0ea12151cc514adb8 0002-gcc-poison-system-directories.patch c1275d77b5269386a2ec683933570810f5a2ba1208c161ed887797eb9aee3cb82ef08a8964635902614e6a6e83f3065ba0801c9355d85dd8d60cb1fa20bdf687 0003-specs-turn-on-Wl-z-now-by-default.patch @@ -793,26 +791,20 @@ b40d7e4712c035674c993bbb55475290ec14523b3f0fd05493514bac4e9adaa6641faf815fc40ffc 674360ce2ee9f704d0632cc98756f9fe8dd8ca30064fb9d3423b437f7e679c1c51e765b15e535dcb278cd2769583690acb3395b91e4fd5f6f4e3b97879fcc313 0027-always-build-libgcc_eh.a.patch f060687adcd5297124e4000f1ba1e3fd5d7d124da04d948cbd0d4a6c69a90a2b29a4a0dbbe13a83ab6950724f434de012b681bdbcdf53c0100b40fe3d00f2f2f 0028-ada-libgnarl-compatibility-for-musl.patch 5160bae68e20a1966c1f6d655ee98af759e9b9ee842718ae6007d467b418e1cf3b307528a0841477b5259671ce868521b06c0f2e947b7b8f3a398c53dd978252 0029-ada-musl-support-fixes.patch -74c70a752ff24f231b45c69ca1d86ebf261bca643334cb6ba518ac204986ccd7fa84f4df4fdb38bbc0bb61832514b0100b2d2ba069fb1842929369d073220f24 0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch -9786711f308d5f93f2f5a45862f340d4741e1d8aef116d696b85a6debb6149d3772b0cfab4d9ef8782172b102664d9acdd27021af433b504c5918f379b1dd978 0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch -4ffd2f279fbcf5abb1ac8cc6435204e48a776e7ef3742f2120eef1a1bdca2d0a01d30c481fd1495926c9166daaf127f9013fda0efefe3ed7bf6e660915cc1b49 0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch -0ad15e78806031cef68da6577f7ce9be178533b3768ca42fff7f12816d61fa745acc77be2e047ac1c5bfdbc04e999202e5cefd04042bca798177197236b79954 0033-gcc-go-link-to-libucontext.patch +3c04b26554a78096296ca9542c77a91219bd26044dd2cb2006db4c1944889a97c215900b3828ba7e8c675162406db543605a815bdfbd915bf810663b1b253bdd 0033-gcc-go-link-to-libucontext.patch 699dc3641099da6136dd3689f06c6553c03b3a85acf83a3fce1beb5425065b3e378535ca9e9100a120fdbafc34871d61c063fd5328a49cd87a15a989ed51706d 0034-Use-generic-errstr.go-implementation-on-musl.patch d9ba710f770e053c8f212e821817c188091a829658050b9ab5906388553ec60fec37943ea43c270e92a9014902949f3c98fc4639032d92b8145b375bb29e193e 0035-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch ab90d8fdd977d6cd3da096a1c76d77be3e89a020b2127247771711a32eb608cceed21834ef488ab4b69bb0f408b098fdfb61630819e3d1a1e57d5af67800ee74 0036-configure-fix-detection-of-atomic-builtins-in-libato.patch -7b356e11f66877bee864e2b1f81ae4be6c6c586040afb3ac220ff902f694efd60dcb4647cc7a37890c91dd539535b9992d463b785d3158205dbf9369b17c8ab7 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch -5905e4309670cfa4a5883aa21f744391ee2107731795817e0ffcccfaa22b0c21df883038c86362b091e7b35730aa4de6dce827c908ea398a161add851df5c31e 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch -570e084d223671fa29cb460b1b536a216920a7bcdfcdad21fe8cd7610e13f6942c1b1dd34ec861e9e3d830b9fe1f0e02e305c50c54d83aaf20526be09ca2256c 0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch -a8b53c7d6e0d6d19c655844cab074f49b8f14c54a7af920b5792303f73713fdc69b723a0a6041548d227dfaa98ef63641460ea355487619eb29f9fec4a1e301b 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch -15c93c9f2d68b19d00c6e82748e5f14470a120a3996f64d1ce91f17a65a5334cca478b4a6eba7d2d0a1d6d22206407ac3b1b5255987cc1144f5177bbb68153c8 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch +8bc6823f0b3c66f7b73d7ddb64ffa6930463285c2e9a14a2bc1882bcc4271144eaa1107d713294699caf9481648163cbf43921a2b8e4ac0d55c78a804bae8a3d 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch +e9699f4721778869eb3a8fef2c679208ef5b98584892f30b0e1cb5dc1669f8158198d7792659b1b56c381baf62247d21990dcced9178547affd5d6bfb2d12548 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch +d6dc1bfb881a313d167aaa5658790b0f55eea4336c408cfc6613dd5783440dafd0d37c43031a5f3e69be40f632e38371cd4fb6e5f0494ac4ea4d7d5025d2ae02 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch +684c6a6d52512b973429b6e709966439ac1e174f9e79a33d4a638b452245b457b34752b4b4034ba983f6a712f86522e7adf715bab00a6603f64a12139c5b1e39 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch 25014dfa99d96ee70ce0ad22e9f7974f0a51cc50b3b9c2db49df50774c8cd29e497ceed120486bee50be83bfb07f2009ed310eb9b0543f2795bd7359b87eadd2 0043-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch 75fd83ac05ab0a08d5f48547b08810f9934209bc78b5db59d65f33887b382af7ec24d8a29d40f86325c05af40c1ae1ec6466c839f646af90afc895a13073d07b 0044-gdc-unconditionally-link-libgphobos-against-libucont.patch 13e047153076d6e1fc40c9f5b6bfe5699c0e5460248f3d2b35ae36677cb960525af7b0b025997e5000a8492cec5e77a86828d66b4058c0d7f89fde0ab3890142 0045-druntime-link-against-libucontext-on-all-platforms.patch -ba87d4b4433e5f018071ce933ae523c62334574be2e46881a8945c9dc7ecc0fadfed3aaf837f13f93fd4c0d6d33feb24cb67c77d9c0adb40b62637991fed4374 0046-c-avoid-memory-poisoning-on-musl-PR106102.patch -03e7c0caf59ee7c7d13a840178befb378b734f18a5c36ec4bbfad3f78253f0afab80864ea0905b58454178c8c31b2441622dd38668dd54e6550e30e6249e882b 0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch -be7688a44707991c31337bff24245394aa385e7b4ba151f18e21e734a4bbb151348458f413965e5cba50185ab8e0aba8b793eba04c0802dc563b148ed490f26d 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch +c33ca2553642c2dbd1c65cd97046548f08775785a3db06d761e3bbe61398c37bc382fe132c0c3fa2101dfd4eea2a6d48bf4fae899a0ddb811c81abd7be35c122 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch 179cd15d629884a66e954fd76066675efa594686b970facbb12ad50769e5d70b5530d7f61e77120e26d1c3dfc701cfc5295f341f635db998df73c41bc8e62172 0050-libphobos-don-t-define-__mode_t-twice-on-musl-target.patch -d7592589cbf982f4518cb07572f96131278c7d2fd8fbbcd7fcb47f6628529ae9a5fc22b2dfe929be06845d137e1c5d2efeb6f63b1c2fb9c36cd6bdb97d41c65f 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch +c82d7c8d340a76df3d796565a79b0ccc04ddffef39927620e1f3719bf2dc1db101ba13aef24b46c5bc95b7bf1e31c8bda4ab0936ba4c9c5e5047ba08826c982c 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch eb403d8ea665fd5dc2c11faf43b055e6a3bf480a397ceee3e0ca1e38ec7d2392315f2694ed9a34ffbc99e464f2873fbbf91be8646ea4dea5d3636e3ea22fefa0 0052-libgnat-time_t-is-always-64-bit-on-musl-libc.patch -29c4fe28e5bf232e01b44106b2f8a3e50b5e00fc4302a69d3f5f90695e43ef07721a917b51d49dc40ae0543d8d97d432cb475834059c92176b73d326af9496e3 0053-libgo-make-match.sh-POSIX-shell-compatible.patch +22fb6edf1ed0387e2b93839ffe6e82a7fee420950af90e91199c3488d966702fdeb1a3396d22be0c73a4051525da9349c93d070a0d83b724c83f2b268da6483f 0053-libgo-make-match.sh-POSIX-shell-compatible.patch " diff --git a/cross/gcc-armv7/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch b/cross/gcc-armv7/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch deleted file mode 100644 index c032ba7e1..000000000 --- a/cross/gcc-armv7/0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 7feb681596c4cfa34c769505058aa5bdf31c5131 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 17:59:45 +0200 -Subject: [PATCH] gcc-go: Fix handling of signal 34 on musl -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Taken from Adélie Linux. ---- - libgo/mksigtab.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/mksigtab.sh b/libgo/mksigtab.sh -index bea8739957e..3876002efab 100644 ---- a/libgo/mksigtab.sh -+++ b/libgo/mksigtab.sh -@@ -86,7 +86,7 @@ checksig _SIGPWR '{_SigNotify, "SIGPWR: power failure restart"}' - checksig _SIGEMT '{_SigThrow, "SIGEMT: emulate instruction executed"}' - checksig _SIGINFO '{_SigNotify, "SIGINFO: status request from keyboard"}' - checksig _SIGTHR '{_SigNotify, "SIGTHR: reserved"}' --checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' -+#checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' - checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}' - checksig _SIGLWP '{_SigNotify, "SIGLWP: reserved signal no longer used by"}' - checksig _SIGFREEZE '{_SigNotify, "SIGFREEZE: special signal used by CPR"}' diff --git a/cross/gcc-armv7/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch b/cross/gcc-armv7/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch deleted file mode 100644 index 4f6967977..000000000 --- a/cross/gcc-armv7/0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch +++ /dev/null @@ -1,24 +0,0 @@ -From b6885cf73989161b1b6893b5ae0dafed006d5f13 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Thu, 25 Nov 2021 01:47:03 +0000 -Subject: [PATCH] There are more than one st_{a,m,c}tim fields in struct stat - on time64 machines. - -Run the Go-isation on all of them. ---- - libgo/mksysinfo.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh -index 0c52ea5d71a..6fef104cc1c 100755 ---- a/libgo/mksysinfo.sh -+++ b/libgo/mksysinfo.sh -@@ -510,7 +510,7 @@ fi - - # For historical reasons Go uses the suffix "timespec" instead of "tim" for - # stat_t's time fields on NetBSD. --st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' -+st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' - if test "${GOOS}" = "netbsd"; then - st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' - fi diff --git a/cross/gcc-armv7/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch b/cross/gcc-armv7/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch deleted file mode 100644 index d85d2dbef..000000000 --- a/cross/gcc-armv7/0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch +++ /dev/null @@ -1,24 +0,0 @@ -From c7a22e42ae403154a0c0158495b04b0205102041 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 30 Aug 2020 19:27:51 +0200 -Subject: [PATCH] gcc-go: undef SETCONTEXT_CLOBBERS_TLS in proc.c - ---- - libgo/runtime/proc.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c -index 3a30748d329..a987678fa84 100644 ---- a/libgo/runtime/proc.c -+++ b/libgo/runtime/proc.c -@@ -66,6 +66,10 @@ static void gscanstack(G*); - - __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); - -+/* libucontext does not seem to support tlsbase, undef the macro -+ * here to make sure we define initcontext and fixcontext as dummies. */ -+#undef SETCONTEXT_CLOBBERS_TLS -+ - #ifndef SETCONTEXT_CLOBBERS_TLS - - static inline void diff --git a/cross/gcc-armv7/0033-gcc-go-link-to-libucontext.patch b/cross/gcc-armv7/0033-gcc-go-link-to-libucontext.patch index 86c806d12..802295d3a 100644 --- a/cross/gcc-armv7/0033-gcc-go-link-to-libucontext.patch +++ b/cross/gcc-armv7/0033-gcc-go-link-to-libucontext.patch @@ -1,17 +1,22 @@ -From ef9df74e0c1059e51bb76b1f6d9d4746949d4d34 Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Mon, 31 Aug 2020 08:59:40 +0200 -Subject: [PATCH] gcc-go: link to libucontext +From 0631e2b9453b33c42e12a14c11e8257d470016c5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 30 Aug 2020 19:17:42 +0200 +Subject: [PATCH] gcc-go: support libucontext +This patch allows using gcc-go with libucontext. For this purpose, +it unconditionally links gcc-go against -lucontext. Furthermore, +it undefines SETCONTEXT_CLOBBERS_TLS in proc.c to prevent usage +of makecontext/swapcontext feature that are not support by libucontext. --- - Makefile.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Makefile.in | 2 +- + libgo/runtime/proc.c | 4 ++++ + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in -index b96f60e33e2..b564ddbf792 100644 +index 593495e1650..c3e5d489bc0 100644 --- a/Makefile.in +++ b/Makefile.in -@@ -52802,7 +52802,7 @@ configure-target-libgo: +@@ -52801,7 +52801,7 @@ configure-target-libgo: esac; \ module_srcdir=libgo; \ rm -f no-such-file || : ; \ @@ -20,3 +25,18 @@ index b96f60e33e2..b564ddbf792 100644 $$s/$$module_srcdir/configure \ --srcdir=$${topdir}/$$module_srcdir \ $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ +diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c +index 3a30748d329..a987678fa84 100644 +--- a/libgo/runtime/proc.c ++++ b/libgo/runtime/proc.c +@@ -66,6 +66,10 @@ static void gscanstack(G*); + + __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); + ++/* libucontext does not seem to support tlsbase, undef the macro ++ * here to make sure we define initcontext and fixcontext as dummies. */ ++#undef SETCONTEXT_CLOBBERS_TLS ++ + #ifndef SETCONTEXT_CLOBBERS_TLS + + static inline void diff --git a/cross/gcc-armv7/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch b/cross/gcc-armv7/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch index 2259716b8..e0423d47b 100644 --- a/cross/gcc-armv7/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch +++ b/cross/gcc-armv7/0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch @@ -1,81 +1,199 @@ -From 4655244d80aa67904a88d620361f2d37ea4c8576 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 28 Nov 2021 00:54:37 +0100 -Subject: [PATCH] libgo: Recognize off64_t and loff_t definitions of musl libc +From 3b9243b891cc06373639a23ed5717b0d1c2d8ea6 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Tue, 14 Jun 2022 06:13:43 -0700 +Subject: [PATCH] libgo: permit loff_t and off_t to be macros +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -Without this patch, both off64_t and loff_t are not recognized by --fdump-go-spec which causes a variety Go-related compilation errors on -musl libc since the gcc-go frontend expects both off64_t and loff_t to -be present. +They are macros in musl libc, rather than typedefs, and -fgo-dump-spec +doesn't handle that case. -Also make sure that autoconf recognizes support for loff_t on musl, by -compiling the relevant feature test code with -D_GNU_SOURCE and making -it include fcntl.h which defines loff_t on musl. +Based on patch by Sören Tempel. + +Change-Id: Ic9a608fd964a6f78e754aa8e3100aff06ab3dade +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/412075 +Reviewed-by: Ian Lance Taylor +Reviewed-by: Cherry Mui + +libgo: #include when checking for loff_t + +Fixes https://gcc.gnu.org/PR106033 +Fixes golang/go#53469 + +Change-Id: I060021b7bb9334949b567442448abb6822fd6d35 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/413214 +Reviewed-by: Cherry Mui +Reviewed-by: Than McIntosh --- - libgo/configure | 4 +++- - libgo/configure.ac | 4 +++- - libgo/sysinfo.c | 21 +++++++++++++++++++++ - 3 files changed, 27 insertions(+), 2 deletions(-) + libgo/config.h.in | 3 +++ + libgo/configure | 12 ++++++++++-- + libgo/configure.ac | 11 +++++++++-- + libgo/go/syscall/libcall_linux.go | 17 +++++++++-------- + libgo/mksysinfo.sh | 6 +----- + libgo/sysinfo.c | 15 ++++++++++++++- + 6 files changed, 46 insertions(+), 18 deletions(-) +diff --git a/libgo/config.h.in b/libgo/config.h.in +index 25b8ab8f9ee..2c3c7469675 100644 +--- a/libgo/config.h.in ++++ b/libgo/config.h.in +@@ -70,6 +70,9 @@ + /* Define to 1 if you have the `fchownat' function. */ + #undef HAVE_FCHOWNAT + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_FCNTL_H ++ + /* Define to 1 if you have the `futimesat' function. */ + #undef HAVE_FUTIMESAT + diff --git a/libgo/configure b/libgo/configure -index ffe17c9be55..c2dbecef98c 100755 +index ffe17c9be55..61a49947eb9 100755 --- a/libgo/configure +++ b/libgo/configure -@@ -15546,7 +15546,9 @@ _ACEOF +@@ -15249,7 +15249,7 @@ $as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h + fi + + +-for ac_header in port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h ++for ac_header in fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h + do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` + ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +@@ -15546,7 +15546,14 @@ _ACEOF fi -ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default" -+CFLAGS_hold=$CFLAGS -+CFLAGS="$CFLAGS -D_GNU_SOURCE" -+ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include " ++ ++CFLAGS_hold="$CFLAGS" ++CFLAGS="$OSCFLAGS $CFLAGS" ++ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" " ++#include ++#include ++ ++" if test "x$ac_cv_type_loff_t" = xyes; then : cat >>confdefs.h <<_ACEOF +@@ -15556,6 +15563,7 @@ _ACEOF + + fi + ++CFLAGS="$CFLAGS_hold" + + LIBS_hold="$LIBS" + LIBS="$LIBS -lm" diff --git a/libgo/configure.ac b/libgo/configure.ac -index 7e2b98ba67c..667feae3c03 100644 +index 7e2b98ba67c..274fcfc35c7 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac -@@ -601,7 +601,9 @@ AC_STRUCT_DIRENT_D_TYPE +@@ -579,7 +579,7 @@ AC_C_BIGENDIAN + + GCC_CHECK_UNWIND_GETIPINFO + +-AC_CHECK_HEADERS(port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h) ++AC_CHECK_HEADERS(fcntl.h port.h sched.h semaphore.h sys/file.h sys/mman.h syscall.h sys/epoll.h sys/event.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/sysctl.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/bpf.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/ptrace.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h lwp.h) + + AC_CHECK_HEADERS([netinet/icmp6.h], [], [], + [#include +@@ -601,7 +601,14 @@ AC_STRUCT_DIRENT_D_TYPE AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat) AC_TYPE_OFF_T -AC_CHECK_TYPES([loff_t]) -+CFLAGS_hold=$CFLAGS -+CFLAGS="$CFLAGS -D_GNU_SOURCE" # musl does not define loff_t without this -+AC_CHECK_TYPES([loff_t], [], [], [[#include ]]) ++ ++CFLAGS_hold="$CFLAGS" ++CFLAGS="$OSCFLAGS $CFLAGS" ++AC_CHECK_TYPES([loff_t], [], [], [[ ++#include ++#include ++]]) ++CFLAGS="$CFLAGS_hold" LIBS_hold="$LIBS" LIBS="$LIBS -lm" +diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go +index 96974bd3269..65eb1a745f7 100644 +--- a/libgo/go/syscall/libcall_linux.go ++++ b/libgo/go/syscall/libcall_linux.go +@@ -209,19 +209,20 @@ 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 *_libgo_loff_t_type, wfd int, woff *_libgo_loff_t_type, len int, flags int) (n int64, err error) ++//splice(rfd _C_int, roff *_libgo_loff_t_type, wfd _C_int, woff *_libgo_loff_t_type, 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 _libgo_loff_t_type ++ var plroff *_libgo_loff_t_type + if roff != nil { +- lroff = _loff_t(*roff) ++ lroff = _libgo_loff_t_type(*roff) + plroff = &lroff + } +- var lwoff _loff_t +- var plwoff *_loff_t ++ var lwoff _libgo_loff_t_type ++ var plwoff *_libgo_loff_t_type + if woff != nil { +- lwoff = _loff_t(*woff) ++ lwoff = _libgo_loff_t_type(*woff) + plwoff = &lwoff + } + n, err = splice(rfd, plroff, wfd, plwoff, len, flags) +diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh +index 0c52ea5d71a..5aa309155c3 100755 +--- 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 _libgo_off_t_type" >> ${OUT} + echo "type Mode_t _mode_t" >> ${OUT} + echo "type Pid_t _pid_t" >> ${OUT} + echo "type Uid_t _uid_t" >> ${OUT} diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c -index 8ce061e2f5f..b85add15a7b 100644 +index 336a5983750..fc0210992fa 100644 --- a/libgo/sysinfo.c +++ b/libgo/sysinfo.c -@@ -343,6 +343,27 @@ enum { - #endif +@@ -354,6 +354,18 @@ enum { }; + #endif -+// musl libc has both off64_t and loff_t. However, both of these types -+// are defined as CPP macros, not as C typedefs. Unfortunately, the GCC -+// -fdump-go-spec option, which is responsible for generating type -+// definitions for Go based on this file, only recognizes types defined -+// through typedefs. -+// -+// For this reason, we check here if either off64_t or loff_t are -+// defined as CPP macros and if so, we redefine them using a C typedef. -+#if defined(HAVE_OFF64_T) && defined(off64_t) -+typedef off64_t __musl_off64_t; -+#undef off64_t -+typedef __musl_off64_t off64_t; ++#if defined(HAVE_LOFF_T) ++// loff_t can be defined as a macro; for -fgo-dump-spec make sure we ++// see a typedef. ++typedef loff_t libgo_loff_t_type; +#endif + -+// See comment regarding musl libc above. -+#if defined(HAVE_LOFF_T) && defined(loff_t) -+typedef loff_t __musl_loff_t; -+#undef loff_t -+typedef __musl_loff_t loff_t; ++#if defined(HAVE_OFF64_T) ++typedef off64_t libgo_off_t_type; ++#else ++typedef off_t libgo_off_t_type; +#endif + - // SIOCGIFMTU can't be added in the above enum as it might - // be signed in some OSes. - #ifdef SIOCGIFMTU + // The following section introduces explicit references to types and + // constants of interest to support bootstrapping libgo using a + // compiler that doesn't support -fdump-go-spec (e.g., clang), via +@@ -534,7 +546,8 @@ SREF(timex); + // From sys/types.h + TREF(pid_t); + TREF(off_t); +-TREF(loff_t); ++TREF(libgo_loff_t_type); ++TREF(libgo_off_t_type); + TREF(size_t); + TREF(ssize_t); + TREF(mode_t); diff --git a/cross/gcc-armv7/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch b/cross/gcc-armv7/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch index 14836f27c..4867ab090 100644 --- a/cross/gcc-armv7/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch +++ b/cross/gcc-armv7/0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch @@ -1,43 +1,22 @@ -From 76c13560bba3534bff335e5bb571a8b95d50d4ba Mon Sep 17 00:00:00 2001 -From: "A. Wilcox" -Date: Sun, 30 Aug 2020 18:33:49 +0200 -Subject: [PATCH] gcc-go: Use int64 type as offset argument for mmap -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit +From 4b6240d5301ce04b8bbc3e2152915cbc7da80584 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Wed, 28 Sep 2022 17:30:14 +0200 +Subject: [PATCH] libgo: use _off_t for mmap offset argument -Without this patch, Go run-time memory allocation fails on 32-bit architectures: +On glibc-based systems, off_t is a 32-bit type on 32-bit systems and a +64-bit type on 64-bit systems by default. However, on systems using musl +libc off_t is unconditionally a 64-bit type. As such, it is insufficient +to use a uintptr type for the mmap offset parameter. - fatal error: runtime: cannot allocate memory - runtime stack: - runtime.dopanic__m - :0 - runtime.throw - :0 - :0 - :0 - runtime.systemstack - :0 - runtime.addrRanges.init - :0 - runtime.pageAlloc.init - :0 - runtime.mheap.init - :0 - runtime.schedinit - :0 - :0 - :0 - -Taken from Adélie Linux [1]. - -[1]: https://git.adelielinux.org/adelie/packages/-/commit/63b5fb12c3d75e460799c672bbbdd5d29c3cc33c +Presently, the (incorrect) mmap declaration causes a libgo run-time +failure on 32-bit musl systems (fatal error: runtime: cannot allocate +memory). This commit fixes this run-time error. --- libgo/go/runtime/mem_gccgo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go -index fa3389d857e..57bed97c710 100644 +index fa3389d8..07bf325a 100644 --- a/libgo/go/runtime/mem_gccgo.go +++ b/libgo/go/runtime/mem_gccgo.go @@ -15,7 +15,7 @@ import ( @@ -45,16 +24,16 @@ index fa3389d857e..57bed97c710 100644 //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 ++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off _off_t) unsafe.Pointer //extern munmap func munmap(addr unsafe.Pointer, length uintptr) int32 -@@ -37,7 +37,7 @@ func init() { - } +@@ -38,7 +38,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) + func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) { +- p := sysMmap(addr, n, prot, flags, fd, off) ++ p := sysMmap(addr, n, prot, flags, fd, _off_t(off)) if uintptr(p) == _MAP_FAILED { return nil, errno() + } diff --git a/cross/gcc-armv7/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch b/cross/gcc-armv7/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch deleted file mode 100644 index 7ca25c3df..000000000 --- a/cross/gcc-armv7/0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch +++ /dev/null @@ -1,55 +0,0 @@ -From cf41d579088e1c0b5c33c93657ad041e797b5905 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 2 Jan 2022 01:07:03 +0100 -Subject: [PATCH] libgo: include asm/ptrace.h for pt_regs definition on PowerPC -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Both glibc and musl libc declare pt_regs as an incomplete type. This -type has to be completed by inclusion of another header. On Linux, the -asm/ptrace.h header file provides this type definition. Without -including this header file, it is not possible to access the regs member -of the mcontext_t struct as done in libgo/runtime/go-signal.c. On glibc, -other headers (e.g. sys/user.h) include asm/ptrace.h but on musl -asm/ptrace.h is not included by other headers and thus the -aforementioned files do not compile without an explicit include of -asm/ptrace.h: - - libgo/runtime/go-signal.c: In function 'getSiginfo': - libgo/runtime/go-signal.c:227:63: error: invalid use of undefined type 'struct pt_regs' - 227 | ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip; - | - -Instead of including the asm/ptrace.h header conditionally on PowerPC -only it would alternatively also be possible to include it -unconditionally. - -See also: - -* https://git.musl-libc.org/cgit/musl/commit/?id=c2518a8efb6507f1b41c3b12e03b06f8f2317a1f -* https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d57cb31910ca5c200e4172276749a7f8bd17ae3c -* https://github.com/kaniini/libucontext/issues/36 - -Signed-off-by: Sören Tempel ---- - libgo/runtime/go-signal.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c -index 528d9b6d9fe..c67503f0a79 100644 ---- a/libgo/runtime/go-signal.c -+++ b/libgo/runtime/go-signal.c -@@ -10,6 +10,12 @@ - #include - #include - -+// On PowerPC, ucontext.h uses a pt_regs struct as an incomplete -+// type. This type must be completed by including asm/ptrace.h. -+#ifdef __PPC__ -+#include -+#endif -+ - #include "runtime.h" - - #ifndef SA_RESTART diff --git a/cross/gcc-armv7/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch b/cross/gcc-armv7/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch index cb1cd527a..5cebe745b 100644 --- a/cross/gcc-armv7/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch +++ b/cross/gcc-armv7/0041-go-gospec-forcibly-disable-fsplit-stack-support.patch @@ -1,30 +1,71 @@ -From fbc8240ac15225ede8416a27c9978559b85d6877 Mon Sep 17 00:00:00 2001 -From: Ariadne Conill -Date: Mon, 21 Feb 2022 10:04:47 +0000 -Subject: [PATCH] go/gospec: forcibly disable -fsplit-stack support +From c86b726c048eddc1be320c0bf64a897658bee13d Mon Sep 17 00:00:00 2001 +From: Uros Bizjak +Date: Wed, 18 May 2022 20:03:26 +0200 +Subject: [PATCH] x86: Fix -fsplit-stack feature detection via + TARGET_CAN_SPLIT_STACK +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -for some reason, TARGET_CAN_SPLIT_STACK still gets defined on 32-bit x86, -so hackfix it for now +Since commit c163647ffbc9a20c8feb6e079dbecccfe016c82e -fsplit-stack +is only supported on glibc targets. However, this original commit +required some fixups. As part of the fixup, the changes to the +gnu-user-common.h and gnu.h were partially reverted in commit +60953a23d57b13a672f751bec0c6eefc059eb1ab thus causing TARGET_CAN_SPLIT_STACK +to be defined for non-glibc targets even though -fsplit-stack is +actually not supported and attempting to use it causes a runtime error. + +This causes gcc internal code, such as ./gcc/go/gospec.c to not +correctly detect that -fsplit-stack is not supported and thus causes +gccgo to fail compilation on non-glibc targets. + +This commit ensures that TARGET_CAN_SPLIT_STACK is only set if the +default libc is glibc. It is presently unclear to me if there is a +better way to detect glibc at pre-processor time. + +The proposed changes have been tested on x86 and x86_64 Alpine Linux +(which uses musl libc) and fix compilation of gccgo for this target. + +Signed-off-by: Sören Tempel + +gcc/ChangeLog: + + * config/i386/gnu-user-common.h (defined): Only define + TARGET_CAN_SPLIT_STACK for glibc targets. + * config/i386/gnu.h (defined): Ditto. --- - gcc/go/gospec.cc | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) + gcc/config/i386/gnu-user-common.h | 5 +++-- + gcc/config/i386/gnu.h | 5 +++-- + 2 files changed, 6 insertions(+), 4 deletions(-) -diff --git a/gcc/go/gospec.cc b/gcc/go/gospec.cc -index df92b62d8e6..cf168beb4cf 100644 ---- a/gcc/go/gospec.cc -+++ b/gcc/go/gospec.cc -@@ -269,11 +269,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, - /* Copy the 0th argument, i.e., the name of the program itself. */ - new_decoded_options[j++] = decoded_options[i++]; +diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h +index 23b54c5be52..cab9be2bfb7 100644 +--- a/gcc/config/i386/gnu-user-common.h ++++ b/gcc/config/i386/gnu-user-common.h +@@ -66,7 +66,8 @@ along with GCC; see the file COPYING3. If not see + #define STACK_CHECK_STATIC_BUILTIN 1 --#ifdef TARGET_CAN_SPLIT_STACK -+ /* Hackfix: we never support split stack on Alpine GCC */ -+#if 0 - supports_split_stack = 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 ++ assembler has full support for the CFI directives. Also ++ we only support -fsplit-stack on glibc targets. */ ++#if (DEFAULT_LIBC == LIBC_GLIBC) && HAVE_GAS_CFI_PERSONALITY_DIRECTIVE + #define TARGET_CAN_SPLIT_STACK #endif +diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h +index 401e60c9a02..fb8d69a97d8 100644 +--- a/gcc/config/i386/gnu.h ++++ b/gcc/config/i386/gnu.h +@@ -41,8 +41,9 @@ along with GCC. If not, see . + #define TARGET_THREAD_SSP_OFFSET 0x14 --#ifdef TARGET_CAN_SPLIT_STACK_64BIT -+#if 0 - if (is_m64) - supports_split_stack = 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 ++ assembler has full support for the CFI directives. Also ++ we only support -fsplit-stack on glibc targets. */ ++#if (DEFAULT_LIBC == LIBC_GLIBC) && HAVE_GAS_CFI_PERSONALITY_DIRECTIVE + #define TARGET_CAN_SPLIT_STACK #endif + /* We steal the last transactional memory word. */ diff --git a/cross/gcc-armv7/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch b/cross/gcc-armv7/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch index 0ce960966..db38df3b0 100644 --- a/cross/gcc-armv7/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch +++ b/cross/gcc-armv7/0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch @@ -1,31 +1,41 @@ -From 38270192ea355d8035d9f1b5fe50e36ca3fa3708 Mon Sep 17 00:00:00 2001 -From: Natanael Copa -Date: Thu, 30 Jun 2022 17:04:23 +0000 -Subject: [PATCH] gcc-go: fix build error with SYS_SECCOMP +From 548720bca6bff21ebc9aba22249d9ce45bbd90c7 Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Wed, 29 Jun 2022 15:32:04 -0700 +Subject: [PATCH] libgo: handle stat st_atim32 field and SYS_SECCOMP +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -fix the build error: - sysinfo.go:6606:7: error: redefinition of 'SYS_SECCOMP' - 6606 | const SYS_SECCOMP = _SYS_SECCOMP - | ^ - sysinfo.go:6600:7: note: previous definition of 'SYS_SECCOMP' was here - 6600 | const SYS_SECCOMP = _SYS_seccomp - | ^ +Patches for musl support, from Sören Tempel. -Upstream report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105225 +Fixes https://gcc.gnu.org/PR105225 + +Change-Id: If396877d4a4c7d27962226d7a6e3bb91b1344413 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415294 +Reviewed-by: Than McIntosh +Reviewed-by: Ian Lance Taylor --- - libgo/mksysinfo.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/mksysinfo.sh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh -index 6fef104cc1c..06289a43bdf 100755 +index 5aa30915..ea1fa17d 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh -@@ -126,7 +126,7 @@ if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then - fi +@@ -127,6 +127,7 @@ fi # The syscall numbers. We force the names to upper case. --grep '^const _SYS_' gen-sysinfo.go | \ -+grep '^const _SYS_[a-z]' gen-sysinfo.go | \ + grep '^const _SYS_' gen-sysinfo.go | \ ++ grep -v '^const _SYS_SECCOMP = ' | \ sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \ while read sys; do sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` +@@ -506,7 +507,7 @@ fi + + # For historical reasons Go uses the suffix "timespec" instead of "tim" for + # stat_t's time fields on NetBSD. +-st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' ++st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' + if test "${GOOS}" = "netbsd"; then + st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' + fi diff --git a/cross/gcc-armv7/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch b/cross/gcc-armv7/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch deleted file mode 100644 index 09504f1e9..000000000 --- a/cross/gcc-armv7/0046-c-avoid-memory-poisoning-on-musl-PR106102.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 9cef407678b40c20ecc39850c7e43346ad92a60b Mon Sep 17 00:00:00 2001 -From: Sergei Trofimovich -Date: Mon, 27 Jun 2022 03:31:45 +0100 -Subject: [PATCH] c++: avoid poisoning on musl [PR106102] - -On musl uses calloc() (via ). includes -it indirectly and exposes use of poisoned calloc() when module code -is built: - - /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc - In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, - from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35, - .... - from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77, - from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24, - from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25, - from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23, - from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32: - /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" - 84 | void *calloc(size_t, size_t); - | ^ - /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" - 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) - | ^ - -gcc/cp/ - - PR c++/106102 - * mapper-client.cc: Include via "system.h". - * mapper-resolver.cc: Ditto. - * module.cc: Ditto. - -libcc1/ - - PR c++/106102 - * libcc1plugin.cc: Include via "system.h". - * libcp1plugin.cc: Ditto. - -(cherry picked from commit 3b21c21f3f5726823e19728fdd1571a14aae0fb3) ---- - gcc/cp/mapper-client.cc | 1 + - gcc/cp/mapper-resolver.cc | 1 + - gcc/cp/module.cc | 1 + - libcc1/libcc1plugin.cc | 1 + - libcc1/libcp1plugin.cc | 1 + - 5 files changed, 5 insertions(+) - -diff --git a/gcc/cp/mapper-client.cc b/gcc/cp/mapper-client.cc -index 8603a886a09..fe9544b5ba4 100644 ---- a/gcc/cp/mapper-client.cc -+++ b/gcc/cp/mapper-client.cc -@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see - #define INCLUDE_STRING - #define INCLUDE_VECTOR - #define INCLUDE_MAP -+#define INCLUDE_MEMORY - #include "system.h" - - #include "line-map.h" -diff --git a/gcc/cp/mapper-resolver.cc b/gcc/cp/mapper-resolver.cc -index e3d29fb5ada..e70d1b4ae2c 100644 ---- a/gcc/cp/mapper-resolver.cc -+++ b/gcc/cp/mapper-resolver.cc -@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see - #define INCLUDE_VECTOR - #define INCLUDE_ALGORITHM - #define INCLUDE_MAP -+#define INCLUDE_MEMORY - #include "system.h" - - // We don't want or need to be aware of networking -diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc -index cebf9c35c1d..5c5d02bb523 100644 ---- a/gcc/cp/module.cc -+++ b/gcc/cp/module.cc -@@ -202,6 +202,7 @@ Classes used: - - #define _DEFAULT_SOURCE 1 /* To get TZ field of struct tm, if available. */ - #include "config.h" -+#define INCLUDE_MEMORY - #define INCLUDE_STRING - #define INCLUDE_VECTOR - #include "system.h" -diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc -index 12ab5a57c8d..bdd0bdabe77 100644 ---- a/libcc1/libcc1plugin.cc -+++ b/libcc1/libcc1plugin.cc -@@ -31,6 +31,7 @@ - #undef PACKAGE_TARNAME - #undef PACKAGE_VERSION - -+#define INCLUDE_MEMORY - #include "gcc-plugin.h" - #include "system.h" - #include "coretypes.h" -diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc -index 83dab7f58b1..e2d5039a0a1 100644 ---- a/libcc1/libcp1plugin.cc -+++ b/libcc1/libcp1plugin.cc -@@ -32,6 +32,7 @@ - #undef PACKAGE_TARNAME - #undef PACKAGE_VERSION - -+#define INCLUDE_MEMORY - #include "gcc-plugin.h" - #include "system.h" - #include "coretypes.h" diff --git a/cross/gcc-armv7/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch b/cross/gcc-armv7/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch deleted file mode 100644 index 4cc457f53..000000000 --- a/cross/gcc-armv7/0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch +++ /dev/null @@ -1,117 +0,0 @@ -From f982c816d8f52a65231544b838160484b5ed4c71 Mon Sep 17 00:00:00 2001 -From: Sergei Trofimovich -Date: Mon, 27 Jun 2022 14:44:48 +0100 -Subject: [PATCH] jit: avoid calloc() poisoning on musl [PR106102] - -On musl uses calloc() (via ). jit/ includes -it directly and exposes use of poisoned calloc(): - - /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/jit/jit-playback.cc - make[3]: *** [Makefile:1143: jit/libgccjit.o] Error 1 - make[3]: *** Waiting for unfinished jobs.... - In file included from /<>/musl-1.2.3-dev/include/pthread.h:30, - from ../../gcc-13-20220626/gcc/jit/jit-playback.cc:44: - /<>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc" - 84 | void *calloc(size_t, size_t); - | ^ - /<>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc" - 124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n))) - | ^ - -The change moves inclusion to "system.h" under new -INCLUDE_PTHREAD_H guard and uses this mechanism in libgccjit. - -gcc/ - - PR c++/106102 - * system.h: Introduce INCLUDE_PTHREAD_H macros to include . - -gcc/jit/ - - PR c++/106102 - * jit-playback.cc: Include via "system.h" to avoid calloc() - poisoning. - * jit-recording.cc: Ditto. - * libgccjit.cc: Ditto. - -(cherry picked from commit 49d508065bdd36fb1a9b6aad9666b1edb5e06474) ---- - gcc/jit/jit-playback.cc | 3 +-- - gcc/jit/jit-recording.cc | 2 +- - gcc/jit/libgccjit.cc | 2 +- - gcc/system.h | 4 ++++ - 4 files changed, 7 insertions(+), 4 deletions(-) - -diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc -index 6be6bdf8dea..79714132b91 100644 ---- a/gcc/jit/jit-playback.cc -+++ b/gcc/jit/jit-playback.cc -@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "target.h" -@@ -41,8 +42,6 @@ along with GCC; see the file COPYING3. If not see - #include "diagnostic.h" - #include "stmt.h" - --#include -- - #include "jit-playback.h" - #include "jit-result.h" - #include "jit-builtins.h" -diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc -index a31720f043e..5556b9c4905 100644 ---- a/gcc/jit/jit-recording.cc -+++ b/gcc/jit/jit-recording.cc -@@ -19,13 +19,13 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "tm.h" - #include "pretty-print.h" - #include "toplev.h" - --#include - - #include "jit-builtins.h" - #include "jit-recording.h" -diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc -index cc6486c9cad..4c991e5436b 100644 ---- a/gcc/jit/libgccjit.cc -+++ b/gcc/jit/libgccjit.cc -@@ -19,12 +19,12 @@ along with GCC; see the file COPYING3. If not see - . */ - - #include "config.h" -+#define INCLUDE_PTHREAD_H - #include "system.h" - #include "coretypes.h" - #include "timevar.h" - #include "typed-splay-tree.h" - #include "cppbuiltin.h" --#include - - #include "libgccjit.h" - #include "jit-recording.h" -diff --git a/gcc/system.h b/gcc/system.h -index c5562cc49a3..e10c34f70ec 100644 ---- a/gcc/system.h -+++ b/gcc/system.h -@@ -750,6 +750,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); - #endif - #endif - -+#ifdef INCLUDE_PTHREAD_H -+#include -+#endif -+ - #ifdef INCLUDE_ISL - #ifdef HAVE_isl - #include diff --git a/cross/gcc-armv7/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch b/cross/gcc-armv7/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch index 4de9ea2b7..0f949be3a 100644 --- a/cross/gcc-armv7/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch +++ b/cross/gcc-armv7/0049-libgo-adjust-name-of-union-in-sigevent-struct.patch @@ -1,28 +1,108 @@ -From d54419ddcc14f52517017147201560da5353c436 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Sun, 17 Jul 2022 02:52:13 +0200 -Subject: [PATCH] libgo: adjust name of union in sigevent struct +From 8f1a91aeff400d572857895b7f5e863ec5a4d93e Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Mon, 26 Sep 2022 15:03:53 -0400 +Subject: [PATCH] runtime: portable access to sigev_notify_thread_id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -The union in struct sigevent is named __sev_fields on musl but -_sigev_un on glibc. Not sure what this code actually does and -how this works if the union layout is different… +Previously, libgo relied on the _sigev_un implementation-specific +field in struct sigevent, which is only available on glibc. +This patch uses the sigev_notify_thread_id macro instead which is +mandated by timer_create(2). In theory, this should work with any libc +implementation for Linux. Unfortunately, there is an open glibc bug +as glibc does not define this macro. For this reason, a glibc-specific +workaround is required. Other libcs (such as musl) define the macro +and don't require the workaround. + +See https://sourceware.org/bugzilla/show_bug.cgi?id=27417 + +This makes libgo compatible with musl libc. + +Based on patch by Sören Tempel. + +Change-Id: I0924a53d5212730ebc395ecf9199f85967be8cc6 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/434755 +Reviewed-by: Cherry Mui +Reviewed-by: Than McIntosh --- - libgo/go/runtime/os_linux.go | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/go/runtime/os_linux.go | 12 +++++++++++- + libgo/runtime/go-signal.c | 18 ++++++++++++++++++ + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libgo/go/runtime/os_linux.go b/libgo/go/runtime/os_linux.go -index 96fb178870e..a75a2dd703f 100644 +index 96fb1788..2b2d827c 100644 --- a/libgo/go/runtime/os_linux.go +++ b/libgo/go/runtime/os_linux.go -@@ -365,7 +365,7 @@ func setThreadCPUProfiler(hz int32) { +@@ -22,6 +22,12 @@ type mOS struct { + profileTimerValid uint32 + } + ++// setSigeventTID is written in C to set the sigev_notify_thread_id ++// field of a sigevent struct. ++// ++//go:noescape ++func setSigeventTID(*_sigevent, int32) ++ + func getProcID() uint64 { + return uint64(gettid()) + } +@@ -52,9 +58,12 @@ const ( + ) + + // Atomically, ++// + // if(*addr == val) sleep ++// + // Might be woken up spuriously; that's allowed. + // Don't sleep longer than ns; ns < 0 means forever. ++// + //go:nosplit + func futexsleep(addr *uint32, val uint32, ns int64) { + // Some Linux kernels have a bug where futex of +@@ -73,6 +82,7 @@ func futexsleep(addr *uint32, val uint32, ns int64) { + } + + // If any procs are sleeping on addr, wake up at most cnt. ++// + //go:nosplit + func futexwakeup(addr *uint32, cnt uint32) { + ret := futex(unsafe.Pointer(addr), _FUTEX_WAKE_PRIVATE, cnt, nil, nil, 0) +@@ -365,7 +375,7 @@ func setThreadCPUProfiler(hz int32) { var sevp _sigevent sevp.sigev_notify = _SIGEV_THREAD_ID sevp.sigev_signo = _SIGPROF - *((*int32)(unsafe.Pointer(&sevp._sigev_un))) = int32(mp.procid) -+ *((*int32)(unsafe.Pointer(&sevp.__sev_fields))) = int32(mp.procid) ++ setSigeventTID(&sevp, int32(mp.procid)) ret := timer_create(_CLOCK_THREAD_CPUTIME_ID, &sevp, &timerid) if ret != 0 { // If we cannot create a timer for this M, leave profileTimerValid false +diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c +index 528d9b6d..aa1b6305 100644 +--- a/libgo/runtime/go-signal.c ++++ b/libgo/runtime/go-signal.c +@@ -183,6 +183,24 @@ setSigactionHandler(struct sigaction* sa, uintptr handler) + sa->sa_sigaction = (void*)(handler); + } + ++#ifdef __linux__ ++ ++// Workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=27417 ++#ifndef sigev_notify_thread_id ++ #define sigev_notify_thread_id _sigev_un._tid ++#endif ++ ++void setSigeventTID(struct sigevent*, int32_t) ++ __asm__ (GOSYM_PREFIX "runtime.setSigeventTID"); ++ ++void ++setSigeventTID(struct sigevent *sev, int32_t v) ++{ ++ sev->sigev_notify_thread_id = v; ++} ++ ++#endif // defined(__linux__) ++ + // C code to fetch values from the siginfo_t and ucontext_t pointers + // passed to a signal handler. + diff --git a/cross/gcc-armv7/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch b/cross/gcc-armv7/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch index 10f82014a..f2f019119 100644 --- a/cross/gcc-armv7/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch +++ b/cross/gcc-armv7/0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch @@ -1,36 +1,36 @@ -From 3825632cf4007ac93d8e44705a6da042c496318b Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Mon, 18 Jul 2022 20:34:39 +0200 -Subject: [PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl - arches +From d53e8a0e94e34dc609e34dd5e404debda2640cfb Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Sat, 30 Jul 2022 07:29:28 -0700 +Subject: [PATCH] libgo: use SYS_timer_settime32 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -On 32-bit systems musl only defines SYS_timer_settime32 not -SYS_timer_settime. This causes the following compilation error: +Musl defines SYS_timer_settime32, not SYS_timer_settime, on 32-bit systems. - os_linux.go:251:30: error: reference to undefined name '_SYS_timer_settime' - 251 | return int32(syscall(_SYS_timer_settime, uintptr(timerid), uintptr(flags), uintptr(unsafe.Pointer(new)), uintptr(unsafe.Pointer(old)), 0, 0)) - | ^ +Based on patch by Sören Tempel. -This commit fixes this error by defining SYS_timer_settime to -SYS_timer_settime32 if the latter is defined. +Change-Id: I1f3485028d132ceca1aba595325af24b4d72b894 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/420222 +Reviewed-by: Ian Lance Taylor +Reviewed-by: Cherry Mui --- - libgo/sysinfo.c | 6 ++++++ - 1 file changed, 6 insertions(+) + libgo/sysinfo.c | 5 +++++ + 1 file changed, 5 insertions(+) diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c -index b85add15a7b..ff04706a993 100644 +index fc021099..180f5c31 100644 --- a/libgo/sysinfo.c +++ b/libgo/sysinfo.c -@@ -343,6 +343,12 @@ enum { - #endif +@@ -354,6 +354,11 @@ enum { }; + #endif -+// musl libc does not have SYS_timer_settime on 32-bit platforms -+// but defines SYS_timer_settime32 instead, alias accordingly. -+#ifdef SYS_timer_settime32 ++#if !defined(SYS_timer_settime) && defined(SYS_timer_settime32) ++// musl defines SYS_timer_settim32 on 32-bit systems. +#define SYS_timer_settime SYS_timer_settime32 +#endif + - // musl libc has both off64_t and loff_t. However, both of these types - // are defined as CPP macros, not as C typedefs. Unfortunately, the GCC - // -fdump-go-spec option, which is responsible for generating type + #if defined(HAVE_LOFF_T) + // loff_t can be defined as a macro; for -fgo-dump-spec make sure we + // see a typedef. diff --git a/cross/gcc-armv7/0053-libgo-make-match.sh-POSIX-shell-compatible.patch b/cross/gcc-armv7/0053-libgo-make-match.sh-POSIX-shell-compatible.patch index cbfaca9aa..8758cb837 100644 --- a/cross/gcc-armv7/0053-libgo-make-match.sh-POSIX-shell-compatible.patch +++ b/cross/gcc-armv7/0053-libgo-make-match.sh-POSIX-shell-compatible.patch @@ -1,20 +1,29 @@ -From 75a430f66760802bf1ac5afcd716613e3cf8c77d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= -Date: Tue, 19 Jul 2022 07:15:25 +0200 -Subject: [PATCH] libgo: make match.sh POSIX-shell compatible +From a62f20ae78ddd41be682dde8cab075ca4f5dbb2a Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Fri, 22 Jul 2022 11:38:20 -0700 +Subject: [PATCH] libgo: use POSIX shell arithmetic expansion +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit -The `(( expression ))` syntax is a Bash extension. However, the -arithmetic expressions used by the gobuild() function can also -be expressed using Arithmetic POSIX Expansion with `$(( expression ))`. -Contrary to the Bash expression, the Arithmetic Expansion doesn't set -the return value if the expression is non-zero but instead just prints -the expression result. Hence, the expression also needs to be negated. +Avoid bash-specific ((expression)) syntax. As the bash syntax +converts a non-zero value to a zero status (and a zero value to a 1 +status), and POSIX arithmetic expansion does not, we have to negate +the result. + +Based on patch by Sören Tempel. + +Change-Id: I4c64fa15de3994a1a5c7c5ec0de6a82ddd858917 +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/419154 +Reviewed-by: Than McIntosh +Reviewed-by: Ian Lance Taylor --- - libgo/match.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + libgo/match.sh | 2 +- + libgo/testsuite/gotest | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libgo/match.sh b/libgo/match.sh -index 7ed587ff794..b355d47429a 100755 +index 7ed587ff..e5ed98de 100755 --- a/libgo/match.sh +++ b/libgo/match.sh @@ -111,7 +111,7 @@ gobuild() { @@ -22,7 +31,20 @@ index 7ed587ff794..b355d47429a 100755 line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") fi - (($line)) -+ return $((! ( line ))) ++ return $((!($line))) } matched= +diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest +index 04e4267f..0a0a7e14 100755 +--- a/libgo/testsuite/gotest ++++ b/libgo/testsuite/gotest +@@ -302,7 +302,7 @@ gobuild() { + if test "$goarch" != "386"; then + line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") + fi +- (($line)) ++ return $((!($line))) + } + + case "x$gofiles" in diff --git a/cross/gcc-armv7/APKBUILD b/cross/gcc-armv7/APKBUILD index bd471af5d..0dbb6692e 100644 --- a/cross/gcc-armv7/APKBUILD +++ b/cross/gcc-armv7/APKBUILD @@ -24,14 +24,15 @@ CBUILDROOT="/" _cross_configure="--disable-bootstrap --with-sysroot=/usr/$CTARGET" pkgname=gcc-armv7 -_pkgbase=12.1.1 -pkgver=12.1.1_git20220630 +_pkgbase=12.2.1 # must match gcc/BASE-VER +_pkgsnap=20220924 +pkgver=${_pkgbase}_git${_pkgsnap} [ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2" [ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross="" [ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" pkgname=gcc-armv7 -pkgrel=6 +pkgrel=1 pkgdesc="Stage2 cross-compiler for armv7" url="https://gcc.gnu.org" arch="x86_64" @@ -204,11 +205,14 @@ makedepends="$makedepends_build $makedepends_host" # when using upstream releases, use this URI template # https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz # -# right now, we are using a git snapshot. +# right now, we are using a git snapshot. snapshots are taken from gcc.gnu.org/pub/gcc/snapshots. +# However, since they are periodically deleted from the GCC mirrors the utilized snapshots are +# mirrored on dev.alpinelinux.org. Please ensure that the snapshot Git commit (as stated in the +# README) matches the base commit on the version-specific branch in the Git repository below. # # PLEASE submit all patches to gcc to https://gitlab.alpinelinux.org/kaniini/alpine-gcc-patches, # so that they can be properly tracked and easily rebased if needed. -source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz +source="https://dev.alpinelinux.org/archive/gcc/${_pkgbase%%.*}-${_pkgsnap}/gcc-${_pkgbase%%.*}-${_pkgsnap}.tar.xz 0001-posix_memalign.patch 0002-gcc-poison-system-directories.patch 0003-specs-turn-on-Wl-z-now-by-default.patch @@ -238,23 +242,17 @@ source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz 0027-always-build-libgcc_eh.a.patch 0028-ada-libgnarl-compatibility-for-musl.patch 0029-ada-musl-support-fixes.patch - 0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch - 0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch - 0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch 0033-gcc-go-link-to-libucontext.patch 0034-Use-generic-errstr.go-implementation-on-musl.patch 0035-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch 0036-configure-fix-detection-of-atomic-builtins-in-libato.patch 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch - 0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch 0043-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch 0044-gdc-unconditionally-link-libgphobos-against-libucont.patch 0045-druntime-link-against-libucontext-on-all-platforms.patch - 0046-c-avoid-memory-poisoning-on-musl-PR106102.patch - 0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch 0050-libphobos-don-t-define-__mode_t-twice-on-musl-target.patch 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch @@ -263,7 +261,7 @@ source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz " # we build out-of-tree -_gccdir="$srcdir"/gcc-$pkgver +_gccdir="$srcdir"/gcc-${_pkgbase%%.*}-${_pkgsnap} _gcclibdir="/usr/lib/gcc/$CTARGET/${_pkgbase:-$pkgver}" _gcclibexec="/usr/libexec/gcc/$CTARGET/${_pkgbase:-$pkgver}" @@ -763,7 +761,7 @@ gnat() { } sha512sums=" -43de66dfed7b5351bb543f7f2e8253e63d1e544e5bd293829e8ec7bffe60925cabcf8f6972fe8825100b1f1d7839e41d9314ec650c1320150c09317e2be24aa9 gcc-12.1.1_git20220630.tar.xz +ba4d9e73d108088da26fbefe18d9b245b76771ffe752c2b4b31bdf38a2d0b638fbc115c377526c27311d4d7ffd4e0d236a5af5016bd364ccaa11a4989d1401e8 gcc-12-20220924.tar.xz 41cbb4d69218006cf9e0cdb6c86212ef451f8decd52a50a7dbb4d34726009da7a4e0261c852b46cb584db253a4bae2f31dc485c506cb545e64a7d26e0ba6c2b6 0001-posix_memalign.patch 531155055cda7f119bcac6479bcae73af9201cd596af9cf1616850bbcf4393b91c5de9f2fbbc1cde6e158fb4df7237b033146f662dff5fa0ea12151cc514adb8 0002-gcc-poison-system-directories.patch c1275d77b5269386a2ec683933570810f5a2ba1208c161ed887797eb9aee3cb82ef08a8964635902614e6a6e83f3065ba0801c9355d85dd8d60cb1fa20bdf687 0003-specs-turn-on-Wl-z-now-by-default.patch @@ -793,26 +791,20 @@ b40d7e4712c035674c993bbb55475290ec14523b3f0fd05493514bac4e9adaa6641faf815fc40ffc 674360ce2ee9f704d0632cc98756f9fe8dd8ca30064fb9d3423b437f7e679c1c51e765b15e535dcb278cd2769583690acb3395b91e4fd5f6f4e3b97879fcc313 0027-always-build-libgcc_eh.a.patch f060687adcd5297124e4000f1ba1e3fd5d7d124da04d948cbd0d4a6c69a90a2b29a4a0dbbe13a83ab6950724f434de012b681bdbcdf53c0100b40fe3d00f2f2f 0028-ada-libgnarl-compatibility-for-musl.patch 5160bae68e20a1966c1f6d655ee98af759e9b9ee842718ae6007d467b418e1cf3b307528a0841477b5259671ce868521b06c0f2e947b7b8f3a398c53dd978252 0029-ada-musl-support-fixes.patch -74c70a752ff24f231b45c69ca1d86ebf261bca643334cb6ba518ac204986ccd7fa84f4df4fdb38bbc0bb61832514b0100b2d2ba069fb1842929369d073220f24 0030-gcc-go-Fix-handling-of-signal-34-on-musl.patch -9786711f308d5f93f2f5a45862f340d4741e1d8aef116d696b85a6debb6149d3772b0cfab4d9ef8782172b102664d9acdd27021af433b504c5918f379b1dd978 0031-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch -4ffd2f279fbcf5abb1ac8cc6435204e48a776e7ef3742f2120eef1a1bdca2d0a01d30c481fd1495926c9166daaf127f9013fda0efefe3ed7bf6e660915cc1b49 0032-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch -0ad15e78806031cef68da6577f7ce9be178533b3768ca42fff7f12816d61fa745acc77be2e047ac1c5bfdbc04e999202e5cefd04042bca798177197236b79954 0033-gcc-go-link-to-libucontext.patch +3c04b26554a78096296ca9542c77a91219bd26044dd2cb2006db4c1944889a97c215900b3828ba7e8c675162406db543605a815bdfbd915bf810663b1b253bdd 0033-gcc-go-link-to-libucontext.patch 699dc3641099da6136dd3689f06c6553c03b3a85acf83a3fce1beb5425065b3e378535ca9e9100a120fdbafc34871d61c063fd5328a49cd87a15a989ed51706d 0034-Use-generic-errstr.go-implementation-on-musl.patch d9ba710f770e053c8f212e821817c188091a829658050b9ab5906388553ec60fec37943ea43c270e92a9014902949f3c98fc4639032d92b8145b375bb29e193e 0035-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch ab90d8fdd977d6cd3da096a1c76d77be3e89a020b2127247771711a32eb608cceed21834ef488ab4b69bb0f408b098fdfb61630819e3d1a1e57d5af67800ee74 0036-configure-fix-detection-of-atomic-builtins-in-libato.patch -7b356e11f66877bee864e2b1f81ae4be6c6c586040afb3ac220ff902f694efd60dcb4647cc7a37890c91dd539535b9992d463b785d3158205dbf9369b17c8ab7 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch -5905e4309670cfa4a5883aa21f744391ee2107731795817e0ffcccfaa22b0c21df883038c86362b091e7b35730aa4de6dce827c908ea398a161add851df5c31e 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch -570e084d223671fa29cb460b1b536a216920a7bcdfcdad21fe8cd7610e13f6942c1b1dd34ec861e9e3d830b9fe1f0e02e305c50c54d83aaf20526be09ca2256c 0040-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch -a8b53c7d6e0d6d19c655844cab074f49b8f14c54a7af920b5792303f73713fdc69b723a0a6041548d227dfaa98ef63641460ea355487619eb29f9fec4a1e301b 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch -15c93c9f2d68b19d00c6e82748e5f14470a120a3996f64d1ce91f17a65a5334cca478b4a6eba7d2d0a1d6d22206407ac3b1b5255987cc1144f5177bbb68153c8 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch +8bc6823f0b3c66f7b73d7ddb64ffa6930463285c2e9a14a2bc1882bcc4271144eaa1107d713294699caf9481648163cbf43921a2b8e4ac0d55c78a804bae8a3d 0037-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch +e9699f4721778869eb3a8fef2c679208ef5b98584892f30b0e1cb5dc1669f8158198d7792659b1b56c381baf62247d21990dcced9178547affd5d6bfb2d12548 0039-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch +d6dc1bfb881a313d167aaa5658790b0f55eea4336c408cfc6613dd5783440dafd0d37c43031a5f3e69be40f632e38371cd4fb6e5f0494ac4ea4d7d5025d2ae02 0041-go-gospec-forcibly-disable-fsplit-stack-support.patch +684c6a6d52512b973429b6e709966439ac1e174f9e79a33d4a638b452245b457b34752b4b4034ba983f6a712f86522e7adf715bab00a6603f64a12139c5b1e39 0042-gcc-go-fix-build-error-with-SYS_SECCOMP.patch 25014dfa99d96ee70ce0ad22e9f7974f0a51cc50b3b9c2db49df50774c8cd29e497ceed120486bee50be83bfb07f2009ed310eb9b0543f2795bd7359b87eadd2 0043-libstdc-do-not-throw-exceptions-for-non-C-locales-on.patch 75fd83ac05ab0a08d5f48547b08810f9934209bc78b5db59d65f33887b382af7ec24d8a29d40f86325c05af40c1ae1ec6466c839f646af90afc895a13073d07b 0044-gdc-unconditionally-link-libgphobos-against-libucont.patch 13e047153076d6e1fc40c9f5b6bfe5699c0e5460248f3d2b35ae36677cb960525af7b0b025997e5000a8492cec5e77a86828d66b4058c0d7f89fde0ab3890142 0045-druntime-link-against-libucontext-on-all-platforms.patch -ba87d4b4433e5f018071ce933ae523c62334574be2e46881a8945c9dc7ecc0fadfed3aaf837f13f93fd4c0d6d33feb24cb67c77d9c0adb40b62637991fed4374 0046-c-avoid-memory-poisoning-on-musl-PR106102.patch -03e7c0caf59ee7c7d13a840178befb378b734f18a5c36ec4bbfad3f78253f0afab80864ea0905b58454178c8c31b2441622dd38668dd54e6550e30e6249e882b 0047-jit-avoid-calloc-poisoning-on-musl-PR106102.patch -be7688a44707991c31337bff24245394aa385e7b4ba151f18e21e734a4bbb151348458f413965e5cba50185ab8e0aba8b793eba04c0802dc563b148ed490f26d 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch +c33ca2553642c2dbd1c65cd97046548f08775785a3db06d761e3bbe61398c37bc382fe132c0c3fa2101dfd4eea2a6d48bf4fae899a0ddb811c81abd7be35c122 0049-libgo-adjust-name-of-union-in-sigevent-struct.patch 179cd15d629884a66e954fd76066675efa594686b970facbb12ad50769e5d70b5530d7f61e77120e26d1c3dfc701cfc5295f341f635db998df73c41bc8e62172 0050-libphobos-don-t-define-__mode_t-twice-on-musl-target.patch -d7592589cbf982f4518cb07572f96131278c7d2fd8fbbcd7fcb47f6628529ae9a5fc22b2dfe929be06845d137e1c5d2efeb6f63b1c2fb9c36cd6bdb97d41c65f 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch +c82d7c8d340a76df3d796565a79b0ccc04ddffef39927620e1f3719bf2dc1db101ba13aef24b46c5bc95b7bf1e31c8bda4ab0936ba4c9c5e5047ba08826c982c 0051-libgo-Explicitly-define-SYS_timer_settime-for-32-bit.patch eb403d8ea665fd5dc2c11faf43b055e6a3bf480a397ceee3e0ca1e38ec7d2392315f2694ed9a34ffbc99e464f2873fbbf91be8646ea4dea5d3636e3ea22fefa0 0052-libgnat-time_t-is-always-64-bit-on-musl-libc.patch -29c4fe28e5bf232e01b44106b2f8a3e50b5e00fc4302a69d3f5f90695e43ef07721a917b51d49dc40ae0543d8d97d432cb475834059c92176b73d326af9496e3 0053-libgo-make-match.sh-POSIX-shell-compatible.patch +22fb6edf1ed0387e2b93839ffe6e82a7fee420950af90e91199c3488d966702fdeb1a3396d22be0c73a4051525da9349c93d070a0d83b724c83f2b268da6483f 0053-libgo-make-match.sh-POSIX-shell-compatible.patch "