mpd: fix build on SPARC
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 7 Feb 2016 20:54:33 +0000 (21:54 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 7 Feb 2016 21:02:51 +0000 (22:02 +0100)
mpd uses __atomic_*() built-ins, but forgets to link with -latomic
when needed, so this commit adds a patch that ensures it will link
with libatomic, and adds a dependency on BR2_TOOLCHAIN_HAS_ATOMIC.

Fixes:

  http://autobuild.buildroot.net/results/e2207280f3a177e12dba502b1c01f5aeb431d04c/

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/mpd/0005-configure.ac-check-if-libatomic-is-needed.patch [new file with mode: 0644]
package/mpd/Config.in
package/mpd/mpd.mk

diff --git a/package/mpd/0005-configure.ac-check-if-libatomic-is-needed.patch b/package/mpd/0005-configure.ac-check-if-libatomic-is-needed.patch
new file mode 100644 (file)
index 0000000..a9873a7
--- /dev/null
@@ -0,0 +1,40 @@
+From 8eaf14a17244aaf000b4d19e4fde4a637576939f Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Date: Sun, 7 Feb 2016 21:40:47 +0100
+Subject: [PATCH] configure.ac: check if libatomic is needed
+
+The mpd source code uses the C++11 <atomic> functionality, which
+internally is implemented using the __atomic_*() gcc built-ins. On
+certain architectures, the __atomic_*() built-ins are implemented in
+the libatomic library that comes with the rest of the gcc runtime. Due
+to this, code using <atomic> might need to link against libatomic,
+otherwise one hits build issues such as:
+
+GlobalEvents.cxx:(.text._ZN12GlobalEvents4EmitENS_5EventE+0x14): undefined reference to `__atomic_fetch_or_4'
+
+on an architecture like SPARC.
+
+To solve this, a configure.ac check is added to know if we need to
+link against libatomic or not.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+---
+ configure.ac | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index 107b45a..8e6fab7 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -233,6 +233,8 @@ if test x$have_pthread_setname_np = xyes; then
+       AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [Is pthread_setname_np() available?])
+ fi
++AC_SEARCH_LIBS([__atomic_load_4], [atomic])
++
+ dnl ---------------------------------------------------------------------------
+ dnl Event loop selection
+ dnl ---------------------------------------------------------------------------
+-- 
+2.6.4
+
index b3683974874595bb525af2cfbdac5894d0b9f869..3ac806f74a39f2427e6688e4800474f019085fdd 100644 (file)
@@ -6,6 +6,7 @@ menuconfig BR2_PACKAGE_MPD
        depends on BR2_USE_MMU # libglib2
        depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_6
        depends on BR2_PACKAGE_BOOST_ARCH_SUPPORTS
+       depends on BR2_TOOLCHAIN_HAS_ATOMIC
        select BR2_PACKAGE_BOOST
        select BR2_PACKAGE_LIBGLIB2
        select BR2_PACKAGE_LIBICONV if !BR2_ENABLE_LOCALE
@@ -312,5 +313,6 @@ endif
 comment "mpd needs a toolchain w/ C++, threads, wchar, gcc >= 4.6"
        depends on BR2_USE_MMU
        depends on BR2_PACKAGE_BOOST_ARCH_SUPPORTS
+       depends on BR2_TOOLCHAIN_HAS_ATOMIC
        depends on !BR2_INSTALL_LIBSTDCPP || !BR2_USE_WCHAR || \
                !BR2_TOOLCHAIN_HAS_THREADS || !BR2_TOOLCHAIN_GCC_AT_LEAST_4_6
index 7a265f4875b57bab97164bf4ac06b513478d5200..d5d77a638c6bcbe9c5551db6ec777ca3513c5837 100644 (file)
@@ -11,6 +11,7 @@ MPD_SITE = http://www.musicpd.org/download/mpd/$(MPD_VERSION_MAJOR)
 MPD_DEPENDENCIES = host-pkgconf boost libglib2
 MPD_LICENSE = GPLv2+
 MPD_LICENSE_FILES = COPYING
+MPD_AUTORECONF = YES
 
 # Some options need an explicit --disable or --enable