[Buildroot] [git commit branch/2022.11.x] package/libkcapi: Fix symver build error on non-ELF platforms

Peter Korsgaard peter at korsgaard.com
Mon Jan 2 07:22:08 UTC 2023


commit: https://git.buildroot.net/buildroot/commit/?id=1427f9c63fde7fda7edb9c5d841110718d391d5f
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2022.11.x

The following error is observed on Microblaze [1] build:
```
error: symver is only supported on ELF platforms
```
due to using __attribute__((symver)) on non-ELF platform.
So, revert to using .symver in such case.

Fixes:

  http://autobuild.buildroot.net/results/4470efb5a078c0e368f6bd4f5ec455eea5eeebb5/

Upstream status: commit f630ed1f807e26de04b3a5dfd7f1b39d1c5cb642
https://github.com/smuellerDD/libkcapi/pull/147

Signed-off-by: Tan En De <ende.tan at starfivetech.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
(cherry picked from commit 216e201cd0f14aacac2e9727e8da8f64d734a064)
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
---
 ...x-symver-build-error-on-non-ELF-platforms.patch | 84 ++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/package/libkcapi/0003-Fix-symver-build-error-on-non-ELF-platforms.patch b/package/libkcapi/0003-Fix-symver-build-error-on-non-ELF-platforms.patch
new file mode 100644
index 0000000000..206ac7ec4a
--- /dev/null
+++ b/package/libkcapi/0003-Fix-symver-build-error-on-non-ELF-platforms.patch
@@ -0,0 +1,84 @@
+From f630ed1f807e26de04b3a5dfd7f1b39d1c5cb642 Mon Sep 17 00:00:00 2001
+From: Tan En De <ende.tan at starfivetech.com>
+Date: Sat, 26 Nov 2022 07:47:39 +0800
+Subject: [PATCH] Fix symver build error on non-ELF platforms
+
+The following error is observed on Microblaze [1] build:
+```
+error: symver is only supported on ELF platforms
+```
+due to using __attribute__((symver)) on non-ELF platform.
+So, revert to using .symver in such case.
+
+[1]: http://autobuild.buildroot.net/results/447/4470efb5a078c0e368f6bd4f5ec455eea5eeebb5/build-end.log
+
+Signed-off-by: Tan En De <ende.tan at starfivetech.com>
+Signed-off-by: Stephan Mueller <smueller at chronox.de>
+---
+Upstream status: commit f630ed1f807e26de04b3a5dfd7f1b39d1c5cb642
+
+ configure.ac                    |  2 ++
+ lib/internal.h                  |  2 +-
+ m4/ac_check_attribute_symver.m4 | 24 ++++++++++++++++++++++++
+ 3 files changed, 27 insertions(+), 1 deletion(-)
+ create mode 100644 m4/ac_check_attribute_symver.m4
+
+diff --git a/configure.ac b/configure.ac
+index e230577..ba17404 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -76,6 +76,8 @@ AX_ADD_FORTIFY_SOURCE
+ 
+ AC_CHECK_API_VERSION
+ 
++AC_CHECK_ATTRIBUTE_SYMVER
++
+ AC_ARG_ENABLE([werror], [AS_HELP_STRING([--disable-werror], [Disable -Werror])], [with_werror=$enableval], [with_werror=yes])
+ AM_CONDITIONAL([ENABLE_WERROR], [test "x$with_werror" = "xyes"])
+ 
+diff --git a/lib/internal.h b/lib/internal.h
+index 14844a9..7977b04 100644
+--- a/lib/internal.h
++++ b/lib/internal.h
+@@ -352,7 +352,7 @@ static inline int io_getevents(__attribute__((unused)) aio_context_t ctx,
+  * Auxiliary macros
+  ************************************************************/
+ 
+-#if __GNUC__ >= 10
++#if HAVE_ATTRIBUTE_SYMVER && __GNUC__ >= 10
+ # define IMPL_SYMVER(name, version) \
+     __attribute__((__symver__("kcapi_" #name "@@LIBKCAPI_" version)))
+ 
+diff --git a/m4/ac_check_attribute_symver.m4 b/m4/ac_check_attribute_symver.m4
+new file mode 100644
+index 0000000..b484c5e
+--- /dev/null
++++ b/m4/ac_check_attribute_symver.m4
+@@ -0,0 +1,24 @@
++dnl Check compiler support for symver function attribute
++AC_DEFUN([AC_CHECK_ATTRIBUTE_SYMVER], [
++	saved_CFLAGS=$CFLAGS
++	CFLAGS="-O0 -Werror"
++	AC_COMPILE_IFELSE(
++		[AC_LANG_PROGRAM(
++			[[
++				void _test_attribute_symver(void);
++				__attribute__((__symver__("sym at VER_1.2.3"))) void _test_attribute_symver(void) {}
++			]],
++			[[ 
++				_test_attribute_symver()
++			]]
++		)],
++		[
++			AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], 1, [Define to 1 if __attribute__((symver)) is supported])
++		],
++		[
++			AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], 0, [Define to 0 if __attribute__((symver)) is not supported])
++		]
++	)
++	CFLAGS=$saved_CFLAGS
++])
++
+-- 
+2.34.1
+



More information about the buildroot mailing list