Skip to contentSkip to conversation

meson: do not emit modules with no enabled sources

PATCH In review Rohitashv Kumar 3 participants 3 messages Jul 29 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 meson: do not emit modules with no enabled sources

From: Rohitashv Kumar <[email protected]>

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.

---
 meson.build | 3 +++
 1 file changed, 3 insertions(+)
meson.build +3 -0
index 49a5baf5..557edd71 100644
@@ -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'
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Rohitashv Kumar

From: Rohitashv Kumar <[email protected]>

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.

Quoted 4 lines

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

Quoted 21 lines
---
 meson.build | 3 +++
 1 file changed, 3 insertions(+)
meson.build +3 -1
index 49a5baf5..557edd71 100644
@@ -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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Rohitashv Kumar
Quoted 15 lines · Rohitashv Kumar

From: Rohitashv Kumar <[email protected]>

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.

Quoted 8 lines

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

---
 meson.build | 3 +++
 1 file changed, 3 insertions(+)