public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Sören Tempel" <soeren@soeren-tempel.net>
To: Ian Lance Taylor <iant@golang.org>
Cc: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com
Subject: Re: [PATCH v4] libgo: Don't use pt_regs member in mcontext_t
Date: Sat, 02 Apr 2022 10:21:15 +0200	[thread overview]
Message-ID: <28CKR3HNP3V6M.3J4T5E3ITVM1J@8pit.net> (raw)
In-Reply-To: <CAOyqgcWUnVZK5Nd=p9WEDOneoc-0hcZrG+H4A9rRrwKBRoT=hA@mail.gmail.com>

Hi Ian,

Thanks for committing a first fix! Unfortunately, your changes don't
work on ppc64le musl since you are now still using .regs on ppc64le the
include of asm/ptrace.h (as added in the v1 of my patch) is missing.
Hence, your patch fails to compile on ppc64le musl with the following
error message:

	go-signal.c:230:63: error: invalid use of undefined type 'struct pt_regs'
	  230 |         ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip;

If you want to continue using .regs on ppc64le an include of
asm/ptrace.h is needed since both glibc and musl declare `struct
pt_regs` as an incomplete type (with glibc asm/ptrace.h is included
indirectly by other headers used by go-signal.c it seems).

See https://gcc.gnu.org/pipermail/gcc-patches/2022-January/587520.html

Would be nice if this could be fixed :)

Sincerely,
Sören

Ian Lance Taylor <iant@golang.org> wrote:
> On Thu, Mar 31, 2022 at 9:41 AM Sören Tempel <soeren@soeren-tempel.net> wrote:
> >
> > Ping.
> >
> > Would be nice to get this integrated since this one of the changes needed to
> > make gccgo work with musl libc. Let me know if the patch needs to be revised
> > further.
> 
> I went with a simpler solution, more verbose but easier to read.  Now
> committed to mainline.  Please let me know if you have any problems
> with this.  Thanks.
> 
> Ian
> fad0ecb68c08512ac24852b6d5264cdb9809dc6d
> diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
> index afaccb0e9e6..f93eaf48e28 100644
> --- a/gcc/go/gofrontend/MERGE
> +++ b/gcc/go/gofrontend/MERGE
> @@ -1,4 +1,4 @@
> -7f33baa09a8172bb2c5f1ca0435d9efe3e194c9b
> +45108f37070afb696b069768700e39a269f1fecb
>  
>  The first line of this file holds the git revision number of the last
>  merge done from the gofrontend repository.
> diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c
> index 0cb90304730..9c919e1568a 100644
> --- a/libgo/runtime/go-signal.c
> +++ b/libgo/runtime/go-signal.c
> @@ -231,7 +231,14 @@ getSiginfo(siginfo_t *info, void *context __attribute__((unused)))
>  #elif defined(__alpha__) && defined(__linux__)
>  	ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.sc_pc;
>  #elif defined(__PPC__) && defined(__linux__)
> +	// For some reason different libc implementations use
> +	// different names.
> +#if defined(__PPC64__) || defined(__GLIBC__)
>  	ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip;
> +#else
> +	// Assumed to be ppc32 musl.
> +	ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.gregs[32];
> +#endif
>  #elif defined(__PPC__) && defined(_AIX)
>  	ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.jmp_context.iar;
>  #elif defined(__aarch64__) && defined(__linux__)
> @@ -347,6 +354,7 @@ dumpregs(siginfo_t *info __attribute__((unused)), void *context __attribute__((u
>  		mcontext_t *m = &((ucontext_t*)(context))->uc_mcontext;
>  		int i;
>  
> +#if defined(__PPC64__) || defined(__GLIBC__)
>  		for (i = 0; i < 32; i++)
>  			runtime_printf("r%d %X\n", i, m->regs->gpr[i]);
>  		runtime_printf("pc  %X\n", m->regs->nip);
> @@ -355,6 +363,16 @@ dumpregs(siginfo_t *info __attribute__((unused)), void *context __attribute__((u
>  		runtime_printf("lr  %X\n", m->regs->link);
>  		runtime_printf("ctr %X\n", m->regs->ctr);
>  		runtime_printf("xer %X\n", m->regs->xer);
> +#else
> +		for (i = 0; i < 32; i++)
> +			runtime_printf("r%d %X\n", i, m->gregs[i]);
> +		runtime_printf("pc  %X\n", m->gregs[32]);
> +		runtime_printf("msr %X\n", m->gregs[33]);
> +		runtime_printf("cr  %X\n", m->gregs[38]);
> +		runtime_printf("lr  %X\n", m->gregs[36]);
> +		runtime_printf("ctr %X\n", m->gregs[35]);
> +		runtime_printf("xer %X\n", m->gregs[37]);
> +#endif
>  	  }
>  #elif defined(__PPC__) && defined(_AIX)
>  	  {

  reply	other threads:[~2022-04-02  8:21 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-02 16:37 [PATCH] libgo: include asm/ptrace.h for pt_regs definition on PowerPC soeren
2022-02-20 10:43 ` Sören Tempel
2022-02-21 17:25   ` [gofrontend-dev] " Ian Lance Taylor
2022-03-06 12:49     ` Sören Tempel
2022-03-06 15:22     ` Rich Felker
2022-03-06 16:59       ` Rich Felker
2022-02-20 11:01 ` Andreas Schwab
2022-03-06 18:59 ` [PATCH v2] libgo: Don't use pt_regs member in mcontext_t soeren
2022-03-06 21:21   ` Rich Felker
2022-03-07  7:09     ` [PATCH v3] " soeren
2022-03-07 22:59       ` Ian Lance Taylor
2022-03-08 13:23         ` Rich Felker
2022-03-09  7:26         ` Sören Tempel
2022-03-09 11:52           ` Rich Felker
2022-03-11  7:34             ` [PATCH v4] " soeren
2022-03-31 16:41               ` Sören Tempel
2022-03-31 20:26                 ` Ian Lance Taylor
2022-04-02  8:21                   ` Sören Tempel [this message]
2022-04-03  2:02                     ` Ian Lance Taylor
2022-04-03  9:28                       ` Sören Tempel
2022-04-11 17:25                         ` Sören Tempel
2022-04-11 17:35                           ` Ian Lance Taylor
2022-04-11 18:28                             ` Sören Tempel
2022-04-14 22:15                               ` Ian Lance Taylor
2022-04-21  0:50                                 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=28CKR3HNP3V6M.3J4T5E3ITVM1J@8pit.net \
    --to=soeren@soeren-tempel.net \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gofrontend-dev@googlegroups.com \
    --cc=iant@golang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).