public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: Patrick Palka via Gcc-patches <gcc-patches@gcc.gnu.org>,
	libstdc++@gcc.gnu.org
Subject: Re: [PATCH 2/2] libstdc++: Move stream initialization into compiled library [PR44952]
Date: Fri, 04 Nov 2022 19:16:56 +0100	[thread overview]
Message-ID: <87o7tmy487.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <d9d95eb6-54b1-9a3b-98c2-27ee978fa32b@idea> (Patrick Palka's message of "Fri, 4 Nov 2022 13:47:10 -0400 (EDT)")

* Patrick Palka:

> On Fri, 4 Nov 2022, Florian Weimer wrote:
>
>> * Patrick Palka via Gcc-patches:
>> 
>> > This patch moves the global object for constructing the standard streams
>> > out from <iostream> and into the compiled library on targets that support
>> > the init_priority attribute.  This means that <iostream> no longer
>> > introduces a separate global constructor in each TU that includes it.
>> >
>> > We can do this only if the init_priority attribute is supported because
>> > we need to force that the stream initialization runs first before any
>> > user-defined global initializer in programs that that use a static
>> > libstdc++.a.
>> 
>> I think this breaks initialization of iostreams of shared objects that
>> are preloaded with LD_PRELOAD.  With the constructor, they initialize
>> iostreams once they are loaded via their own ELF constructors (even
>> before libstdc++'s ELF constructors run).  Without the constructor in
>> <iostream>, that no longer happens.
>
> IIUC wouldn't that shared object depend on libstdc++.so and hence
> libstdc++'s constructors would still run before the shared object's?

Hmm, right, we only reorder the symbol binding order, not the
initialization order.  The preloaded object will not participate in a
cycle with libstdc++, so I think this should indeed be a safe change.

Thanks,
Florian


  reply	other threads:[~2022-11-04 18:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 15:05 [PATCH 1/2] c++: correct __has_attribute(init_priority) Patrick Palka
2022-11-04 15:05 ` [PATCH 2/2] libstdc++: Move stream initialization into compiled library [PR44952] Patrick Palka
2022-11-04 15:24   ` Jonathan Wakely
2022-11-04 16:31     ` Patrick Palka
2022-11-04 16:42       ` Jonathan Wakely
2022-11-04 16:57   ` Florian Weimer
2022-11-04 17:47     ` Patrick Palka
2022-11-04 18:16       ` Florian Weimer [this message]
2022-11-15 16:10   ` Hans-Peter Nilsson
2022-11-04 15:55 ` [PATCH 1/2] c++: correct __has_attribute(init_priority) Jason Merrill

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=87o7tmy487.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.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).