[PATCH] meson.build: Compile common_ss files with right system header include paths

Thomas Huth posted 1 patch 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250513083343.148497-1-thuth@redhat.com
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
meson.build        | 27 ++++++++++++++++-----------
hw/arm/meson.build |  2 +-
2 files changed, 17 insertions(+), 12 deletions(-)
[PATCH] meson.build: Compile common_ss files with right system header include paths
Posted by Thomas Huth 6 months ago
From: Thomas Huth <thuth@redhat.com>

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")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[thuth: Add commit message + changes in hw/arm/meson.build]
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 meson.build        | 27 ++++++++++++++++-----------
 hw/arm/meson.build |  2 +-
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/meson.build b/meson.build
index 5ac64075be7..7131aa2b21d 100644
--- a/meson.build
+++ b/meson.build
@@ -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
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
index 5098795f61d..8e3bf495dbf 100644
--- a/hw/arm/meson.build
+++ b/hw/arm/meson.build
@@ -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'))
-- 
2.49.0
Re: [PATCH] meson.build: Compile common_ss files with right system header include paths
Posted by Philippe Mathieu-Daudé 6 months ago
Cc'ing Pierrick for 6f4e8a92bbd.

On 13/5/25 10:33, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
> 
> 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")
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> [thuth: Add commit message + changes in hw/arm/meson.build]
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   meson.build        | 27 ++++++++++++++++-----------
>   hw/arm/meson.build |  2 +-
>   2 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 5ac64075be7..7131aa2b21d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -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
> diff --git a/hw/arm/meson.build b/hw/arm/meson.build
> index 5098795f61d..8e3bf495dbf 100644
> --- a/hw/arm/meson.build
> +++ b/hw/arm/meson.build
> @@ -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'))
Re: [PATCH] meson.build: Compile common_ss files with right system header include paths
Posted by Paolo Bonzini 6 months ago
Il mar 13 mag 2025, 10:33 Thomas Huth <thuth@redhat.com> ha scritto:

> From: Thomas Huth <thuth@redhat.com>
>
> 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.
>

Thanks, maybe replace common_ss with hw_common_arch_libs in the subject?
These are not necessarily compiled once.

Paolo

Fixes: 6f4e8a92bbd ("hw/arm: make most of the compilation units common")
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> [thuth: Add commit message + changes in hw/arm/meson.build]
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  meson.build        | 27 ++++++++++++++++-----------
>  hw/arm/meson.build |  2 +-
>  2 files changed, 17 insertions(+), 12 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 5ac64075be7..7131aa2b21d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -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
> diff --git a/hw/arm/meson.build b/hw/arm/meson.build
> index 5098795f61d..8e3bf495dbf 100644
> --- a/hw/arm/meson.build
> +++ b/hw/arm/meson.build
> @@ -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'))
> --
> 2.49.0
>
>