I'm migrating from arm compiler 5 to armclang and I'm struggling with placing functions in RAM.
I tried using what this page suggests - https://www.keil.com/support/docs/3228.htm - and it works, if LTO is disabled.
If I enable LTO and set optimization level to -Oz, function gets inlined in 'normal' flash-function. Using -fno-inline or __attribute__((noinline)) doesn't affect this.
How can I prevent this?
Hi Roman, this is the nature of LTO (link time optimization) - you are asking the linker to put this function in the most optimal place based on how other objects interact with it. LTO will result in a single large object with all the LTO'd code together (this is most easily seen by the --info sizes linker output).
The solution is to disable LTO for this source file (-fno-lto) - you can continue to use LTO for other files.
I just updated to Keil 5.34 and there -LTO really does break ramfunctions. Howerver disabling lto for one file as you suggested - works!
View all questions in Arm Compilers forum