Comment by DaveFlater

1 year ago

GCC optimization causes the frame pointer push to move around, resulting in wrong call stacks. "Wontfix"

https://news.ycombinator.com/item?id=38896343

That was in 2012. Does it still occur on modern GCC?

There definitely have been regressions with frame pointers being enabled, although we've fixed all the ones we've found in current (2024) Fedora.

  • I think so and I vaguely seem to recall -fno-schedule-insns2 being the only thing that fixes it. To get the full power of frame pointers and hackable binary, what I use is:

        -fno-schedule-insns2
        -fno-omit-frame-pointers
        -fno-optimize-sibling-calls
        -mno-omit-leaf-frame-pointer
        -fpatchable-function-entry=18,16
        -fno-inline-functions-called-once
    

    The only flag that's potentially problematic is -fno-optimize-sibling-calls since it breaks the optimal approach to writing interpreters and slows down code that's written in a more mathematical style.