public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ ABI Issues
@ 2002-08-26 15:18 Mark Mitchell
  2002-08-26 16:18 ` Mike Stump
                   ` (6 more replies)
  0 siblings, 7 replies; 73+ messages in thread
From: Mark Mitchell @ 2002-08-26 15:18 UTC (permalink / raw)
  To: gcc

Our testing and investigation has lead to the discovery of several places
where G++'s class layout still does not match the published ABI
specification.  Other vendors (notably HP and Intel) do match the ABI
specification.  Therefore, the ABI specification is probably not going
to change to validate G++'s behavior.

Therefore, we will have to choose whether or not we want to change G++
to match the specification.

Here are the issues:

1. Tail-padding of bit-fields

  Given:

    struct B { virtual void f(); char i1 : 28; };
    struct D : public B { int i2 : 4; };

  G++ incorrectly packs D::i2 into the four bits of tail-padding in
  B.

  This is not only an ABI divergence, but also an optimization issue.
  G++ generates a copy-constructor for B that performs the bit-masking
  operations required to copy only the bitfield at the end of B, which
  is more expensive than copying the entire word.

2. Tail-padding and virtual base classes

  Given:

    struct A { virtual void f(); char c1; };
    struct B { B(); char c2; };
    struct C : public A, public virtual B {};

  G++ does not pack B into the tail padding of A, as required by the ABI
  specification and as implemented in other compilers.

  G++'s behavior is slightly wasteful of space, but is otherwise correct
  in the abstract.

My expectation is that case 1 is relatively uncommon, but that case 2 is
relatively common.

I propose that we fix G++ to match the ABI, but that we issue warnings
about classes whose layout has changed from GCC 3.2.

If we are going to fix G++, we also have to decide how urgently to do
another release.

Thoughts?

(The flame you're about to send about the fact that we didn't catch this
before GCC 3.2 isn't helpful.  Until we have a comprehensive testsuite
(in the works, as discussed), it's very hard to find these things.  And,
even then, there may be issues.  Several free software distributors pushed
hard for a GCC 3.2 release, and everyone knew that there might be more
problems.)

--
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

^ permalink raw reply	[flat|nested] 73+ messages in thread
* Re: C++ ABI Issues
@ 2002-08-27 10:26 Benjamin Kosnik
  2002-08-27 11:06 ` Ziemowit Laski
                   ` (2 more replies)
  0 siblings, 3 replies; 73+ messages in thread
From: Benjamin Kosnik @ 2002-08-27 10:26 UTC (permalink / raw)
  To: gcc; +Cc: mark

I'll restrain my comments to one area only.

Please, let's use the versioning info that already exists. Currently,
the compiler ABI is tracked with __GXX_ABI_VERSION. For the 3.2.0
release, this value is 102.

If there is to be a -fabi=xxx switch, then please use this information.
The idea of having a "-fabi-newest" is completely relative and useless:
newest from what vantage point? 

-benjamin

^ permalink raw reply	[flat|nested] 73+ messages in thread
* Re: C++ ABI Issues
@ 2002-08-26 20:40 Benjamin Kosnik
  2002-08-26 23:55 ` Mark Mitchell
                   ` (3 more replies)
  0 siblings, 4 replies; 73+ messages in thread
From: Benjamin Kosnik @ 2002-08-26 20:40 UTC (permalink / raw)
  To: mark; +Cc: gcc

Dude. 

> I propose that we fix G++ to match the ABI, but that we issue warnings
> about classes whose layout has changed from GCC 3.2.

> If we are going to fix G++, we also have to decide how urgently to do
> another release.

You seem to be very cavalier about the downstream impacts of changing
the C++ ABI, and what this means for sane tool versioning.

Every time you change the underlying compiler ABI, libstdc++ has to
adapt and meaningfully mark the changing versions.

I do not think doing a g++ release, and bumping __GXX_ABI_VERSION to
103, and changing libstdc++.so.5 to libstdc++.so.6, and updating
GLIBCPP_3.2 to GLIBCPP_3.3, and CXXABI_1.2 to CXXABI_1.3 should happen
every three months. 

Come on. 

You found bugs, great. You fixed the bugs, even better. I bet you
fifty bucks you find more by the end of December, or two tickets to a
Giants home game, whichever is more.

Please, let's not do another release where we have a two week period
to find bugs. That's insanity. Instead, let's actually have some kind
of public, check-in-and-GPL'd ABI testsuite g++ users can cling to and
say, hey! We have an ABI and here's what we are checking.

If I were king, I'd say, finish up the codesourcery ABI tester. Fix
all the bugs you find. Then, do a bug-fix ABI release in a year, after
g++ has successfully shown to be inter-operable with another compiler
so it actually means something.

Sorry if this sounds pissy. I know you are working on the side of
angels, but please. Try not to abuse your considerable power. Let's
try to come up with a long term plan for managing C++ ABI changes, and
stop calling "FIRE!!!" every time there is a bug. Pretty soon nobody
will care.

yours in struggle,
benjamin



^ permalink raw reply	[flat|nested] 73+ messages in thread
* Re: C++ ABI issues
@ 2002-03-18 13:44 mike stump
  0 siblings, 0 replies; 73+ messages in thread
From: mike stump @ 2002-03-18 13:44 UTC (permalink / raw)
  To: bkoz, jason; +Cc: gcc

> To: Benjamin Kosnik <bkoz@redhat.com>
> Cc: gcc@gcc.gnu.org
> From: Jason Merrill <jason@redhat.com>
> Date: Mon, 18 Mar 2002 21:03:45 +0000

> > Why just non-ia64 targets?

> Because for ia64, the ABI is a cross-vendor standard.

Ah, but don't we want as much from the standard for other targets, as
we want for ia64?  If we never treat it this way, can we ever achieve
our goal?  My take is that we should be more interested in all the
other targets than ia64, not less.

> If we bumped the version, we would be incompatible with all other
> compilers, which would subvert the entire point of the ABI.

Bingo, which is why I think we should not.

^ permalink raw reply	[flat|nested] 73+ messages in thread
* Re: C++ ABI issues
@ 2002-03-18 10:30 Benjamin Kosnik
  2002-03-18 13:05 ` Jason Merrill
  0 siblings, 1 reply; 73+ messages in thread
From: Benjamin Kosnik @ 2002-03-18 10:30 UTC (permalink / raw)
  To: gcc, jason


Hey Jason. I've been wondering about this myself. One of the things I
think might be helpful, when thinking about this, would be a detailed
list of ABI changes between gcc-3.0.4 and gcc-3.1.0. I've noticed that
you have started marking ABI-changing patches explicitly: thank you
very much for this, it's very illuminating. I could come up with a
list of library changes, if that would be helpful.

I'm not as up on this stuff as yourself, but it appears as if the
following are a subset of the things that have changed in the FE:

- pointers to cv-qualified member functions
  http://gcc.gnu.org/ml/gcc-patches/2002-02/msg01363.html

- c++/3948
  run destructors for value parms in the caller, pass params by invisible ref
  http://gcc.gnu.org/ml/gcc-patches/2002-03/msg01056.html

- 128-bit ints
  http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00761.html

In addition, it appears as if non-C++ FE work has ABI impacts for some targets:

- mips o32 ABI
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00706.html

> One answer would be to bump the mangling version for non-ia64 targets,
> so that incompatible code will fail to link.

Why just non-ia64 targets?

Won't the major version number change from .3 to .4 in libstdc++-v3
also prevent linkage?

I'd feel better if there was a better mechanism for testing the C++
ABI. Thoughts? 

In a related note, there doesn't seem to be a plan in place to test
the C++ library versioning. Even if it's not documented, it would be
nice to have some procedure that's documented.

best,
benjamin

^ permalink raw reply	[flat|nested] 73+ messages in thread
* C++ ABI issues
@ 2002-03-17 16:33 Jason Merrill
  0 siblings, 0 replies; 73+ messages in thread
From: Jason Merrill @ 2002-03-17 16:33 UTC (permalink / raw)
  To: gcc; +Cc: Jason Merrill

There are several C++ ABI incompatibilities between 3.0.x and 3.1.x.  Most
of these will not prevent code built with different compilers from linking
together, but will cause a resulting program to fail in obscure ways.  I'm
not happy with this state of affairs, but I'm not sure what to do about
it.  One answer would be to bump the mangling version for non-ia64 targets,
so that incompatible code will fail to link.

Thoughts?

Jason

^ permalink raw reply	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2002-09-23 18:30 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-26 15:18 C++ ABI Issues Mark Mitchell
2002-08-26 16:18 ` Mike Stump
2002-08-26 16:43 ` Zack Weinberg
2002-08-26 21:58   ` Geoff Keating
2002-08-26 16:46 ` Loren James Rittle
2002-08-26 17:10 ` Joe Buck
2002-08-26 18:32   ` David Edelsohn
2002-08-26 18:35     ` David S. Miller
2002-08-26 19:25       ` David Edelsohn
2002-08-26 20:40         ` Per Bothner
2002-08-27 10:08         ` Joe Buck
2002-08-27 11:51           ` Jeff Law
2002-08-28  4:32             ` Richard Earnshaw
2002-08-26 18:47     ` Joe Buck
2002-08-26 23:27   ` Jakub Jelinek
2002-08-26 23:57     ` Mark Mitchell
2002-08-27  7:40     ` Jeff Law
2002-08-27 11:28   ` Phil Edwards
2002-08-27 11:32     ` Joe Buck
2002-08-27 11:43       ` Jan Hubicka
2002-08-27 12:00         ` Gabriel Dos Reis
2002-08-27 15:10           ` Joe Buck
2002-08-27 15:18             ` Gabriel Dos Reis
2002-08-27 12:09         ` Joe Buck
2002-08-27 12:34           ` Gabriel Dos Reis
2002-08-27 11:58       ` Gabriel Dos Reis
2002-08-27 14:50         ` Joe Buck
2002-08-27 15:06           ` Gabriel Dos Reis
2002-08-27 15:21             ` Joe Buck
2002-08-27 15:32               ` Gabriel Dos Reis
2002-08-27 15:46                 ` Joe Buck
2002-08-27 22:28                   ` Gabriel Dos Reis
2002-08-28 10:04                     ` Joe Buck
2002-08-26 19:18 ` Jamie Lokier
2002-08-26 23:44   ` Mark Mitchell
2002-08-27  5:33 ` Nathan Sidwell
2002-08-27  5:58   ` Allan Sandfeld Jensen
2002-08-27  7:32     ` Nathan Sidwell
2002-09-07 13:32     ` David O'Brien
2002-09-22  2:49 ` David O'Brien
2002-09-22 11:15   ` Mark Mitchell
2002-09-23 10:01     ` Joe Buck
2002-09-23 13:04       ` David O'Brien
  -- strict thread matches above, loose matches on Subject: below --
2002-08-27 10:26 Benjamin Kosnik
2002-08-27 11:06 ` Ziemowit Laski
2002-08-27 11:15   ` Mike Stump
2002-08-27 11:27     ` Ziemowit Laski
2002-08-27 11:56       ` Mike Stump
2002-08-27 15:19   ` Toon Moene
2002-09-07 13:33   ` David O'Brien
2002-08-27 14:37 ` Joe Buck
2002-08-28  4:41 ` Richard Earnshaw
2002-08-26 20:40 Benjamin Kosnik
2002-08-26 23:55 ` Mark Mitchell
2002-08-27  6:03   ` Daniel Jacobowitz
2002-08-27  6:40   ` Andreas Jaeger
2002-08-27  7:27     ` Jeff Law
2002-08-27  7:49   ` Jeff Law
2002-08-27  7:30 ` Jeff Law
2002-08-27  8:45   ` Mark Mitchell
2002-08-27  9:33     ` Janis Johnson
2002-08-27 14:55       ` Mark Mitchell
2002-08-27  9:50 ` Mark Mitchell
2002-08-27 10:50   ` Devang Patel
2002-08-27 12:02     ` Per Bothner
2002-08-27 10:37 ` Mike Stump
2002-03-18 13:44 C++ ABI issues mike stump
2002-03-18 10:30 Benjamin Kosnik
2002-03-18 13:05 ` Jason Merrill
2002-03-18 13:46   ` Mark Mitchell
2002-03-18 14:13   ` Benjamin Kosnik
2002-03-18 15:19     ` Jason Merrill
2002-03-17 16:33 Jason Merrill

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).