This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: How to configure GCC as debuggable


> -----Original Message-----
> From: gcc-owner On Behalf Of Bernd Feindt
> Sent: 15 October 2004 11:09

> -----
> Dave Korn wrote:
> 
> > Say, do we support "configure --help" in the source 
> directory?  > <g>  [
> Sorry Bernd.  Gcc in-joke.  Please ignore! ]
> 
> Please inaugurate me! ;)

  Oh.  Well, with most gnu packages, you just unpack the source, cd into the
same directory where the source is, and type "./configure && make all &&
make install".  That way you build all the .o files in the same directory as
the source files, so it's a bit messy.  You can also build in a separate
directory by making one somewhere else, cd'ing to it, and using the same
command, only with a full (relative or absolute) path to the configure
script; that way your sources stay neat and tidy and all the generated files
end up tucked away in a build dir.

  Unlike most packages, however, gcc doesn't fully support building the
objects in the same directory as the compiler.  You _have_ to use a separate
build dir.  This is more down to bugs in the build machinery than to any
deliberate decision, and nobody's fixed it because it doesn't really cause
any inconvenience.  But, it's out-of-the-ordinary for an open source
package.

  So, we say "gcc doesn't support configuring in the source dir".  But
"configure --help" probably does work just fine!

  Wow.  Three paras and 183 words to explain a 10 word throwaway joke that
wasn't even very funny.  Now do you see why I just wanted you to skip over
it ?  :-)

> > CFLAGS='-g -O0'
> 
> That was a big help for me! "export CFLAGS='-g -O0' CXXFLAGS=$CFLAGS
> CFLAGS_FOR_TARGET=$CFLAGS" did it. "configure" then produces 
> a corresponding
> makefile, except for "CFLAGS_FOR_TARGET". What is it's purpose? Is it
> considered by make as an environment variable?

  Make has its own variables, although they can set and be set from
environment vars.  CFLAGS_FOR_TARGET comes into its own when you're building
a cross compiler.  When you do this, you're actually building two different
kinds of code: the compiler will be in the machine code of the system that
is going to host the compiler, but the internal libraries (libgcc, libstdc++
etc) need to be built (using the newly-generated cross-compiler) using the
machine code of the target machine.  And since there are objects being
compiled for two different targets, they may need different settings for the
command line options for the compiler, different link libraries, etc. etc.
etc.  So CFLAGS is used whenever the compiler or anything that runs on the
host machine is being compiled; CFLAGS_FOR_TARGET is used whenever anything
that runs on the target machine is being compiled.

> -----
> Phil Edwards wrote:
> 
> > building with -g3 lets you use preprocessor macros


  Phil, thanks very much for this _incredibly_ useful information that I
hadn't heard before!


> I had big
> troubles in understanding the C++-parser until now, but now I 
> can follow the
> control flow and see what is going on there at last.

  Yes, there really is nothing remotely as good as stepping through the code
in a debugger and seeing how it runs to gain a deeper understanding of
what's going on where in gcc!

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]