[PATCH] libgo: check if -lucontext is required for {make, set, get}context

2022-12-19 Thread soeren--- via Gcc-patches
From: Sören Tempel This patch is similar to the existing check for librt. If libucontext is installed and libucontext.a provides the aforementioned symbols, then it is added to $LIBS. If not, no error is emitted. We could, alternatively, also check libc.a for these symbols and thus prefer libc ov

[PATCH v2] libgo: Don't rely on GNU-specific strerror_r variant on Linux

2022-11-29 Thread soeren--- via Gcc-patches
From: Sören Tempel On glibc, there are two versions of strerror_r: An XSI-compliant and a GNU-specific version. The latter is only available on glibc. In order to avoid duplicating the post-processing code of error messages, this commit provides a separate strerror_go symbol which always refers t

[PATCH] libgo: Don't rely on GNU-specific strerror_r variant on Linux

2022-11-29 Thread soeren--- via Gcc-patches
From: Sören Tempel On glibc, there are two versions of strerror_r: An XSI-compliant and a GNU-specific version. The latter is only available on glibc. In order to avoid duplicating the post-processing code of error messages, this commit provides a separate strerror_go symbol which always refers t

[PATCH] libgo: use _off_t for mmap offset argument

2022-09-29 Thread soeren--- via Gcc-patches
From: Sören Tempel 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. Present

[PATCH v2] libgo: Portable access to thread ID in struct sigevent

2022-09-23 Thread soeren--- via Gcc-patches
From: Sören Tempel Tested on x86_64 Arch Linux (glibc) and Alpine Linux (musl libc). 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_c

[PATCH] libgo: Explicitly define SYS_timer_settime for 32-bit musl targets

2022-07-28 Thread soeren--- via Gcc-patches
From: Sören Tempel On 32-bit systems, musl only defines SYS_timer_settime32 not SYS_timer_settime. This causes the following compilation error: os_linux.go:251:30: error: reference to undefined name '_SYS_timer_settime' 251 | return int32(syscall(_SYS_timer_set

[PATCH] libgo: make match.sh POSIX-shell compatible

2022-07-19 Thread soeren--- via Gcc-patches
From: Sören Tempel The `(( expression ))` syntax is a Bash extension and not supported by POSIX shell [1]. However, the arithmetic expressions used by the gobuild() function can also be expressed using arithmetic POSIX expansions with `$(( expression ))` [2]. Contrary to the Bash extension, arit

[PATCH] mksysinfo: add support for musl libc

2022-06-27 Thread soeren--- via Gcc-patches
From: Sören Tempel This patch addresses two minor compatibility issues with musl libc: * On some architecture (e.g. PowerPC), musl has more than one field prefixed with st_{a,m,c}tim in struct stat. This causes the sed(1) invocation to not work correctly (since it will only replace the first

[PATCH] libgo: Recognize off64_t / loff_t type definition of musl libc

2022-04-24 Thread soeren--- via Gcc-patches
From: Sören Tempel The libgo code assumes both off64_t and loff_t to be present. For example, for the splice(2) function prototype. Similar to glibc, musl libc supports these types but defines them as macros, not as typedefs. Unfortunately, -fdump-go-spec only recognizes types defined using typed

[PATCH v4] libgo: Don't use pt_regs member in mcontext_t

2022-03-10 Thread soeren--- via Gcc-patches
From: Sören Tempel The .regs member is primarily intended to be used in conjunction with ptrace. Since this code is not using ptrace, using .regs is a bad idea. Furthermore, the code currently fails to compile on musl since the pt_regs type (used by .regs) is in an incomplete type which has to be

[PATCH v3] libgo: Don't use pt_regs member in mcontext_t

2022-03-06 Thread soeren--- via Gcc-patches
From: Sören Tempel The .regs member is primarily intended to be used in conjunction with ptrace. Since this code is not using ptrace, using .regs is a bad idea. Furthermore, the code currently fails to compile on musl since the pt_regs type (used by .regs) is in an incomplete type which has to be

[PATCH v2] libgo: Don't use pt_regs member in mcontext_t

2022-03-06 Thread soeren--- via Gcc-patches
From: Sören Tempel The .regs member is primarily intended to be used in conjunction with ptrace. Since this code is not using ptrace, using .regs is a bad idea. Furthermore, the code currently fails to compile on musl since the pt_regs type (used by .regs) is in an incomplete type which has to be

[PATCH v2] x86: Fix -fsplit-stack feature detection via TARGET_CAN_SPLIT_STACK

2022-02-21 Thread soeren--- via Gcc-patches
From: Sören Tempel 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 60953a23d57b13a672f

[PATCH] x86: Fix -fsplit-stack feature detection via TARGET_CAN_SPLIT_STACK

2022-02-20 Thread soeren--- via Gcc-patches
From: Sören Tempel 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 where partially reverted in commit 60953a23d57b13a672

[PATCH v3] Disable -fsplit-stack support on non-glibc targets

2022-01-21 Thread soeren--- via Gcc-patches
From: Sören Tempel The -fsplit-stack option requires the pthread_t TCB definition in the libc to provide certain struct fields at specific hardcoded offsets. As far as I know, only glibc provides these fields at the required offsets. Most notably, musl libc does not have these fields. However, si

[PATCH] libgo: include asm/ptrace.h for pt_regs definition on PowerPC

2022-01-02 Thread soeren--- via Gcc-patches
From: Sören Tempel 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 o

[PATCH v2] Disable -fsplit-stack support on non-glibc targets

2021-12-18 Thread soeren--- via Gcc-patches
From: Sören Tempel The -fsplit-stack option requires the pthread_t TCB definition in the libc to provide certain struct fields at specific hardcoded offsets. As far as I know, only glibc provides these fields at the required offsets. Most notably, musl libc does not have these fields. However, si

[PATCH] Disable -fsplit-stack support on non-glibc targets

2021-12-18 Thread soeren--- via Gcc-patches
From: Sören Tempel The -fsplit-stack option requires the pthread_t TCB definition in the libc to provide certain struct fields at specific hardcoded offsets. As far as I know, only glibc provides these fields at the required offsets. Most notably, musl libc does not have these fields. However, si

[PATCH] stddef.h: add support for musl typedef macro guards

2021-11-26 Thread soeren--- via Gcc-patches
From: Sören Tempel The stddef.h header checks/sets various hardcoded toolchain/os specific macro guards to prevent redefining types such as ptrdiff_t, wchar_t, or size_t. However, without this patch, the file does not check/set the typedef macro guards for musl libc. This causes types such as siz