summaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorHelge Deller <deller@kernel.org>2026-04-05 00:40:16 +0200
committerMichael Tokarev <mjt@tls.msk.ru>2026-04-08 13:48:50 +0300
commitcf634dfcd8fc5dded8849d41e2eeaa189b06feb0 (patch)
tree4657037297c09eb85c1c705713dc293dbb037b17 /meson.build
parent276b060a743609bb41bc7ae3f6942e2bcc29a641 (diff)
downloadqemu-cf634dfcd8fc5dded8849d41e2eeaa189b06feb0.tar.gz
qemu-cf634dfcd8fc5dded8849d41e2eeaa189b06feb0.zip
Allow building qemu tools on 32-bit hosts
Qemu's tools like qemu-img are often needed on 32-bit platforms, although the actual qemu emulators have been discontinued on 32-bit. To allow building the tools on 32-bit this patch implements three small changes: a) The check in meson.build is changed to still error out if the user tries to build qemu-system or qemu-user on a 32-bit platform, but allows building tools (e.g. by "--enable-tools") alone. b) The compile time check in atomic.h now checks against sizeof(uint64_t) so that 32-bit environments can still build successfully, while 128-bit atomic operations are prevented to sneak in. c) Allow linking against libatomic as long as we don't build the qemu-system and qemu-user binaries. Sucessfully tested on the 32-bit big-endian powerpc architecture. Signed-off-by: Helge Deller <deller@gmx.de> Suggested-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build16
1 files changed, 12 insertions, 4 deletions
diff --git a/meson.build b/meson.build
index daa58e46a3..ab3e97eb9f 100644
--- a/meson.build
+++ b/meson.build
@@ -323,8 +323,8 @@ endif
# Compiler flags #
##################
-if cc.sizeof('void *') < 8
- error('QEMU requires a 64-bit CPU host architecture')
+if (cc.sizeof('void *') < 8) and (have_system or have_user)
+ error('QEMU emulator requires a 64-bit CPU host architecture. Only tools may be built for 32-bit.')
endif
foreach lang : all_languages
@@ -423,8 +423,16 @@ endif
#
# Later checks assume we won't get atomic ops for int128 without
# explicitly asking for -latomic, so we must disable GCC's new
-# automatic linking with the new -fno-link-libatomic flag
-qemu_isa_flags += cc.get_supported_arguments('-fno-link-libatomic')
+# automatic linking with the new -fno-link-libatomic flag.
+#
+# When not building the emulators, but qemu helper tools only
+# (e.g. on 32-bit hosts), libatomic is sometimes required and
+# thus acceptable.
+if (have_system or have_user)
+ qemu_isa_flags += cc.get_supported_arguments('-fno-link-libatomic')
+else
+ qemu_ldflags += cc.get_supported_link_arguments('-latomic')
+endif
qemu_common_flags = qemu_isa_flags + qemu_common_flags