UPSTREAM: configure: check if -latomic is needed for __atomic_*

On some platforms, gcc generates library calls when __atomic_* functions
are used, but does not link the required library (libatomic) automatically
(supposedly to allow the app to use some other atomics implementation?).

Detect this at configure time and add the library when needed. Tested
on armel (library was added) and on x86_64 (was not, as expected).

Some documentation on this is provided in GCC wiki:
https://gcc.gnu.org/wiki/Atomic/GCCMM

Fixes: 8915f0c0 "util: use GCC atomic intrinsics with explicit memory model"
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102573
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
(cherry-picked from 2ef7f23820a67e958c2252bd81eb0458903ebf33)

BUG=b:64515630
TEST=Successfully loaded graphics drivers in ARC++ on kahlee;
     Built arc-mesa for eve.

Change-Id: I37b3f37e4cd92d1c71a0a75f008c4152c4a15abb
Reviewed-on: https://chromium-review.googlesource.com/710533
Commit-Ready: Benjamin Gordon <bmgordon@chromium.org>
Tested-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
2 files changed