[Mesa-dev] [PATCH] configure.ac: rework -latomic check
Thomas Petazzoni
thomas.petazzoni at bootlin.com
Thu May 10 08:43:18 UTC 2018
Hello Matt,
On Wed, 9 May 2018 16:30:12 -0700, Matt Turner wrote:
> Hi Thomas,
>
> I rebased this patch on
>
> commit 54ba73ef102f7b9085922686bb31719539e0dc3c
> Author: Nicolas Boichat <drinkcat at chromium.org>
> Date: Thu Apr 5 09:33:09 2018 +0800
>
> configure.ac/meson.build: Fix -latomic test
>
> and readded the AC_MSG_CHECKING/AC_MSG_RESULT. If it looks good to you,
> I'll commit it.
Thanks for this new iteration! I didn't test it, but it looks good to
me. Just one minor nit below.
> -dnl Check for new-style atomic builtins
> -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
> +dnl Check for new-style atomic builtins. We first check without linking to
> +dnl -latomic.
> +AC_MSG_CHECKING(whether __atomic_load_n is supported)
> +AC_LINK_IFELSE([AC_LANG_SOURCE([[
> +#include <stdint.h>
> int main() {
> - int n;
> - return __atomic_load_n(&n, __ATOMIC_ACQUIRE);
> -}]])], GCC_ATOMIC_BUILTINS_SUPPORTED=1)
> -if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" = x1; then
> - DEFINES="$DEFINES -DUSE_GCC_ATOMIC_BUILTINS"
> - dnl On some platforms, new-style atomics need a helper library
> - AC_MSG_CHECKING(whether -latomic is needed)
> - AC_LINK_IFELSE([AC_LANG_SOURCE([[
> - #include <stdint.h>
> struct {
> uint64_t *v;
> } x;
> - int main() {
> + return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE);
> +}]])], GCC_ATOMIC_BUILTINS_SUPPORTED=yes, GCC_ATOMIC_BUILTINS_SUPPORTED=no)
> +
> +dnl If that didn't work, we try linking with -latomic, which is needed on some
> +dnl platforms.
> +if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" != xyes; then
> + save_LDFLAGS=$LDFLAGS
> + LDFLAGS="$LDFLAGS -latomic"
> + AC_LINK_IFELSE([AC_LANG_SOURCE([[
> + #include <stdint.h>
> + int main() {
> + struct {
> + uint64_t *v;
> + } x;
> return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE);
> - }]])], GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=no, GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC=yes)
> - AC_MSG_RESULT($GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC)
> - if test "x$GCC_ATOMIC_BUILTINS_NEED_LIBATOMIC" = xyes; then
> - LIBATOMIC_LIBS="-latomic"
> - fi
> + }]])], GCC_ATOMIC_BUILTINS_SUPPORTED=yes LIBATOMIC_LIBS="-latomic",
> + GCC_ATOMIC_BUILTINS_SUPPORTED=no)
> + LDFLAGS=$save_LDFLAGS
> +
> +
Those two empty lines don't seem to be very useful.
> +fi
> +AC_MSG_RESULT($GCC_ATOMIC_BUILTINS_SUPPORTED)
> +
> +if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" = xyes; then
> + DEFINES="$DEFINES -DUSE_GCC_ATOMIC_BUILTINS"
> fi
> AC_SUBST([LIBATOMIC_LIBS])
>
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
More information about the mesa-dev
mailing list