From fd2e50cd333324ca18d8186a5c9211aa03c439cf Mon Sep 17 00:00:00 2001
From: James Page <james.page@ubuntu.com>
Date: Thu, 5 Dec 2013 17:29:05 +0000
Subject: [PATCH] Add check for -latomic

Later versions of gcc on some architectures push atomic functions
out into a separate atomic library; add a check to see when this
is required and add it to LIBS if need be.

Specifically the problem was observed on GCC 4.8.2 on powerpc
architecture for Ubuntu 14.04:

https://launchpadlibrarian.net/155235096/buildlog_ubuntu-trusty-powerpc.openvswitch_2.0.0-0ubuntu1_FAILEDTOBUILD.txt.gz

Signed-off-by: James Page <james.page@ubuntu.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
---
 configure.ac      | 1 +
 m4/openvswitch.m4 | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/configure.ac b/configure.ac
index 13d2d31b9..167cc7124 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,7 @@ OVS_CHECK_XENSERVER_VERSION
 OVS_CHECK_GROFF
 OVS_CHECK_GNU_MAKE
 OVS_CHECK_TLS
+OVS_CHECK_ATOMIC_LIBS
 OVS_CHECK_GCC4_ATOMICS
 OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(1)
 OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(2)
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 7c3798568..55c48ecc5 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -432,6 +432,12 @@ static thread_local int var;], [return var;])],
      fi
    fi])
 
+dnl OVS_CHECK_ATOMIC_LIBS
+dnl
+dnl Check to see if -latomic is need for GCC atomic built-ins.
+AC_DEFUN([OVS_CHECK_ATOMIC_LIBS],
+   [AC_SEARCH_LIBS([__atomic_load_8], [atomic])])
+
 dnl OVS_CHECK_GCC4_ATOMICS
 dnl
 dnl Checks whether the compiler and linker support GCC 4.0+ atomic built-ins.
-- 
2.47.0