* [PATCH 0/6] single-binary: build target common libraries with dependencies
@ 2025-05-16 5:27 Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 1/6] meson: build target libraries with common dependencies Pierrick Bouvier
` (8 more replies)
0 siblings, 9 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 5:27 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Pierrick Bouvier, Alex Bennée
Recently, common libraries per target base architecture were introduced in order
to compile those files only once. However, it was missing common dependencies
(which include external libraries), so it failed to build on some hosts.
This series fixes this, inspired by Thomas fix [1], and applied to other
libraries introduced very recently with [2].
As well, we do further cleanup by removing lib{system, user} source sets that
were recently introduced, by merging them in system/user libraries, thus
simplifying the work on single-binary.
This series was built on {linux, macos, windows} x {x86_64, aarch64} and
freebsd on x86_64. Fully tested on linux x {x86_64, aarch64}.
In addition to that, it was checked that compilation units compiled per binary
stayed the same, and that their size was identical.
[1] https://lore.kernel.org/qemu-devel/20250513115637.184940-1-thuth@redhat.com/
[2] https://gitlab.com/qemu-project/qemu/-/commit/b2bb3f3576e5dc99218607dde09e25ac0e55693c
Pierrick Bouvier (6):
meson: build target libraries with common dependencies
hw/arm: remove explicit dependencies listed
target/arm: remove explicit dependencies listed
meson: apply target config for picking files from lib{system, user}
meson: merge lib{system, user}_ss with {system, user}_ss.
meson: remove lib{system, user}_ss aliases
meson.build | 65 +++++++++++++++++++++++++++---------------
accel/tcg/meson.build | 8 +++---
gdbstub/meson.build | 4 +--
hw/arm/meson.build | 4 +--
hw/core/meson.build | 4 +--
plugins/meson.build | 4 +--
system/meson.build | 2 +-
target/arm/meson.build | 2 +-
tcg/meson.build | 4 +--
9 files changed, 58 insertions(+), 39 deletions(-)
--
2.47.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/6] meson: build target libraries with common dependencies
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
@ 2025-05-16 5:27 ` Pierrick Bouvier
2025-05-16 11:42 ` Philippe Mathieu-Daudé
2025-05-17 15:00 ` Paolo Bonzini
2025-05-16 5:27 ` [PATCH 2/6] hw/arm: remove explicit dependencies listed Pierrick Bouvier
` (7 subsequent siblings)
8 siblings, 2 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 5:27 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Pierrick Bouvier, Alex Bennée
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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/6] hw/arm: remove explicit dependencies listed
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 1/6] meson: build target libraries with common dependencies Pierrick Bouvier
@ 2025-05-16 5:27 ` Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 3/6] target/arm: " Pierrick Bouvier
` (6 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 5:27 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Pierrick Bouvier, Alex Bennée
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
hw/arm/meson.build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
index 5098795f61d..d90be8f4c94 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'))
@@ -79,7 +79,7 @@ arm_common_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c'))
arm_common_ss.add(when: 'CONFIG_VERSATILE', if_true: files('versatilepb.c'))
arm_common_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c'))
-arm_common_ss.add(fdt, files('boot.c'))
+arm_common_ss.add(files('boot.c'))
hw_arch += {'arm': arm_ss}
hw_common_arch += {'arm': arm_common_ss}
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/6] target/arm: remove explicit dependencies listed
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 1/6] meson: build target libraries with common dependencies Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 2/6] hw/arm: remove explicit dependencies listed Pierrick Bouvier
@ 2025-05-16 5:27 ` Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 4/6] meson: apply target config for picking files from lib{system, user} Pierrick Bouvier
` (5 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 5:27 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Pierrick Bouvier, Alex Bennée
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
target/arm/meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/arm/meson.build b/target/arm/meson.build
index b404fa54863..2ff7ed6e98f 100644
--- a/target/arm/meson.build
+++ b/target/arm/meson.build
@@ -28,7 +28,7 @@ arm_user_ss.add(files(
'vfp_fpscr.c',
))
-arm_common_system_ss.add(files('cpu.c'), capstone)
+arm_common_system_ss.add(files('cpu.c'))
arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files(
'cpu32-stubs.c'))
arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/6] meson: apply target config for picking files from lib{system, user}
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
` (2 preceding siblings ...)
2025-05-16 5:27 ` [PATCH 3/6] target/arm: " Pierrick Bouvier
@ 2025-05-16 5:27 ` Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 5/6] meson: merge lib{system, user}_ss with {system, user}_ss Pierrick Bouvier
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 5:27 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Pierrick Bouvier, Alex Bennée
semihosting code needs to be included only if CONFIG_SEMIHOSTING is set.
However, this is a target configuration, so we need to apply it to the
lib{system, user}_ss.
As well, this prepares merging lib{system, user}_ss with
{system, user}_ss.
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
meson.build | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/meson.build b/meson.build
index 197fdc1c210..fadee0f29fa 100644
--- a/meson.build
+++ b/meson.build
@@ -4101,27 +4101,19 @@ common_ss.add(qom, qemuutil)
common_ss.add_all(when: 'CONFIG_SYSTEM_ONLY', if_true: [system_ss])
common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
-libuser_ss = libuser_ss.apply({})
libuser = static_library('user',
- libuser_ss.sources() + genh,
+ libuser_ss.all_sources() + genh,
c_args: ['-DCONFIG_USER_ONLY',
'-DCOMPILING_SYSTEM_VS_USER'],
- dependencies: libuser_ss.dependencies(),
+ dependencies: libuser_ss.all_dependencies(),
build_by_default: false)
-libuser = declare_dependency(objects: libuser.extract_all_objects(recursive: false),
- dependencies: libuser_ss.dependencies())
-common_ss.add(when: 'CONFIG_USER_ONLY', if_true: libuser)
-libsystem_ss = libsystem_ss.apply({})
libsystem = static_library('system',
- libsystem_ss.sources() + genh,
+ libsystem_ss.all_sources() + genh,
c_args: ['-DCONFIG_SOFTMMU',
'-DCOMPILING_SYSTEM_VS_USER'],
- dependencies: libsystem_ss.dependencies(),
+ dependencies: libsystem_ss.all_dependencies(),
build_by_default: false)
-libsystem = declare_dependency(objects: libsystem.extract_all_objects(recursive: false),
- dependencies: libsystem_ss.dependencies())
-common_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: libsystem)
# Note that this library is never used directly (only through extract_objects)
# and is not built by default; therefore, source files not used by the build
@@ -4365,6 +4357,16 @@ 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_type == 'system'
+ src = libsystem_ss.apply(config_target, strict: false)
+ objects += libsystem.extract_objects(src.sources())
+ arch_deps += src.dependencies()
+ endif
+ if target_type == 'user'
+ src = libuser_ss.apply(config_target, strict: false)
+ objects += libuser.extract_objects(src.sources())
+ arch_deps += src.dependencies()
+ endif
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]
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/6] meson: merge lib{system, user}_ss with {system, user}_ss.
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
` (3 preceding siblings ...)
2025-05-16 5:27 ` [PATCH 4/6] meson: apply target config for picking files from lib{system, user} Pierrick Bouvier
@ 2025-05-16 5:27 ` Pierrick Bouvier
2025-05-17 15:04 ` Paolo Bonzini
2025-05-16 5:27 ` [PATCH 6/6] meson: remove lib{system, user}_ss aliases Pierrick Bouvier
` (3 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 5:27 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Pierrick Bouvier, Alex Bennée
Now that target configuration can be applied to lib{system, user}_ss,
there is no reason to keep that separate from the existing {system,
user}_ss.
We extract existing system/user code common common libraries to
lib{system, user}.
To not break existing meson files, we alias libsystem_ss to system_ss
and libuser_ss to user_ss, so we can do the cleanup in next commit.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
meson.build | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/meson.build b/meson.build
index fadee0f29fa..98b97fd7ba3 100644
--- a/meson.build
+++ b/meson.build
@@ -3712,14 +3712,14 @@ io_ss = ss.source_set()
qmp_ss = ss.source_set()
qom_ss = ss.source_set()
system_ss = ss.source_set()
-libsystem_ss = ss.source_set()
+libsystem_ss = system_ss
specific_fuzz_ss = ss.source_set()
specific_ss = ss.source_set()
rust_devices_ss = ss.source_set()
stub_ss = ss.source_set()
trace_ss = ss.source_set()
user_ss = ss.source_set()
-libuser_ss = ss.source_set()
+libuser_ss = user_ss
util_ss = ss.source_set()
# accel modules
@@ -4098,21 +4098,19 @@ common_ss.add(hwcore)
system_ss.add(authz, blockdev, chardev, crypto, io, qmp)
common_ss.add(qom, qemuutil)
-common_ss.add_all(when: 'CONFIG_SYSTEM_ONLY', if_true: [system_ss])
-common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
-
libuser = static_library('user',
- libuser_ss.all_sources() + genh,
+ user_ss.all_sources() + genh,
c_args: ['-DCONFIG_USER_ONLY',
'-DCOMPILING_SYSTEM_VS_USER'],
- dependencies: libuser_ss.all_dependencies(),
+ include_directories: common_user_inc,
+ dependencies: user_ss.all_dependencies(),
build_by_default: false)
libsystem = static_library('system',
- libsystem_ss.all_sources() + genh,
+ system_ss.all_sources() + genh,
c_args: ['-DCONFIG_SOFTMMU',
'-DCOMPILING_SYSTEM_VS_USER'],
- dependencies: libsystem_ss.all_dependencies(),
+ dependencies: system_ss.all_dependencies(),
build_by_default: false)
# Note that this library is never used directly (only through extract_objects)
@@ -4121,7 +4119,6 @@ libsystem = static_library('system',
common_all = static_library('common',
build_by_default: false,
sources: common_ss.all_sources() + genh,
- include_directories: common_user_inc,
implicit_include_directories: false,
dependencies: common_ss.all_dependencies())
@@ -4135,10 +4132,20 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
inc = [common_user_inc + target_inc]
target_common = common_ss.apply(config_target, strict: false)
+ target_system = system_ss.apply(config_target, strict: false)
+ target_user = user_ss.apply(config_target, strict: false)
common_deps = []
+ system_deps = []
+ user_deps = []
foreach dep: target_common.dependencies()
common_deps += dep.partial_dependency(compile_args: true, includes: true)
endforeach
+ foreach dep: target_system.dependencies()
+ system_deps += dep.partial_dependency(compile_args: true, includes: true)
+ endforeach
+ foreach dep: target_user.dependencies()
+ user_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
@@ -4154,7 +4161,7 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
sources: src.all_sources() + genh,
include_directories: inc,
c_args: target_system_c_args,
- dependencies: src.all_dependencies() + common_deps)
+ dependencies: src.all_dependencies() + common_deps + system_deps)
hw_common_arch_libs += {target_base_arch: lib}
endif
endif
@@ -4168,7 +4175,8 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
sources: src.all_sources() + genh,
include_directories: inc,
c_args: target_c_args,
- dependencies: src.all_dependencies() + common_deps)
+ dependencies: src.all_dependencies() + common_deps +
+ system_deps + user_deps)
target_common_arch_libs += {target_base_arch: lib}
endif
endif
@@ -4182,7 +4190,7 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
sources: src.all_sources() + genh,
include_directories: inc,
c_args: target_system_c_args,
- dependencies: src.all_dependencies() + common_deps)
+ dependencies: src.all_dependencies() + common_deps + system_deps)
target_common_system_arch_libs += {target_base_arch: lib}
endif
endif
@@ -4358,12 +4366,12 @@ foreach target : target_dirs
objects = [common_all.extract_objects(target_common.sources())]
arch_deps += target_common.dependencies()
if target_type == 'system'
- src = libsystem_ss.apply(config_target, strict: false)
+ src = system_ss.apply(config_target, strict: false)
objects += libsystem.extract_objects(src.sources())
arch_deps += src.dependencies()
endif
if target_type == 'user'
- src = libuser_ss.apply(config_target, strict: false)
+ src = user_ss.apply(config_target, strict: false)
objects += libuser.extract_objects(src.sources())
arch_deps += src.dependencies()
endif
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 6/6] meson: remove lib{system, user}_ss aliases
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
` (4 preceding siblings ...)
2025-05-16 5:27 ` [PATCH 5/6] meson: merge lib{system, user}_ss with {system, user}_ss Pierrick Bouvier
@ 2025-05-16 5:27 ` Pierrick Bouvier
2025-05-16 5:40 ` [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 5:27 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Pierrick Bouvier, Alex Bennée
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
meson.build | 2 --
accel/tcg/meson.build | 8 ++++----
gdbstub/meson.build | 4 ++--
hw/core/meson.build | 4 ++--
plugins/meson.build | 4 ++--
system/meson.build | 2 +-
tcg/meson.build | 4 ++--
7 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/meson.build b/meson.build
index 98b97fd7ba3..7aca61a1e8f 100644
--- a/meson.build
+++ b/meson.build
@@ -3712,14 +3712,12 @@ io_ss = ss.source_set()
qmp_ss = ss.source_set()
qom_ss = ss.source_set()
system_ss = ss.source_set()
-libsystem_ss = system_ss
specific_fuzz_ss = ss.source_set()
specific_ss = ss.source_set()
rust_devices_ss = ss.source_set()
stub_ss = ss.source_set()
trace_ss = ss.source_set()
user_ss = ss.source_set()
-libuser_ss = user_ss
util_ss = ss.source_set()
# accel modules
diff --git a/accel/tcg/meson.build b/accel/tcg/meson.build
index 97d5e5a7112..575e92bb9e8 100644
--- a/accel/tcg/meson.build
+++ b/accel/tcg/meson.build
@@ -18,15 +18,15 @@ if get_option('plugins')
tcg_ss.add(files('plugin-gen.c'))
endif
-libuser_ss.add_all(tcg_ss)
-libsystem_ss.add_all(tcg_ss)
+user_ss.add_all(tcg_ss)
+system_ss.add_all(tcg_ss)
-libuser_ss.add(files(
+user_ss.add(files(
'user-exec.c',
'user-exec-stub.c',
))
-libsystem_ss.add(files(
+system_ss.add(files(
'cputlb.c',
'icount-common.c',
'monitor.c',
diff --git a/gdbstub/meson.build b/gdbstub/meson.build
index b25db86767e..15c666f5752 100644
--- a/gdbstub/meson.build
+++ b/gdbstub/meson.build
@@ -5,13 +5,13 @@
#
# We build two versions of gdbstub, one for each mode
-libuser_ss.add(files(
+user_ss.add(files(
'gdbstub.c',
'syscalls.c',
'user.c'
))
-libsystem_ss.add(files(
+system_ss.add(files(
'gdbstub.c',
'syscalls.c',
'system.c'
diff --git a/hw/core/meson.build b/hw/core/meson.build
index 547de6527cf..b5a545a0edd 100644
--- a/hw/core/meson.build
+++ b/hw/core/meson.build
@@ -26,7 +26,7 @@ system_ss.add(when: 'CONFIG_XILINX_AXI', if_true: files('stream.c'))
system_ss.add(when: 'CONFIG_PLATFORM_BUS', if_true: files('sysbus-fdt.c'))
system_ss.add(when: 'CONFIG_EIF', if_true: [files('eif.c'), zlib, libcbor, gnutls])
-libsystem_ss.add(files(
+system_ss.add(files(
'cpu-system.c',
'fw-path-provider.c',
'gpio.c',
@@ -46,7 +46,7 @@ libsystem_ss.add(files(
'vm-change-state-handler.c',
'clock-vmstate.c',
))
-libuser_ss.add(files(
+user_ss.add(files(
'cpu-user.c',
'qdev-user.c',
))
diff --git a/plugins/meson.build b/plugins/meson.build
index 5383c7b88bf..b20edfbabc1 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -61,8 +61,8 @@ endif
user_ss.add(files('user.c', 'api-user.c'))
system_ss.add(files('system.c', 'api-system.c'))
-libuser_ss.add(files('api.c', 'core.c'))
-libsystem_ss.add(files('api.c', 'core.c'))
+user_ss.add(files('api.c', 'core.c'))
+system_ss.add(files('api.c', 'core.c'))
common_ss.add(files('loader.c'))
diff --git a/system/meson.build b/system/meson.build
index c2f00827669..7514bf3455d 100644
--- a/system/meson.build
+++ b/system/meson.build
@@ -7,7 +7,7 @@ system_ss.add(files(
'vl.c',
), sdl, libpmem, libdaxctl)
-libsystem_ss.add(files(
+system_ss.add(files(
'balloon.c',
'bootdevice.c',
'cpus.c',
diff --git a/tcg/meson.build b/tcg/meson.build
index bd2821e4b54..706a6eb260e 100644
--- a/tcg/meson.build
+++ b/tcg/meson.build
@@ -27,5 +27,5 @@ if host_os == 'linux'
tcg_ss.add(files('perf.c'))
endif
-libuser_ss.add_all(tcg_ss)
-libsystem_ss.add_all(tcg_ss)
+user_ss.add_all(tcg_ss)
+system_ss.add_all(tcg_ss)
--
2.47.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 0/6] single-binary: build target common libraries with dependencies
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
` (5 preceding siblings ...)
2025-05-16 5:27 ` [PATCH 6/6] meson: remove lib{system, user}_ss aliases Pierrick Bouvier
@ 2025-05-16 5:40 ` Pierrick Bouvier
2025-05-16 7:24 ` Thomas Huth
2025-05-21 22:38 ` Pierrick Bouvier
8 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 5:40 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Alex Bennée
On 5/15/25 10:27 PM, Pierrick Bouvier wrote:
> Recently, common libraries per target base architecture were introduced in order
> to compile those files only once. However, it was missing common dependencies
> (which include external libraries), so it failed to build on some hosts.
>
> This series fixes this, inspired by Thomas fix [1], and applied to other
> libraries introduced very recently with [2].
>
> As well, we do further cleanup by removing lib{system, user} source sets that
> were recently introduced, by merging them in system/user libraries, thus
> simplifying the work on single-binary.
>
> This series was built on {linux, macos, windows} x {x86_64, aarch64} and
> freebsd on x86_64. Fully tested on linux x {x86_64, aarch64}.
> In addition to that, it was checked that compilation units compiled per binary
> stayed the same, and that their size was identical.
>
> [1] https://lore.kernel.org/qemu-devel/20250513115637.184940-1-thuth@redhat.com/
> [2] https://gitlab.com/qemu-project/qemu/-/commit/b2bb3f3576e5dc99218607dde09e25ac0e55693c
>
> Pierrick Bouvier (6):
> meson: build target libraries with common dependencies
> hw/arm: remove explicit dependencies listed
> target/arm: remove explicit dependencies listed
> meson: apply target config for picking files from lib{system, user}
> meson: merge lib{system, user}_ss with {system, user}_ss.
> meson: remove lib{system, user}_ss aliases
>
> meson.build | 65 +++++++++++++++++++++++++++---------------
> accel/tcg/meson.build | 8 +++---
> gdbstub/meson.build | 4 +--
> hw/arm/meson.build | 4 +--
> hw/core/meson.build | 4 +--
> plugins/meson.build | 4 +--
> system/meson.build | 2 +-
> target/arm/meson.build | 2 +-
> tcg/meson.build | 4 +--
> 9 files changed, 58 insertions(+), 39 deletions(-)
>
As well, openbsd build works with:
make vm-build-openbsd J=4 TARGET_LIST=aarch64-softmmu
(thanks for the command Thomas)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/6] single-binary: build target common libraries with dependencies
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
` (6 preceding siblings ...)
2025-05-16 5:40 ` [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
@ 2025-05-16 7:24 ` Thomas Huth
2025-05-21 22:38 ` Pierrick Bouvier
8 siblings, 0 replies; 16+ messages in thread
From: Thomas Huth @ 2025-05-16 7:24 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, Peter Maydell,
Marc-André Lureau, Alex Bennée
On 16/05/2025 07.27, Pierrick Bouvier wrote:
> Recently, common libraries per target base architecture were introduced in order
> to compile those files only once. However, it was missing common dependencies
> (which include external libraries), so it failed to build on some hosts.
>
> This series fixes this, inspired by Thomas fix [1],
Actually, credits should go to Paolo who came up with the meson magic :-)
> and applied to other
> libraries introduced very recently with [2].
>
> As well, we do further cleanup by removing lib{system, user} source sets that
> were recently introduced, by merging them in system/user libraries, thus
> simplifying the work on single-binary.
>
> This series was built on {linux, macos, windows} x {x86_64, aarch64} and
> freebsd on x86_64. Fully tested on linux x {x86_64, aarch64}.
> In addition to that, it was checked that compilation units compiled per binary
> stayed the same, and that their size was identical.
Thanks, works for me, on both, Linux and OpenBSD:
Tested-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/6] meson: build target libraries with common dependencies
2025-05-16 5:27 ` [PATCH 1/6] meson: build target libraries with common dependencies Pierrick Bouvier
@ 2025-05-16 11:42 ` Philippe Mathieu-Daudé
2025-05-16 14:34 ` Pierrick Bouvier
2025-05-17 15:00 ` Paolo Bonzini
1 sibling, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-05-16 11:42 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange, thuth, Peter Maydell,
Marc-André Lureau, Alex Bennée
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(-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/6] meson: build target libraries with common dependencies
2025-05-16 11:42 ` Philippe Mathieu-Daudé
@ 2025-05-16 14:34 ` Pierrick Bouvier
0 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-16 14:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange, thuth, Peter Maydell,
Marc-André Lureau, Alex Bennée
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!
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/6] meson: build target libraries with common dependencies
2025-05-16 5:27 ` [PATCH 1/6] meson: build target libraries with common dependencies Pierrick Bouvier
2025-05-16 11:42 ` Philippe Mathieu-Daudé
@ 2025-05-17 15:00 ` Paolo Bonzini
2025-05-17 19:37 ` Pierrick Bouvier
1 sibling, 1 reply; 16+ messages in thread
From: Paolo Bonzini @ 2025-05-17 15:00 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Richard Henderson, berrange, Philippe Mathieu-Daudé, thuth,
Peter Maydell, Marc-André Lureau, Alex Bennée
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/6] meson: merge lib{system, user}_ss with {system, user}_ss.
2025-05-16 5:27 ` [PATCH 5/6] meson: merge lib{system, user}_ss with {system, user}_ss Pierrick Bouvier
@ 2025-05-17 15:04 ` Paolo Bonzini
2025-05-17 19:34 ` Pierrick Bouvier
0 siblings, 1 reply; 16+ messages in thread
From: Paolo Bonzini @ 2025-05-17 15:04 UTC (permalink / raw)
To: Pierrick Bouvier, qemu-devel
Cc: Richard Henderson, berrange, Philippe Mathieu-Daudé, thuth,
Peter Maydell, Marc-André Lureau, Alex Bennée
On 5/16/25 07:27, Pierrick Bouvier wrote:
> Now that target configuration can be applied to lib{system, user}_ss,
> there is no reason to keep that separate from the existing {system,
> user}_ss.
The reason would be that previously you wouldn't have
-DCOMPILING_SYSTEM_VS_USER defined for the files in system_ss/user_ss.
I don't think it's a problem, because it's usually clear if a file is
common QEMU infrastructure or specific to system emulation; but it's
worth mentioning it in the commit message.
Paolo
> c_args: ['-DCONFIG_USER_ONLY',
> '-DCOMPILING_SYSTEM_VS_USER'],
> - dependencies: libuser_ss.all_dependencies(),
> + include_directories: common_user_inc,
> + dependencies: user_ss.all_dependencies(),
> build_by_default: false)
>
> libsystem = static_library('system',
> - libsystem_ss.all_sources() + genh,
> + system_ss.all_sources() + genh,
> c_args: ['-DCONFIG_SOFTMMU',
> '-DCOMPILING_SYSTEM_VS_USER'],
> - dependencies: libsystem_ss.all_dependencies(),
> + dependencies: system_ss.all_dependencies(),
> build_by_default: false)
>
> # Note that this library is never used directly (only through extract_objects)
> @@ -4121,7 +4119,6 @@ libsystem = static_library('system',
> common_all = static_library('common',
> build_by_default: false,
> sources: common_ss.all_sources() + genh,
> - include_directories: common_user_inc,
> implicit_include_directories: false,
> dependencies: common_ss.all_dependencies())
>
> @@ -4135,10 +4132,20 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
> inc = [common_user_inc + target_inc]
>
> target_common = common_ss.apply(config_target, strict: false)
> + target_system = system_ss.apply(config_target, strict: false)
> + target_user = user_ss.apply(config_target, strict: false)
> common_deps = []
> + system_deps = []
> + user_deps = []
> foreach dep: target_common.dependencies()
> common_deps += dep.partial_dependency(compile_args: true, includes: true)
> endforeach
> + foreach dep: target_system.dependencies()
> + system_deps += dep.partial_dependency(compile_args: true, includes: true)
> + endforeach
> + foreach dep: target_user.dependencies()
> + user_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
> @@ -4154,7 +4161,7 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
> sources: src.all_sources() + genh,
> include_directories: inc,
> c_args: target_system_c_args,
> - dependencies: src.all_dependencies() + common_deps)
> + dependencies: src.all_dependencies() + common_deps + system_deps)
> hw_common_arch_libs += {target_base_arch: lib}
> endif
> endif
> @@ -4168,7 +4175,8 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
> sources: src.all_sources() + genh,
> include_directories: inc,
> c_args: target_c_args,
> - dependencies: src.all_dependencies() + common_deps)
> + dependencies: src.all_dependencies() + common_deps +
> + system_deps + user_deps)
> target_common_arch_libs += {target_base_arch: lib}
> endif
> endif
> @@ -4182,7 +4190,7 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
> sources: src.all_sources() + genh,
> include_directories: inc,
> c_args: target_system_c_args,
> - dependencies: src.all_dependencies() + common_deps)
> + dependencies: src.all_dependencies() + common_deps + system_deps)
> target_common_system_arch_libs += {target_base_arch: lib}
> endif
> endif
> @@ -4358,12 +4366,12 @@ foreach target : target_dirs
> objects = [common_all.extract_objects(target_common.sources())]
> arch_deps += target_common.dependencies()
> if target_type == 'system'
> - src = libsystem_ss.apply(config_target, strict: false)
> + src = system_ss.apply(config_target, strict: false)
> objects += libsystem.extract_objects(src.sources())
> arch_deps += src.dependencies()
> endif
> if target_type == 'user'
> - src = libuser_ss.apply(config_target, strict: false)
> + src = user_ss.apply(config_target, strict: false)
> objects += libuser.extract_objects(src.sources())
> arch_deps += src.dependencies()
> endif
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/6] meson: merge lib{system, user}_ss with {system, user}_ss.
2025-05-17 15:04 ` Paolo Bonzini
@ 2025-05-17 19:34 ` Pierrick Bouvier
0 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-17 19:34 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Richard Henderson, berrange, Philippe Mathieu-Daudé, thuth,
Peter Maydell, Marc-André Lureau, Alex Bennée
On 5/17/25 8:04 AM, Paolo Bonzini wrote:
> On 5/16/25 07:27, Pierrick Bouvier wrote:
>> Now that target configuration can be applied to lib{system, user}_ss,
>> there is no reason to keep that separate from the existing {system,
>> user}_ss.
>
> The reason would be that previously you wouldn't have
> -DCOMPILING_SYSTEM_VS_USER defined for the files in system_ss/user_ss.
> I don't think it's a problem, because it's usually clear if a file is
> common QEMU infrastructure or specific to system emulation; but it's
> worth mentioning it in the commit message.
>
Yes, sure, I'll add it.
Indeed, it's not changing much, just unpoisoining CONFIG_USER_ONLY and
CONFIG_SOFTMMU.
The only difference this change make is that existing system/user files
now can eventually use those defines, which should be harmless as they
were not using them before.
> Paolo
>
>> c_args: ['-DCONFIG_USER_ONLY',
>> '-DCOMPILING_SYSTEM_VS_USER'],
>> - dependencies: libuser_ss.all_dependencies(),
>> + include_directories: common_user_inc,
>> + dependencies: user_ss.all_dependencies(),
>> build_by_default: false)
>>
>> libsystem = static_library('system',
>> - libsystem_ss.all_sources() + genh,
>> + system_ss.all_sources() + genh,
>> c_args: ['-DCONFIG_SOFTMMU',
>> '-DCOMPILING_SYSTEM_VS_USER'],
>> - dependencies: libsystem_ss.all_dependencies(),
>> + dependencies: system_ss.all_dependencies(),
>> build_by_default: false)
>>
>> # Note that this library is never used directly (only through extract_objects)
>> @@ -4121,7 +4119,6 @@ libsystem = static_library('system',
>> common_all = static_library('common',
>> build_by_default: false,
>> sources: common_ss.all_sources() + genh,
>> - include_directories: common_user_inc,
>> implicit_include_directories: false,
>> dependencies: common_ss.all_dependencies())
>>
>> @@ -4135,10 +4132,20 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
>> inc = [common_user_inc + target_inc]
>>
>> target_common = common_ss.apply(config_target, strict: false)
>> + target_system = system_ss.apply(config_target, strict: false)
>> + target_user = user_ss.apply(config_target, strict: false)
>> common_deps = []
>> + system_deps = []
>> + user_deps = []
>> foreach dep: target_common.dependencies()
>> common_deps += dep.partial_dependency(compile_args: true, includes: true)
>> endforeach
>> + foreach dep: target_system.dependencies()
>> + system_deps += dep.partial_dependency(compile_args: true, includes: true)
>> + endforeach
>> + foreach dep: target_user.dependencies()
>> + user_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
>> @@ -4154,7 +4161,7 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
>> sources: src.all_sources() + genh,
>> include_directories: inc,
>> c_args: target_system_c_args,
>> - dependencies: src.all_dependencies() + common_deps)
>> + dependencies: src.all_dependencies() + common_deps + system_deps)
>> hw_common_arch_libs += {target_base_arch: lib}
>> endif
>> endif
>> @@ -4168,7 +4175,8 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
>> sources: src.all_sources() + genh,
>> include_directories: inc,
>> c_args: target_c_args,
>> - dependencies: src.all_dependencies() + common_deps)
>> + dependencies: src.all_dependencies() + common_deps +
>> + system_deps + user_deps)
>> target_common_arch_libs += {target_base_arch: lib}
>> endif
>> endif
>> @@ -4182,7 +4190,7 @@ foreach target_base_arch, config_base_arch : config_base_arch_mak
>> sources: src.all_sources() + genh,
>> include_directories: inc,
>> c_args: target_system_c_args,
>> - dependencies: src.all_dependencies() + common_deps)
>> + dependencies: src.all_dependencies() + common_deps + system_deps)
>> target_common_system_arch_libs += {target_base_arch: lib}
>> endif
>> endif
>> @@ -4358,12 +4366,12 @@ foreach target : target_dirs
>> objects = [common_all.extract_objects(target_common.sources())]
>> arch_deps += target_common.dependencies()
>> if target_type == 'system'
>> - src = libsystem_ss.apply(config_target, strict: false)
>> + src = system_ss.apply(config_target, strict: false)
>> objects += libsystem.extract_objects(src.sources())
>> arch_deps += src.dependencies()
>> endif
>> if target_type == 'user'
>> - src = libuser_ss.apply(config_target, strict: false)
>> + src = user_ss.apply(config_target, strict: false)
>> objects += libuser.extract_objects(src.sources())
>> arch_deps += src.dependencies()
>> endif
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/6] meson: build target libraries with common dependencies
2025-05-17 15:00 ` Paolo Bonzini
@ 2025-05-17 19:37 ` Pierrick Bouvier
0 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-17 19:37 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Cc: Richard Henderson, berrange, Philippe Mathieu-Daudé, thuth,
Peter Maydell, Marc-André Lureau, Alex Bennée
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
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/6] single-binary: build target common libraries with dependencies
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
` (7 preceding siblings ...)
2025-05-16 7:24 ` Thomas Huth
@ 2025-05-21 22:38 ` Pierrick Bouvier
8 siblings, 0 replies; 16+ messages in thread
From: Pierrick Bouvier @ 2025-05-21 22:38 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Paolo Bonzini, berrange,
Philippe Mathieu-Daudé, thuth, Peter Maydell,
Marc-André Lureau, Alex Bennée
On 5/15/25 10:27 PM, Pierrick Bouvier wrote:
> Recently, common libraries per target base architecture were introduced in order
> to compile those files only once. However, it was missing common dependencies
> (which include external libraries), so it failed to build on some hosts.
>
> This series fixes this, inspired by Thomas fix [1], and applied to other
> libraries introduced very recently with [2].
>
> As well, we do further cleanup by removing lib{system, user} source sets that
> were recently introduced, by merging them in system/user libraries, thus
> simplifying the work on single-binary.
>
> This series was built on {linux, macos, windows} x {x86_64, aarch64} and
> freebsd on x86_64. Fully tested on linux x {x86_64, aarch64}.
> In addition to that, it was checked that compilation units compiled per binary
> stayed the same, and that their size was identical.
>
> [1] https://lore.kernel.org/qemu-devel/20250513115637.184940-1-thuth@redhat.com/
> [2] https://gitlab.com/qemu-project/qemu/-/commit/b2bb3f3576e5dc99218607dde09e25ac0e55693c
>
> Pierrick Bouvier (6):
> meson: build target libraries with common dependencies
> hw/arm: remove explicit dependencies listed
> target/arm: remove explicit dependencies listed
> meson: apply target config for picking files from lib{system, user}
> meson: merge lib{system, user}_ss with {system, user}_ss.
> meson: remove lib{system, user}_ss aliases
>
> meson.build | 65 +++++++++++++++++++++++++++---------------
> accel/tcg/meson.build | 8 +++---
> gdbstub/meson.build | 4 +--
> hw/arm/meson.build | 4 +--
> hw/core/meson.build | 4 +--
> plugins/meson.build | 4 +--
> system/meson.build | 2 +-
> target/arm/meson.build | 2 +-
> tcg/meson.build | 4 +--
> 9 files changed, 58 insertions(+), 39 deletions(-)
>
v2 was posted here:
https://lore.kernel.org/qemu-devel/20250521223414.248276-1-pierrick.bouvier@linaro.org
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2025-05-21 22:39 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16 5:27 [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 1/6] meson: build target libraries with common dependencies Pierrick Bouvier
2025-05-16 11:42 ` Philippe Mathieu-Daudé
2025-05-16 14:34 ` Pierrick Bouvier
2025-05-17 15:00 ` Paolo Bonzini
2025-05-17 19:37 ` Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 2/6] hw/arm: remove explicit dependencies listed Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 3/6] target/arm: " Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 4/6] meson: apply target config for picking files from lib{system, user} Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 5/6] meson: merge lib{system, user}_ss with {system, user}_ss Pierrick Bouvier
2025-05-17 15:04 ` Paolo Bonzini
2025-05-17 19:34 ` Pierrick Bouvier
2025-05-16 5:27 ` [PATCH 6/6] meson: remove lib{system, user}_ss aliases Pierrick Bouvier
2025-05-16 5:40 ` [PATCH 0/6] single-binary: build target common libraries with dependencies Pierrick Bouvier
2025-05-16 7:24 ` Thomas Huth
2025-05-21 22:38 ` Pierrick Bouvier
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).