RE: [arm-gnu] Linker driven optimization. Possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [arm-gnu] Linker driven optimization. Possible?



> -----Original Message-----
> From: Kishore [mailto:kitts.mailinglists@xxxxxxxxx]
> Sent: Friday, 29 May 2009 2:21 PM
> To: arm-gnu@xxxxxxxxxxxxxxxx
> Subject: [arm-gnu] Linker driven optimization. Possible?
> 
> Now, most projects only use one of the "Adc" implementation in the
entire
> project. So now, under such circumstances is it really possible to
> optimize so
> that MaximAdc and Adc are "merged" thereby avoiding the inheritance
and
> the
> virtual function call? Is this also possible if the Adc and MaximAdc
are
> part
> of a static link library?
> 

There is the -combine and -fwhole-program options. I don't know how
reliable and effective these are, esp. for bare-metal ARM C++ (which may
be three strikes against new features, in a way). They must work using
intermediate representation to do any sort of optimization at all, so
you won't get static link libraries; you'll more likely just get doubled
build times.

Can I suggest another idea?

First, make sure MaximADC and any other ADC implementations have the
same API. In C this would be easy; in C++, you'll have to use the same
classname for both, and you'll probably have to use a pimpl for your
private data (which will incur an extra lookup penalty).

Compile them separately, and into different static libraries if they
happen to use multiple files.

Then, only pass the implementation you want to use to the linker:
-lmaximadc or -ltiadc or...

This might not be the textbook inheritance-based OO solution, but it's
simple, modular, and relatively maintainable. (And just as a point of
perspective: if doing a clean build of your project would take longer
than changing the ADC, I either want to know your PCB supplier, or
should offer my sympathy for your build system!)

James