Compiler flags when profiling a build
Jacob Carlborg
doob at me.com
Mon Oct 26 10:18:43 UTC 2020
On Sunday, 25 October 2020 at 14:08:21 UTC, Per Nordlöw wrote:
> What flags do you feed to dmd/ldc when you profile a build?
>
> Do you initially
>
> - compile in debug or release mode?
> - activate inlining or not?
> - use dmd or ldc?
> - use any other alternatives not mentioned above?
For maximum performance you should compile with LDC and do the
following:
* Enable optimizations: -O3
* Enable Link Time Optimizations (LTO): --flto=full
* Link against druntime and Phobos compiled for LTO:
--defaultlib=druntime-ldc-lto,phobos2-ldc-lto
* Target your specific CPU instead of some generic CPU. This will
enable SSE and other features that otherwise are disabled:
-mcpu=native
* Depending on you're preferences, you might want to disable
asserts, contracts and invariants and bounds checks in non- at safe
functions: --release
* You can also control the bounds check in more details using
this flag: --boundscheck
* For profiling I assume you want debug symbols as well: -g
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list