2
1

0003-Fix-symver-build-error-on-non-ELF-platforms.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. From f630ed1f807e26de04b3a5dfd7f1b39d1c5cb642 Mon Sep 17 00:00:00 2001
  2. From: Tan En De <ende.tan@starfivetech.com>
  3. Date: Sat, 26 Nov 2022 07:47:39 +0800
  4. Subject: [PATCH] Fix symver build error on non-ELF platforms
  5. The following error is observed on Microblaze [1] build:
  6. ```
  7. error: symver is only supported on ELF platforms
  8. ```
  9. due to using __attribute__((symver)) on non-ELF platform.
  10. So, revert to using .symver in such case.
  11. [1]: http://autobuild.buildroot.net/results/447/4470efb5a078c0e368f6bd4f5ec455eea5eeebb5/build-end.log
  12. Signed-off-by: Tan En De <ende.tan@starfivetech.com>
  13. Signed-off-by: Stephan Mueller <smueller@chronox.de>
  14. ---
  15. Upstream status: commit f630ed1f807e26de04b3a5dfd7f1b39d1c5cb642
  16. configure.ac | 2 ++
  17. lib/internal.h | 2 +-
  18. m4/ac_check_attribute_symver.m4 | 24 ++++++++++++++++++++++++
  19. 3 files changed, 27 insertions(+), 1 deletion(-)
  20. create mode 100644 m4/ac_check_attribute_symver.m4
  21. diff --git a/configure.ac b/configure.ac
  22. index e230577..ba17404 100644
  23. --- a/configure.ac
  24. +++ b/configure.ac
  25. @@ -76,6 +76,8 @@ AX_ADD_FORTIFY_SOURCE
  26. AC_CHECK_API_VERSION
  27. +AC_CHECK_ATTRIBUTE_SYMVER
  28. +
  29. AC_ARG_ENABLE([werror], [AS_HELP_STRING([--disable-werror], [Disable -Werror])], [with_werror=$enableval], [with_werror=yes])
  30. AM_CONDITIONAL([ENABLE_WERROR], [test "x$with_werror" = "xyes"])
  31. diff --git a/lib/internal.h b/lib/internal.h
  32. index 14844a9..7977b04 100644
  33. --- a/lib/internal.h
  34. +++ b/lib/internal.h
  35. @@ -352,7 +352,7 @@ static inline int io_getevents(__attribute__((unused)) aio_context_t ctx,
  36. * Auxiliary macros
  37. ************************************************************/
  38. -#if __GNUC__ >= 10
  39. +#if HAVE_ATTRIBUTE_SYMVER && __GNUC__ >= 10
  40. # define IMPL_SYMVER(name, version) \
  41. __attribute__((__symver__("kcapi_" #name "@@LIBKCAPI_" version)))
  42. diff --git a/m4/ac_check_attribute_symver.m4 b/m4/ac_check_attribute_symver.m4
  43. new file mode 100644
  44. index 0000000..b484c5e
  45. --- /dev/null
  46. +++ b/m4/ac_check_attribute_symver.m4
  47. @@ -0,0 +1,24 @@
  48. +dnl Check compiler support for symver function attribute
  49. +AC_DEFUN([AC_CHECK_ATTRIBUTE_SYMVER], [
  50. + saved_CFLAGS=$CFLAGS
  51. + CFLAGS="-O0 -Werror"
  52. + AC_COMPILE_IFELSE(
  53. + [AC_LANG_PROGRAM(
  54. + [[
  55. + void _test_attribute_symver(void);
  56. + __attribute__((__symver__("sym@VER_1.2.3"))) void _test_attribute_symver(void) {}
  57. + ]],
  58. + [[
  59. + _test_attribute_symver()
  60. + ]]
  61. + )],
  62. + [
  63. + AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], 1, [Define to 1 if __attribute__((symver)) is supported])
  64. + ],
  65. + [
  66. + AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], 0, [Define to 0 if __attribute__((symver)) is not supported])
  67. + ]
  68. + )
  69. + CFLAGS=$saved_CFLAGS
  70. +])
  71. +
  72. --
  73. 2.34.1