views:

29

answers:

1

Hello,

I've got a solution with ~70 projects, with lots of dependencies between them (I actually made a graph, it had ~300 edges). I know that some dependencies are not necessary. I'd like it to use multiple cores while building, and I guess these unnecessary dependencies might influence on how parallel can the build become.

Basically I'd like to find out which dependencies are necessary for building program, and which can be removed. I care only about being able to build software, not run it. Is there any way to find that out automatically?

Projects are C++, C++/CLI and C#. Some dependencies are specified manually (using Project Dependencies window in VS), some are given as managed assembly references (which might be not necessary), some are given as statically/dynamically linked libraries (which also might be not necessary).

+1  A: 

For C# projects you can use Ildasm.exe. Look at the manifest for the .assembly directives. The C# compiler automatically removes ones that are not used. If you see a reference in the References node of the project that doesn't have a matching .assembly directive then you can remove it.

Not sure if the C++/CLI compiler does this as well. Try it out.

C++ is much more difficult because the build tools can generate files beyond a .lib. Like a type library, created from IDL and used by managed code. Or a .h file from IDL. Or a .res file from a .rc file. It is also likely that there's a dependency that nobody has found yet. The kind that breaks the build when you use a machine with a lot of cores.

You can find out if a static or import .lib is used by analyzing the output of the linker with the /VERBOSE option. There will be a line in the (large) output when it used a symbol from the .lib. Flush out missing project dependencies by reversing the order of the projects in the .sln file and doing a clean build, forcing only one CPU to be used.

Hans Passant
Wow, thanks for ideas. This looks promising.
liori