[libcamera-devel] [PATCH] ipa: tweak constant expressions that fail to be determined on ppc64el

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Oct 15 18:39:15 CEST 2022


Hi Olivier,

Thank you for the patch.

On Mon, Oct 10, 2022 at 03:45:08PM +0200, Olivier Gayot wrote:
> From: Olivier Gayot <olivier.gayot at canonical.com>
> 
> On ppc64el, GCC fails to determine the result of some long double
> expressions at compile time. This makes libcamera fail to build with GCC
> on that architecture.

Could you provide the exact compiler version ? Looking at
https://bugzilla.redhat.com/show_bug.cgi?id=1538817#c11, I'd like to
know if newer gcc versions still fail to compile libcamera for ppc64el.
A comment in the bug report also claims

"The IBM long double format is too weird and not everything in it is
possible to be evaluated at compile time."

which sounds hard to believe.

Anyway, the change below looks OK to me. Once you provide the compiler
version I'll add that to the commit message and push the patch.

> e.g.:
> 
> constexpr auto x = 1.0l/30.0;
> 
> in ‘constexpr’ expansion of ‘std::chrono::operator/<long double, std::ratio<1>,
>   double>(std::literals::chrono_literals::operator""s(1.0e+0l), 6.0e+1)’
> /usr/include/c++/11/chrono:710:39: error: ‘(1.0e+0l / 6.0e+1)’ is not a constant expression
>   710 |         return __cd(__cd(__d).count() / __s);
> 
> Tweaking the expressions just a bit makes GCC happy and allows libcamera
> to build properly on ppc64el.
> 
> Signed-off-by: Olivier Gayot <olivier.gayot at canonical.com>
> ---
>  src/ipa/raspberrypi/raspberrypi.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp
> index 14b06a4f..3e4383f9 100644
> --- a/src/ipa/raspberrypi/raspberrypi.cpp
> +++ b/src/ipa/raspberrypi/raspberrypi.cpp
> @@ -60,7 +60,7 @@ using utils::Duration;
>  /* Configure the sensor with these values initially. */
>  constexpr double defaultAnalogueGain = 1.0;
>  constexpr Duration defaultExposureTime = 20.0ms;
> -constexpr Duration defaultMinFrameDuration = 1.0s / 30.0;
> +constexpr Duration defaultMinFrameDuration = 1s / 30.0;
>  constexpr Duration defaultMaxFrameDuration = 250.0s;
>  
>  /*
> @@ -69,7 +69,7 @@ constexpr Duration defaultMaxFrameDuration = 250.0s;
>   * we rate-limit the controller Prepare() and Process() calls to lower than or
>   * equal to this rate.
>   */
> -constexpr Duration controllerMinFrameDuration = 1.0s / 30.0;
> +constexpr Duration controllerMinFrameDuration = 1s / 30.0;
>  
>  /* List of controls handled by the Raspberry Pi IPA */
>  static const ControlInfoMap::Map ipaControls{

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list