Last Comment Bug 284767 - MOZ_DEBUG_FLAGS are hardcoded
: MOZ_DEBUG_FLAGS are hardcoded
Product: Core
Classification: Components
Component: Build Config (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla1.8beta3
Assigned To: Nobody; OK to take it and work on it
: Gregory Szorc [:gps]
: 268292 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2005-03-04 07:09 PST by Martin Mokrejs
Modified: 2005-07-03 11:44 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

patch 2 lines in configure --help output (782 bytes, patch)
2005-03-04 07:10 PST, Martin Mokrejs
benjamin: review-
Details | Diff | Splinter Review
patch 2 lines in configure --help output and disable default host optimization (5.77 KB, patch)
2005-03-21 02:19 PST, Martin Mokrejs
cls: review-
Details | Diff | Splinter Review
Allow --enable-debug to accept compiler flags like --enable-optimize (4.48 KB, patch)
2005-04-06 19:17 PDT, cls
benjamin: review+
shaver: approval1.8b3+
Details | Diff | Splinter Review

Description Martin Mokrejs 2005-03-04 07:09:09 PST
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b2) Gecko/20050304
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b2) Gecko/20050304

As explained in the bug, one
needs to specify both, --enable-optimize and --disable-debug to get fully
optimzied build. Alternatively, --disable-optimize and --enable-debug must be
used to yield binaries with full debug.

The patch changes the configure --help output on those 2 respective lines.

Reproducible: Always
Comment 1 Martin Mokrejs 2005-03-04 07:10:11 PST
Created attachment 176282 [details] [diff] [review]
patch 2 lines in configure --help output

applies to current cvs
Comment 2 Benjamin Smedberg [:bsmedberg] 2005-03-14 06:41:25 PST
Comment on attachment 176282 [details] [diff] [review]
patch 2 lines in configure --help output

1) The configure output should wrap at 78 columns.

2) "must" is not the correct word. Use a simple imperative sentence instead:
"Use with --disable-optimize for full debugging."
Comment 3 Martin Mokrejs 2005-03-21 02:19:36 PST
Created attachment 178101 [details] [diff] [review]
patch 2 lines in configure --help output and disable default host optimization

This patch does slightly more then the previous one. It prevents configure
zapping debug options with default optimize values. Further, forcing "-g" on
some systems turns on minimal debug info, which effciently zaps -g3 is
specified previously. Simply, using "-g" is not safe (sometimes overrides -g3
Comment 4 Benjamin Smedberg [:bsmedberg] 2005-04-05 05:21:26 PDT
Comment on attachment 178101 [details] [diff] [review]
patch 2 lines in configure --help output and disable default host optimization

Chris, can you look at this? If not, can you punt it to dbaron?
Comment 5 cls 2005-04-05 10:45:13 PDT
Comment on attachment 178101 [details] [diff] [review]
patch 2 lines in configure --help output and disable default host optimization

Why is this necessary?	Host optimizations are only used for programs that are
built & used as part of the build process (eg. mkdepend and when
cross-compiling, xpidl).  On some systems, the optimization makes a signficant
difference in the performance of these programs.  If you want to debug those
programs, you can set HOST_OPTIMIZE_FLAGS=-g. 

Most of this patch doesn't make sense to me.
+if test "${HOST_OPTIMIZE_FLAGS=}"; then

If HOST_OPTIMIZE_FLAGS is set then set it?

+    if test -z "${HOST_OPTIMIZE_FLAGS}"; then
+    fi

HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}" implicitly does the if emtpy
test.  It doesn't need to be wrapped.

Why are you disabling MOZ_OPTIMIZE_FLAGS if MOZ_DEBUG_FLAGS isn't empty?  It's
possible to use both flags by design.  We're not going to change that.
Comment 6 Martin Mokrejs 2005-04-06 05:15:15 PDT
Per comment #5:
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}" implicitly does the if emtpy
test.  It doesn't need to be wrapped.

I didn't know this, but you're right. This part of the patch is not necessary.

The patch is about improvement of configures output and that MOZ_DEBUG_FLAGS are
blindly set regardless any other options ... I have to get rid of this as it
efectively kills my HOST_OPTIMIZE_FLAGS. Imagine in HOST_OPTIMIZE_FLAGS I ask
for some compiler options, but MOZ_DEBUG_FLAGS enforces some own options.

+    if test ! "${MOZ_DEBUG_FLAGS}"; then
     MOZ_DEBUG_FLAGS="-g -fno-inline"  # most people on linux use gcc/gdb,
                                       # and that combo is not yet good at
                                       # debugging inlined functions (even
                                       # when using DWARF2 as the debugging
                                       # format)    
+    fi
Comment 7 cls 2005-04-06 09:49:50 PDT
You are correct that the MOZ_DEBUG_FLAGS are hardcoded.  Your patch should
simply modify those settings to use the shell empty test construct that
HOST_OPTIMIZE_FLAGS uses.  I don't understand why you hardcoded the use of -ggdb
in your patch either.

I still think the configure output changes are unnecessary given our discussion
in bug 232748.
Comment 8 cls 2005-04-06 10:05:24 PDT
*** Bug 268292 has been marked as a duplicate of this bug. ***
Comment 9 cls 2005-04-06 19:17:01 PDT
Created attachment 179906 [details] [diff] [review]
Allow --enable-debug to accept compiler flags like --enable-optimize

This patch allows --enable-debug to take compiler flags in the same fashion
that --enable-optimize does.  These flags will override the default
Comment 10 Wan-Teh Chang 2005-04-07 07:18:30 PDT
Let's also take this opportunity to standardize
the description of the --enable-debug flag in the
three configure scripts.

In NSPR, --enable-debug means:
1. Produce debugging information (for use by debuggers).
This is where the compiler flags like -g or /Zi come in.
2. Conditionally compile debugging code by defining
the DEBUG and closely related macros.

These two things are actually orthogonal, but they
are both controlled by the --enable-debug configure

I hope we can come up with a concise definition of
--enable-debug that conveys both of these points.
Comment 11 Wan-Teh Chang 2005-04-07 07:41:40 PDT
I found that Mozilla's toplevel script
(mozilla/ distinguishes the two meanings
of "enable debugging" with the --enable-debugger-info-modules
and --enable-debug-modules options.

This means the description of --enable-debug probably
should not be the same for the three configure scripts.
The description in mozilla/ should cover
its relations with --enable-debugger-info-modules
and --enable-debug-modules.
Comment 12 Wan-Teh Chang 2005-04-07 07:46:19 PDT
The current description of the --enable-debug-modules is wrong:

4751 MOZ_ARG_ENABLE_STRING(debug-modules,
4752 [  --enable-debug-modules  Enable/disable debug info for specific modules],
4753 [ MOZ_DEBUG_MODULES=`echo $enableval| sed 's/,/ /g'` ] )

"debug info" should be changed to "debug code" or
"debugging code" because this option controls -DDEBUG,
not -g.
Comment 13 cls 2005-04-07 10:43:53 PDT
The definition of --enable-debug is basically the same across all 3 configure
scripts:  enable compiler debugging + maintainer DEBUG macros.

The additional options in the toplevel configure script just give a finer
grained control over which modules use the debug flags.  These options were
added so that developers working on a small fairly self-contained piece of code
(like exthandlers) do not have to suffer through a full debug build (in
particular, the linking of a debug version of liblayout).  The use of these
additional options is not required for a debug build.
Comment 14 Mike Shaver (:shaver -- probably not reading bugmail closely) 2005-06-01 06:03:22 PDT
Comment on attachment 179906 [details] [diff] [review]
Allow --enable-debug to accept compiler flags like --enable-optimize

Comment 15 cls 2005-06-01 14:07:32 PDT
The patch has been checked in.
Comment 16 Martin Mokrejs 2005-07-03 01:57:47 PDT
Finally I had a time to re-check on this current cvs. No, it is not fixed at
least everywhere:

gmake[3]: Entering directory `/scratch/mozilla/dbm/src'
gcc -o db.o -c -I../../dist/include/system_wrappers -include
../../config/gcc_hidden.h -DOSTYPE=\"Linux2.6\" -DOSARCH=\"Linux\"
-DBUILD_ID=0000000000 -DMEMMOVE -D__DBINTERFACE_PRIVATE  -I./../include 
-I../../dist/include -I../../dist/include -I../../dist/include/nspr   
-I../../dist/sdk/include    -fPIC  -Wall -W -Wno-unused -Wpointer-arith
-Wcast-align -Wno-long-long -pedantic -g3 -O0 -ggdb -pthread -pipe  -DDEBUG
-D_DEBUG -DDEBUG_root -DTRACING -g -fno-inline   -include ../../mozilla-config.h
-DMOZILLA_CLIENT -Wp,-MD,.deps/db.pp db.c

Do you see the "-g -fno-inline" overrding the former "-g3 -O0 -ggdb" flags?
Please see comment #6.
Comment 17 cls 2005-07-03 10:36:06 PDT
WFM. How are you trying to override the debug flags?  You'll have to use the
--enable-debug=<flags> option.
Comment 18 Martin Mokrejs 2005-07-03 11:05:16 PDT
I configure like this:

MOZ_DEBUG_FLAGS="-g3 -O0 -ggdb" CFLAGS="-g3 -O0 -ggdb" CXXFLAGS="-g3 -O0 -ggdb"
./configure --enable-debug --disable-optimize 
--enable-debug-modules=all --enable-debugger-info-modules
--enable-detect-webshell-leaks --enable-svg --enable-svg-renderer-libart
--enable-image-decoders=all --with-qtdir=/usr/qt/3 --enable-application=suite
--disable-freetype2 --enable-jprof --enable --default-toolkit=gtk2 --enable-xft

With overrding I meant that the latter values override the former.
So "-g3 -O0 -ggdb -g -fno-inline" gives "-O0 -ggdb -g2 -fno-inline"

           Request debugging information and also use level to specify how much
           information.  The default level is 2.

           Level 1 produces minimal information, enough for making backtraces
           in parts of the program that you don't plan to debug.  This includes
           descriptions of functions and external variables, but no information 
           about local variables and no line numbers.

           Level 3 includes extra information, such as all the macro definitions
           present in the program.  Some debuggers support macro expansion when
           you use -g3.

           Produce debugging information for use by GDB.  This means to use the
           most expressive format available (DWARF 2, stabs, or the native
           format if neither of those are supported), including GDB extensions
           if at all possible.

I think if "-g" is already set in CFLAGS/CXXFLAGS but if you don't aggree then
consider at least when set in MOZ_DEBUG_FLAGS (as was in my case) ... then "-g
-no-inline" defining code should be cautious and append only "-no-inline".
Comment 19 cls 2005-07-03 11:19:18 PDT
Sorry, but we don't suport setting MOZ_DEBUG_FLAGS via the environment.  We
don't support setting MOZ_OPTIMIZE_FLAGS via the environment either.  We
extended --enable-debug & --enable-optimize so that people wouldn't have to set
the environment variables that correspond to those options.  Is there some
reason why you keep avoiding those options?  

Btw, setting CFLAGS & CXXFLAGS should be completely unnecessary at this point.

Comment 20 Martin Mokrejs 2005-07-03 11:30:10 PDT
My apologies then. I thought I still have to use them to set "-ggdb" for example.
So what's the proposed method then? ;-)
Comment 21 cls 2005-07-03 11:38:53 PDT
./configure --disable-optimize --enable-debug='-g3 -O0 -ggdb'

Comment 22 Martin Mokrejs 2005-07-03 11:44:44 PDT
I see, you are right, that works. ;)

gmake[3]: Entering directory `/scratch/mozilla/nsprpub/config'
gcc -o now.o -c      -pipe -ansi -Wall -pthread -g3 -O0 -ggdb -fPIC  -UNDEBUG

Note You need to log in before you can comment on or make changes to this bug.