diff --git a/app/meson.build b/app/meson.build index 5b2c80c7a1..7ff17a527b 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 40f22a54d5..f222971b67 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 785317621d..2ac9be4599 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 34e0ef9422..029545653c 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