public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* __register_frame_info & shared library compatibility
@ 1999-04-06 14:00 Eric Kidd
  1999-04-06 14:16 ` Zack Weinberg
                   ` (2 more replies)
  0 siblings, 3 replies; 124+ messages in thread
From: Eric Kidd @ 1999-04-06 14:00 UTC (permalink / raw)
  To: egcs; +Cc: otaylor

First, some background. I run Red Hat Linux 5.2, and build binaries for a
couple of projects involving shared libraries. I also maintain and upgrade
a number of Linux systems with locally compiled software.

egcs is starting to cause problems for me--or more precisely, the way
people *use* egcs is starting to cause problems for me. Let's start with
the latest problem I've encountered:

On Tue, Apr 06, 1999 at 11:23:23AM -0400, Owen Taylor wrote:
> Not true. As has been explained a couple of times here before, these
> RPM's are linked against glibc2.0. However, they are compiled against
> egcs. (The version of egcs shipped with 5.2, in fact)
>
> The consequence of the second thing is that you can't use those libraries
> with applications compiled with gcc, so if you want to compile other
> GNOME applications against these libraries, you'll temporarily have to
> make egcs your default compiler.

So here's the scenario, as best I understand it. My hypothetical system
initially contains:

 Object      Soname           Compiler
 ------      ------           --------
 glibc 2.0   libc.so.6        gcc 2.7.2.3
 gtk+ 1.2    libgtk-1.2.so.0  gcc 2.7.2.3
 randomapp   N/A              gcc 2.7.2.3 (linked against glibc and gtk+)

Now, as I understand it, the purpose of sonames is to manage binary
compatibility of shared objects. Any file providing a soname
(libgtk-1.2.so.0, for example) should be compatible with all other files
that ever provided that soname. If somebody breaks that invariant, then my
system supposedly dies in flames.

As far as I can tell, breaking sonames is (1) incorrect from a technical
perspective, (2) disasterous for users and (3) really unprofessional.

Now, let's pretend that my vendor issues some updated gtk+ packages. These
are a bug fix release--and don't change any APIs--so they still use the
soname 'libgtk-1.2.so.0'. However, my vendor has chosen to compile this
library with egcs:

 Object      Soname           Compiler
 ------      ------           --------
 glibc 2.0   libc.so.6        gcc 2.7.2.3
 gtk+ 1.2    libgtk-1.2.so.0  egcs-1.0.3
 randomapp   N/A              gcc 2.7.2.3 (linked against glibc and gtk+)

In theory, randomapp should still run. After all, ld.so can still find
libraries with the appropriate sonames. But when I try to run randomapp,
things get ugly:

  undefined symbol: __register_frame_info

A little bit of research discovers something nasty: egcs and gcc have
incompatible runtimes, and ld.so can't deal with this gracefully. When you
compile a program with egcs, it pulls in a runtime providing
__register_frame_info. When you compile an application with gcc 2.7, it
pulls in an older runtime that lacks this symbol.

This apparently means that you can't use an egcs-compiled shared library
with a gcc-compiled application. Or am I missing something?

If my understanding is correct, however, my hypothetical system is now
broken. The bugfix upgrade to gtk+ broke binary compatibility for the
soname 'libgtk+-1.2.so.0', with potentially disasterous consequences.

Three questions for the audience:

 1) Am I badly confused? (I often am.)
 2) What happens if I recompile glibc 2.0 with ecgs and install it under
    the soname 'libc.so.6'?
 3) Will any of this cause bad problems in the future, and if so, how
    can these problems be prevented?

Thank you for your time!

Cheers,
Eric

^ permalink raw reply	[flat|nested] 124+ messages in thread
* Re: __register_frame_info & shared library compatibility
@ 1999-04-07  5:14 Mark Kettenis
  1999-04-07  5:33 ` Jeffrey A Law
  1999-04-30 23:15 ` Mark Kettenis
  0 siblings, 2 replies; 124+ messages in thread
From: Mark Kettenis @ 1999-04-07  5:14 UTC (permalink / raw)
  To: law; +Cc: egcs

   From: Jeffrey A Law (law@cygnus.com)

   Back in 1997 we tried _very_ hard to convince Richard Kenner and Richard
   Stallman to keep the old "__register_frame_info" interface in libgcc.a for
   gcc2 for precisely this problem.

I think that you mean "__register_frame" instead of
"__register_frame_info".

   Against our recommendations, the interface was removed from gcc2.8.

The "__register_frame" interface was never included in any official
FSF release of gcc before 2.8.  Back then, egcs was still
"experimental" which was probably the reason why Kenner didn't want to
include the (broken) "__register_frame" interface that was part of
egcs 1.0 in gcc 2.8.  However, compatibility for the old
"__register_frame" was included in gcc 2.8.1.  This has not been
noticed by a lot of people since, where the "__register_frame_info"
and "__register_frame" functions are part of the same object module in
egcs's libgcc.a, they are in different modules in gcc's libgcc.a.
This was exactly why 

However, this issue is irrelevant for the current
"__register_frame_info & shared library compatibility" discussion.
The way "__register_frame_info" is referenced in 2.8 <= gcc <= 2.8.1
and 1.0.3 <= egcs <= 1.1.1 is in principle the same.  The problem is
indeed that egcs 1.1.2 now puts only a weak reference to
"__register_frame_info" in crtstuff.  This means that "du moment" one
recompiles a shared library that previously contained
"__register_frame_info" it probably does not anymore, and programs
linked with that library stop running.

Now, things get really complicated because of the egcs/Linux
``releases''.  In an attempt to fix problems the author has messed
around with the way "__register_frame_info" is used in the varied
egcs-1.1.1/Linux ``releases''.  This might mean that some people that
use these versions will experience the same problems, but report that
they're using egcs-1.1.1 instead of egcs-1.1.2.  IMHO we have to
prevent that this happens again for egcs-1.1.2, and discourage the
author to release any "fixed" version of egcs-1.1.2.

It is probably not a bad idea to revert the weak reference to
"__register_frame_info" patch in egcs-1.1.2.  It may result in larger
executables with glibc 2.0, but at least we get rid of the shared
library compatibility problem.  For glibc 2.1 things shouldn't matter
since "__register_frame_info" is exported from libc, which by default
every program and shared library is linked against.

Mark

P.S. I haven't tested this, but using

   "-Wl,-u __register_frame_info"

when rebuilding a shared library with egcs-1.1.2 (or egcs-1.1.1/Linux)
will probably avoid the problems discussed in this thread.

^ permalink raw reply	[flat|nested] 124+ messages in thread
* Re: __register_frame_info & shared library compatibility
@ 1999-04-09  4:49 Mark Kettenis
  1999-04-10  1:41 ` Jeffrey A Law
  1999-04-30 23:15 ` Mark Kettenis
  0 siblings, 2 replies; 124+ messages in thread
From: Mark Kettenis @ 1999-04-09  4:49 UTC (permalink / raw)
  To: zack; +Cc: egcs, law

Here is a rather long mail, but I hope that people who want a real
solution to the __register_frame_info & shared library compatibility
problem will take the time to read it.  If you think I'm wrong, please
tell me!

   Leaving the patch out causes a different set of people problems,
   namely the ones that want to compile stuff with egcs-1.1.x and have it
   port over to systems with gcc 2.7-compiled libc.

OK, here are the facts as I understand them.  I only look at C
programs (that should not explicitly be using exceptions).  Binary
compatibility for C++ should be OK if they use the right shared
libstdc++.

gcc 2.7 = all sub-versions of gcc 2.7

gcc 2.8 = all sub-versions of gcc 2.8

egcs 1.1 = egcs-1.1 or egcs-1.1.1 and probably egcs-1.0.3

* All shared libraries compiled with gcc 2.7 do not contain or
  reference __register_frame_info.

* GNU libc compiled with gcc 2.8, egcs-1.1 should not contain or
  reference __register_frame_info [1].

* All other shared libraries compiled with gcc 2.8 or egcs-1.1 do
  contain __register_frame_info, except when they are linked against
  an other shared library that contains __register_frame_info.  They
  will all reference __register_frame_info.

* All shared libraries compiled with egcs-1.1.2 do not contain
  __register_frame_info, but have a weak reference to
  __register_frame_info.

* All programs compiled with gcc 2.7 do not contain or reference
  __register_frame_info.

* All programs compiled with gcc 2.8 or egcs-1.1 and linked
  only against libc contain and reference __register_frame_info.

* All programs compiled with gcc 2.8 or egcs-1.1 and linked against an
  other shared library besides libc do not contain
  __register_frame_info but do reference __register_frame_info.

* All programs compiled with egcs 1.1.2 do not contain
  __register_frame_info but have a weak reference to
  __register_frame_info.

Now there are a few possibilities where programs will not run:

* Any program built with gcc 2.8 or egcs-1.1 linked against an other
  shared library besides libc will not run on a system where this
  shared library was compiled with gcc 2.7 or egcs-1.1.2.

* Any program built with gcc 2.8 or egcs-1.1 linked against lib A
  where lib A was linked against lib B will not run on a system where
  lib A was not linked against lib B.

The last case is a bit far-fetched and I don't think that we should
care about it.  The first case is an unacceptable problem.

How can it be solved:

* Revert the weak __register_frame_info patch.  This solves the
  problem where the shared library was compiled with egcs-1.1.3, but
  does not solve the problem for shared libraries compiled with gcc
  2.7.  Moreover programs built with egcs-1.1.3 linked against a
  library other than libc compiled with gcc 2.8 or egcs will also not
  work with shared libraries compiled with gcc 2.7.

* Keep the weak __register_frame_info patch.  Tell people to link
  their shared libraries with the -u __register_frame_info linker
  option, or put it in the specs.

* Make crtbegin.o have a weak reference to __register_frame_info, and
  crtbeginS.o have an ordinary reference to __register_frame_info.

The third solution is probably the best one, but I don't know if all
ELF targets have a separate crtbegin.o and crtbeginS.o.

The second solution would also work.  Putting the -u option in the
specs has the advantage that it does not require any user
interaction.  However this does not work if people invoke the linker
directly.  Not putting it in the specs makes it possible for people
to omit it when they are changing the shared libraries ABI anyway.  It
should be throughly documented, but since a lot of people will not
read the documentation it will lead to a lot of "bug"-reports.

The first option keeps things as they were before egcs 1.1.2.

Note that this discussion is rather specific to Linux with glibc 2.0.
Linux with glibc 2.1 has no problems with __register_frame_info,
because __register_frame_info is included in glibc's ABI.  I don't
know how things work for the old ELF libc (libc5).

Other targets that use ELF will have similar problems, although they
might not be detected because there are less people distributing
binaries for these targets.  (The various BSD variants come to mind
where one typically builds the entire tree with only one compiler).
If it is no problem for such a target to break binary compatibility,
using the weak __register_frame_info patch as in egcs-1.1.2 is the
right thing to do.  Otherwise one of the options mentioned above
should probably be used there too.  For new ELF targets the weak
__register_frame_info patch is the right thing to do, both for
programs and shared libraries.

   I don't believe there is a right answer.

It is probably not possible to make absolutely sure that nobody will
have __register_frame_info problems anymore, but I think it is
possible to avoid problems in the more common cases.

Mark

[1] I'm not sure if this is really the case, because people always
tend to find ways to break things, but a lot of effort was made to
make sure that this is the case.

^ permalink raw reply	[flat|nested] 124+ messages in thread
* __register_frame_info & shared library compatibility
@ 1999-04-14  5:58 Mark Kettenis
  1999-04-14 14:15 ` Jeffrey A Law
  1999-04-30 23:15 ` Mark Kettenis
  0 siblings, 2 replies; 124+ messages in thread
From: Mark Kettenis @ 1999-04-14  5:58 UTC (permalink / raw)
  To: law; +Cc: egcs, zack

   From: Jeffrey A Law (law@cygnus.com)
   Date: Tue, 13 Apr 1999 21:57:56 -0600
 
     > Please note the wording: "upgrade to a glibc that was not built with
     > egcs".  As long as the official libc binaries shipped by the
     > distributions are built by gcc 2.7, egcs MUST match gcc 2.7's ABI for
     > C programs.  That is what the patch achieves.  And we told the
     > distributions to use gcc 2.7 until they switch to glibc 2.1, so this
     > will continue to be a problem.
   OK.  This kind of compatibility is not a priority and never has been.  We've
   always known this would not work.

I don't think there are many people that are aware of this.

   If you can find a solution that works in both worlds, then great.
   But I do not believe one exists.  And in the absence of a perfect
   solution we must continue be compatible with our own releases over
   compatibility with gcc-2.7.

What about my suggestion to use weak references to
__register_frame_info and __deregister_frame_info in crtbegin.o and
normal (non-weak) references in crtbeginS.o?

   At this point I'm still planning to remove the patch and make an
   egcs-1.1.3 release.

Unless you think the solution suggested above is viable, and we can
test it on short term, that's indeed the only right solution (sorry Zack).

Mark

^ permalink raw reply	[flat|nested] 124+ messages in thread
* Re: __register_frame_info & shared library compatibility
@ 1999-04-21 19:14 N8TM
  1999-04-30 23:15 ` N8TM
  0 siblings, 1 reply; 124+ messages in thread
From: N8TM @ 1999-04-21 19:14 UTC (permalink / raw)
  To: obrien, egcs; +Cc: egcs

In a message dated 4/21/99 11:55:19 AM Pacific Daylight Time, obrien@NUXI.com 
writes:

> X   Thou shalt foreswear, renounce, and abjure the vile heresy which
>      claimeth that ``All the world's a VAX'', and have no commerce with
>      the benighted heathens who cling to this barbarous belief, that
>      the days of thy program may be long even though the days of thy
>      current machine be short.
Well, there's some truth in it.  We're still running VAX, and they've seen 
fit to support something resembling standard C and a Fortran with more g77 
compatibility.

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

end of thread, other threads:[~1999-04-30 23:15 UTC | newest]

Thread overview: 124+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-06 14:00 __register_frame_info & shared library compatibility Eric Kidd
1999-04-06 14:16 ` Zack Weinberg
1999-04-06 14:52   ` Eric Kidd
1999-04-06 15:16     ` Zack Weinberg
1999-04-06 15:39       ` Eric Kidd
1999-04-06 15:51         ` Zack Weinberg
1999-04-06 16:14           ` Eric Kidd
1999-04-30 23:15             ` Eric Kidd
1999-04-07  1:35           ` Andreas Schwab
1999-04-07  6:32             ` Zack Weinberg
1999-04-30 23:15               ` Zack Weinberg
1999-04-30 23:15             ` Andreas Schwab
1999-04-30 23:15           ` Zack Weinberg
1999-04-30 23:15         ` Eric Kidd
1999-04-30 23:15       ` Zack Weinberg
1999-04-30 23:15     ` Eric Kidd
1999-04-06 16:58   ` Jeffrey A Law
1999-04-06 17:35     ` Zack Weinberg
1999-04-06 17:55       ` H.J. Lu
1999-04-30 23:15         ` H.J. Lu
1999-04-07  2:10       ` Jeffrey A Law
1999-04-07  6:29         ` Zack Weinberg
1999-04-07  6:53           ` alex.buell
1999-04-30 23:15             ` alex.buell
1999-04-30 23:15           ` Zack Weinberg
1999-04-30 23:15         ` Jeffrey A Law
1999-04-30 23:15       ` Zack Weinberg
1999-04-30 23:15     ` Jeffrey A Law
1999-04-30 23:15   ` Zack Weinberg
1999-04-06 17:04 ` Jeffrey A Law
1999-04-30 23:15   ` Jeffrey A Law
1999-04-30 23:15 ` Eric Kidd
1999-04-07  5:14 Mark Kettenis
1999-04-07  5:33 ` Jeffrey A Law
1999-04-07 18:11   ` John Polstra
1999-04-07 23:36     ` Jeffrey A Law
1999-04-08  9:57       ` Jamie Lokier
1999-04-08 10:31         ` H.J. Lu
1999-04-08 12:44           ` Jeffrey A Law
1999-04-08 12:49             ` Jamie Lokier
1999-04-08 12:57               ` H.J. Lu
1999-04-08 13:12                 ` Jeffrey A Law
1999-04-08 13:24                   ` Jamie Lokier
1999-04-08 13:31                     ` Jeffrey A Law
1999-04-08 13:42                       ` Jamie Lokier
1999-04-08 13:54                         ` Jeffrey A Law
1999-04-30 23:15                           ` Jeffrey A Law
1999-04-30 23:15                         ` Jamie Lokier
1999-04-30 23:15                       ` Jeffrey A Law
1999-04-08 14:38                     ` Eric Kidd
1999-04-30 23:15                       ` Eric Kidd
1999-04-30 23:15                     ` Jamie Lokier
1999-04-30 23:15                   ` Jeffrey A Law
1999-04-30 23:15                 ` H.J. Lu
1999-04-08 13:02               ` Jeffrey A Law
1999-04-30 23:15                 ` Jeffrey A Law
1999-04-30 23:15               ` Jamie Lokier
1999-04-08 12:55             ` Jamie Lokier
1999-04-08 13:01               ` H.J. Lu
1999-04-08 13:25                 ` Jeffrey A Law
1999-04-08 13:33                   ` Jamie Lokier
1999-04-08 13:47                     ` Jeffrey A Law
1999-04-30 23:15                       ` Jeffrey A Law
1999-04-30 23:15                     ` Jamie Lokier
1999-04-30 23:15                   ` Jeffrey A Law
1999-04-30 23:15                 ` H.J. Lu
1999-04-08 13:05               ` Jeffrey A Law
1999-04-30 23:15                 ` Jeffrey A Law
1999-04-30 23:15               ` Jamie Lokier
1999-04-30 23:15             ` Jeffrey A Law
1999-04-30 23:15           ` H.J. Lu
1999-04-08 12:28         ` Jeffrey A Law
1999-04-30 23:15           ` Jeffrey A Law
1999-04-21 11:53         ` David O'Brien
1999-04-21 12:00           ` Jamie Lokier
1999-04-21 13:02             ` David O'Brien
1999-04-21 13:20               ` Joe Buck
1999-04-21 13:33                 ` Marc Espie
1999-04-22 22:29                   ` Jeffrey A Law
1999-04-30 23:15                     ` Jeffrey A Law
1999-04-30 23:15                   ` Marc Espie
1999-04-30 23:15                 ` Joe Buck
1999-04-30 23:15               ` David O'Brien
1999-04-30 23:15             ` Jamie Lokier
1999-04-30 23:15           ` David O'Brien
1999-04-30 23:15         ` Jamie Lokier
1999-04-08 14:56       ` John Polstra
1999-04-08 15:58         ` Jeffrey A Law
1999-04-30 23:15           ` Jeffrey A Law
1999-04-09 13:01         ` Philipp Thomas
1999-04-30 23:15           ` Philipp Thomas
1999-04-30 23:15         ` John Polstra
1999-04-30 23:15       ` Jeffrey A Law
1999-04-30 23:15     ` John Polstra
1999-04-30 23:15   ` Jeffrey A Law
1999-04-30 23:15 ` Mark Kettenis
1999-04-09  4:49 Mark Kettenis
1999-04-10  1:41 ` Jeffrey A Law
1999-04-10  6:41   ` Zack Weinberg
1999-04-11 21:21     ` Jeffrey A Law
1999-04-30 23:15       ` Jeffrey A Law
1999-04-30 23:15     ` Zack Weinberg
1999-04-10  8:28   ` Mark Kettenis
1999-04-11 21:25     ` Jeffrey A Law
1999-04-12  6:15       ` Zack Weinberg
1999-04-13 21:05         ` Jeffrey A Law
1999-04-13 23:16           ` Zack Weinberg
1999-04-13 23:38             ` Jeffrey A Law
1999-04-30 23:15               ` Jeffrey A Law
1999-04-30 23:15             ` Zack Weinberg
1999-04-30 23:15           ` Jeffrey A Law
1999-04-30 23:15         ` Zack Weinberg
1999-04-30 23:15       ` Jeffrey A Law
1999-04-30 23:15     ` Mark Kettenis
1999-04-30 23:15   ` Jeffrey A Law
1999-04-30 23:15 ` Mark Kettenis
1999-04-14  5:58 Mark Kettenis
1999-04-14 14:15 ` Jeffrey A Law
1999-04-14 14:57   ` Mark Kettenis
1999-04-30 23:15     ` Mark Kettenis
1999-04-30 23:15   ` Jeffrey A Law
1999-04-30 23:15 ` Mark Kettenis
1999-04-21 19:14 N8TM
1999-04-30 23:15 ` N8TM

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