public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathaniel Shead <nathanieloshead@gmail.com>
To: Jason Merrill <jason@redhat.com>
Cc: Patrick Palka <ppalka@redhat.com>,
	gcc-patches@gcc.gnu.org, Nathan Sidwell <nathan@acm.org>
Subject: Re: [PATCH v2] c++/modules: Differentiate extern templates and TYPE_DECL_SUPPRESS_DEBUG [PR112820]
Date: Tue, 16 Jan 2024 23:14:44 +1100	[thread overview]
Message-ID: <65a6733a.630a0220.7933a.df29@mx.google.com> (raw)
In-Reply-To: <7c45785c-f1e4-4e90-9a41-497433b7d5f7@redhat.com>

On Mon, Jan 15, 2024 at 06:10:55PM -0500, Jason Merrill wrote:
> On 1/8/24 10:27, Patrick Palka wrote:
> > On Mon, 8 Jan 2024, Nathaniel Shead wrote:
> > > On Thu, Jan 04, 2024 at 03:39:15PM -0500, Patrick Palka wrote:
> > > > On Sun, 3 Dec 2023, Nathaniel Shead wrote:
> > > > > 
> > > > > The TYPE_DECL_SUPPRESS_DEBUG and DECL_EXTERNAL flags use the same
> > > > > underlying bit. This is causing confusion when attempting to determine
> > > > > the interface for a streamed-in class type, since the modules code
> > > > > currently assumes that all DECL_EXTERNAL types are extern templates.
> > > > > However, when -g is specified then TYPE_DECL_SUPPRESS_DEBUG (and hence
> > > > > DECL_EXTERNAL) is marked on various other kinds of declarations, such as
> > > > > vtables, which causes them to never be emitted.
> 
> But a vtable isn't a TYPE_DECL?
> 
> I suspect what you mean is that maybe_suppress_debug_info is setting
> TYPE_DECL_SUPPRESS_DEBUG to try to avoid duplication of debug info for
> classes with vtables, and then the modules code is wrongly assuming that you
> can check DECL_EXTERNAL for TYPE_DECL, and that it's set only if
> CLASSTYPE_INTERFACE_ONLY is also set, which is wrong in this case, so we
> avoid emitting the vtable or anything else for that class.
> 

Ah, right; I definitely misread what was going on.

> It seems unnecessary to start setting DECL_EXTERNAL on the TYPE_DECL to mean
> the exact same thing as CLASSTYPE_INTERFACE_ONLY.  Rather, the modules code
> should stop trying to check DECL_EXTERNAL on a TYPE_DECL.
> 
> Under what circumstances does it make sense for CLASSTYPE_INTERFACE_ONLY to
> be set in the context of modules, anyway?  We probably want to propagate it
> for things in the global module so that various libstdc++ explicit
> instantiations work the same with import std.
> 
> For an class imported from a named module, this ties into the earlier
> discussion about vtables and inlines that hasn't resolved yet in the ABI
> committee.  But it's certainly significantly interface-like.  And I would
> expect maybe_suppress_debug_info to suppress the debug info for such a class
> on the assumption that the module unit has the needed debug info.
> 
> Jason
> 

I didn't consider messing with 'CLASSTYPE_INTERFACE_ONLY' because the
modules code currently always sets 'lang->interface_unknown = true' on
read with the comment "Redetermine interface". But I see now as well
this comment:

  // Interfaceness is recalculated upon reading.  May have to revisit?
  // How do dllexport and dllimport interact across a module?
  // lang->interface_only
  // lang->interface_unknown

So it seems reasonable to reconsider this now. I hadn't considered
declarations in the GMF but I think you're right that we'll want to
propagate it; I guess in general things in the GMF should try to behave
as close to how they would have if they were #included directly in the
importing TU.

I suspect this fix will be more involved but I'll try to wrap my head
around it and see what I can come up with.

  reply	other threads:[~2024-01-16 12:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-03 12:46 [PATCH] c++/modules: Prevent treating suppressed debug info as extern template [PR112820] Nathaniel Shead
2024-01-02 22:52 ` Nathaniel Shead
2024-01-04 20:39 ` Patrick Palka
2024-01-08  9:57   ` [PATCH v2] c++/modules: Differentiate extern templates and TYPE_DECL_SUPPRESS_DEBUG [PR112820] Nathaniel Shead
2024-01-08 11:50     ` Richard Biener
2024-01-08 15:27     ` Patrick Palka
2024-01-15 23:10       ` Jason Merrill
2024-01-16 12:14         ` Nathaniel Shead [this message]
2024-01-17  6:33         ` [PATCH v3] c++/modules: Fix handling of extern templates in modules [PR112820] Nathaniel Shead
2024-01-17 15:51           ` Jason Merrill
2024-01-22 11:04             ` Nathaniel Shead

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=65a6733a.630a0220.7933a.df29@mx.google.com \
    --to=nathanieloshead@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=nathan@acm.org \
    --cc=ppalka@redhat.com \
    /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).