Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-03-05 Thread Emil Velikov
[Trimming down the CC list]

Hi Mike,

On 4 March 2018 at 00:20, Mike Lothian  wrote:
> Hi
>
> Sorry to be a pain again
>
> I've just tested this with clang and the 32bit build still fails without
> -latomic
>
> libtool: link: /bin/true glsl/.libs/libstandalone.a
Eric has a point here - the patch brings meson up-to scratch, while
you're having some issues with autotools.

The link issue is in libstandalone, which pulls libmesautil/disk_cache.o
Yet libmesautil already has LIBATOMIC_LIBS (-latomic) so why things
fail is a bit fishy.

Can you isolate any funky LTO interactions?

If that doesn't cut it - please open a bug attaching the output of
make V=1. In particular the src/util and src/compiler bits.

Thanks
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-03-05 Thread Eric Engestrom
On Sunday, 2018-03-04 00:20:16 +, Mike Lothian wrote:
> Hi
> 
> Sorry to be a pain again
> 
> I've just tested this with clang and the 32bit build still fails without
> -latomic

This fix was for meson, and you're using make here; does it work if you
build using meson? First thing is to figure out if it's an issue with
your setup or the build system.

> 
> libtool: link: /bin/true glsl/.libs/libstandalone.a
> libtool: link: rm -fr glsl/.libs/libstandalone.lax
> glsl/.libs/libstandalone.lax
> libtool: link: ( cd "glsl/.libs" && rm -f "libstandalone.la" && ln -s "../
> libstandalone.la" "libstandalone.la" )
> /bin/sh ../../libtool  --tag=CXX   --mode=link clang++ -m32
> -fvisibility=hidden -Werror=pointer-arith -Werror=vla -O3 -march=native
> -pipe -flto=thin -Wall -fno-math-errno -fno-trapping-math
> -Qunused-arguments   -O3 -march=native -pipe -flto=thin -o glsl_
> compiler glsl/main.o glsl/libstandalone.la
> libtool: link: clang++ -m32 -fvisibility=hidden -Werror=pointer-arith
> -Werror=vla -O3 -march=native -pipe -flto=thin -Wall -fno-math-errno
> -fno-trapping-math -Qunused-arguments -O3 -march=native -pipe -flto=thin -o
> glsl_compiler glsl/main.o  glsl/.libs/l
> ibstandalone.a -lz -lpthread -pthread
> /var/tmp/portage/media-libs/mesa-/temp/lto-llvm-4efaa5.o:disk_cache.c:function
> disk_cache_remove: error: undefined reference to '__atomic_fetch_add_8'
> clang-7.0: error: linker command failed with exit code 1 (use -v to see
> invocation)
> make[4]: *** [Makefile:2364: glsl_compiler] Error 1
> make[4]: Leaving directory
> '/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86/src/compiler'
> 
> make[3]: *** [Makefile:1793: all] Error 2
> make[3]: Leaving directory
> '/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86/src/compiler'
> 
> make[2]: *** [Makefile:875: all-recursive] Error 1
> make[2]: Leaving directory
> '/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86/src'
> make[1]: *** [Makefile:660: all] Error 2
> make[1]: Leaving directory
> '/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86/src'
> make: *** [Makefile:668: all-recursive] Error 1
> * ERROR: media-libs/mesa-::gentoo failed (compile phase):
> *   emake failed
> *
> * If you need support, post the output of `emerge --info
> '=media-libs/mesa-::gentoo'`,
> * the complete build log and the output of `emerge -pqv
> '=media-libs/mesa-::gentoo'`.
> * The complete build log is located at
> '/var/tmp/portage/media-libs/mesa-/temp/build.log'.
> * The ebuild environment file is located at
> '/var/tmp/portage/media-libs/mesa-/temp/environment'.
> * Working directory:
> '/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86'
> * S: '/var/tmp/portage/media-libs/mesa-/work/mesa-'
> 
> If I pass -latomic in with the LDFLAGS it builds fine
> 
> On Tue, 27 Feb 2018 at 20:22 Matt Turner  wrote:
> 
> > On Tue, Feb 27, 2018 at 2:26 AM, Thierry Reding
> >  wrote:
> > > On Mon, Feb 26, 2018 at 11:14:05AM -0800, Matt Turner wrote:
> > >> On Fri, Feb 23, 2018 at 5:18 AM, Thierry Reding
> > >>  wrote:
> > >> > From: Thierry Reding 
> > >> >
> > >> > The disk cache implementation uses 64-bit atomic operations. For some
> > >> > architectures, such as 32-bit ARM, GCC will not be able to translate
> > >> > these operations into lock-free instructions and will instead rely on
> > >>
> > >> Here, and in the comment in meson.build, I think you mean "atomic"
> > >> rather than "lock-free" instructions? It's at least confusing, since
> > >> on x86 atomic instructions have a "lock" prefix.
> > >
> > > This uses the terminology used by the GCC documentation, see:
> > >
> > > https://gcc.gnu.org/wiki/Atomic/GCCMM
> > >
> > > I think the GCC terms merely mean that you don't need any explicit
> > > locking for these operations to be atomic.
> > >
> > > How about this instead:
> > >
> > > "... operations into atomic, lock-free instructions..."
> > >
> > > ?
> >
> > Ah, I see. Thanks, that works for me.
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >

> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-03-03 Thread Mike Lothian
Hi

Sorry to be a pain again

I've just tested this with clang and the 32bit build still fails without
-latomic

libtool: link: /bin/true glsl/.libs/libstandalone.a
libtool: link: rm -fr glsl/.libs/libstandalone.lax
glsl/.libs/libstandalone.lax
libtool: link: ( cd "glsl/.libs" && rm -f "libstandalone.la" && ln -s "../
libstandalone.la" "libstandalone.la" )
/bin/sh ../../libtool  --tag=CXX   --mode=link clang++ -m32
-fvisibility=hidden -Werror=pointer-arith -Werror=vla -O3 -march=native
-pipe -flto=thin -Wall -fno-math-errno -fno-trapping-math
-Qunused-arguments   -O3 -march=native -pipe -flto=thin -o glsl_
compiler glsl/main.o glsl/libstandalone.la
libtool: link: clang++ -m32 -fvisibility=hidden -Werror=pointer-arith
-Werror=vla -O3 -march=native -pipe -flto=thin -Wall -fno-math-errno
-fno-trapping-math -Qunused-arguments -O3 -march=native -pipe -flto=thin -o
glsl_compiler glsl/main.o  glsl/.libs/l
ibstandalone.a -lz -lpthread -pthread
/var/tmp/portage/media-libs/mesa-/temp/lto-llvm-4efaa5.o:disk_cache.c:function
disk_cache_remove: error: undefined reference to '__atomic_fetch_add_8'
clang-7.0: error: linker command failed with exit code 1 (use -v to see
invocation)
make[4]: *** [Makefile:2364: glsl_compiler] Error 1
make[4]: Leaving directory
'/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86/src/compiler'

make[3]: *** [Makefile:1793: all] Error 2
make[3]: Leaving directory
'/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86/src/compiler'

make[2]: *** [Makefile:875: all-recursive] Error 1
make[2]: Leaving directory
'/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86/src'
make[1]: *** [Makefile:660: all] Error 2
make[1]: Leaving directory
'/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86/src'
make: *** [Makefile:668: all-recursive] Error 1
* ERROR: media-libs/mesa-::gentoo failed (compile phase):
*   emake failed
*
* If you need support, post the output of `emerge --info
'=media-libs/mesa-::gentoo'`,
* the complete build log and the output of `emerge -pqv
'=media-libs/mesa-::gentoo'`.
* The complete build log is located at
'/var/tmp/portage/media-libs/mesa-/temp/build.log'.
* The ebuild environment file is located at
'/var/tmp/portage/media-libs/mesa-/temp/environment'.
* Working directory:
'/var/tmp/portage/media-libs/mesa-/work/mesa--abi_x86_32.x86'
* S: '/var/tmp/portage/media-libs/mesa-/work/mesa-'

If I pass -latomic in with the LDFLAGS it builds fine

On Tue, 27 Feb 2018 at 20:22 Matt Turner  wrote:

> On Tue, Feb 27, 2018 at 2:26 AM, Thierry Reding
>  wrote:
> > On Mon, Feb 26, 2018 at 11:14:05AM -0800, Matt Turner wrote:
> >> On Fri, Feb 23, 2018 at 5:18 AM, Thierry Reding
> >>  wrote:
> >> > From: Thierry Reding 
> >> >
> >> > The disk cache implementation uses 64-bit atomic operations. For some
> >> > architectures, such as 32-bit ARM, GCC will not be able to translate
> >> > these operations into lock-free instructions and will instead rely on
> >>
> >> Here, and in the comment in meson.build, I think you mean "atomic"
> >> rather than "lock-free" instructions? It's at least confusing, since
> >> on x86 atomic instructions have a "lock" prefix.
> >
> > This uses the terminology used by the GCC documentation, see:
> >
> > https://gcc.gnu.org/wiki/Atomic/GCCMM
> >
> > I think the GCC terms merely mean that you don't need any explicit
> > locking for these operations to be atomic.
> >
> > How about this instead:
> >
> > "... operations into atomic, lock-free instructions..."
> >
> > ?
>
> Ah, I see. Thanks, that works for me.
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-27 Thread Matt Turner
On Tue, Feb 27, 2018 at 2:26 AM, Thierry Reding
 wrote:
> On Mon, Feb 26, 2018 at 11:14:05AM -0800, Matt Turner wrote:
>> On Fri, Feb 23, 2018 at 5:18 AM, Thierry Reding
>>  wrote:
>> > From: Thierry Reding 
>> >
>> > The disk cache implementation uses 64-bit atomic operations. For some
>> > architectures, such as 32-bit ARM, GCC will not be able to translate
>> > these operations into lock-free instructions and will instead rely on
>>
>> Here, and in the comment in meson.build, I think you mean "atomic"
>> rather than "lock-free" instructions? It's at least confusing, since
>> on x86 atomic instructions have a "lock" prefix.
>
> This uses the terminology used by the GCC documentation, see:
>
> https://gcc.gnu.org/wiki/Atomic/GCCMM
>
> I think the GCC terms merely mean that you don't need any explicit
> locking for these operations to be atomic.
>
> How about this instead:
>
> "... operations into atomic, lock-free instructions..."
>
> ?

Ah, I see. Thanks, that works for me.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-27 Thread Dylan Baker
Quoting Thierry Reding (2018-02-27 02:29:22)
> On Mon, Feb 26, 2018 at 12:05:51PM -0800, Dylan Baker wrote:
> > Quoting Thierry Reding (2018-02-23 05:18:28)
> > > From: Thierry Reding 
> > > 
> > > The disk cache implementation uses 64-bit atomic operations. For some
> > > architectures, such as 32-bit ARM, GCC will not be able to translate
> > > these operations into lock-free instructions and will instead rely on
> > > the external atomics library to provide these operations.
> > > 
> > > Check at configuration time whether or not linking against libatomic
> > > is necessary and if so, create a dependency that can be used while
> > > linking the mesautil library.
> > > 
> > > This is the meson equivalent of 2ef7f23820a6 ("configure: check if
> > > -latomic is needed for __atomic_*").
> > > 
> > > Signed-off-by: Thierry Reding 
> > > ---
> > >  meson.build  | 15 +++
> > >  src/util/meson.build |  2 +-
> > >  2 files changed, 16 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/meson.build b/meson.build
> > > index 121341a950c4..7c6f40573421 100644
> > > --- a/meson.build
> > > +++ b/meson.build
> > > @@ -800,6 +800,21 @@ endif
> > >  if cc.compiles('int main() { int n; return __atomic_load_n(, 
> > > __ATOMIC_ACQUIRE); }',
> > > name : 'GCC atomic builtins')
> > >pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
> > > +
> > > +  # Not all atomic calls can be turned into lock-free instructions, in 
> > > which
> > > +  # GCC will make calls into the libatomic library. Check whether we 
> > > need to
> > > +  # link with -latomic.
> > > +  #
> > > +  # This can happen for 64-bit atomic operations on 32-bit architectures 
> > > such
> > > +  # as ARM.
> > > +  if not cc.links('''#include 
> > > + int main() {
> > > +   uint64_t n;
> > > +   return (int)__atomic_load_n(, __ATOMIC_ACQUIRE);
> > > + }''',
> > > +  name : 'GCC atomic builtins required -latomic')
> > > +dep_atomic = cc.find_library('atomic')
> > 
> > dep_atomic is undefined if the cc.links() succeeds right?
> 
> Yeah, I noticed that too when building on 64-bit ARM and then forgot to
> send out v2. I'll do that shortly. The fix, though I'm not sure if it's
> the correct way to do it in Meson, is to declare dep_atomic as an empty
> dependency:
> 
> dep_atomic = declare_dependency()
> 
> unconditionally and then overwrite it with the proper dependency after
> libatomic was detected.
> 
> Any ideas if this can be done more idiomatically?
> 
> Thierry

We've mostly used an empty list for this (which is the old way),
declare_dependency is the way people seem to be doing this now in meson, so
either way. You can overwrite it or put it in the else block, doesn't matter to
me.

Dylan


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-27 Thread Thierry Reding
On Mon, Feb 26, 2018 at 11:28:23PM +, Mike Lothian wrote:
> On Fri, 23 Feb 2018 at 13:18 Thierry Reding 
> wrote:
> 
> > From: Thierry Reding 
> >
> > The disk cache implementation uses 64-bit atomic operations. For some
> > architectures, such as 32-bit ARM, GCC will not be able to translate
> > these operations into lock-free instructions and will instead rely on
> > the external atomics library to provide these operations.
> >
> > Check at configuration time whether or not linking against libatomic
> > is necessary and if so, create a dependency that can be used while
> > linking the mesautil library.
> >
> > This is the meson equivalent of 2ef7f23820a6 ("configure: check if
> > -latomic is needed for __atomic_*").
> >
> > Signed-off-by: Thierry Reding 
> > ---
> >  meson.build  | 15 +++
> >  src/util/meson.build |  2 +-
> >  2 files changed, 16 insertions(+), 1 deletion(-)
> >
> > diff --git a/meson.build b/meson.build
> > index 121341a950c4..7c6f40573421 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -800,6 +800,21 @@ endif
> >  if cc.compiles('int main() { int n; return __atomic_load_n(,
> > __ATOMIC_ACQUIRE); }',
> > name : 'GCC atomic builtins')
> >pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
> > +
> > +  # Not all atomic calls can be turned into lock-free instructions, in
> > which
> > +  # GCC will make calls into the libatomic library. Check whether we need
> > to
> > +  # link with -latomic.
> > +  #
> > +  # This can happen for 64-bit atomic operations on 32-bit architectures
> > such
> > +  # as ARM.
> > +  if not cc.links('''#include 
> > + int main() {
> > +   uint64_t n;
> > +   return (int)__atomic_load_n(, __ATOMIC_ACQUIRE);
> > + }''',
> > +  name : 'GCC atomic builtins required -latomic')
> > +dep_atomic = cc.find_library('atomic')
> > +  endif
> >  endif
> >  if not cc.links('''#include 
> > uint64_t v;
> > diff --git a/src/util/meson.build b/src/util/meson.build
> > index b23dba3a9851..eece1cefef6a 100644
> > --- a/src/util/meson.build
> > +++ b/src/util/meson.build
> > @@ -102,7 +102,7 @@ libmesa_util = static_library(
> >'mesa_util',
> >[files_mesa_util, format_srgb],
> >include_directories : inc_common,
> > -  dependencies : [dep_zlib, dep_clock, dep_thread],
> > +  dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic],
> >c_args : [c_msvc_compat_args, c_vis_args],
> >build_by_default : false
> >  )
> > --
> > 2.16.2
> >
> >
> Hi
> 
> I had this issue when building a 32bit Mesa on x86-64 when using Clang,
> 64bit was fine.
> 
> Will this work for Clang too and if so can a similar change be made for
> autotools?

I think this should work for clang as well. I'm not overly familiar with
it, but Google suggests that clang supports these atomic operations and
will fallback to generating calls into libatomic for those that can't be
turned into lock-free operations.

My understanding is that this should already work for autotools. See my
note about the equivalent commit already in Mesa's master.

Thierry


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-27 Thread Thierry Reding
On Mon, Feb 26, 2018 at 12:05:51PM -0800, Dylan Baker wrote:
> Quoting Thierry Reding (2018-02-23 05:18:28)
> > From: Thierry Reding 
> > 
> > The disk cache implementation uses 64-bit atomic operations. For some
> > architectures, such as 32-bit ARM, GCC will not be able to translate
> > these operations into lock-free instructions and will instead rely on
> > the external atomics library to provide these operations.
> > 
> > Check at configuration time whether or not linking against libatomic
> > is necessary and if so, create a dependency that can be used while
> > linking the mesautil library.
> > 
> > This is the meson equivalent of 2ef7f23820a6 ("configure: check if
> > -latomic is needed for __atomic_*").
> > 
> > Signed-off-by: Thierry Reding 
> > ---
> >  meson.build  | 15 +++
> >  src/util/meson.build |  2 +-
> >  2 files changed, 16 insertions(+), 1 deletion(-)
> > 
> > diff --git a/meson.build b/meson.build
> > index 121341a950c4..7c6f40573421 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -800,6 +800,21 @@ endif
> >  if cc.compiles('int main() { int n; return __atomic_load_n(, 
> > __ATOMIC_ACQUIRE); }',
> > name : 'GCC atomic builtins')
> >pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
> > +
> > +  # Not all atomic calls can be turned into lock-free instructions, in 
> > which
> > +  # GCC will make calls into the libatomic library. Check whether we need 
> > to
> > +  # link with -latomic.
> > +  #
> > +  # This can happen for 64-bit atomic operations on 32-bit architectures 
> > such
> > +  # as ARM.
> > +  if not cc.links('''#include 
> > + int main() {
> > +   uint64_t n;
> > +   return (int)__atomic_load_n(, __ATOMIC_ACQUIRE);
> > + }''',
> > +  name : 'GCC atomic builtins required -latomic')
> > +dep_atomic = cc.find_library('atomic')
> 
> dep_atomic is undefined if the cc.links() succeeds right?

Yeah, I noticed that too when building on 64-bit ARM and then forgot to
send out v2. I'll do that shortly. The fix, though I'm not sure if it's
the correct way to do it in Meson, is to declare dep_atomic as an empty
dependency:

dep_atomic = declare_dependency()

unconditionally and then overwrite it with the proper dependency after
libatomic was detected.

Any ideas if this can be done more idiomatically?

Thierry


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-27 Thread Thierry Reding
On Mon, Feb 26, 2018 at 11:14:05AM -0800, Matt Turner wrote:
> On Fri, Feb 23, 2018 at 5:18 AM, Thierry Reding
>  wrote:
> > From: Thierry Reding 
> >
> > The disk cache implementation uses 64-bit atomic operations. For some
> > architectures, such as 32-bit ARM, GCC will not be able to translate
> > these operations into lock-free instructions and will instead rely on
> 
> Here, and in the comment in meson.build, I think you mean "atomic"
> rather than "lock-free" instructions? It's at least confusing, since
> on x86 atomic instructions have a "lock" prefix.

This uses the terminology used by the GCC documentation, see:

https://gcc.gnu.org/wiki/Atomic/GCCMM

I think the GCC terms merely mean that you don't need any explicit
locking for these operations to be atomic.

How about this instead:

"... operations into atomic, lock-free instructions..."

?

Thierry


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-26 Thread Mike Lothian
On Fri, 23 Feb 2018 at 13:18 Thierry Reding 
wrote:

> From: Thierry Reding 
>
> The disk cache implementation uses 64-bit atomic operations. For some
> architectures, such as 32-bit ARM, GCC will not be able to translate
> these operations into lock-free instructions and will instead rely on
> the external atomics library to provide these operations.
>
> Check at configuration time whether or not linking against libatomic
> is necessary and if so, create a dependency that can be used while
> linking the mesautil library.
>
> This is the meson equivalent of 2ef7f23820a6 ("configure: check if
> -latomic is needed for __atomic_*").
>
> Signed-off-by: Thierry Reding 
> ---
>  meson.build  | 15 +++
>  src/util/meson.build |  2 +-
>  2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/meson.build b/meson.build
> index 121341a950c4..7c6f40573421 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -800,6 +800,21 @@ endif
>  if cc.compiles('int main() { int n; return __atomic_load_n(,
> __ATOMIC_ACQUIRE); }',
> name : 'GCC atomic builtins')
>pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
> +
> +  # Not all atomic calls can be turned into lock-free instructions, in
> which
> +  # GCC will make calls into the libatomic library. Check whether we need
> to
> +  # link with -latomic.
> +  #
> +  # This can happen for 64-bit atomic operations on 32-bit architectures
> such
> +  # as ARM.
> +  if not cc.links('''#include 
> + int main() {
> +   uint64_t n;
> +   return (int)__atomic_load_n(, __ATOMIC_ACQUIRE);
> + }''',
> +  name : 'GCC atomic builtins required -latomic')
> +dep_atomic = cc.find_library('atomic')
> +  endif
>  endif
>  if not cc.links('''#include 
> uint64_t v;
> diff --git a/src/util/meson.build b/src/util/meson.build
> index b23dba3a9851..eece1cefef6a 100644
> --- a/src/util/meson.build
> +++ b/src/util/meson.build
> @@ -102,7 +102,7 @@ libmesa_util = static_library(
>'mesa_util',
>[files_mesa_util, format_srgb],
>include_directories : inc_common,
> -  dependencies : [dep_zlib, dep_clock, dep_thread],
> +  dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic],
>c_args : [c_msvc_compat_args, c_vis_args],
>build_by_default : false
>  )
> --
> 2.16.2
>
>
Hi

I had this issue when building a 32bit Mesa on x86-64 when using Clang,
64bit was fine.

Will this work for Clang too and if so can a similar change be made for
autotools?

I'm waiting for a change to Meson that'll allow me to specify a 32bit
llvm-config to test this on Meson with 32bit

Thanks

Mike
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-26 Thread Dylan Baker
Quoting Thierry Reding (2018-02-23 05:18:28)
> From: Thierry Reding 
> 
> The disk cache implementation uses 64-bit atomic operations. For some
> architectures, such as 32-bit ARM, GCC will not be able to translate
> these operations into lock-free instructions and will instead rely on
> the external atomics library to provide these operations.
> 
> Check at configuration time whether or not linking against libatomic
> is necessary and if so, create a dependency that can be used while
> linking the mesautil library.
> 
> This is the meson equivalent of 2ef7f23820a6 ("configure: check if
> -latomic is needed for __atomic_*").
> 
> Signed-off-by: Thierry Reding 
> ---
>  meson.build  | 15 +++
>  src/util/meson.build |  2 +-
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index 121341a950c4..7c6f40573421 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -800,6 +800,21 @@ endif
>  if cc.compiles('int main() { int n; return __atomic_load_n(, 
> __ATOMIC_ACQUIRE); }',
> name : 'GCC atomic builtins')
>pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
> +
> +  # Not all atomic calls can be turned into lock-free instructions, in which
> +  # GCC will make calls into the libatomic library. Check whether we need to
> +  # link with -latomic.
> +  #
> +  # This can happen for 64-bit atomic operations on 32-bit architectures such
> +  # as ARM.
> +  if not cc.links('''#include 
> + int main() {
> +   uint64_t n;
> +   return (int)__atomic_load_n(, __ATOMIC_ACQUIRE);
> + }''',
> +  name : 'GCC atomic builtins required -latomic')
> +dep_atomic = cc.find_library('atomic')

dep_atomic is undefined if the cc.links() succeeds right?

Dylan


signature.asc
Description: signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-26 Thread Matt Turner
On Fri, Feb 23, 2018 at 5:18 AM, Thierry Reding
 wrote:
> From: Thierry Reding 
>
> The disk cache implementation uses 64-bit atomic operations. For some
> architectures, such as 32-bit ARM, GCC will not be able to translate
> these operations into lock-free instructions and will instead rely on

Here, and in the comment in meson.build, I think you mean "atomic"
rather than "lock-free" instructions? It's at least confusing, since
on x86 atomic instructions have a "lock" prefix.

Otherwise:

Acked-by: Matt Turner 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] disk cache: Link with -latomic if necessary

2018-02-23 Thread Thierry Reding
From: Thierry Reding 

The disk cache implementation uses 64-bit atomic operations. For some
architectures, such as 32-bit ARM, GCC will not be able to translate
these operations into lock-free instructions and will instead rely on
the external atomics library to provide these operations.

Check at configuration time whether or not linking against libatomic
is necessary and if so, create a dependency that can be used while
linking the mesautil library.

This is the meson equivalent of 2ef7f23820a6 ("configure: check if
-latomic is needed for __atomic_*").

Signed-off-by: Thierry Reding 
---
 meson.build  | 15 +++
 src/util/meson.build |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 121341a950c4..7c6f40573421 100644
--- a/meson.build
+++ b/meson.build
@@ -800,6 +800,21 @@ endif
 if cc.compiles('int main() { int n; return __atomic_load_n(, 
__ATOMIC_ACQUIRE); }',
name : 'GCC atomic builtins')
   pre_args += '-DUSE_GCC_ATOMIC_BUILTINS'
+
+  # Not all atomic calls can be turned into lock-free instructions, in which
+  # GCC will make calls into the libatomic library. Check whether we need to
+  # link with -latomic.
+  #
+  # This can happen for 64-bit atomic operations on 32-bit architectures such
+  # as ARM.
+  if not cc.links('''#include 
+ int main() {
+   uint64_t n;
+   return (int)__atomic_load_n(, __ATOMIC_ACQUIRE);
+ }''',
+  name : 'GCC atomic builtins required -latomic')
+dep_atomic = cc.find_library('atomic')
+  endif
 endif
 if not cc.links('''#include 
uint64_t v;
diff --git a/src/util/meson.build b/src/util/meson.build
index b23dba3a9851..eece1cefef6a 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -102,7 +102,7 @@ libmesa_util = static_library(
   'mesa_util',
   [files_mesa_util, format_srgb],
   include_directories : inc_common,
-  dependencies : [dep_zlib, dep_clock, dep_thread],
+  dependencies : [dep_zlib, dep_clock, dep_thread, dep_atomic],
   c_args : [c_msvc_compat_args, c_vis_args],
   build_by_default : false
 )
-- 
2.16.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev