DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] disable lock annotation with clang 3.4.2
@ 2023-02-13 14:44 David Marchand
  2023-02-13 14:54 ` Bruce Richardson
  0 siblings, 1 reply; 5+ messages in thread
From: David Marchand @ 2023-02-13 14:44 UTC (permalink / raw)
  To: dev; +Cc: thomas, rasland, Chenbo Xia, Morten Brørup, Maxime Coquelin

Venerable RHEL7 clang 3.4.2 has (at least) two issues with lock
annotations.

A first one with regards to the attribute position:
../lib/vhost/vhost.h:518:2: error: GCC does not allow
	assert_exclusive_lock attribute in this position on a
	function definition [-Werror,-Wgcc-compat]
        __rte_assert_exclusive_lock(&vq->access_lock)
        ^
../lib/eal/include/rte_lock_annotations.h:29:38: note: expanded
	from macro '__rte_assert_exclusive_lock'
        __attribute__((assert_exclusive_lock(__VA_ARGS__)))
                                            ^

This can be worked around by splitting and having the allocation on the
function declaration.

But on the other hand, clang 3.4.2 does not seem to propagate those
annotations in presence of a __builtin_expect (i.e. unlikely()), like
for example when calling if (unlikely(rte_spinlock_trylock() == 0)).

Those annotations were only working with clang in any case, so restrict
to clang versions newer than 3.5.0.

Fixes: 657a98f38940 ("eal: annotate spinlock, rwlock and seqlock")

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/meson.build | 2 +-
 lib/meson.build     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/meson.build b/drivers/meson.build
index bddc4a6cc4..0618c31a69 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -168,7 +168,7 @@ foreach subpath:subdirs
         enabled_drivers += name
         lib_name = '_'.join(['rte', class, name])
         cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=' + '.'.join([log_prefix, name])
-        if annotate_locks and cc.has_argument('-Wthread-safety')
+        if annotate_locks and cc.get_id() == 'clang' and cc.version().version_compare('>=3.5.0')
             cflags += '-DRTE_ANNOTATE_LOCKS'
             cflags += '-Wthread-safety'
         endif
diff --git a/lib/meson.build b/lib/meson.build
index 450c061d2b..2bc0932ad5 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -203,7 +203,7 @@ foreach l:libraries
         cflags += '-DRTE_USE_FUNCTION_VERSIONING'
     endif
     cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l
-    if annotate_locks and cc.has_argument('-Wthread-safety')
+    if annotate_locks and cc.get_id() == 'clang' and cc.version().version_compare('>=3.5.0')
         cflags += '-DRTE_ANNOTATE_LOCKS'
         cflags += '-Wthread-safety'
     endif
-- 
2.39.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-14 11:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-13 14:44 [PATCH] disable lock annotation with clang 3.4.2 David Marchand
2023-02-13 14:54 ` Bruce Richardson
2023-02-13 16:09   ` Morten Brørup
2023-02-13 16:36     ` Raslan Darawsheh
2023-02-14 11:27       ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).