LTO support

Asked by David Dufke

I'm a long time embedded GCC user, but I'm new to this particular toolchain. Working quite well so far.
One question did occur to me however:
Are there any plans to enable LTO (Link Time Optimizer) support in this toolchain? It appears to be turned off in the binaries at the moment at least.
I'm unsure about the state of LTO on ARM overall, maybe it isn't quite ready for production use yet?

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
chengbin (can-finner) said :
#1

Hi David,
Thanks for trying the tool.
As you said, LTO is currently disabled in our toolchain. I am collecting information on this and will update you ASAP.
Another word, according to your experience, is LTO very useful for embedded programs?

Thanks very much.

Revision history for this message
David Dufke (dufke) said :
#2

Hi,
I haven't actually used GCC LTO in an embedded application, since it is disabled in ALL the precombiled toolchains I have tried.

But I have experience with it in other compilers, and it is very useful for cross-module inlining. The point being that you can divide a large project into submodules as much as you want, and still get all suitable functions inlined, without having to bother putting code in headers and the like. There are probably more optimizations that might be useful, but inlining is the big one for me.

Revision history for this message
chengbin (can-finner) said :
#3

Hi David,
Thanks for your information.

Now I remember at least for GCC 4.6, LTO causes some GCC regression tests failed for bare metal toolchain, that's why we disabled it.
Though newer version GCC/LTO works on arm-linux toolchain, there is no guarantee that it works on arm-none-eabi. Seems to us it is not a very popular feature in embedded word for now, so recently we have no plan to enable/improve it. Sorry for that.
Of course, we may do some preliminary investigation work in the future.

Looking forward to your other feed-backs. Thanks very much.

Revision history for this message
Andreas Fritiofson (andreas-fritiofson) said :
#4

The latest few releases (a year or two back) of CodeSourcery arm-none-eabi has LTO enabled and I've been using it successfully. It tends to give significant code space savings comparable to or better than -ffunction-sections -fdata-sections -Wl,--gc-sections but faster due to cross-module inlining and other optimizations.

It's not rock stable and tends to ICE if you link modules compiled with different optimization flags. Also it doesn't play well with debug. It more or less has the same problems and improvements as the old -combine -fwhole-program flags but much more convenient to use since you can still organize your code into libraries.

Might be worth to see if CodeSourcery has done any significant work on the LTO code compared to vanilla GCC.

Revision history for this message
David Dufke (dufke) said :
#5

Yes, I can verify that CodeSourcery's latest version does work. (I was under the mistaken impression that their version was gone since they became part of Mentor...) Thanks for the tip!

LTO gave me a tidy performance gain, which is excellent since my current project is performance limited. It should be noted that without LTO, GCC 4.7 appears to produce slower code than the old 4.3 i was using before. But this is just from my first quick look, there might be something else going on.

At the very least, my conclusion this far is that LTO is a worthwhile feature for ARM bare metal GCC. I wonder how we should go about getting it to a more finished state? Hacking GCC myself seems a somewhat daunting concept at the moment, honestly...

Revision history for this message
Joey Ye (jinyun-ye) said :
#6

David,

Thanks for you suggestion. There are some stability problems with LTO and we are evaluating it. Hopefully, though not guaranteed, next release will be with LTO.

- Joey

Can you help with this problem?

Provide an answer of your own, or ask David Dufke for more information if necessary.

To post a message you must log in.