Thread overview
Compiling optimized release build with debug info turns off optimizations?
Dec 21, 2013
Mikko Ronkainen
Dec 23, 2013
David Nadlinger
Jan 01, 2014
Kai Nacke
Jan 01, 2014
David Nadlinger
December 21, 2013
I want to profile a program with a profiler (say Intel VTune). If I have understood correctly, the build to be profiled should be an optimized release version. It would be beneficial to have debug info in that profile build though so that the profiler can show correct functions names etc.

Now if I add -g to an optimized build (-O3 -release) in LDC, it seems that all/some optimizations are turned off. The debug (-g) and profile (-O3 -release -g) builds have the same performance. Release (-O3 -release) is noticeably faster.

The profile build works as expected in GDC.

I don't know if this something to do with this: http://forum.dlang.org/thread/iiqppmojezdrmnsfienq@forum.dlang.org
December 23, 2013
On Saturday, 21 December 2013 at 12:17:57 UTC, Mikko Ronkainen wrote:
> Now if I add -g to an optimized build (-O3 -release) in LDC, it seems that all/some optimizations are turned off. The debug (-g) and profile (-O3 -release -g) builds have the same performance. Release (-O3 -release) is noticeably faster.

The issue is that currently -g links in a non-optimized build of druntime/Phobos, which is probably not a good idea: https://github.com/ldc-developers/ldc/issues/417

I'm currently thinking about enabling the druntime/Phobos debug libraries when -d-debug is given (which also enables debug {} blocks), but if you have a better idea, please comment on the above GitHub issue.

David
January 01, 2014
Hi David!

On Monday, 23 December 2013 at 15:15:55 UTC, David Nadlinger wrote:
>
> The issue is that currently -g links in a non-optimized build of druntime/Phobos, which is probably not a good idea: https://github.com/ldc-developers/ldc/issues/417

The problem behind this issue can be generalized. E.g. I like to create a druntime/Phobos version compiled with the address sanitizer turned on. How do I link against this library?

Regards,
Kai
January 01, 2014
Hi Kai,

On Wed, Jan 1, 2014 at 5:05 PM, Kai Nacke <kai@redstar.de> wrote:
> The problem behind this issue can be generalized. E.g. I like to create a druntime/Phobos version compiled with the address sanitizer turned on. How do I link against this library?

ldc2 -defaultlib=libphobos-ldc-asan -debuglib=libphobos-ldc-asan, or something like that?

David