qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	kvm@vger.kernel.org, alex.bennee@linaro.org,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-arm@nongnu.org, anjo@rev.ng, richard.henderson@linaro.org,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>
Subject: [PATCH 03/13] meson: add common libs for target and target_system
Date: Mon, 28 Apr 2025 22:00:00 -0700	[thread overview]
Message-ID: <20250429050010.971128-4-pierrick.bouvier@linaro.org> (raw)
In-Reply-To: <20250429050010.971128-1-pierrick.bouvier@linaro.org>

Following what we did for hw/, we need target specific common libraries
for target. We need 2 different libraries:
- code common to a base architecture
- system code common to a base architecture

For user code, it can stay compiled per target for now.

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 meson.build | 78 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 61 insertions(+), 17 deletions(-)

diff --git a/meson.build b/meson.build
index 68d36ac140f..7b2cf3cd7d1 100644
--- a/meson.build
+++ b/meson.build
@@ -3684,6 +3684,8 @@ target_arch = {}
 target_system_arch = {}
 target_user_arch = {}
 hw_common_arch = {}
+target_common_arch = {}
+target_common_system_arch = {}
 
 # NOTE: the trace/ subdirectory needs the qapi_trace_events variable
 # that is filled in by qapi/.
@@ -4087,29 +4089,59 @@ common_all = static_library('common',
 
 # construct common libraries per base architecture
 hw_common_arch_libs = {}
+target_common_arch_libs = {}
+target_common_system_arch_libs = {}
 foreach target : target_dirs
   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]
 
-  # check if already generated
-  if target_base_arch in hw_common_arch_libs
-    continue
-  endif
+  # prevent common code to access cpu compile time definition,
+  # but still allow access to cpu.h
+  target_c_args = ['-DCPU_DEFS_H']
+  target_system_c_args = target_c_args + ['-DCOMPILING_SYSTEM_VS_USER', '-DCONFIG_SOFTMMU']
 
   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,
-      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())
-    hw_common_arch_libs += {target_base_arch: lib}
+    if target_base_arch not in hw_common_arch_libs
+      src = hw_common_arch[target_base_arch]
+      lib = static_library(
+        'hw_' + target_base_arch,
+        build_by_default: false,
+        sources: src.all_sources() + genh,
+        include_directories: inc,
+        c_args: target_system_c_args,
+        dependencies: src.all_dependencies())
+      hw_common_arch_libs += {target_base_arch: lib}
+    endif
+  endif
+
+  if target_base_arch in target_common_arch
+    if target_base_arch not in target_common_arch_libs
+      src = target_common_arch[target_base_arch]
+      lib = static_library(
+        'target_' + target_base_arch,
+        build_by_default: false,
+        sources: src.all_sources() + genh,
+        include_directories: inc,
+        c_args: target_c_args,
+        dependencies: src.all_dependencies())
+      target_common_arch_libs += {target_base_arch: lib}
+    endif
+  endif
+
+  if target_base_arch in target_common_system_arch
+    if target_base_arch not in target_common_system_arch_libs
+      src = target_common_system_arch[target_base_arch]
+      lib = static_library(
+        'target_system_' + target_base_arch,
+        build_by_default: false,
+        sources: src.all_sources() + genh,
+        include_directories: inc,
+        c_args: target_system_c_args,
+        dependencies: src.all_dependencies())
+      target_common_system_arch_libs += {target_base_arch: lib}
+    endif
   endif
 endforeach
 
@@ -4282,12 +4314,24 @@ foreach target : target_dirs
   target_common = common_ss.apply(config_target, strict: false)
   objects = [common_all.extract_objects(target_common.sources())]
   arch_deps += target_common.dependencies()
+  if target_base_arch in target_common_arch_libs
+    src = target_common_arch[target_base_arch].apply(config_target, strict: false)
+    lib = target_common_arch_libs[target_base_arch]
+    objects += lib.extract_objects(src.sources())
+    arch_deps += src.dependencies()
+  endif
   if target_type == 'system' and target_base_arch in hw_common_arch_libs
     src = hw_common_arch[target_base_arch].apply(config_target, strict: false)
     lib = hw_common_arch_libs[target_base_arch]
     objects += lib.extract_objects(src.sources())
     arch_deps += src.dependencies()
   endif
+  if target_type == 'system' and target_base_arch in target_common_system_arch_libs
+    src = target_common_system_arch[target_base_arch].apply(config_target, strict: false)
+    lib = target_common_system_arch_libs[target_base_arch]
+    objects += lib.extract_objects(src.sources())
+    arch_deps += src.dependencies()
+  endif
 
   target_specific = specific_ss.apply(config_target, strict: false)
   arch_srcs += target_specific.sources()
-- 
2.47.2



  parent reply	other threads:[~2025-04-29  5:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29  4:59 [PATCH 00/13] single-binary: compile target/arm twice Pierrick Bouvier
2025-04-29  4:59 ` [PATCH 01/13] target/arm: Replace target_ulong -> uint64_t for HWBreakpoint Pierrick Bouvier
2025-04-29  9:15   ` Alex Bennée
2025-04-29  4:59 ` [PATCH 02/13] include/system/hvf: missing vaddr include Pierrick Bouvier
2025-04-29  5:36   ` Philippe Mathieu-Daudé
2025-04-29  7:13   ` Philippe Mathieu-Daudé
2025-04-29 21:09     ` Pierrick Bouvier
2025-04-29  5:00 ` Pierrick Bouvier [this message]
2025-04-29 18:01   ` [PATCH 03/13] meson: add common libs for target and target_system Philippe Mathieu-Daudé
2025-04-29 21:11     ` Pierrick Bouvier
2025-04-30  6:06       ` Philippe Mathieu-Daudé
2025-04-30  6:12         ` Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 04/13] target/arm: move kvm stubs and remove CONFIG_KVM from kvm_arm.h Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 05/13] target/arm/kvm_arm: copy definitions from kvm headers Pierrick Bouvier
2025-04-29 10:28   ` Alex Bennée
2025-04-29 21:14     ` Pierrick Bouvier
2025-04-29 22:02       ` Pierrick Bouvier
2025-04-30  6:08         ` Philippe Mathieu-Daudé
2025-04-29  5:00 ` [PATCH 06/13] target/arm/kvm-stub: add missing stubs Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 07/13] target/arm/cpu: remove CONFIG_KVM from arm_cpu_kvm_set_irq Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 08/13] accel/hvf: add hvf_enabled() for common code Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 09/13] target/arm/cpu: get endianness from cpu state Pierrick Bouvier
2025-04-29 12:26   ` Anton Johansson via
2025-04-29 21:07     ` Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 10/13] target/arm/cpu: remove TARGET_AARCH64 around aarch64_cpu_dump_state common Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 11/13] target/arm/cpu: remove TARGET_AARCH64 in arm_cpu_finalize_features Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 12/13] target/arm/cpu: compile file twice (user, system) only Pierrick Bouvier
2025-04-30  8:32   ` Philippe Mathieu-Daudé
2025-04-30 14:39     ` Pierrick Bouvier
2025-04-29  5:00 ` [PATCH 13/13] target/arm/cpu32-stubs.c: compile file twice (user, system) Pierrick Bouvier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250429050010.971128-4-pierrick.bouvier@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=anjo@rev.ng \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).