Build ROOT with -O2 -g

Hello,

I would like to compile ROOT with the options “-O2 -g”.
I read the file README/BUILDSYSTEM, but couldn’t find the answer. I don’t want to use

because it would use -O0, correct ?

Could you give me a pointer ?

Thank you
Barth

Dear Barth,

I would recommend you to use two root installations, one compiled with debug, one without. This because the -O2 option will make the compiler “rewrite” your code so it no longer matches what is in your source files.

kind regards

Joa

Hello,

Thank you for your reply.

My aim was actually to have something that I can install in production but still get a chance to see a proper stack trace when my program crashes. It is the equivalent of RelWithDebInfo when using CMake.
Do you think it is a mistake ?

Cheers,
Barth

Hi again,

I quite often do the same thing, but almost always ends up debugging on a non optimized version. But that first stack trace is of course nice. However, you don’t have to have all the code build in debug version to get a good stack trace. Most likely the code will crash on something you did. I’ve found that a development cycle using aclic, compiling with +g option and gDebug set high enough to keep all source files, and attaching the root session to a debugger work quite well.

cheers

Joa

Hi,

You can customize the flags used by creating in the top directory of your ROOT source, the file
name MyRules.mk and containing for example:

CXXFLAGS += -g (and set ROOTBUILD to opt)

Cheers,
Philippe.

Ok, this is what I was looking for. Thank you very much.

Barth