Skip to contentSkip to conversation

meson.build: Compile hw_common_arch_libs files with right header include paths

PATCH In review Thomas Huth 2 participants 4 messages May 13, 2025 – May 16, 2025 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 meson.build: Compile hw_common_arch_libs files with right header include paths

From: Thomas Huth <[email protected]>

Since commit 6f4e8a92bbd ("hw/arm: make most of the compilation units common"), compilation of some arm machines (like musicpal) fails on certain host systems like OpenBSD 7.6/7.7 since headers like <epoxy/gl.h> don't reside in /usr/include and we currently don't add the right CFLAGS for the common files to include the additional header search paths. Add a loop similar to what we already did in commit 727bb5b477e6 to fix it.

With this fix applied, we can now also drop the explicit dependency on pixman for the arm musicpal machine.

Fixes 6f4e8a92bbd ("hw/arm: make most of the compilation units common")
[thuth: Add commit message + changes in hw/arm/meson.build]

---
v2: Change the subject of the patch according to Paolo's suggestion

 meson.build        | 27 ++++++++++++++++-----------
 hw/arm/meson.build |  2 +-
 2 files changed, 17 insertions(+), 12 deletions(-)
meson.build +16 -11
index 5ac64075be7..7131aa2b21d 100644
@@ -3228,6 +3228,7 @@ config_devices_mak_list = []
 config_devices_h = {}
 config_target_h = {}
 config_target_mak = {}
+config_base_arch_mak = {}
 
 disassemblers = {
   'alpha' : ['CONFIG_ALPHA_DIS'],
@@ -3419,6 +3420,11 @@ foreach target : target_dirs
     config_all_devices += config_devices
   endif
   config_target_mak += {target: config_target}
+
+  # build a merged config for all targets with the same TARGET_BASE_ARCH
+  target_base_arch = config_target['TARGET_BASE_ARCH']
+  config_base_arch = config_base_arch_mak.get(target_base_arch, {}) + config_target
+  config_base_arch_mak += {target_base_arch: config_base_arch}
 endforeach
 target_dirs = actual_target_dirs
 
@@ -4099,28 +4105,27 @@ common_all = static_library('common',
 
 # construct common libraries per base architecture
 hw_common_arch_libs = {}
-foreach target : target_dirs
-  config_target = config_target_mak[target]
-  target_base_arch = config_target['TARGET_BASE_ARCH']
+foreach target_base_arch, config_base_arch : config_base_arch_mak
+  if target_base_arch in hw_common_arch
+    base_arch_hw = hw_common_arch[target_base_arch].apply(config_base_arch, strict: false)
+    base_arch_common = common_ss.apply(config_base_arch, strict: false)
 
-  # check if already generated
-  if target_base_arch in hw_common_arch_libs
-    continue
-  endif
+    lib_deps = base_arch_hw.dependencies()
+    foreach dep : base_arch_common.dependencies()
+      lib_deps += dep.partial_dependency(compile_args: true, includes: true)
+    endforeach
 
-  if target_base_arch in hw_common_arch
     target_inc = [include_directories('target' / target_base_arch)]
-    src = hw_common_arch[target_base_arch]
     lib = static_library(
       'hw_' + target_base_arch,
       build_by_default: false,
-      sources: src.all_sources() + genh,
+      sources: base_arch_hw.sources() + genh,
       include_directories: common_user_inc + target_inc,
       implicit_include_directories: false,
       # prevent common code to access cpu compile time
       # definition, but still allow access to cpu.h
       c_args: ['-DCPU_DEFS_H', '-DCOMPILING_SYSTEM_VS_USER', '-DCONFIG_SOFTMMU'],
-      dependencies: src.all_dependencies())
+      dependencies: lib_deps)
     hw_common_arch_libs += {target_base_arch: lib}
   endif
 endforeach
hw/arm/meson.build +1 -1
index 5098795f61d..8e3bf495dbf 100644
@@ -8,7 +8,7 @@ arm_common_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c'))
 arm_common_ss.add(when: 'CONFIG_INTEGRATOR', if_true: files('integratorcp.c'))
 arm_common_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c'))
 arm_common_ss.add(when: 'CONFIG_MPS3R', if_true: files('mps3r.c'))
-arm_common_ss.add(when: 'CONFIG_MUSICPAL', if_true: [pixman, files('musicpal.c')])
+arm_common_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c'))
 arm_common_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c'))
 arm_common_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c'))
 arm_common_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c', 'npcm7xx_boards.c'))
Signature · 1 line
2.49.0
#1 lore raw

Hi Thomas,

Quoted 17 lines · Thomas Huth

From: Thomas Huth <[email protected]>

Since commit 6f4e8a92bbd ("hw/arm: make most of the compilation units common"), compilation of some arm machines (like musicpal) fails on certain host systems like OpenBSD 7.6/7.7 since headers like <epoxy/gl.h> don't reside in /usr/include and we currently don't add the right CFLAGS for the common files to include the additional header search paths. Add a loop similar to what we already did in commit 727bb5b477e6 to fix it.

With this fix applied, we can now also drop the explicit dependency on pixman for the arm musicpal machine.

Fixes 6f4e8a92bbd ("hw/arm: make most of the compilation units common")
[thuth: Add commit message + changes in hw/arm/meson.build]
Quoted 6 lines

---
v2: Change the subject of the patch according to Paolo's suggestion

  meson.build        | 27 ++++++++++++++++-----------
  hw/arm/meson.build |  2 +-
  2 files changed, 17 insertions(+), 12 deletions(-)

Thanks for the patch.
I didn't run into any issue when building for {linux, macos, windows, freebsd}, so I assumed it was safe to do things this way and specific dependencies could just be listed with associated sources. It seems like there are cracks in this approach, so adding all the dependencies per base arch is a good idea.

Any chance you could base it on this commit [1] (and add it for new libraries as well)?

This is going to be pulled very shortly (as part of a wider series), and the same fix will be needed.

[1] [email protected]

Thanks,
Pierrick

#2 lore raw
Quoted 35 lines · Pierrick Bouvier

Hi Thomas,

Quoted 17 lines · Thomas Huth

From: Thomas Huth <[email protected]>

Since commit 6f4e8a92bbd ("hw/arm: make most of the compilation units common"), compilation of some arm machines (like musicpal) fails on certain host systems like OpenBSD 7.6/7.7 since headers like <epoxy/gl.h> don't reside in /usr/include and we currently don't add the right CFLAGS for the common files to include the additional header search paths. Add a loop similar to what we already did in commit 727bb5b477e6 to fix it.

With this fix applied, we can now also drop the explicit dependency on pixman for the arm musicpal machine.

Fixes 6f4e8a92bbd ("hw/arm: make most of the compilation units common")
[thuth: Add commit message + changes in hw/arm/meson.build]
Quoted 6 lines

---
v2: Change the subject of the patch according to Paolo's suggestion

   meson.build        | 27 ++++++++++++++++-----------
   hw/arm/meson.build |  2 +-
   2 files changed, 17 insertions(+), 12 deletions(-)

Thanks for the patch.
I didn't run into any issue when building for {linux, macos, windows, freebsd}, so I assumed it was safe to do things this way and specific dependencies could just be listed with associated sources. It seems like there are cracks in this approach, so adding all the dependencies per base arch is a good idea.

Quoted 7 lines

Any chance you could base it on this commit [1] (and add it for new libraries as well)?

This is going to be pulled very shortly (as part of a wider series), and the same fix will be needed.
[1] [email protected]

[1] was merged.
I'm working on a series integrating your work, and doing further cleanups on meson side, so you can leave it for now.

Thanks,
Pierrick

#3 lore raw
Quoted 39 lines · Pierrick Bouvier
Quoted 38 lines · Pierrick Bouvier

Hi Thomas,

Quoted 17 lines · Thomas Huth

From: Thomas Huth <[email protected]>

Since commit 6f4e8a92bbd ("hw/arm: make most of the compilation units common"), compilation of some arm machines (like musicpal) fails on certain host systems like OpenBSD 7.6/7.7 since headers like <epoxy/gl.h> don't reside in /usr/include and we currently don't add the right CFLAGS for the common files to include the additional header search paths. Add a loop similar to what we already did in commit 727bb5b477e6 to fix it.

With this fix applied, we can now also drop the explicit dependency on pixman for the arm musicpal machine.

Fixes 6f4e8a92bbd ("hw/arm: make most of the compilation units common")
[thuth: Add commit message + changes in hw/arm/meson.build]
Quoted 6 lines

---

    v2: Change the subject of the patch according to Paolo's suggestion

    meson.build        | 27 ++++++++++++++++-----------
    hw/arm/meson.build |  2 +-
    2 files changed, 17 insertions(+), 12 deletions(-)

Thanks for the patch.
I didn't run into any issue when building for {linux, macos, windows, freebsd}, so I assumed it was safe to do things this way and specific dependencies could just be listed with associated sources. It seems like there are cracks in this approach, so adding all the dependencies per base arch is a good idea.

Any chance you could base it on this commit [1] (and add it for new libraries as well)?

Quoted 9 lines
Quoted 4 lines

This is going to be pulled very shortly (as part of a wider series), and the same fix will be needed.
[1] [email protected]

[1] was merged.
I'm working on a series integrating your work, and doing further cleanups on meson side, so you can leave it for now.

Posted here:
https://lore.kernel.org/qemu-devel/[email protected]

Regards,
Pierrick