How to compile a debugging VM?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to compile a debugging VM?

Michael van der Gulik-2
 
On Linux, how do you tell the build scripts to make GCC compile with
the -g flag rather than -O2 (i.e. don't optimise and leave debugging
symbols in the VM)?

So far I've been manually editing relevant Makefiles, but surely
there's a better way.

Gulik.

--
http://gulik.pbwiki.com/
Reply | Threaded
Open this post in threaded view
|

Re: How to compile a debugging VM?

Igor Stasenko
 
2009/3/24 Michael van der Gulik <[hidden email]>:
>
> On Linux, how do you tell the build scripts to make GCC compile with
> the -g flag rather than -O2 (i.e. don't optimise and leave debugging
> symbols in the VM)?
>
> So far I've been manually editing relevant Makefiles, but surely
> there's a better way.
>

AFAIK, there is configure script for unix build. Maybe running
configure with certain options can produce make files with debug
flags.

> Gulik.
>
> --
> http://gulik.pbwiki.com/
>



--
Best regards,
Igor Stasenko AKA sig.
Reply | Threaded
Open this post in threaded view
|

Re: How to compile a debugging VM?

Gavin Romig-Koch
In reply to this post by Michael van der Gulik-2
 

Michael van der Gulik wrote:
 
On Linux, how do you tell the build scripts to make GCC compile with
the -g flag rather than -O2 (i.e. don't optimise and leave debugging
symbols in the VM)?
  

There is a (not always followed) convention for writing Makefiles where the Make variable CFLAGS is only used for debugging flags, optimization flags, and warning flags, and specifically _not_ used for include flags, define flags, or any flags that are required for correct compilation.   If this convention is followed then one can do:
$ make CFLAGS=-g whatever
That is, CFLAGS is set on the Make command line.  Setting CFLAGS on the command line causes that value to override the value set in the Makefile, if any, and Make passes this value on to the C compiler.   Unfortunately, the SqueakVM makefiles don't follow this convention in at least a few cases.   For example, in npsqueak/Makefile, several -I's are included in  CFLAGS, and when one does:
$ cd platforms/unix
$ make CFLAGS=-g
the compile of npsqueak.c fails because it can't find several include files.  If instead the -I's and -fPIC were moved to the actual compile of npsqueak.c and npunix.c, then the convention works.

If you decide to do some Makefile editing, consider changing the Makefiles to follow this convention, and submit a patch. 

                                                                               -gavin...