[libcamera-devel] libcamera: base: Suppress clang-11 compile error on ARM32
diff mbox series

Message ID 20220713020320.19636-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 1fa2d579de9af84b4e419a568de193c0e1e57ac7
Headers show
Series
  • [libcamera-devel] libcamera: base: Suppress clang-11 compile error on ARM32
Related show

Commit Message

Laurent Pinchart July 13, 2022, 2:03 a.m. UTC
From: Naushir Patuck <naush@raspberrypi.com>

Compiling backtrace.cpp for ARM32 produces the following error with the
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 at
https://github.com/dotnet/runtime/issues/38652

Bug: https://bugs.libcamera.org/show_bug.cgi?id=136
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/base/backtrace.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)


base-commit: ba6435930f08e802cffc688d90f156a8959a0f86

Comments

Naushir Patuck July 13, 2022, 7:33 a.m. UTC | #1
Hi Laurent,

Thanks for the updates.

On Wed, 13 Jul 2022 at 03:03, Laurent Pinchart <
laurent.pinchart@ideasonboard.com> wrote:

> From: Naushir Patuck <naush@raspberrypi.com>
>
> Compiling backtrace.cpp for ARM32 produces the following error with the
> 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 at
> https://github.com/dotnet/runtime/issues/38652


As mentioned in the last email, I did mean to refer to
https://github.com/dotnet/runtime/issues/5595

But your link is also related, so happy to keep it (or both).


>
>
> Bug: https://bugs.libcamera.org/show_bug.cgi?id=136
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> Tested-by: Jacopo Mondi <jacopo@jmondi.org>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>

Reviewed-by: Naushir Patuck <naush@rasbperrypi.com>
Tested-by: Naushir Patuck <naush@rasbperrypi.com>


> ---
>  src/libcamera/base/backtrace.cpp | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/src/libcamera/base/backtrace.cpp
> b/src/libcamera/base/backtrace.cpp
> index 483492c390c3..be30589d255e 100644
> --- a/src/libcamera/base/backtrace.cpp
> +++ b/src/libcamera/base/backtrace.cpp
> @@ -191,10 +191,22 @@ __attribute__((__noinline__))
>  bool Backtrace::unwindTrace()
>  {
>  #if HAVE_UNWIND
> +/*
> + * unw_getcontext() for ARM32 is an inline assembly function using the
> stmia
> + * instruction to store SP and PC. This is considered by clang-11 as
> deprecated,
> + * and generates a warning.
> + */
> +#ifdef __clang__
> +#pragma clang diagnostic push
> +#pragma clang diagnostic ignored "-Winline-asm"
> +#endif
>         unw_context_t uc;
>         int ret = unw_getcontext(&uc);
>         if (ret)
>                 return false;
> +#ifdef __clang__
> +#pragma clang diagnostic pop
> +#endif
>
>         unw_cursor_t cursor;
>         ret = unw_init_local(&cursor, &uc);
>
> base-commit: ba6435930f08e802cffc688d90f156a8959a0f86
> --
> Regards,
>
> Laurent Pinchart
>
>

Patch
diff mbox series

diff --git a/src/libcamera/base/backtrace.cpp b/src/libcamera/base/backtrace.cpp
index 483492c390c3..be30589d255e 100644
--- a/src/libcamera/base/backtrace.cpp
+++ b/src/libcamera/base/backtrace.cpp
@@ -191,10 +191,22 @@  __attribute__((__noinline__))
 bool Backtrace::unwindTrace()
 {
 #if HAVE_UNWIND
+/*
+ * unw_getcontext() for ARM32 is an inline assembly function using the stmia
+ * instruction to store SP and PC. This is considered by clang-11 as deprecated,
+ * and generates a warning.
+ */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Winline-asm"
+#endif
 	unw_context_t uc;
 	int ret = unw_getcontext(&uc);
 	if (ret)
 		return false;
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
 
 	unw_cursor_t cursor;
 	ret = unw_init_local(&cursor, &uc);