Visual D: Settings to Improve compil and link process

Rainer Schuetze via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 6 01:09:03 PDT 2014



On 05.07.2014 16:05, ParticlePeter wrote:
> Hello Community,
>
> I thought there's a separate forum for VisualD. It did exist when
> VisualD was on DSource, so why not add it here as well? Or am I to blind
> to see?

The forum digitalmars.D.ide is probably the best fit.

>
> Anyway, this thread is an addition to my previous one in this forum:
> http://forum.dlang.org/thread/wkkuvzkzeupyfdpweals@forum.dlang.org
>
> I noticed increasing compile times in my projects. As I use only VisualD
> I would like to understand how I would shorten compile time with this tool.
> Brief description to my setup, more details can be fond in the other post.
> I have one Lib, called MyLib consisting of around 15 modules, one class
> per module, zero to two template methods per class with one type
> parameter each.
> All my projects use MyLib, and call the template methods with different
> types. Most of the compile time of any of theses projects is spent in
> rebuilding MyLib.
> I am not sure why and where so much time is spent, but is there a way to
> profile my COMPILE time with VisualD?

The longer compile time is very likely caused by the compiler. You could 
check "Verbose compile" (command line option -v) to see what templates 
are expanded and what functions are compiled. This might give you a hint 
where the compiler spends the time.

> There are several VisualD project properties which I do not understand
> fully, but hope that they might help, namely:
>
> Configuration Properties - General - Files to clean
> Configuration Properties - Compiler - Output - Multiple Object Files
> Configuration Properties - Compiler - Output - Keep Path From Source File
>
> Could not cleaning some files improve compilation ?

No.

> Could Multiple Object Files be used to separately compile non-template
> and template code blocks ?

No. This option exposes an undocumented command line option that splits 
a module into multiple object files as if dmd creates a library. Do not 
use it.

> What does Keep Path From Source File do at all ?

This instructs dmd to not strip the path components from module source 
file name when generating the object file name. This avoids troubles if 
you build to multiple object files, but there are modules with identical 
names in different packages.

>
> It is possible to remove the template methods from my classes, create
> free functions instead and use them in a UFCS way.
> Unfortunately I have not figured out UFCS properly, as my approaches do
> not work ( guess due to UFCS restrictions ).
>

That would not help, templates are instantiated and compiled when they 
are used, not when they are declared.

> Anyway, would it help ( and is it possible at all ) to put the template
> functions in a separate module so that only the corresponding object
> file requires a recompile ?
> I am asking in the context of the Multiple Object Files setting.

Incremental building of single object files is not well supported by 
dmd, there are too many troubles with instantiating templates in 
different object files.

>
> I tried to not build MyLib at all, and use the sources directly, but the
> project setup is kind of confusing. Again, there is a setting which I
> seem to not understand fully. So one project, lets say MyProject, has
> only its own module files added to the VisualD project. I want the
> compiler to also use the MyLib source files, but do not want to add them
> to MyProject, reasoning bellow. There is one entry in the project
> properties, which should make this behavior possible, but it doses not.
> Why ?
>
> Configuration Properties - Compiler - General - Additional Imports
>
> As far as I understand this setting, I am supposed to enter module
> search paths.

This is correct.

 > But I do get linker errors when I do not add either
> MyLib.lib to the linker settings or all the source files of MyLib to
> MyProject.
>

You should add a dependency in the "Project -> Project Dependencies" 
dialog. This will ensure proper rebuilds and add the library to the 
command line of dependent projects.


> Reasoning why I do not want to do this: I have one solution file with
> the MyLib project and ten projects like MyProject using MyLib. I would
> need to add all the source files to all the projects, they would be
> reachable and editable at 11 different location within my solution file.
> This does not not seem to be a clean way to set it up.
>
> Any advice to any or all the thoughts and issues ?
>
> Thanks in advance.
>
> Cheers, ParticlePeter


More information about the Digitalmars-d-learn mailing list