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

Naushir Patuck naush at raspberrypi.com
Tue Jul 12 15:01:38 CEST 2022


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__
+#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