disable lock annotation with clang 3.4.2
Subsystems (2)
PATCH 1/1 disable lock annotation with clang 3.4.2
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.
--- drivers/meson.build | 2 +- lib/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/meson.build +1 -1
@@ -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
lib/meson.build +1 -1
@@ -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
Signature · 1 line
2.39.1
Quoted 37 lines · David Marchand
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 allowassert_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 <[email protected]>--- drivers/meson.build | 2 +- lib/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/meson.build +0
-0
drivers/meson.build foreach subpath:subdirs · line 174
Quoted 8 lines
drivers/meson.build +1
-1@@ -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
Are we likely to see any issues with this with any other compilers? Should we look to do a built-test in meson to determine feature support rather than checking clang versions explicitly?
On the plus side, checking clang version like this makes it clear when we can drop the conditional.
/Bruce
Morten Brørup
Acked-byQuoted 54 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 13 February 2023 15.55Quoted 14 lines · David Marchand
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 allowassert_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__))) ^Quoted 1 line
This can be worked around by splitting and having the allocation on
the
Quoted 7 lines
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
Quoted 15 lines
to clang versions newer than 3.5.0.
Fixes 657a98f38940 ("eal: annotate spinlock, rwlock and seqlock")Signed-off-by David Marchand <[email protected]>--- drivers/meson.build | 2 +- lib/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/meson.build +0
-0drivers/meson.build foreach subpath:subdirs · line 170
Quoted 3 lines
drivers/meson.build +0
-0@@ -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])
drivers/meson.build foreach subpath:subdirs · line 171
Quoted 2 lines
drivers/meson.build +1
-1- if annotate_locks and cc.has_argument('-Wthread-safety') + if annotate_locks and cc.get_id() == 'clang' andcc.version().version_compare('>=3.5.0')
drivers/meson.build foreach subpath:subdirs · line 174
Quoted 3 lines
drivers/meson.build +0
-0cflags += '-DRTE_ANNOTATE_LOCKS' cflags += '-Wthread-safety' endif
Quoted 8 lines
Are we likely to see any issues with this with any other compilers? Should
we look to do a built-test in meson to determine feature support rather than checking clang versions explicitly?On the plus side, checking clang version like this makes it clear when we
can drop the conditional.
I prefer this over auto-detection in meson, for the reason mentioned by Bruce.
Furthermore, different compilers may use different syntax in the code, so it is impossible to detect generically; the auto-detection would be per compiler anyway.
Raslan Darawsheh
Tested-byQuoted 75 lines
-----Original Message-----
From: Morten Brørup <[email protected]>
Sent: Monday, February 13, 2023 6:09 PM
To: Bruce Richardson <[email protected]>; David Marchand <[email protected]>
Cc: [email protected]; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Raslan Darawsheh <[email protected]>; Chenbo Xia <[email protected]>; Maxime Coquelin <[email protected]>
Subject: RE: [PATCH] disable lock annotation with clang 3.4.2Quoted 54 lines
From: Bruce Richardson [mailto:[email protected]]
Sent: Monday, 13 February 2023 15.55Quoted 14 lines · David Marchand
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 allowassert_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__))) ^Quoted 1 line
This can be worked around by splitting and having the allocation on
the
Quoted 7 lines
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
Quoted 15 lines
to clang versions newer than 3.5.0.
Fixes 657a98f38940 ("eal: annotate spinlock, rwlock and seqlock")Signed-off-by David Marchand <[email protected]>--- drivers/meson.build | 2 +- lib/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/meson.build +0
-0drivers/meson.build foreach subpath:subdirs · line 170
Quoted 3 lines
drivers/meson.build +0
-0@@ -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])
drivers/meson.build foreach subpath:subdirs · line 171
Quoted 2 lines
drivers/meson.build +1
-1- if annotate_locks and cc.has_argument('-Wthread-safety') + if annotate_locks and cc.get_id() == 'clang' andcc.version().version_compare('>=3.5.0')
drivers/meson.build foreach subpath:subdirs · line 174
Quoted 3 lines
drivers/meson.build +0
-0cflags += '-DRTE_ANNOTATE_LOCKS' cflags += '-Wthread-safety' endifQuoted 8 lines
Are we likely to see any issues with this with any other compilers? Should
we look to do a built-test in meson to determine feature support rather than checking clang versions explicitly?On the plus side, checking clang version like this makes it clear when we
can drop the conditional.
Quoted 8 lines
I prefer this over auto-detection in meson, for the reason mentioned by Bruce.
Furthermore, different compilers may use different syntax in the code, so it is impossible to detect generically; the auto-detection would be per compiler anyway.
Acked-by Morten Brørup <[email protected]>
Kindest regards,
Raslan Darawsheh
Thomas Monjalon
Applied13/02/2023 17:36, Raslan Darawsheh:
Quoted 32 lines
From: Morten Brørup <[email protected]>
Quoted 31 lines
From: Bruce Richardson [mailto:[email protected]]
Quoted 30 lines · David Marchand
Quoted 14 lines
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 allowassert_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__))) ^Quoted 1 line
This can be worked around by splitting and having the allocation on
the
Quoted 7 lines
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
Quoted 5 lines
to clang versions newer than 3.5.0.
Fixes 657a98f38940 ("eal: annotate spinlock, rwlock and seqlock")Signed-off-by David Marchand <[email protected]>
[...]
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
Are we likely to see any issues with this with any other compilers? Should
we look to do a built-test in meson to determine feature support rather than checking clang versions explicitly?On the plus side, checking clang version like this makes it clear when we
can drop the conditional.I prefer this over auto-detection in meson, for the reason mentioned by Bruce.
Quoted 6 lines
Quoted 5 lines
Furthermore, different compilers may use different syntax in the code, so it is impossible to detect generically; the auto-detection would be per compiler anyway.
Acked-by Morten Brørup <[email protected]>Tested-by Raslan Darawsheh <[email protected]>
Applied, thanks.