From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 5908D385841B for ; Fri, 4 Nov 2022 18:17:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5908D385841B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667585823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TFD4ohIz70/8Lc0BtWDFtzuLcdzRH4C+xkcOoHzDJOE=; b=N4BY/jytdt07VLDJTl/ZkktSuVJj4+74MtFlfdGg7lfCMrP8DVPiNMDuuyEjm6oDil1Wqq m1wM+zSOj/eYEFpR/wpc0tdXTm0Kneix3XdVRKjZ2fD25UQNjmykdqkHeqq2lJS0is8iYw tBhqHDxpq/Iu1lju0Jl7INGqkACfMY0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-YWq_PTKSMsWM8w--eHWDjA-1; Fri, 04 Nov 2022 14:17:00 -0400 X-MC-Unique: YWq_PTKSMsWM8w--eHWDjA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A29D085A59D; Fri, 4 Nov 2022 18:16:59 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5E254EA4C; Fri, 4 Nov 2022 18:16:57 +0000 (UTC) From: Florian Weimer To: Patrick Palka Cc: Patrick Palka via Gcc-patches , libstdc++@gcc.gnu.org Subject: Re: [PATCH 2/2] libstdc++: Move stream initialization into compiled library [PR44952] References: <20221104150525.2968778-1-ppalka@redhat.com> <20221104150525.2968778-2-ppalka@redhat.com> <87eduizmhj.fsf@oldenburg.str.redhat.com> Date: Fri, 04 Nov 2022 19:16:56 +0100 In-Reply-To: (Patrick Palka's message of "Fri, 4 Nov 2022 13:47:10 -0400 (EDT)") Message-ID: <87o7tmy487.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * 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 and into the compiled library on targets that support >> > the init_priority attribute. This means that 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 >> , 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