Work-around GCC LTO codegen bug in process_commands()

When building with GCC 4.9.2 (bundled with PF-build-env-1.0.6.*), -Os
and LTO enabled, PID_autotune gets automatically inlined into
process_commands().

Sadly, due to the massive size of process_commands(), it results in
codegen bug doing a partial stack overwrite in process_commands()
itself, manifesting as random behavior depending on the timing of
interrupts and the codepath taken inside the merged function.

Mark the function as noinline and add a note about the affected compiler
version in order to be checked again in the future.
This commit is contained in:
Yuri D'Elia 2021-06-23 21:52:25 +02:00 committed by DRracer
parent 66ee9a295f
commit 53fcd6fc8f

View File

@ -287,8 +287,10 @@ bool checkAllHotends(void)
return(result);
}
void PID_autotune(float temp, int extruder, int ncycles)
{
// WARNING: the following function has been marked noinline to avoid a GCC 4.9.2 LTO
// codegen bug causing a stack overwrite issue in process_commands()
void __attribute__((noinline)) PID_autotune(float temp, int extruder, int ncycles)
{
pid_number_of_cycles = ncycles;
pid_tuning_finished = false;
float input = 0.0;