[Qemu-devel] [PATCH 7/7] rdmacm-mux: convert to Meson

Paolo Bonzini posted 7 patches 6 years, 8 months ago
Maintainers: Yuval Shaia <yuval.shaia@oracle.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Cleber Rosa <crosa@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
There is a newer version of this series
[Qemu-devel] [PATCH 7/7] rdmacm-mux: convert to Meson
Posted by Paolo Bonzini 6 years, 8 months ago
We can use config-host.mak to decide whether the tool has to be built,
apart from that the conversion is straightforward.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 .gitignore                       | 1 +
 Makefile                         | 5 -----
 Makefile.objs                    | 1 -
 contrib/rdmacm-mux/Makefile.objs | 3 ---
 contrib/rdmacm-mux/meson.build   | 6 ++++++
 meson.build                      | 2 ++
 6 files changed, 9 insertions(+), 9 deletions(-)
 delete mode 100644 contrib/rdmacm-mux/Makefile.objs
 create mode 100644 contrib/rdmacm-mux/meson.build

diff --git a/.gitignore b/.gitignore
index 3934eff..b8d38a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,6 +63,7 @@
 /qemu-version.h.tmp
 /module_block.h
 /scsi/qemu-pr-helper
+/contrib/rdmacm-mux/rdmacm-mux
 /contrib/vhost-user-scsi/vhost-user-scsi
 /contrib/vhost-user-blk/vhost-user-blk
 /fsdev/virtfs-proxy-helper
diff --git a/Makefile b/Makefile
index bff097c..713f301 100644
--- a/Makefile
+++ b/Makefile
@@ -425,7 +425,6 @@ dummy := $(call unnest-vars,, \
                 elf2dmp-obj-y \
                 ivshmem-client-obj-y \
                 ivshmem-server-obj-y \
-                rdmacm-mux-obj-y \
                 vhost-user-input-obj-y \
                 vhost-user-gpu-obj-y \
                 qga-vss-dll-obj-y \
@@ -629,10 +628,6 @@ ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
 	$(call LINK, $^)
 endif
 
-rdmacm-mux$(EXESUF): LIBS += "-libumad"
-rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
-	$(call LINK, $^)
-
 vhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) contrib/libvhost-user/libvhost-user.a
 	$(call LINK, $^)
 
diff --git a/Makefile.objs b/Makefile.objs
index adf2f92..cf02f63 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -116,7 +116,6 @@ qga-vss-dll-obj-y = qga/
 elf2dmp-obj-y = contrib/elf2dmp/
 ivshmem-client-obj-$(CONFIG_IVSHMEM) = contrib/ivshmem-client/
 ivshmem-server-obj-$(CONFIG_IVSHMEM) = contrib/ivshmem-server/
-rdmacm-mux-obj-y = contrib/rdmacm-mux/
 vhost-user-input-obj-y = contrib/vhost-user-input/
 vhost-user-gpu-obj-y = contrib/vhost-user-gpu/
 
diff --git a/contrib/rdmacm-mux/Makefile.objs b/contrib/rdmacm-mux/Makefile.objs
deleted file mode 100644
index 3df744a..0000000
--- a/contrib/rdmacm-mux/Makefile.objs
+++ /dev/null
@@ -1,3 +0,0 @@
-ifdef CONFIG_PVRDMA
-rdmacm-mux-obj-y = main.o
-endif
diff --git a/contrib/rdmacm-mux/meson.build b/contrib/rdmacm-mux/meson.build
new file mode 100644
index 0000000..8451756
--- /dev/null
+++ b/contrib/rdmacm-mux/meson.build
@@ -0,0 +1,6 @@
+if config_host['CONFIG_PVRDMA'] == 'y'
+  # if not found, CONFIG_PVRDMA should not be set
+  libumad = cc.find_library('ibumad', required: true)
+  executable('rdmacm-mux', files('main.c'),
+             dependencies: [glib, libumad])
+endif
diff --git a/meson.build b/meson.build
index bc7fbea..2fc6111 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,5 @@
 project('qemu', 'c', meson_version: '>=0.50.999')
+cc = meson.get_compiler('c')
 
 kconfig = import('unstable-kconfig')
 config_host = kconfig.load(meson.current_build_dir() / 'config-host.mak')
@@ -14,5 +15,6 @@ libiscsi = declare_dependency(compile_args: config_host['LIBISCSI_CFLAGS'].split
                           link_args: config_host['LIBISCSI_LIBS'].split())
 
 subdir('contrib/libvhost-user')
+subdir('contrib/rdmacm-mux')
 subdir('contrib/vhost-user-blk')
 subdir('contrib/vhost-user-scsi')
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH 7/7] rdmacm-mux: convert to Meson
Posted by Markus Armbruster 6 years, 7 months ago
Paolo Bonzini <pbonzini@redhat.com> writes:

> We can use config-host.mak to decide whether the tool has to be built,
> apart from that the conversion is straightforward.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  .gitignore                       | 1 +
>  Makefile                         | 5 -----
>  Makefile.objs                    | 1 -
>  contrib/rdmacm-mux/Makefile.objs | 3 ---
>  contrib/rdmacm-mux/meson.build   | 6 ++++++
>  meson.build                      | 2 ++
>  6 files changed, 9 insertions(+), 9 deletions(-)
>  delete mode 100644 contrib/rdmacm-mux/Makefile.objs
>  create mode 100644 contrib/rdmacm-mux/meson.build
>
> diff --git a/.gitignore b/.gitignore
> index 3934eff..b8d38a8 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -63,6 +63,7 @@
>  /qemu-version.h.tmp
>  /module_block.h
>  /scsi/qemu-pr-helper
> +/contrib/rdmacm-mux/rdmacm-mux
>  /contrib/vhost-user-scsi/vhost-user-scsi
>  /contrib/vhost-user-blk/vhost-user-blk
>  /fsdev/virtfs-proxy-helper
> diff --git a/Makefile b/Makefile
> index bff097c..713f301 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -425,7 +425,6 @@ dummy := $(call unnest-vars,, \
>                  elf2dmp-obj-y \
>                  ivshmem-client-obj-y \
>                  ivshmem-server-obj-y \
> -                rdmacm-mux-obj-y \
>                  vhost-user-input-obj-y \
>                  vhost-user-gpu-obj-y \
>                  qga-vss-dll-obj-y \
> @@ -629,10 +628,6 @@ ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
>  	$(call LINK, $^)
>  endif
>  
> -rdmacm-mux$(EXESUF): LIBS += "-libumad"
> -rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
> -	$(call LINK, $^)
> -

Another way to pass extra flags to the compiler: target-specific
variables.  More direct than the funny variables we saw in the previous
patch.

The fine manual describes a way how to shoot yourself in the foot with
target-specific variabes.  Been there, done that, had "fun" debugging.

>  vhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) contrib/libvhost-user/libvhost-user.a
>  	$(call LINK, $^)
>  
> diff --git a/Makefile.objs b/Makefile.objs
> index adf2f92..cf02f63 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -116,7 +116,6 @@ qga-vss-dll-obj-y = qga/
>  elf2dmp-obj-y = contrib/elf2dmp/
>  ivshmem-client-obj-$(CONFIG_IVSHMEM) = contrib/ivshmem-client/
>  ivshmem-server-obj-$(CONFIG_IVSHMEM) = contrib/ivshmem-server/
> -rdmacm-mux-obj-y = contrib/rdmacm-mux/
>  vhost-user-input-obj-y = contrib/vhost-user-input/
>  vhost-user-gpu-obj-y = contrib/vhost-user-gpu/
>  
> diff --git a/contrib/rdmacm-mux/Makefile.objs b/contrib/rdmacm-mux/Makefile.objs
> deleted file mode 100644
> index 3df744a..0000000
> --- a/contrib/rdmacm-mux/Makefile.objs
> +++ /dev/null
> @@ -1,3 +0,0 @@
> -ifdef CONFIG_PVRDMA
> -rdmacm-mux-obj-y = main.o
> -endif
> diff --git a/contrib/rdmacm-mux/meson.build b/contrib/rdmacm-mux/meson.build
> new file mode 100644
> index 0000000..8451756
> --- /dev/null
> +++ b/contrib/rdmacm-mux/meson.build
> @@ -0,0 +1,6 @@
> +if config_host['CONFIG_PVRDMA'] == 'y'
> +  # if not found, CONFIG_PVRDMA should not be set

Our Makefiles use "either unset or 'y'" booleans pretty pervasively.  Is
it idiomatic meson?

> +  libumad = cc.find_library('ibumad', required: true)

With configure & make, we have configure check -libumad works, and make
use it.

Ignorant question: cc.find_library() looks like it checks.  Could this
replace checking in configure?

> +  executable('rdmacm-mux', files('main.c'),
> +             dependencies: [glib, libumad])
> +endif
> diff --git a/meson.build b/meson.build
> index bc7fbea..2fc6111 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1,4 +1,5 @@
>  project('qemu', 'c', meson_version: '>=0.50.999')
> +cc = meson.get_compiler('c')
>  
>  kconfig = import('unstable-kconfig')
>  config_host = kconfig.load(meson.current_build_dir() / 'config-host.mak')
> @@ -14,5 +15,6 @@ libiscsi = declare_dependency(compile_args: config_host['LIBISCSI_CFLAGS'].split
>                            link_args: config_host['LIBISCSI_LIBS'].split())
>  
>  subdir('contrib/libvhost-user')
> +subdir('contrib/rdmacm-mux')
>  subdir('contrib/vhost-user-blk')
>  subdir('contrib/vhost-user-scsi')

Re: [Qemu-devel] [PATCH 7/7] rdmacm-mux: convert to Meson
Posted by Paolo Bonzini 6 years, 7 months ago
On 27/06/19 13:38, Markus Armbruster wrote:
>> +if config_host['CONFIG_PVRDMA'] == 'y'
>> +  # if not found, CONFIG_PVRDMA should not be set
> Our Makefiles use "either unset or 'y'" booleans pretty pervasively.  Is
> it idiomatic meson?

No, the idiomatic way would be to use the found() method.  Something like:

# in toplevel meson.build:
ibverbs = cc.find_library('ibverbs')
ibumad = cc.find_library('ibumad')
rdmacm = cc.find_library('rdmacm')
if ibverbs.found() and ibumad.found() and rdmacm.found()
  pvrdma = declare_dependency(dependencies: [ibverbs, ibumad, rdmacm]
else
  # magic "not found" dependency
  pvrdma = dependency('', required: false)
endif

# in contrib/rdmacm-mux/meson.build
if pvrdma.found() then
  executable('rdmacm-mux', files('main.c'),
             dependencies: [glib, ibumad])
endif

>> +  libumad = cc.find_library('ibumad', required: true)
> With configure & make, we have configure check -libumad works, and make
> use it.
> 
> Ignorant question: cc.find_library() looks like it checks.  Could this
> replace checking in configure?

Yes, see above.  However, you would have to remove all uses of
$(RDMA_LIBS) and in the Makefiles first.

Paolo