Subject: [Patch] skipping import libraries for performance reasons - direct auto-import of dll's
From: "Ralf Habacker" <[email-masked]>
To: "Binutils" <[email-masked]>, "cygwin" <[email-masked]>, "Kde-Cygwin" <[email-masked]>
Cc: "Charles Wilson" <[email-masked]>
Date: Mon, 25 Nov 2002 13:46:50 +0100

Hi all,

the recent ld contains support importing of symbols located in other dll's
through import libraries.

Especially for big libraries using import libraries has some big disadvantages:

1. ld need much time and very much memory to process them  - This is because
each symbol is located in a seperate objectfile and ld opens a bfd for each.

2. The size of import libraries could be very huge (for example 10 MB for
qt-3) - This is because each symbol is located in a seperate objectfile.

current ld releases are able to skip import libraries by grabbing the needed
informations directly from a dll. The only issue which was open until now, is
that ld has no auto-import support for linking directly to a dll, but this is be
fixed with the appended patch.

Using dll's directly instead of import libraries has several advantages:

1. linking goes much faster (for qt-3 about 50%: from 2 minutes down to one
minute)

2. ld uses much less memory (for qt-3 about 70%: from 500 MB to 150 MB)

3. ld works more like the linux version. There are only static archives and
shared libraries which could be linked directly without the indirection of using
import libraries. This simplifies for example libtool handling.

How does it works:

See the example path layout. There are two dll's xxx.dll and yyy.dll in an
applications bin dir. In the lib dir there are the import library for xxx.dll
and a link to the dll cygyyy.dll.

../bin/
	cygxxx.dll
	cygyyy.dll

../lib/
	libxxx.dll.a
	[cyg|lib|]yyy.dll	(may be the dll  or a symbolic link to ../bin/cygyyy.dll)

Now the link line (you can see that using the dll directly is the same as using
the import libraries, there is no difference)

gcc -Wl,-verbose  -o a.exe -L../lib/ -lxxx -lyyy ...

The ld log below shows, that for xxx the import library is used and for yyy the
dll is directly used. This means, the only task of using the dll instead of the
import library is to replace the import library with a symbolic link to the dll.

<snip>
==================================================
attempt to open /usr/lib/crt0.o succeeded
/usr/lib/crt0.o
attempt to open client.o succeeded
client.o
attempt to open ../lib/libxxx.dll.a succeeded !!!
...
attempt to open ../lib/libyyy.dll.a failed
attempt to open ../lib/yyy.dll.a failed
attempt to open ../lib/libyyy.a failed
attempt to open ../lib/cygyyy.dll failed
attempt to open ../lib/libyyy.dll failed
attempt to open ../lib/yyy.dll succeeded !!!
<snip>
Info: resolving _var by linking to __imp__var (auto-import)
Info: resolving _foo by linking to __imp__foo (auto-import)
Info: resolving _func_ptr by linking to __imp__func_ptr (auto-import)

I have tested this patch with recent qt-2/3 and kde2 sources without any
problems. A sample test case is appended too.

Please give this patch a try and report problems to me o0r to this list.

Thank you

Ralf Habacker

KDE on cygwin http://cygwin.kde.org

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/