{"id":2219745,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2219745/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260404061215.505913-1-deller@kernel.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260404061215.505913-1-deller@kernel.org>","date":"2026-04-04T06:12:15","name":"[v2] Allow building qemu tools on 32-bit hosts","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"13b24a41b2d193934d0e9b64ca218679809fede8","submitter":{"id":87076,"url":"http://patchwork.ozlabs.org/api/1.1/people/87076/?format=json","name":"Helge Deller","email":"deller@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260404061215.505913-1-deller@kernel.org/mbox/","series":[{"id":498698,"url":"http://patchwork.ozlabs.org/api/1.1/series/498698/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=498698","date":"2026-04-04T06:12:15","name":"[v2] Allow building qemu tools on 32-bit hosts","version":2,"mbox":"http://patchwork.ozlabs.org/series/498698/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219745/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219745/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=tnuu/Yhg;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fnljq3Dn9z1yCs\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 04 Apr 2026 17:17:03 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w8uIx-0004ca-Cy; Sat, 04 Apr 2026 02:16:23 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <deller@kernel.org>) id 1w8uFP-0008J9-LE\n for qemu-devel@nongnu.org; Sat, 04 Apr 2026 02:12:46 -0400","from sea.source.kernel.org ([172.234.252.31])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <deller@kernel.org>) id 1w8uFN-0006IQ-2k\n for qemu-devel@nongnu.org; Sat, 04 Apr 2026 02:12:42 -0400","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n by sea.source.kernel.org (Postfix) with ESMTP id 9573444218;\n Sat,  4 Apr 2026 06:12:30 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 6D424C19423;\n Sat,  4 Apr 2026 06:12:29 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n s=k20201202; t=1775283150;\n bh=Qu1MmIA319sagiWUVovBMOJREzMLGa8fh5BgQBpLZLI=;\n h=From:To:Cc:Subject:Date:From;\n b=tnuu/YhgBLYwlsaCBVLlHBUiwK4TbomUoS8iLeqsJJK9v+oGpfPYznhra9F/jxYjT\n 8/CbA5hOX6RIDlk3BzztvnZNNojMQ1Nw9ViKyFiO4W9KDxFwcSSFtOmdkPVrq5/YrO\n Nowe6JmJiVTIv9IjCCD83KIKjppnn1zsi/2udTXTCCxGJW/IcXwI6d2UX3l8elct6T\n GeuiQbc/4afl7FEWFU+aNgIi/A3IKBkpxF2jZ/Qy5uSFtb2EI62ndmY3/NPhr/SNRr\n sdZiDxctaRVo3qaMjtBkF/8eUCesNcyNFL2ccBfKkFTWNEiopXrV1Wz+7ftglbJuIL\n 5xT5pIYR0RWRw==","From":"Helge Deller <deller@kernel.org>","To":"qemu-devel@nongnu.org","Cc":"deller@gmx.de, Michael Tokarev <mjt@tls.msk.ru>,\n richard.henderson@linaro.org","Subject":"[PATCH] [PATCH v2] Allow building qemu tools on 32-bit hosts","Date":"Sat,  4 Apr 2026 08:12:15 +0200","Message-ID":"<20260404061215.505913-1-deller@kernel.org>","X-Mailer":"git-send-email 2.53.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=172.234.252.31; envelope-from=deller@kernel.org;\n helo=sea.source.kernel.org","X-Spam_score_int":"-25","X-Spam_score":"-2.6","X-Spam_bar":"--","X-Spam_report":"(-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.544,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Helge Deller <deller@gmx.de>\n\nQemu's tools like qemu-img are often needed on 32-bit platforms,\nalthough the actual qemu emulators have been discontinued on 32-bit.\n\nTo allow building the tools on 32-bit this patch implements three small\nchanges:\n\na) The check in meson.build is changed to still error out if the user\ntries to build qemu-system or qemu-user on a 32-bit platform, but allows\nbuilding tools (e.g. by \"--enable-tools\") alone.\n\nb) The compile time check in atomic.h now checks against\nsizeof(uint64_t) so that 32-bit environments can still build\nsuccessfully, while 128-bit atomic operations are prevented to sneak in.\n\nc) Allow linking against libatomic as long as we don't build the\nqemu-system and qemu-user binaries.\n\nSucessfully tested on the 32-bit big-endian powerpc architecture.\n\nv2:\n- keep comple time checks in atomic.h\n- allow linking against libatomic when building tools\n\nSigned-off-by: Helge Deller <deller@gmx.de>\nSiggested-by: Richard Henderson <richard.henderson@linaro.org>\n---\n include/qemu/atomic.h |  6 +++---\n meson.build           | 16 ++++++++++++----\n 2 files changed, 15 insertions(+), 7 deletions(-)","diff":"diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h\nindex dc9290084b..e4dd948863 100644\n--- a/include/qemu/atomic.h\n+++ b/include/qemu/atomic.h\n@@ -58,11 +58,11 @@\n \n /*\n  * Sanity check that the size of an atomic operation isn't \"overly large\".\n- * Despite the fact that e.g. i686 has 64-bit atomic operations, we do not\n+ * Despite the fact that e.g. x86-64 has 128-bit atomic operations, we do not\n  * want to use them because we ought not need them, and this lets us do a\n- * bit of sanity checking that other 32-bit hosts might build.\n+ * bit of sanity checking that other 32- and 64-bit hosts might build.\n  */\n-#define ATOMIC_REG_SIZE  sizeof(void *)\n+#define ATOMIC_REG_SIZE  sizeof(uint64_t)\n \n /* Weak atomic operations prevent the compiler moving other\n  * loads/stores past the atomic operation load/store. However there is\ndiff --git a/meson.build b/meson.build\nindex daa58e46a3..8b0f00608d 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -323,8 +323,8 @@ endif\n # Compiler flags #\n ##################\n \n-if cc.sizeof('void *') < 8\n-  error('QEMU requires a 64-bit CPU host architecture')\n+if (cc.sizeof('void *') < 8) and (have_system or have_user)\n+  error('QEMU emulator requires a 64-bit CPU host architecture. Only tools may be built for 32-bit.')\n endif\n \n foreach lang : all_languages\n@@ -423,8 +423,16 @@ endif\n #\n # Later checks assume we won't get atomic ops for int128 without\n # explicitly asking for -latomic, so we must disable GCC's new\n-# automatic linking with the new -fno-link-libatomic flag\n-qemu_isa_flags += cc.get_supported_arguments('-fno-link-libatomic')\n+# automatic linking with the new -fno-link-libatomic flag.\n+#\n+# When not building the emulators, but qemu helper tools only\n+# (e.g. on 32-bit hosts), libatomic is sometimes required and\n+# thus acceptable.\n+if (have_system or have_user)\n+  qemu_isa_flags += cc.get_supported_arguments('-fno-link-libatomic')\n+else\n+  qemu_ldflags += cc.get_supported_link_arguments('-Wl,-latomic')\n+endif\n \n qemu_common_flags = qemu_isa_flags + qemu_common_flags\n \n","prefixes":["v2"]}