From 979ae78318c3e37cc0e0579b8d1f05c46bb76e7d Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Tue, 19 May 2020 20:35:49 +0300 Subject: [PATCH] meson: Disable GCC's dead store elimination for memory zeroing custom new MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2977 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/1358 Signed-off-by: Danylo Piliaiev Reviewed-by: Marek Olšák Part-of: (cherry picked from commit 5500a2b7fc558217bbd4c2a966ab6fcadaed8b3b) Signed-off-by: Laurent Carlier --- meson.build | 5 +++++ 1 files changed, 5 insertions(+), 0 deletion(-) diff --git a/meson.build b/meson.build index ba4fdb2a59f..434684c8bcc 100644 --- a/meson.build +++ b/meson.build @@ -980,6 +980,11 @@ else '-fno-math-errno', '-fno-trapping-math', '-Qunused-arguments', + # 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. + '-flifetime-dse=1', ] # MinGW chokes on format specifiers and I can't get it all working if not (cc.get_id() == 'gcc' and host_machine.system() == 'windows') -- 2.26.2