diff mbox series

[1/6] meson: build target libraries with common dependencies

Message ID 20250516052708.930928-2-pierrick.bouvier@linaro.org
State New
Headers show
Series single-binary: build target common libraries with dependencies | expand

Commit Message

Pierrick Bouvier May 16, 2025, 5:27 a.m. UTC
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(-)

Comments

Philippe Mathieu-Daudé May 16, 2025, 11:42 a.m. UTC | #1
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(-)
Pierrick Bouvier May 16, 2025, 2:34 p.m. UTC | #2
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!
diff mbox series

Patch

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