public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Iain Sandoe <iain@sandoe.co.uk>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	John David Anglin <dave.anglin@bell.net>,
	Aldy Hernandez <aldyh@redhat.com>,
	Andrew MacLeod <amacleod@redhat.com>,
	Richard Biener <rguenther@suse.de>
Subject: Re: [PATCH] pch: Add support for PCH for relocatable executables
Date: Tue, 9 Nov 2021 13:18:36 +0100	[thread overview]
Message-ID: <20211109121836.GQ2710@tucnak> (raw)
In-Reply-To: <C2CB3CDD-F765-4F79-9F0B-3F57BD18D6F8@sandoe.co.uk>

On Tue, Nov 09, 2021 at 11:40:08AM +0000, Iain Sandoe wrote:
> There were two issues, of which one remains and probably affects all targets.
> 
> 1.  The Darwin PCH memory allocation scheme used a system that works reliably
>     for no-PIE but not for PIE
> 
> .. I hacked in a similar scheme to the mmap one used on Linux .. the suspect stuff
>    there is in choosing some place in the map that is likely to succeed…
> 
>   With that I get passes on all c-family pch.exp (I didn’t try to bootstrap).

Yeah, certainly.

> 2. This problem remains.
> 
>   - if we try to emit a diagnostic when the PCH read-in has failed, it seems that
>    cc1 hangs somewhere in trying to lookup line table info.
> 
>  - this was happening with the Darwin fixed PCH memory address because it
>    was trying to report a fatal error in being unable to read the file (or trying to
>   execute fancy_abort, in response to a segv).

I guess once we:
  /* Read in all the scalar variables.  */
  for (rt = gt_pch_scalar_rtab; *rt; rt++)
    for (rti = *rt; rti->base != NULL; rti++)
      if (fread (rti->base, rti->stride, 1, f) != 1)
        fatal_error (input_location, "cannot read PCH file: %m");

  /* Read in all the global pointers, in 6 easy loops.  */
  for (rt = gt_ggc_rtab; *rt; rt++)
    for (rti = *rt; rti->base != NULL; rti++)
      for (i = 0; i < rti->nelt; i++)
        if (fread ((char *)rti->base + rti->stride * i,
                   sizeof (void *), 1, f) != 1)
          fatal_error (input_location, "cannot read PCH file: %m");
we overwrite the GTY(()) marked global vars including
extern GTY(()) class line_maps *line_table;
with pointers into the area we haven't mapped yet (or if the error happens
after that mmap but before everything is fixed up (e.g. the new relocation
processing), it is no wonder it doesn't work well.

Could we save line_table (and perhaps a few other vars) into non-GTY! copies
of them in ggc-common.c and instead of those fatal_error (input_location, ...)
calls in gt_pch_restore and ggc_pch_read call fatal_pch_error (...) where
void
fatal_pch_error (const char *gmsg)
{
  line_table = saved_line_table;
  // Restore anything else that is needed for fatal_error
  fatal_error (input_location, gmsg);
}

	Jakub


  reply	other threads:[~2021-11-09 12:18 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04 20:02 [PATCH 0/4] config: Allow a host to opt out of PCH Iain Sandoe
2021-11-04 20:02 ` [PATCH 1/4] config: Add top-level flag to disable host PCH Iain Sandoe
2021-11-04 20:02   ` [PATCH 2/4] libstdc++: Adjust build of PCH files accounting configured host support Iain Sandoe
2021-11-04 20:02     ` [PATCH 3/4] libcpp: Honour a configuration without host support for PCH Iain Sandoe
2021-11-04 20:02       ` [PATCH 4/4] c-family, gcc: Allow configuring without " Iain Sandoe
     [not found]     ` <EB9AC754-904B-4877-AD17-94886712C10E@gmail.com>
2021-11-05 23:23       ` [PATCH 2/4] libstdc++: Adjust build of PCH files accounting configured host support Jonathan Wakely
2021-11-05  9:42 ` [PATCH 0/4] config: Allow a host to opt out of PCH Richard Biener
2021-11-05  9:54   ` Jakub Jelinek
2021-11-05 10:31     ` Richard Biener
2021-11-05 15:25       ` Jakub Jelinek
2021-11-05 16:37         ` Iain Sandoe
2021-11-08  7:16           ` Richard Biener
2021-11-08  7:43             ` Iain Sandoe
2021-11-08 11:46           ` Jakub Jelinek
2021-11-08 19:48             ` [PATCH] pch: Add support for PCH for relocatable executables Jakub Jelinek
2021-11-08 21:03               ` John David Anglin
2021-11-09  9:50                 ` Jakub Jelinek
2021-11-09  7:12               ` Richard Biener
2021-11-09  8:07                 ` Iain Sandoe
2021-11-09 11:40                   ` Iain Sandoe
2021-11-09 12:18                     ` Jakub Jelinek [this message]
2021-11-10  8:14                       ` Iain Sandoe
2021-11-10 20:24                         ` Iain Sandoe
2021-11-13 20:32                           ` Iain Sandoe
2021-11-16  8:52                             ` Jakub Jelinek
2021-11-09  9:44                 ` Jakub Jelinek
2021-11-09 11:32                   ` Jakub Jelinek
2021-11-09 12:03                     ` Richard Biener
2021-11-09 12:29                       ` Jakub Jelinek
2021-11-09 14:41                         ` Andrew MacLeod
2021-11-09 14:58                           ` Jakub Jelinek
2021-11-09 15:23                             ` Andrew MacLeod
2021-11-09 15:28                               ` Jakub Jelinek
2021-11-09 18:29                                 ` [COMMITTED] Keep x_range_query NULL for global ranges Andrew MacLeod
2021-11-18  8:04               ` [PATCH] pch, v2: Add support for PCH for relocatable executables Jakub Jelinek
2021-12-02 18:26                 ` Jeff Law
2021-12-06 10:00                 ` Martin Liška
2021-12-06 10:23                   ` [committed] avr: Fix AVR build [PR71934] Jakub Jelinek
2021-12-06 11:28                     ` Martin Liška

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=20211109121836.GQ2710@tucnak \
    --to=jakub@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=dave.anglin@bell.net \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iain@sandoe.co.uk \
    --cc=rguenther@suse.de \
    /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).