It's helpful to know if a binary is compiled with or without sanitizers.
So append " ASAN" and/or " UBSAN" to the binary version when OVN was
configured with either sanitizer.

Example compiled with both sanitizers:
    $ ovn-controller --version
    ovn-controller 26.09.90 ASAN UBSAN

Or just one:
    $ ovn-northd --version
    ovn-northd 26.09.90 UBSAN

This can be verified with the following command, and removing and adding
the sanitizers:
    $ printf '#include "include/ovn/version.h"\nOVN_PACKAGE_VERSION\n'
          | gcc -fsanitize=address,undefined -E - | tail -n 1

Also reformat the version suffix comment in acinclude.m4 to be in line
with the other functions.

Signed-off-by: Rosemarie O'Riorden <[email protected]>
---
v2:
 - Introduced in v2.
v3:
 - Move from acinclude.m4 to version.h.in.
 - Only append to version string.
 - Use spaces instead of dashes, and capitals instead of lowercase.
---
 acinclude.m4             |  2 ++
 include/ovn/version.h.in | 17 ++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 82070dc52..c2acda881 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -389,6 +389,8 @@ AC_DEFUN([OVN_ENABLE_VIF_PLUG], [
     fi
 ])
 
+dnl OVN_CHECK_VERSION_SUFFIX
+dnl
 dnl Append a version suffix.
 AC_DEFUN([OVN_CHECK_VERSION_SUFFIX], [
   AC_ARG_WITH([version-suffix],
diff --git a/include/ovn/version.h.in b/include/ovn/version.h.in
index 5f88931b7..a58428913 100644
--- a/include/ovn/version.h.in
+++ b/include/ovn/version.h.in
@@ -18,8 +18,23 @@
 #ifndef OVN_VERSION_H
 #define OVN_VERSION_H 1
 
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
+#define ASAN_SUFFIX " ASAN"
+#else
+#define ASAN_SUFFIX ""
+#endif
+#if __has_feature(undefined_behavior_sanitizer)
+#define UBSAN_SUFFIX " UBSAN"
+#else
+#define UBSAN_SUFFIX ""
+#endif
+
 #define OVN_PACKAGE_STRING  "@PACKAGE_STRING@"
-#define OVN_PACKAGE_VERSION "@PACKAGE_VERSION@@VERSION_SUFFIX@"
+#define OVN_PACKAGE_VERSION "@PACKAGE_VERSION@@VERSION_SUFFIX@" \
+                                ASAN_SUFFIX UBSAN_SUFFIX
 
 #define OVN_LIB_VERSION     @LT_CURRENT@
 #define OVN_LIB_REVISION    @LT_REVISION@
-- 
2.56.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to