]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Fix symver build error on non-ELF platforms
authorBernd Kuhls <bernd@kuhls.net>
Thu, 29 Jun 2023 05:57:21 +0000 (07:57 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 1 Sep 2023 14:54:44 +0000 (16:54 +0200)
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.

[1] http://autobuild.buildroot.net/results/1e9/1e965d83d75615f35308440c5db044314a349357/build-end.log

ac_check_attribute_symver.m4 was downloaded from
https://github.com/smuellerDD/libkcapi/blob/master/m4/ac_check_attribute_symver.m4

Fixes: https://github.com/alsa-project/alsa-lib/pull/334
Signed-off-by: Tan En De <ende.tan@starfivetech.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
configure.ac
include/alsa-symbols.h
m4/ac_check_attribute_symver.m4 [new file with mode: 0644]

index 3d917f82e6306a7026c91af0095822c1b07d86e8..04541790b8f9d387a2e219d84ebb20defbb11e2e 100644 (file)
@@ -46,6 +46,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
 AC_HEADER_TIME
+AC_CHECK_ATTRIBUTE_SYMVER
 
 dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
index f8c49103fea869d8c9e1800503318e0a39d634a8..2298cb5039dc9bf6215cb2812446119a8d5393f5 100644 (file)
@@ -29,7 +29,7 @@
 #define INTERNAL_CONCAT2_2(Pre, Post) Pre##Post
 #define INTERNAL(Name) INTERNAL_CONCAT2_2(__, Name)
 
-#if __GNUC__ > 10
+#if HAVE_ATTRIBUTE_SYMVER && __GNUC__ > 10
 #define symbol_version(real, name, version) \
        extern __typeof (real) real __attribute__((symver (#name "@" #version)))
 #define default_symbol_version(real, name, version) \
diff --git a/m4/ac_check_attribute_symver.m4 b/m4/ac_check_attribute_symver.m4
new file mode 100644 (file)
index 0000000..ac62bf3
--- /dev/null
@@ -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@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
+])
+