Content originally posted in LPCWare by Muis on Thu Feb 26 05:14:34 MST 2015 My code does not depend on semi-hosting, and the release version is always compiled as Redlib (None).
Now last week I tried to debug a HardFault which occurs in my code only with LTO (Link Time Optimization) enabled (-oS). I couldn't find the reason. Today I accidently enabled 'Redlib (Nohost) for my release-build. And now LTO-compiled binaries don't give a HardFault anymore?
What can be the cause of this miraclous behaviour of None Vs NoHost?
Content originally posted in LPCWare by Muis on Thu Feb 26 09:36:32 MST 2015 No, I am sure the HardFault is not being masked.
My code works on all optimization levels (O1 to OS) even with LTO enabled. Only when I switch from Redlib (Nohost) to Redlib (None) it becomes unstable with LTO. In release mode, the Hardfault handler isnt even executed, the firmware just freezes. In debug mode, I get Hardfaults on the weirdest places, usually VECTPT contains 'g_pfnVectors' and the line is calling 'memset' or 'memcpy'.
It just seems the LPCXpresso wasn't prepared for LTO very well. I already had to modify the startup files to add "__attribute__ ((used" or else your own examples won't even boot when compiled with LTO.
Content originally posted in LPCWare by lpcxpresso-support on Thu Feb 26 07:06:27 MST 2015 This sounds like the change of library is either masking the Hard Fault (does your application work?) or it has changed the way that the linker is optimizing the code, so it now works.
I would recommend that you build without LTO, or try LTO with lower optimization levels.