--out-implib when linking shared libraries

Hi, I've just built a Haskell dll on Windows. As part of the process it generated an 14Mb foo.dll, and a 40Mb foo.dll.a. Looking at the flags passed to ld I see --out-implib=foo.dll.a. What is the purpose of the .a file? What might it be needed for? Is it possible to suppress it? I could easily be building 100 of these things and 4Gb of disk for unused files is a little painful. Thanks Neil

On Fri, 2009-05-15 at 15:31 +0100, Neil Mitchell wrote:
Hi,
I've just built a Haskell dll on Windows. As part of the process it generated an 14Mb foo.dll, and a 40Mb foo.dll.a. Looking at the flags passed to ld I see --out-implib=foo.dll.a. What is the purpose of the .a file? What might it be needed for? Is it possible to suppress it?
I'm less familiar with the windows dlls as I've been working on the unix case first, but as I understand it, .lib files serve a dual purpose as static libs and as import libs for corresponding dlls. To add confusion the windows gnu tools use the .dll.a extension rather than .lib which the MS tools use. It looks like what you're getting is an import lib that also contains a full copy of all the code. I think it's possible to have minimal .lib files that do not contain any code and only refer to the corresponding dll. Further, I think recent gnu ld versions can link directly against dlls without using an import lib (though you may still need the import lib if you want to use MSVC to link to your dll). So my suggestion is remove it, if you're linking using gcc it should work. See also: http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gnu-linker/win32... Duncan

I've just built a Haskell dll on Windows. As part of the process it generated an 14Mb foo.dll, and a 40Mb foo.dll.a. Looking at the flags passed to ld I see --out-implib=foo.dll.a. What is the purpose of the .a file? What might it be needed for? Is it possible to suppress it?
It looks like what you're getting is an import lib that also contains a full copy of all the code.
Yes, that seems likely. My guess is it's just a cat of the .o's, with header tables etc.
I think it's possible to have minimal .lib files that do not contain any code and only refer to the corresponding dll. Further, I think recent gnu ld versions can link directly against dlls without using an import lib (though you may still need the import lib if you want to use MSVC to link to your dll).
I don't, although having that option wouldn't be a bad thing - having a minimal .lib is perfectly reasonable as a default. Having a massive .lib seems crazy. (The fact that .lib is named .dll.a isn't too much of an issue)
So my suggestion is remove it, if you're linking using gcc it should work.
I'm not linking the .dll at all, only using dynamic linking, which works without the .lib. But I don't really want to start removing files - doing that in a build system seems like a bad idea. Thanks Neil

On Sat, 2009-05-16 at 11:07 +0100, Neil Mitchell wrote:
I don't, although having that option wouldn't be a bad thing - having a minimal .lib is perfectly reasonable as a default. Having a massive .lib seems crazy. (The fact that .lib is named .dll.a isn't too much of an issue)
It's possible to create a minimal import lib via a .def file (which lists the exports). I think the dlltool helps with that.
So my suggestion is remove it, if you're linking using gcc it should work.
I'm not linking the .dll at all, only using dynamic linking, which works without the .lib. But I don't really want to start removing files - doing that in a build system seems like a bad idea.
Sure, so at least you don't have to install them. Duncan

I remember that the .dll.a libraries that GCC produces are not always
compatible with MSVC. Sometimes it works if you rename them to .lib
but sometimes it doesn't. It is much more realiable to create .lib
from .def file via some of the MS tools. If GCC can link dynamic
libraries without using the static library then it might be good idea
not to build the import libraries at all.
Regards,
Krasimir
On Sat, May 16, 2009 at 1:26 PM, Duncan Coutts
On Sat, 2009-05-16 at 11:07 +0100, Neil Mitchell wrote:
I don't, although having that option wouldn't be a bad thing - having a minimal .lib is perfectly reasonable as a default. Having a massive .lib seems crazy. (The fact that .lib is named .dll.a isn't too much of an issue)
It's possible to create a minimal import lib via a .def file (which lists the exports). I think the dlltool helps with that.
So my suggestion is remove it, if you're linking using gcc it should work.
I'm not linking the .dll at all, only using dynamic linking, which works without the .lib. But I don't really want to start removing files - doing that in a build system seems like a bad idea.
Sure, so at least you don't have to install them.
Duncan
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Hi
Following up on a slightly old thread, it seems that the use of
--out-implib is unnecessary for my purposes and generates 50Mb of
.dll.a files. I'm also concerned that the generation of these .dll.a
files may be taking considerable time (in the range of minutes).
I'd like to disable the flags, using things such as -optl, but can't
figure out how. The best I've come up with is:
-optl=-Wl,--opt-implib=nul
When doing this is generates the implib to nul, instead of to a file.
That saves me 10 seconds and 50Mb of disk space, but I suspect if I
could properly eliminate the opt-implib flag I'd save a significant
chunk more time. Is there any way to override implib so it doesn't
even try to generate it? Given Krasimir's comments, could this bug
changed in a future version of GHC?
Thanks, Neil
On Sat, May 16, 2009 at 1:22 PM, Krasimir Angelov
I remember that the .dll.a libraries that GCC produces are not always compatible with MSVC. Sometimes it works if you rename them to .lib but sometimes it doesn't. It is much more realiable to create .lib from .def file via some of the MS tools. If GCC can link dynamic libraries without using the static library then it might be good idea not to build the import libraries at all.
Regards, Krasimir
On Sat, May 16, 2009 at 1:26 PM, Duncan Coutts
wrote: On Sat, 2009-05-16 at 11:07 +0100, Neil Mitchell wrote:
I don't, although having that option wouldn't be a bad thing - having a minimal .lib is perfectly reasonable as a default. Having a massive .lib seems crazy. (The fact that .lib is named .dll.a isn't too much of an issue)
It's possible to create a minimal import lib via a .def file (which lists the exports). I think the dlltool helps with that.
So my suggestion is remove it, if you're linking using gcc it should work.
I'm not linking the .dll at all, only using dynamic linking, which works without the .lib. But I don't really want to start removing files - doing that in a build system seems like a bad idea.
Sure, so at least you don't have to install them.
Duncan
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (3)
-
Duncan Coutts
-
Krasimir Angelov
-
Neil Mitchell