Module Definition file (MSVC build)
- From: John Emmas <johne53 tiscali co uk>
- To: gtkmm-list gnome org
- Subject: Module Definition file (MSVC build)
- Date: Wed, 26 Jun 2013 20:39:41 +0100
I just discovered this problem in glibmm. It probably affects gtkmm and atkmm too but I haven't got as far
as building them yet.
When building with MSVC, glibmm uses a utility called "gendef" to generate a Module Definition file which is
later used (at link time) to produce exported symbols in the built DLL(s). Gendef works by examining all the
built '.obj' modules and somehow extracting function names to go into the project's '.def' file (which gendef
creates). However....
MSVC offers a useful form of optimisation called "link time code generation" which is a form of "whole
program optimisation". When you only have a few source modules, LTCG doesn't make much of a difference.
However, it really comes into its own when a project has a large number of source modules. LTCG can produce
a very noticeable improvement in program execution speed. It's described here:-
http://msdn.microsoft.com/en-us/magazine/cc301698.aspx
The above article gives the impression that LTCG is only relevant to .NET but that's not true. We use it
extensively in our regular C++ programs and it does work wonders. BUT....
One of the features of LTCG is that the '.obj' files aren't object files in the traditional sense. The
program's actual object code doesn't get generated until link time (hence the name 'link time code
generation'). One unfortunate consequence of this is that it prevents gendef from doing its job (when it
looks for exportable functions in the object files, there aren't any).
Glib / Gtk etc get around this by generating the .def file from a "symbols" file but because of name
mangling, that probably won't work for (C++) glibmm. A better solution for glibmm would probably involve the
'__declspec' macros that are often found in other cross-platform libraries. However, that would mean pretty
extensive changes to the glibmm sources, I'd imagine (though it's definitely desirable in the longer term).
__declspec macros can easily null out to zero for platforms where __declspec isn't relevant.
In the shorter term it might be advisable to run gendef only for the Debug builds (where optimisation is
usually turned off anyway). The resulting .def file could then simply get copied so that Release builds
could use the same file. This would allow glibmm to be built with LTCG which is highly desirable. I
haven't tried that yet but I could give it a try if that would be helpful.
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]