From 6b9d451c56ada4a1ecd8be6234a1e0c91d4a2555 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Thu, 19 Jan 2023 15:00:38 +0100 Subject: [PATCH] app: enable lock check Signed-off-by: David Marchand --- app/meson.build | 6 ++++++ app/test/meson.build | 5 +++++ app/test/test_rwlock.c | 2 ++ app/test/test_spinlock.c | 2 ++ 4 files changed, 15 insertions(+) diff --git a/app/meson.build b/app/meson.build index 5b2c80c7a15..7ff17a527be 100644 --- a/app/meson.build +++ b/app/meson.build @@ -56,6 +56,7 @@ foreach app:apps reason = '' # set if build == false to explain sources = [] includes = [] + annotate_locks = true cflags = default_cflags ldflags = default_ldflags objs = [] # other object files to link against, used e.g. for @@ -114,6 +115,11 @@ foreach app:apps link_libs = dpdk_static_libraries + dpdk_drivers endif + if annotate_locks and cc.has_argument('-Wthread-safety') + cflags += '-DRTE_ANNOTATE_LOCKS' + cflags += '-Wthread-safety' + endif + exec = executable('dpdk-' + name, sources, c_args: cflags, diff --git a/app/test/meson.build b/app/test/meson.build index 40f22a54d51..f222971b67f 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -259,6 +259,11 @@ cflags += '-fno-strict-aliasing' # Enable using internal APIs in unit tests cflags += '-DALLOW_INTERNAL_API' +if cc.has_argument('-Wthread-safety') + cflags += '-DRTE_ANNOTATE_LOCKS' + cflags += '-Wthread-safety' +endif + # create a symlink in the app/test directory for the binary, for backward compatibility if not is_windows custom_target('test_symlink', diff --git a/app/test/test_rwlock.c b/app/test/test_rwlock.c index 785317621dd..2ac9be4599e 100644 --- a/app/test/test_rwlock.c +++ b/app/test/test_rwlock.c @@ -2,6 +2,8 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#undef RTE_ANNOTATE_LOCKS + #include #include #include diff --git a/app/test/test_spinlock.c b/app/test/test_spinlock.c index 34e0ef9422f..029545653c4 100644 --- a/app/test/test_spinlock.c +++ b/app/test/test_spinlock.c @@ -2,6 +2,8 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#undef RTE_ANNOTATE_LOCKS + #include #include #include