Skip to contentSkip to conversation

configure/Makefile.am: use pkg-config to discover libatomic_ops

PATCH In review Peter Seiderer 3 participants 8 messages Feb 6, 2018 – Mar 9, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure/Makefile.am: use pkg-config to discover libatomic_ops

From: Thomas Petazzoni <[email protected]>

The configure script currently tests the availability of libatomic_ops by checking the presence of atomic_ops.h. While this is good enough as an availability test, it is not sufficient as on some platforms, libatomic_ops provides an actual shared library against which we should be linked to access libatomic_ops functionality.

Therefore, we instead use PKG_CHECK_MODULES() to test the availability of libatomic_ops. Besides testing its availability, this also fills in the ATOMIC_OPS_LIBS variable with the list of libraries we need to link with to use libatomic_ops.

All Mesa drivers that include xf86atomic.h have been updated to link against ATOMIC_OPS_LIBS.

Of course, if we're not using libatomic_ops, ATOMIC_OPS_LIBS is empty, and we don't link against it.

[Bernd: PKG_CHECK_MODULES should not fail when libatomic_ops is missing]
---
 amdgpu/Makefile.am    | 2 +-
 configure.ac          | 2 +-
 etnaviv/Makefile.am   | 3 ++-
 freedreno/Makefile.am | 3 ++-
 intel/Makefile.am     | 3 ++-
 nouveau/Makefile.am   | 2 +-
 omap/Makefile.am      | 2 +-
 radeon/Makefile.am    | 2 +-
 tegra/Makefile.am     | 2 +-
 9 files changed, 12 insertions(+), 9 deletions(-)
amdgpu/Makefile.am +1 -1
index a1b0d05c..b2bcceff 100644
@@ -36,7 +36,7 @@ AM_CPPFLAGS = -DAMDGPU_ASIC_ID_TABLE=\"${libdrmdatadir}/amdgpu.ids\"
 libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la
 libdrm_amdgpu_ladir = $(libdir)
 libdrm_amdgpu_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_amdgpu_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_amdgpu_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
 
 libdrm_amdgpu_la_SOURCES = $(LIBDRM_AMDGPU_FILES)
 amdgpu_asic_id.lo: $(top_srcdir)/data/amdgpu.ids
configure.ac +1 -1
index 321ab2c0..1386d15c 100644
@@ -247,7 +247,7 @@ AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives, [
 					  ]],[[]])], [drm_cv_atomic_primitives="Intel"],[])
 
 	if test "x$drm_cv_atomic_primitives" = "xnone"; then
-		AC_CHECK_HEADER([atomic_ops.h], drm_cv_atomic_primitives="libatomic-ops")
+		PKG_CHECK_MODULES(ATOMIC_OPS, [atomic_ops], drm_cv_atomic_primitives="libatomic-ops", true)
 	fi
 
 	# atomic functions defined in <atomic.h> & libc on Solaris
etnaviv/Makefile.am +2 -1
index be96ba86..669cf14f 100644
@@ -12,7 +12,8 @@ libdrm_etnaviv_la_LDFLAGS = -version-number 1:0:0 -no-undefined
 libdrm_etnaviv_la_LIBADD = \
 	../libdrm.la \
 	@PTHREADSTUBS_LIBS@ \
-	@CLOCK_LIB@
+	@CLOCK_LIB@ \
+	@ATOMIC_OPS_LIBS@
 
 libdrm_etnaviv_la_SOURCES = $(LIBDRM_ETNAVIV_FILES)
 
freedreno/Makefile.am +2 -1
index cbb0d031..238407e3 100644
@@ -14,7 +14,8 @@ libdrm_freedreno_la_LDFLAGS = -version-number 1:0:0 -no-undefined
 libdrm_freedreno_la_LIBADD = \
 	../libdrm.la \
 	@PTHREADSTUBS_LIBS@ \
-	@CLOCK_LIB@
+	@CLOCK_LIB@ \
+	@ATOMIC_OPS_LIBS@
 
 libdrm_freedreno_la_SOURCES = $(LIBDRM_FREEDRENO_FILES)
 if HAVE_FREEDRENO_KGSL
intel/Makefile.am +2 -1
index c52e8c08..f3635a64 100644
@@ -38,7 +38,8 @@ libdrm_intel_la_LDFLAGS = -version-number 1:0:0 -no-undefined
 libdrm_intel_la_LIBADD = ../libdrm.la \
 	@PTHREADSTUBS_LIBS@ \
 	@PCIACCESS_LIBS@ \
-	@CLOCK_LIB@
+	@CLOCK_LIB@ \
+	@ATOMIC_OPS_LIBS@
 
 libdrm_intel_la_SOURCES = $(LIBDRM_INTEL_FILES)
 
nouveau/Makefile.am +1 -1
index 344a8445..a4e6a78b 100644
@@ -10,7 +10,7 @@ AM_CFLAGS = \
 libdrm_nouveau_la_LTLIBRARIES = libdrm_nouveau.la
 libdrm_nouveau_ladir = $(libdir)
 libdrm_nouveau_la_LDFLAGS = -version-number 2:0:0 -no-undefined
-libdrm_nouveau_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_nouveau_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
 
 libdrm_nouveau_la_SOURCES = $(LIBDRM_NOUVEAU_FILES)
 
omap/Makefile.am +1 -1
index 599bb9de..524afee3 100644
@@ -7,7 +7,7 @@ AM_CFLAGS = \
 libdrm_omap_la_LTLIBRARIES = libdrm_omap.la
 libdrm_omap_ladir = $(libdir)
 libdrm_omap_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_omap_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_omap_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
 
 libdrm_omap_la_SOURCES = omap_drm.c
 
radeon/Makefile.am +1 -1
index e2415314..c27d3c75 100644
@@ -33,7 +33,7 @@ AM_CFLAGS = \
 libdrm_radeon_la_LTLIBRARIES = libdrm_radeon.la
 libdrm_radeon_ladir = $(libdir)
 libdrm_radeon_la_LDFLAGS = -version-number 1:0:1 -no-undefined
-libdrm_radeon_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_radeon_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
 
 libdrm_radeon_la_SOURCES = $(LIBDRM_RADEON_FILES)
 
tegra/Makefile.am +1 -1
index fb40be55..12abe8c4 100644
@@ -9,7 +9,7 @@ AM_CFLAGS = \
 libdrm_tegra_ladir = $(libdir)
 libdrm_tegra_la_LTLIBRARIES = libdrm_tegra.la
 libdrm_tegra_la_LDFLAGS = -version-number 0:0:0 -no-undefined
-libdrm_tegra_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_tegra_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@ @ATOMIC_OPS_LIBS@
 
 libdrm_tegra_la_SOURCES = \
 	private.h \
Signature · 6 lines
2.16.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/1 meson: use pkg-config to detect libatomic_ops

---
 amdgpu/meson.build    | 2 +-
 etnaviv/meson.build   | 2 +-
 freedreno/meson.build | 2 +-
 intel/meson.build     | 2 +-
 meson.build           | 3 ++-
 nouveau/meson.build   | 2 +-
 omap/meson.build      | 2 +-
 radeon/meson.build    | 2 +-
 tegra/meson.build     | 2 +-
 9 files changed, 10 insertions(+), 9 deletions(-)
amdgpu/meson.build +1 -1
index 8b0452056e2513892c2c..7040ebab86e271022323 100644
@@ -37,7 +37,7 @@ libdrm_amdgpu = shared_library(
   ],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : dep_pthread_stubs,
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
etnaviv/meson.build +1 -1
index 1767733bd510efdaad86..ca2aa544c58924a15d8b 100644
@@ -31,7 +31,7 @@ libdrm_etnaviv = shared_library(
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
   c_args : warn_c_args,
-  dependencies : [dep_pthread_stubs, dep_rt],
+  dependencies : [dep_pthread_stubs, dep_rt, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
freedreno/meson.build +1 -1
index de6a413fa93e63c0ad4a..da993c10355578838f29 100644
@@ -44,7 +44,7 @@ libdrm_freedreno = shared_library(
   [files_freedreno, config_file],
   c_args : warn_c_args,
   include_directories : [inc_root, inc_drm],
-  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt],
+  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt, dep_atomic_ops],
   link_with : libdrm,
   version : '1.0.0',
   install : true,
intel/meson.build +1 -1
index ad877274f8d488a80d54..42402f60e38cd5e7359f 100644
@@ -29,7 +29,7 @@ libdrm_intel = shared_library(
   ],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind],
+  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind, dep_atomic_ops],
   c_args : warn_c_args,
   version : '1.0.0',
   install : true,
meson.build +2 -1
index a19e600c7475b2578e2d..f45c14a70baa2456582d 100644
@@ -51,6 +51,7 @@ cc = meson.get_compiler('c')
 intel_atomics = false
 lib_atomics = false
 
+dep_atomic_ops = dependency('atomic_ops', required : false)
 if cc.compiles('''
     int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
     int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
@@ -58,7 +59,7 @@ if cc.compiles('''
     name : 'Intel Atomics')
   intel_atomics = true
   with_atomics = true
-elif cc.has_header('atomic_ops.h')
+elif dep_atomic_ops.found()
   lib_atomics = true
   with_atomics = true
 elif cc.has_function('atomic_cas_uint')
nouveau/meson.build +1 -1
index f031cd63b71bab9f7e7a..b8affd9ef776c99ba896 100644
@@ -25,7 +25,7 @@ libdrm_nouveau = shared_library(
   c_args : warn_c_args,
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : dep_threads,
+  dependencies : [dep_threads, dep_atomic_ops],
   version : '2.0.0',
   install : true,
 )
omap/meson.build +1 -1
index 1881087fb0d180b668d3..f89436f0e99970b381aa 100644
@@ -24,7 +24,7 @@ libdrm_omap = shared_library(
   include_directories : [inc_root, inc_drm],
   c_args : warn_c_args,
   link_with : libdrm,
-  dependencies : [dep_pthread_stubs],
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
radeon/meson.build +1 -1
index b02166fe87ea27470e4b..557a878042bb78df4096 100644
@@ -31,7 +31,7 @@ libdrm_radeon = shared_library(
   c_args : warn_c_args,
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : [dep_pthread_stubs],
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   version : '1.0.1',
   install : true,
 )
tegra/meson.build +1 -1
index 99fdd194f50aceb6858b..7ac815177718d301b76c 100644
@@ -23,7 +23,7 @@ libdrm_tegra = shared_library(
   [files('tegra.c'), config_file],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : [dep_pthread_stubs],
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   c_args : warn_c_args,
   version : '0.0.0',
   install : true,
Signature · 7 lines
Cheers,
  Eric

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH libdrm] meson: use pkg-config to detect libatomic_ops

Ping? :)
Both for this patch and the equivalent autotools patch it replies to.

Quoted 78 lines · Eric Engestrom
---
 amdgpu/meson.build    | 2 +-
 etnaviv/meson.build   | 2 +-
 freedreno/meson.build | 2 +-
 intel/meson.build     | 2 +-
 meson.build           | 3 ++-
 nouveau/meson.build   | 2 +-
 omap/meson.build      | 2 +-
 radeon/meson.build    | 2 +-
 tegra/meson.build     | 2 +-
 9 files changed, 10 insertions(+), 9 deletions(-)
amdgpu/meson.build +1 -1
index 8b0452056e2513892c2c..7040ebab86e271022323 100644
@@ -37,7 +37,7 @@ libdrm_amdgpu = shared_library(
   ],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : dep_pthread_stubs,
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
etnaviv/meson.build +1 -1
index 1767733bd510efdaad86..ca2aa544c58924a15d8b 100644
@@ -31,7 +31,7 @@ libdrm_etnaviv = shared_library(
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
   c_args : warn_c_args,
-  dependencies : [dep_pthread_stubs, dep_rt],
+  dependencies : [dep_pthread_stubs, dep_rt, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
freedreno/meson.build +1 -1
index de6a413fa93e63c0ad4a..da993c10355578838f29 100644
@@ -44,7 +44,7 @@ libdrm_freedreno = shared_library(
   [files_freedreno, config_file],
   c_args : warn_c_args,
   include_directories : [inc_root, inc_drm],
-  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt],
+  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt, dep_atomic_ops],
   link_with : libdrm,
   version : '1.0.0',
   install : true,
intel/meson.build +1 -1
index ad877274f8d488a80d54..42402f60e38cd5e7359f 100644
@@ -29,7 +29,7 @@ libdrm_intel = shared_library(
   ],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind],
+  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind, dep_atomic_ops],
   c_args : warn_c_args,
   version : '1.0.0',
   install : true,
meson.build +1 -0
index a19e600c7475b2578e2d..f45c14a70baa2456582d 100644
@@ -51,6 +51,7 @@ cc = meson.get_compiler('c')
 intel_atomics = false
 lib_atomics = false
 
+dep_atomic_ops = dependency('atomic_ops', required : false)
 if cc.compiles('''
     int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
     int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }

meson.build if cc.compiles(''' · line 61

Quoted 3 lines
meson.build +0 -0
@@ -58,7 +59,7 @@ if cc.compiles('''
     name : 'Intel Atomics')
   intel_atomics = true
   with_atomics = true

Change added here locally; there's no need to link again dep_atomic_ops in this branch, although it doesn't hurt:

+ dep_atomic_ops = []

Quoted 61 lines
meson.build +1 -1
-elif cc.has_header('atomic_ops.h')
+elif dep_atomic_ops.found()
   lib_atomics = true
   with_atomics = true
 elif cc.has_function('atomic_cas_uint')
nouveau/meson.build +1 -1
index f031cd63b71bab9f7e7a..b8affd9ef776c99ba896 100644
@@ -25,7 +25,7 @@ libdrm_nouveau = shared_library(
   c_args : warn_c_args,
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : dep_threads,
+  dependencies : [dep_threads, dep_atomic_ops],
   version : '2.0.0',
   install : true,
 )
omap/meson.build +1 -1
index 1881087fb0d180b668d3..f89436f0e99970b381aa 100644
@@ -24,7 +24,7 @@ libdrm_omap = shared_library(
   include_directories : [inc_root, inc_drm],
   c_args : warn_c_args,
   link_with : libdrm,
-  dependencies : [dep_pthread_stubs],
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
radeon/meson.build +1 -1
index b02166fe87ea27470e4b..557a878042bb78df4096 100644
@@ -31,7 +31,7 @@ libdrm_radeon = shared_library(
   c_args : warn_c_args,
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : [dep_pthread_stubs],
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   version : '1.0.1',
   install : true,
 )
tegra/meson.build +1 -1
index 99fdd194f50aceb6858b..7ac815177718d301b76c 100644
@@ -23,7 +23,7 @@ libdrm_tegra = shared_library(
   [files('tegra.c'), config_file],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : [dep_pthread_stubs],
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   c_args : warn_c_args,
   version : '0.0.0',
   install : true,
Signature · 2 lines
Cheers,
  Eric

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by
#3 lore raw

Re: [PATCH libdrm] meson: use pkg-config to detect libatomic_ops

Quoted 3 lines · Eric Engestrom

Ping? :)
Both for this patch and the equivalent autotools patch it replies to.

The autotools one needs the CFLAGS added - meson does it automatically for us.

Quoted 86 lines · Eric Engestrom
Quoted 78 lines
---
 amdgpu/meson.build    | 2 +-
 etnaviv/meson.build   | 2 +-
 freedreno/meson.build | 2 +-
 intel/meson.build     | 2 +-
 meson.build           | 3 ++-
 nouveau/meson.build   | 2 +-
 omap/meson.build      | 2 +-
 radeon/meson.build    | 2 +-
 tegra/meson.build     | 2 +-
 9 files changed, 10 insertions(+), 9 deletions(-)
amdgpu/meson.build +1 -1
index 8b0452056e2513892c2c..7040ebab86e271022323 100644
@@ -37,7 +37,7 @@ libdrm_amdgpu = shared_library(
   ],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : dep_pthread_stubs,
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
etnaviv/meson.build +1 -1
index 1767733bd510efdaad86..ca2aa544c58924a15d8b 100644
@@ -31,7 +31,7 @@ libdrm_etnaviv = shared_library(
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
   c_args : warn_c_args,
-  dependencies : [dep_pthread_stubs, dep_rt],
+  dependencies : [dep_pthread_stubs, dep_rt, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
freedreno/meson.build +1 -1
index de6a413fa93e63c0ad4a..da993c10355578838f29 100644
@@ -44,7 +44,7 @@ libdrm_freedreno = shared_library(
   [files_freedreno, config_file],
   c_args : warn_c_args,
   include_directories : [inc_root, inc_drm],
-  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt],
+  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt, dep_atomic_ops],
   link_with : libdrm,
   version : '1.0.0',
   install : true,
intel/meson.build +1 -1
index ad877274f8d488a80d54..42402f60e38cd5e7359f 100644
@@ -29,7 +29,7 @@ libdrm_intel = shared_library(
   ],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind],
+  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind, dep_atomic_ops],
   c_args : warn_c_args,
   version : '1.0.0',
   install : true,
meson.build +1 -0
index a19e600c7475b2578e2d..f45c14a70baa2456582d 100644
@@ -51,6 +51,7 @@ cc = meson.get_compiler('c')
 intel_atomics = false
 lib_atomics = false
 
+dep_atomic_ops = dependency('atomic_ops', required : false)
 if cc.compiles('''
     int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
     int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }

meson.build if cc.compiles(''' · line 61

Quoted 3 lines
meson.build +0 -0
@@ -58,7 +59,7 @@ if cc.compiles('''
     name : 'Intel Atomics')
   intel_atomics = true
   with_atomics = true

Change added here locally; there's no need to link again dep_atomic_ops in this branch, although it doesn't hurt:

Quoted 2 lines

+ dep_atomic_ops = []

The dummy dep_atomic_ops is needed for almost all cases in the if/else ladder. The exception being the .found() case.

With that

-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [PATCH libdrm] meson: use pkg-config to detect libatomic_ops

Quoted 5 lines · Emil Velikov
Quoted 3 lines · Eric Engestrom

Ping? :)
Both for this patch and the equivalent autotools patch it replies to.

The autotools one needs the CFLAGS added - meson does it automatically for us.

I'll let Peter re-spin his patch, but I might push the meson one before his lands.

Quoted 87 lines
Quoted 87 lines · Eric Engestrom
Quoted 78 lines
---
 amdgpu/meson.build    | 2 +-
 etnaviv/meson.build   | 2 +-
 freedreno/meson.build | 2 +-
 intel/meson.build     | 2 +-
 meson.build           | 3 ++-
 nouveau/meson.build   | 2 +-
 omap/meson.build      | 2 +-
 radeon/meson.build    | 2 +-
 tegra/meson.build     | 2 +-
 9 files changed, 10 insertions(+), 9 deletions(-)
amdgpu/meson.build +1 -1
index 8b0452056e2513892c2c..7040ebab86e271022323 100644
@@ -37,7 +37,7 @@ libdrm_amdgpu = shared_library(
   ],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : dep_pthread_stubs,
+  dependencies : [dep_pthread_stubs, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
etnaviv/meson.build +1 -1
index 1767733bd510efdaad86..ca2aa544c58924a15d8b 100644
@@ -31,7 +31,7 @@ libdrm_etnaviv = shared_library(
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
   c_args : warn_c_args,
-  dependencies : [dep_pthread_stubs, dep_rt],
+  dependencies : [dep_pthread_stubs, dep_rt, dep_atomic_ops],
   version : '1.0.0',
   install : true,
 )
freedreno/meson.build +1 -1
index de6a413fa93e63c0ad4a..da993c10355578838f29 100644
@@ -44,7 +44,7 @@ libdrm_freedreno = shared_library(
   [files_freedreno, config_file],
   c_args : warn_c_args,
   include_directories : [inc_root, inc_drm],
-  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt],
+  dependencies : [dep_valgrind, dep_pthread_stubs, dep_rt, dep_atomic_ops],
   link_with : libdrm,
   version : '1.0.0',
   install : true,
intel/meson.build +1 -1
index ad877274f8d488a80d54..42402f60e38cd5e7359f 100644
@@ -29,7 +29,7 @@ libdrm_intel = shared_library(
   ],
   include_directories : [inc_root, inc_drm],
   link_with : libdrm,
-  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind],
+  dependencies : [dep_pciaccess, dep_pthread_stubs, dep_rt, dep_valgrind, dep_atomic_ops],
   c_args : warn_c_args,
   version : '1.0.0',
   install : true,
meson.build +1 -0
index a19e600c7475b2578e2d..f45c14a70baa2456582d 100644
@@ -51,6 +51,7 @@ cc = meson.get_compiler('c')
 intel_atomics = false
 lib_atomics = false
 
+dep_atomic_ops = dependency('atomic_ops', required : false)
 if cc.compiles('''
     int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
     int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }

meson.build if cc.compiles(''' · line 61

Quoted 3 lines
meson.build +0 -0
@@ -58,7 +59,7 @@ if cc.compiles('''
     name : 'Intel Atomics')
   intel_atomics = true
   with_atomics = true

Change added here locally; there's no need to link again dep_atomic_ops in this branch, although it doesn't hurt:

Quoted 4 lines
Quoted 2 lines

+ dep_atomic_ops = []

The dummy dep_atomic_ops is needed for almost all cases in the if/else ladder. The exception being the .found() case.

Actually, because of the way the if chain is written, the dep_atomic_ops has to be created before the list; in the if cases before this one, that dep might exist, but we don't need it. In the branch that uses it, if we got in the branch then it exists, and we need it. In the branches after that, it doesn't exist and we don't need it either.

That means that only up to that branch can it contain anything; afterwards, it's empty anyway.

And like I said, it only has the effect of maybe on the branches before adding unused flags to the compiler & linker, which shouldn't have any effect anyway.

Quoted 3 lines

With that

With the explanation, does your r-b stand for the current version?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

Re: [PATCH libdrm] meson: use pkg-config to detect libatomic_ops

Quoted 11 lines · Eric Engestrom
Quoted 4 lines
Quoted 2 lines

+ dep_atomic_ops = []

The dummy dep_atomic_ops is needed for almost all cases in the if/else ladder. The exception being the .found() case.

Actually, because of the way the if chain is written, the dep_atomic_ops has to be created before the list; in the if cases before this one, that dep might exist, but we don't need it. In the branch that uses it, if we got in the branch then it exists, and we need it. In the branches after that, it doesn't exist and we don't need it either.

Quoted 7 lines

That means that only up to that branch can it contain anything; afterwards, it's empty anyway.

And like I said, it only has the effect of maybe on the branches before adding unused flags to the compiler & linker, which shouldn't have any effect anyway.

Let me see if I get this right:

You're saying that when dep_atomic_ops.found() == false, the dep_atomic_ops dependency listed in the respective will expand to no-op.
I wasn't quite sure if that's the case, hence my pedantic suggestion ;-)

Makes sense though, rb still stands.

Thanks Eric!

-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH libdrm] meson: use pkg-config to detect libatomic_ops

Quoted 20 lines · Emil Velikov
Quoted 11 lines · Eric Engestrom
Quoted 4 lines
Quoted 2 lines

+ dep_atomic_ops = []

The dummy dep_atomic_ops is needed for almost all cases in the if/else ladder. The exception being the .found() case.

Actually, because of the way the if chain is written, the dep_atomic_ops has to be created before the list; in the if cases before this one, that dep might exist, but we don't need it. In the branch that uses it, if we got in the branch then it exists, and we need it. In the branches after that, it doesn't exist and we don't need it either.

Quoted 7 lines

That means that only up to that branch can it contain anything; afterwards, it's empty anyway.

And like I said, it only has the effect of maybe on the branches before adding unused flags to the compiler & linker, which shouldn't have any effect anyway.

Quoted 6 lines

Let me see if I get this right:

You're saying that when dep_atomic_ops.found() == false, the dep_atomic_ops dependency listed in the respective will expand to no-op.
I wasn't quite sure if that's the case, hence my pedantic suggestion ;-)

Exactly :)

Quoted 2 lines

Makes sense though, rb still stands.

OK, pushing in a minute

Quoted 4 lines

Thanks Eric!

-Emil

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
In reply to Peter Seiderer
Quoted 23 lines · Peter Seiderer

From: Thomas Petazzoni <[email protected]>

The configure script currently tests the availability of libatomic_ops by checking the presence of atomic_ops.h. While this is good enough as an availability test, it is not sufficient as on some platforms, libatomic_ops provides an actual shared library against which we should be linked to access libatomic_ops functionality.

Therefore, we instead use PKG_CHECK_MODULES() to test the availability of libatomic_ops. Besides testing its availability, this also fills in the ATOMIC_OPS_LIBS variable with the list of libraries we need to link with to use libatomic_ops.

All Mesa drivers that include xf86atomic.h have been updated to link against ATOMIC_OPS_LIBS.

Of course, if we're not using libatomic_ops, ATOMIC_OPS_LIBS is empty, and we don't link against it.

[Bernd: PKG_CHECK_MODULES should not fail when libatomic_ops is missing]
Quoted 10 lines
---
 amdgpu/Makefile.am    | 2 +-
 configure.ac          | 2 +-
 etnaviv/Makefile.am   | 3 ++-
 freedreno/Makefile.am | 3 ++-
 intel/Makefile.am     | 3 ++-
 nouveau/Makefile.am   | 2 +-
 omap/Makefile.am      | 2 +-
 radeon/Makefile.am    | 2 +-
 tegra/Makefile.am     | 2 +-

You're adding ATOMIC_OPS_LIBS to all the correct places, although ATOMIC_OPS_CFLAGS seems to be missing.
Can you re-spin with that one added?

Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel