[RFC] meson: Make rpi/pisp pipeline build on GCC at low optimization
diff mbox series

Message ID 20260527171041.110173-1-simonparri@ganzeria.com
State New
Headers show
Series
  • [RFC] meson: Make rpi/pisp pipeline build on GCC at low optimization
Related show

Commit Message

Simon Parri May 27, 2026, 5:10 p.m. UTC
The function PiSPCameraData::beOutputDequeue in pipelines/rpi/pisp.cpp
contains a variable "index" that is initialized in the loop along with the
variable "stream". When -ftree-vrp is not enabled, GCC cannot analyze the
code to determine that after "ASSERT(stream)", "index" will always be
initialized. Since it cannot determine that "index" will always be
initialized, it emits a warning, which is elevated to an error.

If the rpi/pisp pipeline is to be built, and the compiler is GCC, add
-ftree-vrp to project arguments for C++.

This is not needed for Clang, since Clang always does the appropriate level of
code analysis (even at -O0).
---

Notes:
    I would like advice on whether using "add_project_arguments" is the correct
    thing to do here. It feels somewhat wrong to me because all the other
    flags (as far as I can tell) are set via common_arguments / c_arguments /
    cpp_arguments. However, since I need to check the enabled pipelines, I put the check
    after the code that sets the "pipelines" variable.
    
    Or is my approach wrong to begin with? Should I be adjusting the code itself
    instead of adding compiler flags? In my opinion, adding compiler flags is the
    correct approach, since the code already works as-is with Clang.
    
    Thank you for your attention.

 meson.build | 4 ++++
 1 file changed, 4 insertions(+)

Patch
diff mbox series

diff --git a/meson.build b/meson.build
index 9cd73462f..0344c55bb 100644
--- a/meson.build
+++ b/meson.build
@@ -241,6 +241,10 @@  else
     pipelines = wanted_pipelines
 endif
 
+if cc.get_id() == 'gcc' and pipelines.contains('rpi/pisp')
+    add_project_arguments('-ftree-vrp', language : 'cpp')
+endif
+
 # Tests require the vimc pipeline handler, include it automatically when tests
 # are enabled.
 if get_option('test')