Link Time Optimization (LTO)

I presume that Particle is using Link Time Optimization for extra memory savings when compiling the system firmware, but how would I go about for using LTO on my user code? Does anyone have experience with this and could share some insight on how to do this the best way?

The only mention I’ve seen is this thread that is several years old.

J

Looking at the Travis continuous-integration testing script on github, builds for debug are done with COMPILE_LTO=n, but builds for production are done with COMPILE_LTO=y.

If you are running make and gcc locally, you are fully in control over this. If you are using the cloud compiler, you do not have control that I know of and I believe it always does COMPILE_LTO=y.

2 Likes

Ok, so what you are saying is that there’s no need to set this up then as it’s already pretty much done for you?

Set up the local compile environment and pass $COMPILE_LTO=y to make looks like it should work. That is what Particle themselves do.

Right, but I won’t gain anything (other than a complex compilation setup) from doing this rather than setting it up myself? I have no experience with LOT, but from what I’ve read it’s just another pass of optimisation that comes after the compile process and it’s fully automated so I can’t do much to affect the output?

I believe that is correct. You are already getting LTO from what I can see.

If you need more control or debugging symbols to use in gdb, then you need a local environment to compile with LTO off.

Yeah. I got Eclipse setup and that part’s working great. I’m just trying to squeeze as much as possible out of the 128k available. I’m not using much RAM, so I’ve been trying to see if I can move things from Flash to the stack. Any help in that regard would be very appreciated.