As mentioned in 20250513115637.184940-1-thuth@redhat.com, dependencies
were missing when compiling per target libraries, thus breaking
compilation on certain host systems.
We now explicitely add common dependencies to those libraries, so it
solves the problem.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
meson.build | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/meson.build b/meson.build
index 49c8b0e5f6a..197fdc1c210 100644
--- a/meson.build
+++ b/meson.build
@@ -3259,6 +3259,7 @@ config_devices_mak_list = []
config_devices_h = {}
config_target_h = {}
config_target_mak = {}
+config_base_arch_mak = {}
disassemblers = {
'alpha' : ['CONFIG_ALPHA_DIS'],
@@ -3451,6 +3452,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
@@ -4131,12 +4137,17 @@ common_all = static_library('common',
hw_common_arch_libs = {}
target_common_arch_libs = {}
target_common_system_arch_libs = {}
-foreach target : target_dirs
+foreach target_base_arch, config_base_arch : config_base_arch_mak
config_target = config_target_mak[target]
- target_base_arch = config_target['TARGET_BASE_ARCH']
target_inc = [include_directories('target' / target_base_arch)]
inc = [common_user_inc + target_inc]
+ target_common = common_ss.apply(config_target, strict: false)
+ common_deps = []
+ foreach dep: target_common.dependencies()
+ common_deps += dep.partial_dependency(compile_args: true, includes: true)
+ endforeach
+
# prevent common code to access cpu compile time definition,
# but still allow access to cpu.h
target_c_args = ['-DCPU_DEFS_H']
@@ -4151,7 +4162,7 @@ foreach target : target_dirs
sources: src.all_sources() + genh,
include_directories: inc,
c_args: target_system_c_args,
- dependencies: src.all_dependencies())
+ dependencies: src.all_dependencies() + common_deps)
hw_common_arch_libs += {target_base_arch: lib}
endif
endif
@@ -4165,7 +4176,7 @@ foreach target : target_dirs
sources: src.all_sources() + genh,
include_directories: inc,
c_args: target_c_args,
- dependencies: src.all_dependencies())
+ dependencies: src.all_dependencies() + common_deps)
target_common_arch_libs += {target_base_arch: lib}
endif
endif
@@ -4179,7 +4190,7 @@ foreach target : target_dirs
sources: src.all_sources() + genh,
include_directories: inc,
c_args: target_system_c_args,
- dependencies: src.all_dependencies())
+ dependencies: src.all_dependencies() + common_deps)
target_common_system_arch_libs += {target_base_arch: lib}
endif
endif
--
2.47.2
On 5/16/25 07:27, Pierrick Bouvier wrote:
> @@ -4131,12 +4137,17 @@ common_all = static_library('common',
> hw_common_arch_libs = {}
> target_common_arch_libs = {}
> target_common_system_arch_libs = {}
> -foreach target : target_dirs
> +foreach target_base_arch, config_base_arch : config_base_arch_mak
> config_target = config_target_mak[target]
> - target_base_arch = config_target['TARGET_BASE_ARCH']
Each target_base_arch is now processed only once. Therefore, all the
"if target_base_arch not in ..." tests can be removed.
> target_inc = [include_directories('target' / target_base_arch)]
> inc = [common_user_inc + target_inc]
> sources: src.all_sources() + genh,
> include_directories: inc,
> c_args: target_system_c_args,
> - dependencies: src.all_dependencies())
> + dependencies: src.all_dependencies() + common_deps)
> hw_common_arch_libs += {target_base_arch: lib}
> endif
> endif
...
> @@ -4179,7 +4190,7 @@ foreach target : target_dirs
> sources: src.all_sources() + genh,
> include_directories: inc,
> c_args: target_system_c_args,
> - dependencies: src.all_dependencies())
> + dependencies: src.all_dependencies() + common_deps)
> target_common_system_arch_libs += {target_base_arch: lib}
> endif
> endif
There is no need for two separate libraries, since hw_* and
target_system_* use the same flags. You can do something like
system_src = []
if target_base_arch in hw_common_arch
system_src += hw_common_arch[target_base_arch].all_sources()
system_deps += hw_common_arch[target_base_arch].all_dependencies()
endif
if target_base_arch in target_common_system_arch
system_src += target_common_system_arch[target_base_arch].all_sources()
system_deps +=
target_common_system_arch[target_base_arch].all_dependencies()
endif
if system_src.length() > 0
...
endif
to build the two arrays of sources and dependencies.
If you reduce the libraries from 3 to 2, you could call them 'common_' +
target_base_arch and 'system_' + target_base_arch. That's more similar
to the existing libcommon and libsystem.
Paolo
On 5/17/25 8:00 AM, Paolo Bonzini wrote:
> On 5/16/25 07:27, Pierrick Bouvier wrote:
>> @@ -4131,12 +4137,17 @@ common_all = static_library('common',
>> hw_common_arch_libs = {}
>> target_common_arch_libs = {}
>> target_common_system_arch_libs = {}
>> -foreach target : target_dirs
>> +foreach target_base_arch, config_base_arch : config_base_arch_mak
>> config_target = config_target_mak[target]
>> - target_base_arch = config_target['TARGET_BASE_ARCH']
>
> Each target_base_arch is now processed only once. Therefore, all the
> "if target_base_arch not in ..." tests can be removed.
>
Yes, that's a good point, thanks.
>> target_inc = [include_directories('target' / target_base_arch)]
>> inc = [common_user_inc + target_inc]
>
>> sources: src.all_sources() + genh,
>> include_directories: inc,
>> c_args: target_system_c_args,
>> - dependencies: src.all_dependencies())
>> + dependencies: src.all_dependencies() + common_deps)
>> hw_common_arch_libs += {target_base_arch: lib}
>> endif
>> endif
>
> ...
>
>> @@ -4179,7 +4190,7 @@ foreach target : target_dirs
>> sources: src.all_sources() + genh,
>> include_directories: inc,
>> c_args: target_system_c_args,
>> - dependencies: src.all_dependencies())
>> + dependencies: src.all_dependencies() + common_deps)
>> target_common_system_arch_libs += {target_base_arch: lib}
>> endif
>> endif
>
> There is no need for two separate libraries, since hw_* and
> target_system_* use the same flags. You can do something like
>
> system_src = []
> if target_base_arch in hw_common_arch
> system_src += hw_common_arch[target_base_arch].all_sources()
> system_deps += hw_common_arch[target_base_arch].all_dependencies()
> endif
> if target_base_arch in target_common_system_arch
> system_src += target_common_system_arch[target_base_arch].all_sources()
> system_deps +=
> target_common_system_arch[target_base_arch].all_dependencies()
> endif
> if system_src.length() > 0
> ...
> endif
>
> to build the two arrays of sources and dependencies.
>
> If you reduce the libraries from 3 to 2, you could call them 'common_' +
> target_base_arch and 'system_' + target_base_arch. That's more similar
> to the existing libcommon and libsystem.
>
I hesitated to do it previously, so I'll merge them together.
> Paolo
>
Thanks for the review,
Pierrick
On 16/5/25 07:27, Pierrick Bouvier wrote:
> As mentioned in 20250513115637.184940-1-thuth@redhat.com, dependencies
Use LORE link instead?
https://lore.kernel.org/qemu-devel/20250513115637.184940-1-thuth@redhat.com/
> were missing when compiling per target libraries, thus breaking
> compilation on certain host systems.
>
> We now explicitely add common dependencies to those libraries, so it
"explicitly"?
> solves the problem.
>
Should we use the following tag?
Fixes: 6f4e8a92bbd ("hw/arm: make most of the compilation units common")
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> meson.build | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
On 5/16/25 4:42 AM, Philippe Mathieu-Daudé wrote:
> On 16/5/25 07:27, Pierrick Bouvier wrote:
>> As mentioned in 20250513115637.184940-1-thuth@redhat.com, dependencies
>
> Use LORE link instead?
> https://lore.kernel.org/qemu-devel/20250513115637.184940-1-thuth@redhat.com/
>
Yes, thanks.
>> were missing when compiling per target libraries, thus breaking
>> compilation on certain host systems.
>>
>> We now explicitely add common dependencies to those libraries, so it
>
> "explicitly"?
>
I'll fix it, thanks.
>> solves the problem.
>>
>
> Should we use the following tag?
>
> Fixes: 6f4e8a92bbd ("hw/arm: make most of the compilation units common")
>
Yes, it makes sense. I'll add it!
© 2016 - 2025 Red Hat, Inc.