diff mbox

[v2] build: link with libatomic on powerpc-linux

Message ID 1459513596-4362-1-git-send-email-olaf@aepfle.de (mailing list archive)
State New, archived
Headers show

Commit Message

Olaf Hering April 1, 2016, 12:26 p.m. UTC
Building on powerpc-linux fails with undefined reference to
__atomic_load_8 in icount_warp_rt(). Force linking to -latomic.

Fixes a0aa44b ("include/qemu/atomic.h: default to __atomic functions")

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---

This was probably sent twice due to git send-email issues...

 configure | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff mbox

Patch

diff --git a/configure b/configure
index 81caff6..ee935bb 100755
--- a/configure
+++ b/configure
@@ -4025,6 +4025,33 @@  if test "$usb_redir" != "no" ; then
     fi
 fi
 
+if test "$cpu" = "ppc" && test "$targetos" = "Linux" ; then
+    # Do we need libm
+    cat > $TMPC << EOF
+    #include <unistd.h>
+    #include <stdint.h>
+    #include <qemu/atomic.h>
+    int64_t val;
+    int main(int argc, char **argv)
+    {
+      val = (int64_t)read(0, NULL, 0);
+      if (atomic_read(&val) == -1) {
+        return 0;
+      }
+      return 1;
+    }
+EOF
+    if compile_prog "-Iinclude" "" ; then
+      :
+      echo "No need to link with -latomic on powerpc-linux"
+    elif compile_prog "-Iinclude" "-latomic" ; then
+      echo "Link with -latomic on powerpc-linux"
+      libs_softmmu="$libs_softmmu -latomic"
+    else
+      error_exit "libatomic check failed"
+    fi
+fi
+
 ##########################################
 # check if we have VSS SDK headers for win