<div dir="ltr"><div dir="ltr">Hi Laurent,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 13 Jul 2022 at 03:01, Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com">laurent.pinchart@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, Jul 12, 2022 at 10:49:07PM +0100, Kieran Bingham via libcamera-devel wrote:<br>
> Quoting Naushir Patuck via libcamera-devel (2022-07-12 14:01:38)<br>
> > Compiling backtrace.cpp produces the follwing error with the ARM clang-11 (and<br>
> > later) compiler:<br>
> > <br>
> > --------------------<br>
> > ../src/libcamera/base/backtrace.cpp:195:12: error: use of SP or PC in the list is deprecated [-Werror,-Winline-asm]<br>
> > int ret = unw_getcontext(&uc);<br>
> > ^<br>
> > /usr/include/arm-linux-gnueabihf/libunwind-common.h:114:29: note: expanded from macro 'unw_getcontext'<br>
> > ^<br>
> > /usr/include/arm-linux-gnueabihf/libunwind-arm.h:270:5: note: expanded from macro 'unw_tdep_getcontext'<br>
> > "stmia %[base], {r0-r15}" \<br>
> > ^<br>
> > <inline asm>:1:2: note: instantiated into assembly here<br>
> > stmia r0, {r0-r15}<br>
> > --------------------<br>
> > <br>
> > Suppress this compilation error with a clang specific pragma around the<br>
> > offending statements.<br>
> > <br>
> > Further information about this error can be found here:<br>
> > <a href="https://github.com/dotnet/runtime/issues/5" rel="noreferrer" target="_blank">https://github.com/dotnet/runtime/issues/5</a><br>
<br>
Naush, did you mean<br>
<br>
<a href="https://github.com/dotnet/runtime/issues/38652" rel="noreferrer" target="_blank">https://github.com/dotnet/runtime/issues/38652</a><br>
<br>
or maybe<br>
<br>
<a href="https://github.com/dotnet/runtime/pull/38971" rel="noreferrer" target="_blank">https://github.com/dotnet/runtime/pull/38971</a></blockquote><div><br></div><div>I actually meant <a href="https://github.com/dotnet/runtime/issues/5595">https://github.com/dotnet/runtime/issues/5595</a></div><div><br></div><div>Not sure what went on with my clipboard there :)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
?<br>
<br>
> > Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
> > ---<br>
> > src/libcamera/base/backtrace.cpp | 10 ++++++++++<br>
> > 1 file changed, 10 insertions(+)<br>
> > <br>
> > diff --git a/src/libcamera/base/backtrace.cpp b/src/libcamera/base/backtrace.cpp<br>
> > index 483492c390c3..b8ae2f6dc331 100644<br>
> > --- a/src/libcamera/base/backtrace.cpp<br>
> > +++ b/src/libcamera/base/backtrace.cpp<br>
> > @@ -191,11 +191,21 @@ __attribute__((__noinline__))<br>
> > bool Backtrace::unwindTrace()<br>
> > {<br>
> > #if HAVE_UNWIND<br>
> > +<br>
> > +#if __clang__<br>
> <br>
> Has this been tested on !__clang__ ? Shouldn't it be #ifdef __clang__?<br>
> <br>
> Otherwise when __clang__ isn't defined ... I expect this will fail?<br>
> <br>
> Ok - so testing this - it seems like at least with GCC it's fine. I<br>
> guess it treats undefined as '0'. So that's ok.<br></blockquote><div><br></div><div>Yes, it works since undefined is treated as 0. It's annoying to add</div><div>the #if as I would have hoped gcc would ignore "pragma clang"</div><div>statements, but it does not.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
#ifdef would still be better I think, so let's do that.<br>
<br>
> I'd probably also put a single line comment above saying /why/ we're<br>
> disabling this here.<br>
> <br>
> <br>
> Even something simple like:<br>
> <br>
> /* clang-11 fails here on arm32 builds. */<br>
<br>
/*<br>
* unw_getcontext() for ARM32 is an inline assembly function using the stmia<br>
* instruction to store SP and PC. This is considered by clang-11 as deprecated,<br>
* and generates a warning.<br>
*/<br>
<br>
> But as Jacopo said - this fixes a compile breakage so lets get it resolved.<br>
> I'll see if I can add a 32 bit compile to my matrix.<br>
<br>
I have one, but it's using gcc. If you manage to write a meson<br>
cross-file for cross-compilation with clang, I'm interested :-)<br>
<br>
> Reviewed-by: Kieran Bingham <<a href="mailto:kieran.bingham@ideasonboard.com" target="_blank">kieran.bingham@ideasonboard.com</a>><br>
<br>
Reviewed-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>><br>
<br>
I'll post a v2 with all the minor changes that have been discussed<br>
during review, just to make sure I didn't make any stupid mistake.<br></blockquote><div><br></div><div>Sounds good!</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> > +#pragma clang diagnostic push<br>
> > +#pragma clang diagnostic ignored "-Winline-asm"<br>
> > +#endif<br>
> > +<br>
> > unw_context_t uc;<br>
> > int ret = unw_getcontext(&uc);<br>
> > if (ret)<br>
> > return false;<br>
> > <br>
> > +#if __clang__<br>
> > +#pragma clang diagnostic pop<br>
> > +#endif<br>
> > +<br>
> > unw_cursor_t cursor;<br>
> > ret = unw_init_local(&cursor, &uc);<br>
> > if (ret)<br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
</blockquote></div></div>