From c1408c2e323bf724db3bb8b1523e4cf5848c7e63 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 d30d1603adc..fc01e04e4a1 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 -- 2.34.1