This is the mail archive of the
mailing list for the libstdc++ project.
Re: V3 static data in classes vs AIX
>>>>> "Jason" == Jason Merrill <email@example.com> writes:
Jason> I disagree. The bug here is that COMMON symbols are not
Jason> combined between shared libraries by default on AIX. This
Jason> will break anything that uses COMMON, not just this use for
Let's argue independently of whether the AIX behavior is correct. On
AIX, it's what we're stuck with.
Do we use COMMON elsewhere in the compiler, other than to mirror
COMDAT, for things like templates and local static variables?
The point is that even if COMMON did what we wanted it to, we're
already forcing users to do explicit instantiations. With the current
code, we're trying to be helpful for certain "simple" cases. With the
result that a user that adds `= 0' to a static data member definition
suddenly has to explicitly instantiate the variable. That's going to
be surprising behavior, since the user knows that there is no semantic
difference in adding the initializer. Even that adding `= 1' causes a
change is confusing. Much easier to explain is "on this target, you
need to use explicit instantiation."
Jason> Non-ELF targets that are not broken in this way can still
Jason> benefit from automatic instantiation of zero- or
Jason> dynamically-initialized template statics.
This is where we critically disagree. I don't think that users are
benefiting from the current behavior; we're being bizarrely
inconistent without completely solving their problem. Much more
honest is to simply admit that we didn't do what it takes to make C++
work automatically on their platform, and explain how they can deal
with it, until and unless we get our act together.
We're not doing the users any favors by making their code fragile --
by making the change of an initializer change whether or not explicit
instantiation is required.
Maybe I would feel differently if you convince me that there a high
percentage of programs that would need explicit instantiations under
my scheme do not need them *at all* under the current scheme, i.e., do
not have any variables that are not zero-initialized. But, I know
that in my own code such a program would be very rare.
Jason> I think it would make sense to add a target macro for AIX
Jason> to say that COMMONs are not always combined, and
Jason> conditionally disable the code in question.
I would argue against anything that further complicates the way we
handle these need-to-be-merged thingies. There's the intrinsic
complexity involved in supporting COMDAT vs. non-COMDAT systems, but
there's no need to make it worse than that.
Systems that have only COMMON really need a template prelinker, or
Jason> Of course, we can run into similar trouble on ELF with
Yes, -Bsymbolic and C++ really just don't mix. Even dlopen doesn't
really work right.
Mark Mitchell firstname.lastname@example.org
CodeSourcery, LLC http://www.codesourcery.com