public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Can collect2 just generate the c file?
@ 2006-01-13 15:20 Perry Smith
  2006-01-13 16:26 ` Ian Lance Taylor
  2006-01-13 21:32 ` John Love-Jensen
  0 siblings, 2 replies; 7+ messages in thread
From: Perry Smith @ 2006-01-13 15:20 UTC (permalink / raw)
  To: gcc-help

Can I call g++ with arguments so that it will generate the source  
file (I assume it is a .c file) and then stop.

I want to call the linker myself.  I think that is going to be easier  
to do in my situation.

Thank you,
Perry Smith

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

* Re: Can collect2 just generate the c file?
  2006-01-13 15:20 Can collect2 just generate the c file? Perry Smith
@ 2006-01-13 16:26 ` Ian Lance Taylor
  2006-01-13 16:53   ` Perry Smith
  2006-01-13 21:32 ` John Love-Jensen
  1 sibling, 1 reply; 7+ messages in thread
From: Ian Lance Taylor @ 2006-01-13 16:26 UTC (permalink / raw)
  To: Perry Smith; +Cc: gcc-help

Perry Smith <pedz@easesoftware.net> writes:

> Can I call g++ with arguments so that it will generate the source
> file (I assume it is a .c file) and then stop.
> 
> I want to call the linker myself.  I think that is going to be easier
> to do in my situation.

g++ does not generate C code.  It translates directly from C++ to
assembler code.

You can get the assembler code with -S, or the assembler output with
-c.  Using -c will give you a .o file which you can use to call the
linker yourself.

Ian

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

* Re: Can collect2 just generate the c file?
  2006-01-13 16:26 ` Ian Lance Taylor
@ 2006-01-13 16:53   ` Perry Smith
  2006-01-13 21:47     ` John Love-Jensen
  2006-01-14  4:24     ` Ian Lance Taylor
  0 siblings, 2 replies; 7+ messages in thread
From: Perry Smith @ 2006-01-13 16:53 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

I think you misunderstood my question.

collect2 runs through the list of files to link and collects the  
constructors and destructors.  It then makes a c file of those items,  
compiles it, then calls ld again with the original list of objects  
plus the new object.  I'd like to stop before the second call to ld  
is made.  (I'm looking at the source now and I don't see that option).

Thanks,
Perry

On Jan 13, 2006, at 10:26 AM, Ian Lance Taylor wrote:

> Perry Smith <pedz@easesoftware.net> writes:
>
>> Can I call g++ with arguments so that it will generate the source
>> file (I assume it is a .c file) and then stop.
>>
>> I want to call the linker myself.  I think that is going to be easier
>> to do in my situation.
>
> g++ does not generate C code.  It translates directly from C++ to
> assembler code.
>
> You can get the assembler code with -S, or the assembler output with
> -c.  Using -c will give you a .o file which you can use to call the
> linker yourself.
>
> Ian
>

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

* Re: Can collect2 just generate the c file?
  2006-01-13 15:20 Can collect2 just generate the c file? Perry Smith
  2006-01-13 16:26 ` Ian Lance Taylor
@ 2006-01-13 21:32 ` John Love-Jensen
  1 sibling, 0 replies; 7+ messages in thread
From: John Love-Jensen @ 2006-01-13 21:32 UTC (permalink / raw)
  To: Perry Smith, MSX to GCC

Hi Perry,

> Can I call g++ with arguments so that it will generate the source file and
then stop.

Yes, there are two stopping places:

g++ -E foo.cpp -o foo.ii
Stops after the preprocessor.

g++ -S foo.cpp -o foo.s
Stops after the compilation to assembler.

>I assume it is a .c file

No, it is either a .ii (preprocessed) file or a .s (assembler) file.

> I want to call the linker myself.  I think that is going to be easier to do in
my situation.

Ummm... well, to invoke the linker you probably want yet another stopping
place:

g++ -c foo.cpp -o foo.o
Stops after the creation of the .o (object) file.

But that's not a "generate the source file and then stop" kind of stopping
place.

Anyway, remember to use g++ to invoke the linker.  The g++ front end is a
tool-chain driver, and will invoke the linker correctly.

HTH,
--Eljay

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

* Re: Can collect2 just generate the c file?
  2006-01-13 16:53   ` Perry Smith
@ 2006-01-13 21:47     ` John Love-Jensen
  2006-01-13 23:29       ` Perry Smith
  2006-01-14  4:24     ` Ian Lance Taylor
  1 sibling, 1 reply; 7+ messages in thread
From: John Love-Jensen @ 2006-01-13 21:47 UTC (permalink / raw)
  To: Perry Smith; +Cc: MSX to GCC

Hi Perry,

> collect2 runs through the list of files to link and collects the
> constructors and destructors.  It then makes a c file of those items,
> compiles it, then calls ld again with the original list of objects
> plus the new object.  I'd like to stop before the second call to ld
> is made.  (I'm looking at the source now and I don't see that option).

Ahh, okay.  Yes, your original question was not clear that you wanted to
stop there, and capture this collect2 temporary file for constructors.

I do not know the options for collect2 (I presume many of them are the same
as the linker, since collect2 mimics the linker in many respects), and I
cannot find a collect2 man page via Google.

I recommend looking at it's source.

HTH,
--Eljay

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

* Re: Can collect2 just generate the c file?
  2006-01-13 21:47     ` John Love-Jensen
@ 2006-01-13 23:29       ` Perry Smith
  0 siblings, 0 replies; 7+ messages in thread
From: Perry Smith @ 2006-01-13 23:29 UTC (permalink / raw)
  To: John Love-Jensen; +Cc: MSX to GCC

Thanks.  Yes, my original question was very poorly stated.

There is a '-r' option to collect2 that stops but it will delete the  
files unless debug is set.  It appears that collect2 is not really  
set up to do what I was hoping to do.

One thing that would help me: can someone tell me of a platform that  
can and does use C++ in device drivers or kernel extensions?

Thanks to all...
Perry

On Jan 13, 2006, at 3:47 PM, John Love-Jensen wrote:

> Hi Perry,
>
>> collect2 runs through the list of files to link and collects the
>> constructors and destructors.  It then makes a c file of those items,
>> compiles it, then calls ld again with the original list of objects
>> plus the new object.  I'd like to stop before the second call to ld
>> is made.  (I'm looking at the source now and I don't see that  
>> option).
>
> Ahh, okay.  Yes, your original question was not clear that you  
> wanted to
> stop there, and capture this collect2 temporary file for constructors.
>
> I do not know the options for collect2 (I presume many of them are  
> the same
> as the linker, since collect2 mimics the linker in many respects),  
> and I
> cannot find a collect2 man page via Google.
>
> I recommend looking at it's source.
>
> HTH,
> --Eljay
>
>

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

* Re: Can collect2 just generate the c file?
  2006-01-13 16:53   ` Perry Smith
  2006-01-13 21:47     ` John Love-Jensen
@ 2006-01-14  4:24     ` Ian Lance Taylor
  1 sibling, 0 replies; 7+ messages in thread
From: Ian Lance Taylor @ 2006-01-14  4:24 UTC (permalink / raw)
  To: Perry Smith; +Cc: gcc-help

Perry Smith <pedz@easesoftware.net> writes:

> I think you misunderstood my question.
> 
> collect2 runs through the list of files to link and collects the
> constructors and destructors.  It then makes a c file of those items,
> compiles it, then calls ld again with the original list of objects
> plus the new object.  I'd like to stop before the second call to ld
> is made.  (I'm looking at the source now and I don't see that option).

My apologies, I did indeed misunderstand the question.

You're right, there is no option to cause collect2 to construct a C
file and not continue with the link.

Ian

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

end of thread, other threads:[~2006-01-14  4:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-13 15:20 Can collect2 just generate the c file? Perry Smith
2006-01-13 16:26 ` Ian Lance Taylor
2006-01-13 16:53   ` Perry Smith
2006-01-13 21:47     ` John Love-Jensen
2006-01-13 23:29       ` Perry Smith
2006-01-14  4:24     ` Ian Lance Taylor
2006-01-13 21:32 ` John Love-Jensen

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).