This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Darwin] Patch, take 2: enable linkonce support for Darwin


On Jan 30, 2004, at 11:16 AM, Kevin B. Hendricks wrote:

Hi Matt,

A quick general question about this patch, the OpenOffice.org porters to MacOSX ran into serious problems with "coalesced" symbols that were not fixed until the most recent Apple version of GCC 3.3. The problem was most easily seen when linking in libstlport (STL) and finding that depending on the mix of the compiler optimization levels used we generated strange linker failures related to coalesced symbols not being present in each linker section (or only in the wrong section?)

For example, rebuilding one library with -O0 -g for debugging purposes seemed to create problems when trying to link with other libraries that typically did not exist if everything was compiled at -O2 or higher. Typically the error message looked like the following:

> ./STLport-4.5/lib/libstlport_gcc.dylib)
> ld: huh.o illegal reference for -dynamic code (section difference
> reference from section (__TEXT,__eh_frame) relocation entry (82) to
> symbol: _STL::__node_alloc<(bool)1, (int)0>::allocate(unsigned long)
> defined in dylib: ./STLport-4.5/lib/libstlport_gcc.dylib)

The GNU Darwin compiler gcc 3.3 *never* seemed to have the same problems at that time that the Apple compiler had until the August gcc 3.3 update (but it did have problems with static objects in templates and other issues).

Has this problem of mixing optimization levels and potentially missing related coalesced been tested in the new Darwin build with your patch in place to make sure the same problem that existed until recently in Apple's gcc 3.3 is not being introduced mistakenly into Darwin?

I haven't put any test cases like that into the dg test suite, because I'm not enough of a dg expert to know how to write complicated test cases that involve multiple dylibs. If anyone can point me to a "writing complicated dg test cases for dummies" tutorial, I'll write better tests.


But a general comment: this is exactly the sort of reason I wanted to redo coalescing, design it more carefully, and get it into the GNU compiler. I want to make sure that this is well tested, that it's reviewed by people outside Apple, and that it's not a set of ad hoc patches that have to get redone every time Apple does an import from the GNU repository. If I introduce any coalescing bugs in the GNU mainline, I'll fix them. Apple quite aware that coalescing has been less reliable than it ought to be, and that's exactly what this is supposed to address.

(The reason you didn't see coalescing bugs in the mainline Darwin compiler is that it didn't have linkonce semantics at all. When you instantiated a template in multiple translation units, you'd get separate copies in each ones. This breaks an awful lot of things. Linkonce semantics aren't just an optimization, they're required for correctness.)

--Matt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]