hermida has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone,

I posted some questions on the chat wondering why most Linux distros include -g in the -Doptimize option when building their included system Perl distribution. For example:

sh Configure -des -Doptimize='-O2 -g ...'

Some people on this site said there are advantages to having -g in ccflags which adds system debugger support and -g has very little if any performance overhead unlike -DDEBUGGING which will build full internal support for debugging Perl and this has a significant performance hit.

The Install docs say, by adding -g to -Doptimize this will only enable support for the system debugger and will not add Perl internal debugging support by making sure -DDEBUGGING in not in the ccflags. Though if you try to build Perl with -g in -Doptimize as instructed it doesn't do what you think and also adds Perl internal debugging support by adding -DDEBUGGING in ccflags and this will make your Perl binary much slower.

If you use the second synonym option from the docs and must remove the -g from -Doptimize and added a separate -DEBUGGING=-g configure option then it does the right thing, it only adds -g to the ccflags and doesn't add -DDEBUGGING. It could be that the install docs are not syntactically incorrect, maybe you must put -Doptimize='-g ...' first or something but that is confusing and possibly misleading.

I took a look at Perl 5.8.8 on RHEL and with 5.8.8 the Install docs behaviour seems to hold, they built it with -Doptimize='-O2 -g ...' and it doesn't build Perl with -DDEBUGGING. Then I tested Perl 5.10.1 and 5.12.3 where the Install docs behaviour is wrong just like I described, something changed between 5.8.8 and the newer versions and if you follow the docs it doesn't do what you want.

  • Comment on Perl Install docs "Building a Debugging Perl" section could have a mistake that builds wrong debugging Perl

Replies are listed 'Best First'.
Re: Perl Install docs "Building a Debugging Perl" section could have a mistake that builds wrong debugging Perl
by hermida (Scribe) on Mar 22, 2011 at 16:19 UTC
          Hi hermida,

          for beginners the INSTALL document is confusing indeed, I believe because of the complexity. I also had to read it several times to get a grasp.

          In my case I think I confused Perl's 4 different debugging modes:

          • -DDEBUGGING
          • -DEBUGGING
          • -DEBUGGING=both

          with the actual script configuration settings which allow a user to fine-tune system dependent settings. For example I tried to enable Perl's -D command line switch to debug command line regular expressions, which by default is not enabled. I confused it because of the DDEBUGGING mode and it's alias DEBUGGING which can be set either together or separately.

          So in my case it was a case of enabling both debugging modes by running the configuration script with:

          ./Configure -des -Doptimize=-g -DEBUGGING=-g

          which activates Perl's -D command line switch (by setting C debugging preprocessor macro with -DEBUGGING=-g) and to activate system debugging.

          I also read the debugging part of my gcc manual (man gcc) for any system related settings which uses the same -g flag.