[Mesa-dev] [PATCH, v2] CHROMIUM: configure.ac/meson.build: Fix -latomic test

Matt Turner mattst88 at gmail.com
Thu Mar 29 18:26:55 UTC 2018


On Thu, Mar 29, 2018 at 1:31 AM, Nicolas Boichat <drinkcat at chromium.org> wrote:
> From: Nicolas Boichat <drinkcat at chromium.org>
>
> When compiling with LLVM 6.0, the test fails to detect that
> -latomic is actually required, as the atomic call is inlined.
>
> In the code itself (src/util/disk_cache.c), we see this pattern:
> p_atomic_add(cache->size, - (uint64_t)size);
> where cache->size is an uint64_t *, and results in the following
> link time error without -latomic:
> src/util/disk_cache.c:628: error: undefined reference to '__atomic_fetch_add_8'
>
> Fix the configure/meson test to replicate this pattern, which then
> correctly realizes the need for -latomic.
>
> Signed-off-by: Nicolas Boichat <drinkcat at chromium.org>
> ---
>
> Changes since v1:
>  - Updated meson.build as well (untested)
>
>  configure.ac | 6 ++++--
>  meson.build  | 6 ++++--
>  2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index e874f8ebfb2..eff9a0ef88f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -445,9 +445,11 @@ if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" = x1; then
>      AC_MSG_CHECKING(whether -latomic is needed)
>      AC_LINK_IFELSE([AC_LANG_SOURCE([[
>      #include <stdint.h>
> -    uint64_t v;
> +    struct {
> +        uint64_t* v;

I wouldn't care expect that you put the * with the v in the Meson case. :)

Looking at this code, I would expect it to behave the same as before.
Do you have an idea why this fixes it, or why the original code didn't
work? I'm guess it's about the compiler's ability to recognize that it
knows the location of the variable.

Also, on what platform does this occur?


More information about the mesa-dev mailing list