Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8327523

Debug builds should optimize for debugging

XMLWordPrintable

      When using gcc, the optimization option used for slowdebug builds is -O0. However, the gcc manual recommends -Og for debug builds, rather than -O0. The description of -Og is

      -----
      Optimize debugging experience. -Og should be the optimization level of choce for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and good debugging experience. It is a better choice than -O0 for producing debuggable code because some compiler passes that collect debug information are disabled at -O0.

      Like -O0, -Og completely disables a number of optimization passes so that individual options controlling them have no effect. Otherwise, -Og enables all -O1 optimization flags except for those that may interfere with debugging: <list of optimization flags>
      -----

      Using -O0 also interferes with using _FORTIFY_SOURCE, thus actually losing some error checking in slowdebug builds as compared to fastdebug builds.

      We should consider using -Og instead of -O0 for slowdebug builds.

            Unassigned Unassigned
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: