binutils 20021107-2

Robert Collins rbcollins@cygwin.com
Sat Nov 9 19:02:00 GMT 2002


On Sun, 2002-11-10 at 12:34, Charles Wilson wrote:


> I don't know if we have enough information in the auto_export() context. 
>   Here's what I found doing a simple link [ printing 
> abfd->my->archive->filename when in auto_export() ].  Each line 
> corresponds to a given symbol under consideration for auto-export (not 
> shown)
> 
> abfd->my_arc->filename=/usr/lib/gcc-lib/i686-pc-cygwin/3.2/libgcc.a

ok, so it is /usr/lib, and has no '..''s in the path.


> abfd->my_arc->filename=/usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../libcygwin.a

And this one, as you say, would need normalising.
 
> First, how does ld know about gcc's built in path 
> /usr/lib/gcc-lib/i686-pc-cygwin/3.2/ ?.

That would be an optional issue. It is in /usr/lib though. So, I'd
consider it a sub-path match.

> Second, we'd have to 
> canonicalize  /usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../ to determine 
> if it corresponded to the "system path" /usr/lib/ (which would be a nice 
> trick on a cross-compiler setup)

We could simply not match paths with '..' as an initial trial.

> The good news is that almost everything in /usr/lib/w32api/ is an import 
> lib, so those symbols are not re-exported anyway...exceptions:
> 
> /usr/lib/w32api/libdxguid.a: x86 archive static
> /usr/lib/w32api/liblargeint.a: x86 archive static
> /usr/lib/w32api/libscrnsave.a: x86 archive static
> /usr/lib/w32api/libscrnsavw.a: x86 archive static
> 
> So at least we needn't worry overmuch about ../w32api/..
> 
> But, I think it's overkill to define "system libs that should not be 
> re-exported" as "anything in /usr/lib" or something similarly broad.

Why? *anything* in /usr/lib is able to be linked to from multiple
packages. If one package creates a dll from there, then we will get this
problem. We're currently *manually* excluding *how many* libs? fortran.
gcc. stdc++. cygwin. And thats from memory. Do we want to hack ld when a
test g++-3.3 is released? IMO No.

> Perhaps the "regular" gcc-supplied system libs (libgcc, libstdc++, 
> libsupc++, etc) can be explicitly rejected by name from within the 
> ld.exe code, but additional **platform** dependent static runtime 
> libraries like libmingwex, etc should actually be controlled by the 
> platform-specific gcc spec file, using
> 
>   --exclude-libs libmingwex.a,libcygwin.a,...

I think that nothing specific to gcc should be handled by ld. If gcc
knows about file foo, be that mingw specific, or c++ specific, it should
tell ld to do the right thing. This centralises the knowledge about the
exceptions.

> -----------------------------------------------------------------
> 
> On the other hand, we're really arguing about a problem that hasn't bit 
> anyone yet.  By excluding the main (gcc) static runtime libs from 
> re-export, and the main (platform) static runtime libs like libmingw32 
> libmingwex from re-export -- we pretty much cover all the important bases.

True. My suspicion though is that as folk find .dll's easier to build,
with the libtool dll support hitting mainstream as of(?1.4?) it will be
more common to link against something. Let me give you another contrived
example:

I create a static lib foo (say readline for arguments sake). It gets
installed into /usr/local/lib.

Someone else makes a library bar depending on foo. This library is a
.dll. It gets installed into /usr/local/lib.

Every app that links against both foo and bar (and if bar is a libtool
library, it will suck in foo for us) will get duplicate symbols.

> Anything else is obviously a corner case, since it hasn't bit anyone yet 
> -- and the fix is for that person to specifically exclude the static lib 
> that "bit" them by using --exclude-libs.

That is *a* fix. Why doesn't it bite folk on linux or BSD? Why should it
bite anyone here when *we can make ld do the right thing*.

We only want to export static archive symbols when 
a) it's a convenience library, 
b) we are creating a forwarding library for the archive.

In a) the library won't be in /usr/lib unless you are building from a
subdir of that (unlikely!).
In b) the library *may* be in /usr/lib, so we can allow a --include-libs
flag to override the heuristic (and I think we already have one, no?)

> The problem here, is that because of our packaging of gcc-2, we're 
> missing the names of the (gcc) static runtime libs for that "package". 
> Plus, libmingwex is another (platform) static runtime lib that we're 
> missing -- but it was only recently added to the mingw "platform".

The problem is that dll's are non intuitive, and our automagic support
is incomplete :}. There's a refactoring smell, uhmm, 'Shotgun Surgery'.
When we change the names of common system libraries, we have to change
ld as well. That's plain wrong.

> (I raised the issue of libtextmode & friends, but since the only 
> "re-exportable" symbol in them is  _cygwin_premain0 which is already 
> excluded by autofilter_symbolprefixlist, there's no problem there.)
> 
> I think the (newly revised) attached patch is sufficient, and is general 
> enough to be submitted for inclusion in the mainline binutils CVS.

I think that the revised patch is fine, along the existing approach, but
the existing approach is much less than optimal.

Rob

-- 
---
GPG key available at: http://users.bigpond.net.au/robertc/keys.txt.
---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://cygwin.com/pipermail/cygwin/attachments/20021109/b243e03e/attachment.sig>


More information about the Cygwin mailing list