[PATCH] meson: do not emit modules with no enabled sources

Rohitashv Kumar posted 1 patch 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260729150420.632747-2-rohit.kuma1313@gmail.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@mailo.com>, Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
meson.build | 3 +++
1 file changed, 3 insertions(+)
[PATCH] meson: do not emit modules with no enabled sources
Posted by Rohitashv Kumar 2 months ago
From: Rohitashv Kumar <roohiit@amazon.de>

With modular builds, the system/block module loop adds the common
boilerplate (modulecommon) to every registered module and emits a
shared_module unconditionally.  A module whose device sources are all
disabled by the configuration then still produces a shared object
containing nothing but the boilerplate: an empty stub that provides no
devices and only complicates packaging.

This happens when a module is registered under a broader condition than
the one gating its sources, e.g. hw-display-virtio-gpu-pci (registered on
CONFIG_VIRTIO_PCI, sources need CONFIG_VIRTIO_GPU) in a build without
virtio-gpu, or hw-s390x-virtio-gpu-ccw (registered unconditionally,
source needs CONFIG_VIRTIO_CCW) in a build without an s390x target.

The target_modules loop already skips modules whose applied source set is
empty; make the system/block loop consistent and do the same.

Signed-off-by: Rohitashv Kumar <roohiit@amazon.de>
---
 meson.build | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/meson.build b/meson.build
index 49a5baf5..557edd71 100644
--- a/meson.build
+++ b/meson.build
@@ -3903,6 +3903,9 @@ foreach d, list : modules
     if enable_modules
       module_ss.add(modulecommon)
       module_ss = module_ss.apply(config_all_devices, strict: false)
+      if module_ss.sources() == []
+        continue
+      endif
       sl = static_library(d + '-' + m, [genh, module_ss.sources()],
                           dependencies: module_ss.dependencies(), pic: true)
       if d == 'block'
-- 
2.47.3
Re: [PATCH] meson: do not emit modules with no enabled sources
Posted by Pierrick Bouvier 2 months ago
On 7/29/2026 8:04 AM, Rohitashv Kumar wrote:
> From: Rohitashv Kumar <roohiit@amazon.de>
> 
> With modular builds, the system/block module loop adds the common
> boilerplate (modulecommon) to every registered module and emits a
> shared_module unconditionally.  A module whose device sources are all
> disabled by the configuration then still produces a shared object
> containing nothing but the boilerplate: an empty stub that provides no
> devices and only complicates packaging.
> 
> This happens when a module is registered under a broader condition than
> the one gating its sources, e.g. hw-display-virtio-gpu-pci (registered on
> CONFIG_VIRTIO_PCI, sources need CONFIG_VIRTIO_GPU) in a build without
> virtio-gpu, or hw-s390x-virtio-gpu-ccw (registered unconditionally,
> source needs CONFIG_VIRTIO_CCW) in a build without an s390x target.
> 
> The target_modules loop already skips modules whose applied source set is
> empty; make the system/block loop consistent and do the same.
> 
> Signed-off-by: Rohitashv Kumar <roohiit@amazon.de>
> ---
>  meson.build | 3 +++
>  1 file changed, 3 insertions(+)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Re: [PATCH] meson: do not emit modules with no enabled sources
Posted by Marc-André Lureau 2 months ago
On Wed, Jul 29, 2026 at 7:09 PM Rohitashv Kumar
<rohit.kuma1313@gmail.com> wrote:
>
> From: Rohitashv Kumar <roohiit@amazon.de>
>
> With modular builds, the system/block module loop adds the common
> boilerplate (modulecommon) to every registered module and emits a
> shared_module unconditionally.  A module whose device sources are all
> disabled by the configuration then still produces a shared object
> containing nothing but the boilerplate: an empty stub that provides no
> devices and only complicates packaging.
>
> This happens when a module is registered under a broader condition than
> the one gating its sources, e.g. hw-display-virtio-gpu-pci (registered on
> CONFIG_VIRTIO_PCI, sources need CONFIG_VIRTIO_GPU) in a build without
> virtio-gpu, or hw-s390x-virtio-gpu-ccw (registered unconditionally,
> source needs CONFIG_VIRTIO_CCW) in a build without an s390x target.
>
> The target_modules loop already skips modules whose applied source set is
> empty; make the system/block loop consistent and do the same.
>
> Signed-off-by: Rohitashv Kumar <roohiit@amazon.de>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  meson.build | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/meson.build b/meson.build
> index 49a5baf5..557edd71 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -3903,6 +3903,9 @@ foreach d, list : modules
>      if enable_modules
>        module_ss.add(modulecommon)
>        module_ss = module_ss.apply(config_all_devices, strict: false)
> +      if module_ss.sources() == []
> +        continue
> +      endif
>        sl = static_library(d + '-' + m, [genh, module_ss.sources()],
>                            dependencies: module_ss.dependencies(), pic: true)
>        if d == 'block'
> --
> 2.47.3
>