[libcamera-devel] [PATCH] libcamera: base: Remove ARM clang-11 compile error

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Jul 12 23:49:07 CEST 2022


Quoting Naushir Patuck via libcamera-devel (2022-07-12 14:01:38)
> Compiling backtrace.cpp produces the follwing error with the ARM clang-11 (and
> later) compiler:
> 
> --------------------
> ../src/libcamera/base/backtrace.cpp:195:12: error: use of SP or PC in the list is deprecated [-Werror,-Winline-asm]
>         int ret = unw_getcontext(&uc);
>                   ^
> /usr/include/arm-linux-gnueabihf/libunwind-common.h:114:29: note: expanded from macro 'unw_getcontext'
>                                         ^
> /usr/include/arm-linux-gnueabihf/libunwind-arm.h:270:5: note: expanded from macro 'unw_tdep_getcontext'
>     "stmia %[base], {r0-r15}"                                           \
>     ^
> <inline asm>:1:2: note: instantiated into assembly here
>         stmia r0, {r0-r15}
> --------------------
> 
> Suppress this compilation error with a clang specific pragma around the
> offending statements.
> 
> Further information about this error can be found here:
> https://github.com/dotnet/runtime/issues/5
> 
> Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
> ---
>  src/libcamera/base/backtrace.cpp | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/libcamera/base/backtrace.cpp b/src/libcamera/base/backtrace.cpp
> index 483492c390c3..b8ae2f6dc331 100644
> --- a/src/libcamera/base/backtrace.cpp
> +++ b/src/libcamera/base/backtrace.cpp
> @@ -191,11 +191,21 @@ __attribute__((__noinline__))
>  bool Backtrace::unwindTrace()
>  {
>  #if HAVE_UNWIND
> +
> +#if __clang__

Has this been tested on !__clang__ ? Shouldn't it be #ifdef __clang__?

Otherwise when __clang__ isn't defined ... I expect this will fail?

Ok - so testing this - it seems like at least with GCC it's fine. I
guess it treats undefined as '0'. So that's ok.


I'd probably also put a single line comment above saying /why/ we're
disabling this here.


Even something simple like:

 /* clang-11 fails here on arm32 builds. */


But as Jacopo said - this fixes a compile breakage so lets get it resolved.
I'll see if I can add a 32 bit compile to my matrix.

Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>


> +#pragma clang diagnostic push
> +#pragma clang diagnostic ignored "-Winline-asm"
> +#endif
> +
>         unw_context_t uc;
>         int ret = unw_getcontext(&uc);
>         if (ret)
>                 return false;
>  
> +#if __clang__
> +#pragma clang diagnostic pop
> +#endif
> +
>         unw_cursor_t cursor;
>         ret = unw_init_local(&cursor, &uc);
>         if (ret)
> -- 
> 2.25.1
>


More information about the libcamera-devel mailing list