[Mesa-dev] [PATCH] meson: enable -fmerge-all-constants by default
Konstantin Kharlamov
Hi-Angel at yandex.ru
Wed Jul 25 11:03:48 UTC 2018
This is a standard non-conforming optimization, which, quoting,
"…considers e.g. even constant initialized arrays or initialized
constant variables with integral or floating-point types. Languages like
C or C++ require each variable, including multiple instances of the same
variable in recursive calls, to have distinct locations, so using this
option results in non-conforming behavior."
Having the same or distinct addresses of constants in recursive calls is
too obscure behavior to make any use of. More over, until 4 April 2018
clang have had this option enabled by default¹, and nobody ever noticed
until kernel build fail this year (having a low-level hackery in kernel
surprises no one), resulting in PR disabling the option by default.
As for Mesa: I personally have been using the option for release builds
since forever, never had any problems.
Real world significance, sizes of binaries in bytes:
default | -fmerge-all-constants | diff
-----------------------------------------------------------------------------------------------------
8048024 <-> bellagio/libomx_mesa.so | 7867800 <-> bellagio/libomx_mesa.so | -180224
10209120 <-> d3d/d3dadapter9.so.1.0.0 | 10016608 <-> d3d/d3dadapter9.so.1.0.0 | -192512
14464936 <-> dri/i915_dri.so | 14383016 <-> dri/i915_dri.so | -81920
16894344 <-> dri/kms_swrast_dri.so | 16644488 <-> dri/kms_swrast_dri.so | -249856
8077560 <-> dri/nouveau_drv_video.so | 7893240 <-> dri/nouveau_drv_video.so | -184320
3882872 <-> gallium-pipe/pipe_nouveau.so | 3870584 <-> gallium-pipe/pipe_nouveau.so | -12288
2511160 <-> gallium-pipe/pipe_r300.so | 2502968 <-> gallium-pipe/pipe_r300.so | -8192
2818520 <-> gallium-pipe/pipe_r600.so | 2810328 <-> gallium-pipe/pipe_r600.so | -8192
4123056 <-> gallium-pipe/pipe_radeonsi.so | 3955120 <-> gallium-pipe/pipe_radeonsi.so | -167936
2413936 <-> gallium-pipe/pipe_swrast.so | 2401648 <-> gallium-pipe/pipe_swrast.so | -12288
2701360 <-> gallium-pipe/pipe_vmwgfx.so | 2689072 <-> gallium-pipe/pipe_vmwgfx.so | -12288
582496 <-> libGLX_mesa.so.0.0.0 | 578400 <-> libGLX_mesa.so.0.0.0 | -4096
23451656 <-> libMesaOpenCL.so.1.0.0 | 23447560 <-> libMesaOpenCL.so.1.0.0 | -4096
10370344 <-> libOSMesa.so.8.0.0 | 10300712 <-> libOSMesa.so.8.0.0 | -69632
4766032 <-> libvulkan_intel.so | 4745552 <-> libvulkan_intel.so | -20480
2761376 <-> libvulkan_radeon.so | 2753184 <-> libvulkan_radeon.so | -8192
4703776 <-> libxatracker.so.2.4.0 | 4687392 <-> libxatracker.so.2.4.0 | -16384
8510392 <-> vdpau/libvdpau_nouveau.so.1.0.0 | 8326072 <-> vdpau/libvdpau_nouveau.so.1.0.0 | -184320
For consistency it's enabled for both debug and release builds.
1: https://reviews.llvm.org/D45289
Signed-off-by: Konstantin Kharlamov <Hi-Angel at yandex.ru>
---
meson.build | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/meson.build b/meson.build
index e05645cbf3..36016cf959 100644
--- a/meson.build
+++ b/meson.build
@@ -794,6 +794,11 @@ foreach a : ['-Wall', '-fno-math-errno', '-fno-trapping-math',
endif
endforeach
+if ['gcc', 'clang'].contains(cc.get_id())
+ c_args += '-fmerge-all-constants'
+ cpp_args += '-fmerge-all-constants'
+endif
+
# For some reason, the test for -Wno-foo always succeeds with gcc, even if the
# option is not supported. Hence, check for -Wfoo instead.
--
2.18.0
More information about the mesa-dev
mailing list