Bug 2188013

Summary: gcc-toolset-13-gcc: Revert <iostream> initialization changes for hybrid linkage
Product: Red Hat Enterprise Linux 9 Reporter: Florian Weimer <fweimer>
Component: gcc-toolset-12-gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED ERRATA QA Contact: Václav Kadlčík <vkadlcik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.3CC: jakub, jwakely, markobri, mpolacek, ppalka, vkadlcik
Target Milestone: rcKeywords: Bugfix, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gcc-toolset-13-gcc-13.1.1-4.1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2188014 (view as bug list) Environment:
Last Closed: 2023-11-07 08:34:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2188014    
Attachments:
Description Flags
Revert ios init changes none

Description Florian Weimer 2023-04-19 13:28:04 UTC
We cannot assume that libstdc++.so.6 performs std::cout etc. initialization, so the GTS header files need to keep using the old initialization model. Otherwise, things will build and link just fine, but the initialization might not happen as expected.

Note: Needs to be transitioned to the gcc-toolset-13-gcc component once that exists.

Comment 1 Florian Weimer 2023-04-19 13:32:44 UTC
Jakub suggests that we could pull in an ELF constructor in libstdc++_nonshared.a instead (with an appropriate early priority).

Comment 2 Marek Polacek 2023-06-07 20:58:47 UTC
Do we want to revert these two commits or some other ones as well?
9a41d2cdbcd2af77a3a91a840a3a13f0eb39971b
4e4e3ffd10f53ef71696bc728ab40258751a2df4

Comment 3 Jonathan Wakely 2023-06-08 10:12:17 UTC
Created attachment 1969733 [details]
Revert ios init changes

Makes sense to me.

I think you also want 87de39e4c3686535728f3a347f772e73af4cf262 (as the first one to revert).

There will be conflicts though, so I've attached a patch that does it cleanly.

Comment 4 Jakub Jelinek 2023-06-08 10:15:14 UTC
I believe what is in the patch should work fine.
If not, the reversions would break the gcc13-libstdc++-compat.patch though.

Comment 5 Marek Polacek 2023-06-08 13:19:08 UTC
Thanks Jonathan.

(In reply to Jakub Jelinek from comment #4)
> I believe what is in the patch should work fine.

the patch = Jon's #c3 patch?  Or gcc13-libstdc++-compat.patch and you actually don't want the reversion?

> If not, the reversions would break the gcc13-libstdc++-compat.patch though.

Relatedly, I see
+_ZSt21ios_base_library_initv FUNC GLOBAL DEFAULT
in our 'diff -up system2vanilla.abilist.diff nonshared.abilist' testing.  Should
_ZSt21ios_base_library_initv be .hidden as well?

Comment 6 Jakub Jelinek 2023-06-08 13:30:22 UTC
I meant gcc13-libstdc++-compat.patch .
What is in there is that if you #include <iostream>, you require _ZSt21ios_base_library_initv symbol, and the object that provides
that symbol (in libstdc++_nonshared.a) should initialize iostreams.
So, instead of the old initializing per TU, it is now effectively initialization per library or binary.  While upstream has it
in libstdc++.so.6 only which does that initialization.

I think the symbol shouldn't be hidden, we don't make the symbols from the system libstdc++.so.6 to libstdc++.so.6.0.32 diff hidden.
If some other library exports it already and you link against that library, the libstdc++_nonshared.a object might not be linked in,
sure, but then the dependent library should have initialized iostreams before running current library's constructors.

Comment 7 Marek Polacek 2023-06-08 17:12:28 UTC
Ok, let's give it (= no reversion) a shot.  I'm also going to keep _ZSt21ios_base_library_initv non-hidden.
If we run into issues, we can consider reverting the optimization again.  Thanks.

Comment 15 errata-xmlrpc 2023-11-07 08:34:40 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (gcc-toolset-13-gcc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2023:6479