Skip to content

meson: Disable GCC's dead store elimination for memory zeroing custom new

Danylo Piliaiev requested to merge GL/mesa:fix/2977-lto-crash into master

Some classes use custom new operator which zeroes memory, however gcc does aggressive dead-store elimination which threats all writes to the memory before the constructor as "dead stores".

For now we disable this optimization.

The new operators in question are declared via:

  • DECLARE_RZALLOC_CXX_OPERATORS
  • DECLARE_LINEAR_ZALLOC_CXX_OPERATORS

The issue was found with lto builds, however there is no guarantee that it didn't happen with ordinary ones.

CC: mesa-stable@lists.freedesktop.org
Closes: #2977 (closed)
Closes: #1358 (closed)

I think we should properly initialize all fields in constructors, however it's safer to disable optimization for 20.0.8 and for 20.1.0 releases.

Edited by Danylo Piliaiev

Merge request reports