* dead function elimination
@ 2006-11-09 7:55 jimmy
2006-11-09 8:48 ` Nick Clifton
0 siblings, 1 reply; 8+ messages in thread
From: jimmy @ 2006-11-09 7:55 UTC (permalink / raw)
To: binutils, gcc-help
Can gcc or ld perform dead procedure elimination apart from using the
combination of --gc-sections/-ffunction-sections?
-jb
--
mathematician, n.:
Some one who believes imaginary things appear right before your
i's.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dead function elimination
2006-11-09 7:55 dead function elimination jimmy
@ 2006-11-09 8:48 ` Nick Clifton
2006-11-09 9:20 ` jimmy
0 siblings, 1 reply; 8+ messages in thread
From: Nick Clifton @ 2006-11-09 8:48 UTC (permalink / raw)
To: jimmy; +Cc: binutils, gcc-help
Hi Jimmy,
> Can gcc or ld perform dead procedure elimination apart from using the
> combination of --gc-sections/-ffunction-sections?
(Why are you excluding the --gc-sections / -ffunction-sections pairing
which were designed precisely for this purpose ?)
The short answer is yes. Gcc can and will eliminate unused local
procedures, and with its --whole-program option it can even eliminate
unused non-local procedures.
But your question implies that you are asking if between them the linker
and compiler can eliminate unused procedures without recompilation of
all the sources, and in this case the answer is no.
Cheers
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dead function elimination
2006-11-09 8:48 ` Nick Clifton
@ 2006-11-09 9:20 ` jimmy
2006-11-09 10:15 ` Andrew Haley
2006-11-14 12:16 ` Nick Clifton
0 siblings, 2 replies; 8+ messages in thread
From: jimmy @ 2006-11-09 9:20 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils, gcc-help
Nick Clifton wrote:
> Hi Jimmy,
>
>> Can gcc or ld perform dead procedure elimination apart from using the
>> combination of --gc-sections/-ffunction-sections?
>
> (Why are you excluding the --gc-sections / -ffunction-sections pairing
> which were designed precisely for this purpose ?)
>
> The short answer is yes. Gcc can and will eliminate unused local
> procedures, and with its --whole-program option it can even eliminate
> unused non-local procedures.
>
> But your question implies that you are asking if between them the linker
> and compiler can eliminate unused procedures without recompilation of
> all the sources, and in this case the answer is no.
>
> Cheers
> Nick
>
I thght the linker alone was supposed to be able to do
dead-procedure-elimination. After all can't the linker determine which
procedures are unreferenced in the final executable?
If i'm not mistaken the diablo linker can do this?
Thanks!
-jb
--
mathematician, n.:
Some one who believes imaginary things appear right before your
i's.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dead function elimination
2006-11-09 9:20 ` jimmy
@ 2006-11-09 10:15 ` Andrew Haley
2006-11-14 12:16 ` Nick Clifton
1 sibling, 0 replies; 8+ messages in thread
From: Andrew Haley @ 2006-11-09 10:15 UTC (permalink / raw)
To: jimmy; +Cc: Nick Clifton, binutils, gcc-help
jimmy writes:
> Nick Clifton wrote:
> > Hi Jimmy,
> >
> >> Can gcc or ld perform dead procedure elimination apart from using the
> >> combination of --gc-sections/-ffunction-sections?
> >
> > (Why are you excluding the --gc-sections / -ffunction-sections pairing
> > which were designed precisely for this purpose ?)
> >
> > The short answer is yes. Gcc can and will eliminate unused local
> > procedures, and with its --whole-program option it can even eliminate
> > unused non-local procedures.
> >
> > But your question implies that you are asking if between them the linker
> > and compiler can eliminate unused procedures without recompilation of
> > all the sources, and in this case the answer is no.
>
> I thght the linker alone was supposed to be able to do
> dead-procedure-elimination. After all can't the linker determine which
> procedures are unreferenced in the final executable?
>
> If i'm not mistaken the diablo linker can do this?
GNU ld can do this too. It does it if you compile with
-ffunction-sections.
Andrew.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dead function elimination
2006-11-09 9:20 ` jimmy
2006-11-09 10:15 ` Andrew Haley
@ 2006-11-14 12:16 ` Nick Clifton
2006-12-18 8:24 ` jimmy
1 sibling, 1 reply; 8+ messages in thread
From: Nick Clifton @ 2006-11-14 12:16 UTC (permalink / raw)
To: jimmy; +Cc: binutils, gcc-help
Hi Jimmy,
> I thght the linker alone was supposed to be able to do
> dead-procedure-elimination.
No. It is a nice feature, but it is not a requirement of a linker.
> After all can't the linker determine which
> procedures are unreferenced in the final executable?
Which is exactly what the --ffunction-sections and --gc-sections
switches do.
> If i'm not mistaken the diablo linker can do this?
It probably can.
Cheers
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dead function elimination
2006-11-14 12:16 ` Nick Clifton
@ 2006-12-18 8:24 ` jimmy
2006-12-19 1:09 ` Nick Clifton
0 siblings, 1 reply; 8+ messages in thread
From: jimmy @ 2006-12-18 8:24 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils, gcc-help
Nick Clifton wrote:
> Hi Jimmy,
>
>> I thght the linker alone was supposed to be able to do
>> dead-procedure-elimination.
>
> No. It is a nice feature, but it is not a requirement of a linker.
>
>> After all can't the linker determine which procedures are unreferenced
>> in the final executable?
>
> Which is exactly what the --ffunction-sections and --gc-sections
> switches do.
>
>> If i'm not mistaken the diablo linker can do this?
>
> It probably can.
>
> Cheers
> Nick
>
If i understand things correctly, there is a restriction on
'--gc-sections' that it doesn't work if the link is dynamic. What if my
scenario is like this:
libsomething.a - some static library built with -ffunction-sections &
-fdata-sections
src.o - my source code also built with -ffucntion-sections
final step:
ld -o exec --gc-sections src.o -lsomething
In the above step, ld simply says
'/usr/bin/ld: Warning: gc-sections option ignored'
My aim here was to remove unreferenced functions from both my code & the
static library, but at the same time using libc as an '.so' (obviously
that makes sense, cos it's shared across many apps & probably not built
with -ffunction-sections to use a static link).
Is there any way to achieve this?
-jb
--
mathematician, n.:
Some one who believes imaginary things appear right before your
i's.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dead function elimination
2006-12-18 8:24 ` jimmy
@ 2006-12-19 1:09 ` Nick Clifton
2006-12-20 7:59 ` jimmy
0 siblings, 1 reply; 8+ messages in thread
From: Nick Clifton @ 2006-12-19 1:09 UTC (permalink / raw)
To: jimmy; +Cc: binutils, gcc-help
Hi Jimmy,
> If i understand things correctly, there is a restriction on
> '--gc-sections' that it doesn't work if the link is dynamic. What if my
> scenario is like this:
>
> libsomething.a - some static library built with -ffunction-sections
> & -fdata-sections
>
> src.o - my source code also built with -ffucntion-sections
>
> final step:
>
> ld -o exec --gc-sections src.o -lsomething
>
> In the above step, ld simply says
>
> '/usr/bin/ld: Warning: gc-sections option ignored'
Hmm, interesting. I had thought that this would work. I will have to
look into it when I get from vacation. Are you using the most up to
date version of the linker sources ?
Cheers
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: dead function elimination
2006-12-19 1:09 ` Nick Clifton
@ 2006-12-20 7:59 ` jimmy
0 siblings, 0 replies; 8+ messages in thread
From: jimmy @ 2006-12-20 7:59 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils, gcc-help
Nick Clifton wrote:
> Hi Jimmy,
>
>> If i understand things correctly, there is a restriction on
>> '--gc-sections' that it doesn't work if the link is dynamic. What if
>> my scenario is like this:
>>
>> libsomething.a - some static library built with
>> -ffunction-sections & -fdata-sections
>>
>> src.o - my source code also built with -ffucntion-sections
>>
>> final step:
>>
>> ld -o exec --gc-sections src.o -lsomething
>>
>> In the above step, ld simply says
>>
>> '/usr/bin/ld: Warning: gc-sections option ignored'
>
> Hmm, interesting. I had thought that this would work. I will have to
> look into it when I get from vacation. Are you using the most up to
> date version of the linker sources ?
>
> Cheers
> Nick
binutils-2.17 is able to do it! thank you for the help.
-jb
--
mathematician, n.:
Some one who believes imaginary things appear right before your
i's.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-12-20 7:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-09 7:55 dead function elimination jimmy
2006-11-09 8:48 ` Nick Clifton
2006-11-09 9:20 ` jimmy
2006-11-09 10:15 ` Andrew Haley
2006-11-14 12:16 ` Nick Clifton
2006-12-18 8:24 ` jimmy
2006-12-19 1:09 ` Nick Clifton
2006-12-20 7:59 ` jimmy
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).