public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* -O or -g on gcc linker frontend?
@ 2006-06-22 16:57 Gerhard Theurich
  2006-06-22 18:38 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Gerhard Theurich @ 2006-06-22 16:57 UTC (permalink / raw)
  To: gcc-help

Hi All,

For a while now I have been wondering if the gcc linker frontend cares knowing 
about -g or -O flags. Let's say I have an object file a.o and I want to link it 
into an executable a.out using gcc I can just say:
     gcc a.o
But I can also use debug or optimization flags:
     gcc -g a.o
     gcc -O2 a.o
     ....
Does the gcc linker frontend care about these flags or are they simply ignored? 
Is it generally advisable to use some consistent set of -g/-O flags during 
linkage compared to what was used during compilation of the objects (what if the 
objects where compiled with different options)?

Thanks for any advice!
-Gerhard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -O or -g on gcc linker frontend?
  2006-06-22 16:57 -O or -g on gcc linker frontend? Gerhard Theurich
@ 2006-06-22 18:38 ` Ian Lance Taylor
  2006-06-22 19:06   ` Charles L. Farbstein
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2006-06-22 18:38 UTC (permalink / raw)
  To: Gerhard Theurich; +Cc: gcc-help

Gerhard Theurich <gtheurich@sgi.com> writes:

> For a while now I have been wondering if the gcc linker frontend cares
> knowing about -g or -O flags. Let's say I have an object file a.o and
> I want to link it into an executable a.out using gcc I can just say:
>      gcc a.o
> But I can also use debug or optimization flags:
>      gcc -g a.o
>      gcc -O2 a.o
>      ....
> Does the gcc linker frontend care about these flags or are they simply
> ignored? Is it generally advisable to use some consistent set of -g/-O
> flags during linkage compared to what was used during compilation of
> the objects (what if the objects where compiled with different
> options)?

The -g and -O options are used only when generating .o files, and are
ignored when linking .o files.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -O or -g on gcc linker frontend?
  2006-06-22 18:38 ` Ian Lance Taylor
@ 2006-06-22 19:06   ` Charles L. Farbstein
  2006-06-22 20:02     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Charles L. Farbstein @ 2006-06-22 19:06 UTC (permalink / raw)
  To: gcc-help

On Thu, 2006-06-22 at 11:37 -0700, Ian Lance Taylor wrote:
> Gerhard Theurich <gtheurich@sgi.com> writes:
> 
> > For a while now I have been wondering if the gcc linker frontend cares
> > knowing about -g or -O flags. Let's say I have an object file a.o and
> > I want to link it into an executable a.out using gcc I can just say:
> >      gcc a.o
> > But I can also use debug or optimization flags:
> >      gcc -g a.o
> >      gcc -O2 a.o
> >      ....
> > Does the gcc linker frontend care about these flags or are they simply
> > ignored? Is it generally advisable to use some consistent set of -g/-O
> > flags during linkage compared to what was used during compilation of
> > the objects (what if the objects where compiled with different
> > options)?
> 
> The -g and -O options are used only when generating .o files, and are
> ignored when linking .o files.
> 
> Ian

Isn't the -g option used by the linker to put the debug information into
the executable image or in the shared object library?


-- 
Charlie Farbstein
L-3 Communications/ Titan Group
e-mail: charles.farbstein@L-3Com.com
phone:  (619) 278-2053
fax:    (619) 278-2070

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: -O or -g on gcc linker frontend?
  2006-06-22 19:06   ` Charles L. Farbstein
@ 2006-06-22 20:02     ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2006-06-22 20:02 UTC (permalink / raw)
  To: Charles L. Farbstein; +Cc: gcc-help

"Charles L. Farbstein" <charles.farbstein@L-3Com.com> writes:

> On Thu, 2006-06-22 at 11:37 -0700, Ian Lance Taylor wrote:

> > The -g and -O options are used only when generating .o files, and are
> > ignored when linking .o files.

> Isn't the -g option used by the linker to put the debug information into
> the executable image or in the shared object library?

No.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-06-22 20:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-22 16:57 -O or -g on gcc linker frontend? Gerhard Theurich
2006-06-22 18:38 ` Ian Lance Taylor
2006-06-22 19:06   ` Charles L. Farbstein
2006-06-22 20:02     ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).