Percetto is using designated struct initializers, but those are not
supported in standard C++ before C++20, resulting in some compilation
warnings.
The previous fix for that was using a diagnostic valid for clang but not
for g++ resulting in another warning when building with g++:
-----------------------------------------------------------------------
In file included from ../monado/src/xrt/auxiliary/math/m_relation_history.cpp:19:
../monado/src/xrt/auxiliary/util/u_trace_marker.h:21:32: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
21 | #pragma GCC diagnostic ignored "-Wc99-designator"
| ^~~~~~~~~~~~~~~~~~
-----------------------------------------------------------------------
For GCC the diagnostics to disable is actually "-Wpedantic", as shown
below:
-----------------------------------------------------------------------
In file included from ../monado/src/xrt/auxiliary/util/u_trace_marker.h:25,
from ../monado/src/xrt/auxiliary/math/m_relation_history.cpp:19:
../external/percetto/src/percetto.h: In function ‘void percetto_event_with_args(percetto_category*, uint32_t, const char*, int32_t, const percetto_track*, int64_t, uint64_t)’:
../external/percetto/src/percetto.h:424:5: warning: C++ designated initializers only available with ‘-std=c++2a’ or ‘-std=gnu++2a’ [-Wpedantic]
424 | .track = track,
| ^
-----------------------------------------------------------------------
And for clang "-Wc++20-designator" should be slightly more accurate:
-----------------------------------------------------------------------
In file included from ../monado/src/xrt/auxiliary/util/u_trace_marker.h:29:
../external/percetto/src/percetto.h:424:5: warning: designated initializers are a C++20 extension [-Wc++20-designator]
.track = track,
^
-----------------------------------------------------------------------
Fix all the warnings by ignoring the right diagnostics depending on the
compiler, taking care of differentiating clang++ from g++ as they both
define __GNUC__.
Should a application load and unload the OpenXR runtime driver multiple times
the Perfetto code becomes unstable and eventually crashes. This unfortunately
happens with the CTS, to avoid having to recompile Monado and a env variable
to control if tracing should be used.