From nobody Sat Apr 11 20:23:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1775673377; cv=none; d=zohomail.com; s=zohoarc; b=hvEL3pDrsVKHlrZRrBUNlDswI2aSv3+N56draXNTeP3t389o11Zwy/YtioYlUv+gZkhzuPB+oxB0LW/TwJcek/Z2WiHfXi73R52E1z7oT7GZXhj4U7PucXQKxtWDF2ZvVOBsNTp1pTMF47Qakojludf5lJEbBdZvKKIRKEI7kjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775673377; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2P/npLsFBUg9qntmXLBkIwqFm5cQ+KB3QVrvDOtMptk=; b=Qge30ZYmwhl2efT7Tiq75aNB80Hy4g5q/USFKE2WHtXlgvu7sSTghVQY1hZcdsxiAzuTbtZk6e4Khz+96UMDzhH+ekJ/6+caU+CuIeRKJJqJjJ8APvrI95/grDiiKCoIFOQD/hPYZOEMqjSLAKyC78wuLS7OoW+gP63wngllrVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775673377213382.51855877515334; Wed, 8 Apr 2026 11:36:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAXkw-0008Ts-Up; Wed, 08 Apr 2026 14:36:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAXkv-0008TM-DR; Wed, 08 Apr 2026 14:36:01 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAQds-0000Pc-Ow; Wed, 08 Apr 2026 07:00:20 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 13E5F19C29C; Wed, 08 Apr 2026 13:55:20 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 62B2C391676; Wed, 08 Apr 2026 13:56:07 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1775645720; bh=yPuWulHjK9XHbqL5n11NbBkjSHKE9YvNKtuG5clkRXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xeh8Vkgj8PvTf6iOOsnHgrCohwXkBTcAsIuoL4pmvmTVzjyOr7CUKBnjLByQ7EDg8 pK2HUNC5cNkbuBty41CJKs3/hHlFqi96bb6g0GhZ45I5CvNGOry1WPNxm5moNi0iOY PZlgnxHsy2sf95HXPFc06kt/OJpswTBds9cxoZjDQY5m7c7SCV+v5FYOwixEJAVGBR F1oQVtfMVw5FX5QQsw0YfT4JZM5PlZ3f8qzPTFjU+2rPNzq7D71GI7zR8Jm9Pcop2s s3rRzbGnTOK+m2rDUHTD5lBJVnARPq3kIlcWRuo4EEZgKJ+OBs4w4dT9HurpatcS/e jUyN0XvrVmblA== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: Helge Deller , qemu-trivial@nongnu.org, Helge Deller , Richard Henderson , Michael Tokarev Subject: [PULL 2/3] Allow building qemu tools on 32-bit hosts Date: Wed, 8 Apr 2026 13:55:57 +0300 Message-ID: <20260408105605.172465-3-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260408105605.172465-1-mjt@tls.msk.ru> References: <20260408105605.172465-1-mjt@tls.msk.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @tls.msk.ru) X-ZM-MESSAGEID: 1775673383271154100 Content-Type: text/plain; charset="utf-8" From: Helge Deller 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 Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Reviewed-by: Michael Tokarev Signed-off-by: Michael Tokarev --- include/qemu/atomic.h | 6 +++--- meson.build | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index dc9290084b..e4dd948863 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -58,11 +58,11 @@ =20 /* * Sanity check that the size of an atomic operation isn't "overly large". - * Despite the fact that e.g. i686 has 64-bit atomic operations, we do not + * Despite the fact that e.g. x86-64 has 128-bit atomic operations, we do = not * want to use them because we ought not need them, and this lets us do a - * bit of sanity checking that other 32-bit hosts might build. + * bit of sanity checking that other 32- and 64-bit hosts might build. */ -#define ATOMIC_REG_SIZE sizeof(void *) +#define ATOMIC_REG_SIZE sizeof(uint64_t) =20 /* Weak atomic operations prevent the compiler moving other * loads/stores past the atomic operation load/store. However there is 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 # ################## =20 -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 =20 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 +=3D 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 +=3D cc.get_supported_arguments('-fno-link-libatomic') +else + qemu_ldflags +=3D cc.get_supported_link_arguments('-latomic') +endif =20 qemu_common_flags =3D qemu_isa_flags + qemu_common_flags =20 --=20 2.47.3