Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Which options should I pass to gcc when compiling for profiling?

0
Posted

Which options should I pass to gcc when compiling for profiling?

0

Options which are essential to produce output suitable are: • -pg : generate profiling instrumentation code (only for gprof) • -g : produce debugging information • -fno-omit-frame-pointer : use the frame pointer (frame pointer usage is disabled by default in some architectures like x86_64 and for some optimization levels; it is impossible to walk the call stack without it) You want the code you are profiling to be as close as possible as the code that you will be releasing. So you should include all options that you use in your release code, typically: • -O2 : optimizations that do not involve a space-speed tradeoff • -DNDEBUG : disable debugging code in the standard library (such as the assert macro) However, due to the profiling mechanism used by gprof (and other profilers), many of the optimizations performed by gcc interfere with the accuracy/granularity of the profiling. You should pass these options to disable those particular optimizations: • -fno-inline-functions : do not inlin

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.