0001-Add-check-program-for-symver-attribute.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From 7c6ec620de3f99d4212f4a54aa576df1b97020ab Mon Sep 17 00:00:00 2001
  2. From: Ondrej Kozina <okozina@redhat.com>
  3. Date: Wed, 2 Feb 2022 11:34:57 +0100
  4. Subject: [PATCH] Add check program for symver attribute.
  5. Fixes: #709.
  6. Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
  7. ---
  8. configure.ac | 11 +++++++++++
  9. lib/libcryptsetup_symver.h | 8 +++-----
  10. 2 files changed, 14 insertions(+), 5 deletions(-)
  11. diff --git a/configure.ac b/configure.ac
  12. index a0e5990d..b052f8cf 100644
  13. --- a/configure.ac
  14. +++ b/configure.ac
  15. @@ -554,6 +554,17 @@ if test "x$enable_static_cryptsetup" = "xyes"; then
  16. PKG_CONFIG=$saved_PKG_CONFIG
  17. fi
  18. +dnl Check compiler support for symver function attribute
  19. +saved_CFLAGS=$CFLAGS
  20. +CFLAGS="-O0 -Werror"
  21. +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  22. + void _test_sym(void);
  23. + __attribute__((__symver__("sym@VERSION_4.2"))) void _test_sym(void) {}
  24. +]],
  25. +[[ _test_sym() ]]
  26. +)],[ AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], 1, [Define to 1 to use __attribute__((symver))])])
  27. +CFLAGS=$saved_CFLAGS
  28. +
  29. AC_MSG_CHECKING([for systemd tmpfiles config directory])
  30. PKG_CHECK_VAR([systemd_tmpfilesdir], [systemd], [tmpfilesdir], [], [systemd_tmpfilesdir=no])
  31. AC_MSG_RESULT([$systemd_tmpfilesdir])
  32. diff --git a/lib/libcryptsetup_symver.h b/lib/libcryptsetup_symver.h
  33. index 2a804b6a..3558310d 100644
  34. --- a/lib/libcryptsetup_symver.h
  35. +++ b/lib/libcryptsetup_symver.h
  36. @@ -67,11 +67,9 @@
  37. * under CRYPT_SYMBOL_EXPORT_OLD(int, crypt_func_X, ...) macro
  38. */
  39. -#ifdef __has_attribute
  40. -# if __has_attribute(symver)
  41. -# define _CRYPT_SYMVER(_local_sym, _public_sym, _ver_str, _maj, _min) \
  42. - __attribute__((__symver__(#_public_sym _ver_str #_maj "." #_min)))
  43. -# endif
  44. +#if HAVE_ATTRIBUTE_SYMVER
  45. +# define _CRYPT_SYMVER(_local_sym, _public_sym, _ver_str, _maj, _min) \
  46. + __attribute__((__symver__(#_public_sym _ver_str #_maj "." #_min)))
  47. #endif
  48. #if !defined(_CRYPT_SYMVER) && defined(__GNUC__)
  49. --
  50. 2.25.1