[MDEV-3784] LP:576468 - Problem building --with-debug Created: 2010-05-06  Updated: 2012-10-04  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Paul McCullagh (Inactive) Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug576468.xml    

 Description   

I configured MariaDB with --with-debug=full, but I still get it building with "-O2", for example:

gcc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include -g -g -O2 -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -MT strxmov.o -MD -MP -MF .deps/strxmov.Tpo -c -o strxmov.o strxmov.c

It looks like AC_PROG_LIBTOOL sets:

CFLAGS = -g -O2
CXXFLAGS = -g -O2

This is the same with autoconf 2.63 on Mac and autoconf 2.59 on Linux.

MySQL 5.1.46 configure has the same problem.

Here is a quick patch which fixes the problem:

=== modified file 'configure.in'
— configure.in 2010-04-29 07:29:04 +0000
+++ configure.in 2010-05-06 15:41:15 +0000
@@ -15,6 +15,12 @@

  1. first part and a 100 character second part.
    AM_INIT_AUTOMAKE([1.9 tar-ustar])
    AC_PROG_LIBTOOL
    +if test "$CFLAGS" = "-g -O2" ; then
    + CFLAGS=""
    +fi
    +if test "$CXXFLAGS" = "-g -O2" ; then
    + CXXFLAGS=""
    +fi

AM_CONFIG_HEADER([include/config.h])



 Comments   
Comment by Michael Widenius [ 2010-05-10 ]

[Bug 576468] [NEW] Problem building --with-debug

Hi!

>>>>> "Paul" == Paul McCullagh <paul.mccullagh@primebase.org> writes:

Paul> Public bug reported:
Paul> I configured MariaDB with --with-debug=full, but I still get it building
Paul> with "-O2", for example:

Paul> gcc -DHAVE_CONFIG_H -I. -I../include -I../include -I../include -g -g
Paul> -O2 -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE
Paul> -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT
Paul> -DDONT_DECLARE_CXA_PURE_VIRTUAL -MT strxmov.o -MD -MP -MF
Paul> .deps/strxmov.Tpo -c -o strxmov.o strxmov.c

Paul> It looks like AC_PROG_LIBTOOL sets:

Paul> CFLAGS = -g -O2
Paul> CXXFLAGS = -g -O2

Paul> This is the same with autoconf 2.63 on Mac and autoconf 2.59 on Linux.

Paul> MySQL 5.1.46 configure has the same problem.

Paul> Here is a quick patch which fixes the problem:

I usually don't mind the -O2 (except sometimes in the debugger) as
this makes the code act in more similar ways as it will for the
final user. (Some strange bugs are more likely to appear in optimized
code).

What I do when I don't want the -O2 is :

CFLAGS="" CXXFLAGS="" ./configure --with-debug=full

I tested this and with this I didn't get -O2 in my Makefiles

Regards,
Monty

Comment by Paul McCullagh (Inactive) [ 2010-05-10 ]

Re: Problem building --with-debug
Thanks Monty, setting CFLAGS and CXXFLAGS to "" in the environment works for me too.

But I guess I am now missing a configuration option that specifically turns optimizations off. The problem is (as you mentioned) when working in the debugger.

With -O2 local variables are often not available in the debugger.

So it may be convenient to have an option like, for example, --without-optimization. Default will be enabled, of course.

Comment by Paul McCullagh (Inactive) [ 2010-05-10 ]

Re: Problem building --with-debug
This is not a bug. But I changing this to a feature request because I think it would be convenient to have a configure option that specifically turns off optimization for debug and development purposes.

Comment by Rasmus Johansson (Inactive) [ 2010-05-10 ]

Launchpad bug id: 576468

Generated at Thu Feb 08 06:51:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.