From patchwork Thu Nov 28 20:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 845959 Delivered-To: patch@linaro.org Received: by 2002:adf:f2c4:0:b0:382:43a8:7b94 with SMTP id d4csp447150wrp; Thu, 28 Nov 2024 12:16:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW+xOUvEztDqRrBW6OcyxxTpS1/PLZiJT9M0+VoUo35pgczz0G8t2EK07oHPGcrn3sgxb9Ofg==@linaro.org X-Google-Smtp-Source: AGHT+IFDI+fCISG96Zf9pHHvFTuF5rKit2VwRdCyVLoKzy8WjNkOHxLxG1wWFq6UjSVnJdl95iLW X-Received: by 2002:a05:620a:2715:b0:7b6:6701:7a4a with SMTP id af79cd13be357-7b67c466a64mr1167905885a.53.1732824980057; Thu, 28 Nov 2024 12:16:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732824980; cv=none; d=google.com; s=arc-20240605; b=RoeQB4AchqFETA6Ou7o3qhzdQ11X29yeaJsbIheYpbstZ5QUpwICH09kP8etbXqHU6 +PiQ6khKF9tKLhxt6LQUyjXajn3hNd3i+SQCXoCVyq8d1LCLPcoKfKYYncgFUdKA6IcH 2kp/nzb0/j+ElfB9XR0CQLvX4PfjNRGn4qjmZXcbdePLXo03CRYex/6spXVCwfEKx3lL pgq8mNzrnvVUDuthtbG2VoXE79SIF2zxwkRoOfaSAvWjA3ZmxrhhxNbb8TMLJIS7hNYO qXv+PWf7YMlrg9zyLw1+wysaLwRXXWyrl6KfA61dQ04k3wlTXFlyOVExzeIu14zFtC/R hvfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ONBBnO5spdOxnYQqxE80/N6XLVKqgeL1XxIVJJ/xyUo=; fh=OrmH+MZV3V0n4Ue2VMCDM+kSAfQpbYLvWXqE3FZ9q3E=; b=idgfxhqb5ZwITkJfRYT7geFi1xgBth91VyrN5xssOGXBlh7hHkaqFXnL2BatBHpHDU /bj+U4W1qGKyG32pcVr7lspoLxJn9okM4pfbhjWN3fjpjd5jA8UmJ8Em1hmC15CRqMim 0yAOF3GbiAFa0s1KPazJ6p2DlUvAbQAqIlPkKWud9ca8VF28vGRhfbohZiC5vS0uWnjL vNM1BmTj+Iv7zDt/29u8r5U1YK65MNbBUmN7byuv0Ou0yFpAwdV2EsoUlGmdyOLkgimY a7sMZeL+bJBGVgRRrsETRS/gvK0qioCB3WPjoQNGHBT0qKfl5xzMQpc+SOmhB+bqhPKn 8/gQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ErtqzJMp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b6849f5158si247756985a.659.2024.11.28.12.16.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Nov 2024 12:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ErtqzJMp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkvA-0001Gr-3x; Thu, 28 Nov 2024 15:15:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkv8-0001D3-3P for qemu-devel@nongnu.org; Thu, 28 Nov 2024 15:15:26 -0500 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tGkv5-0001m5-Hp for qemu-devel@nongnu.org; Thu, 28 Nov 2024 15:15:25 -0500 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-7fc41dab8e3so761914a12.3 for ; Thu, 28 Nov 2024 12:15:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732824922; x=1733429722; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ONBBnO5spdOxnYQqxE80/N6XLVKqgeL1XxIVJJ/xyUo=; b=ErtqzJMpyXnidmmAbRQ1f3ywP9D6FSg66a9mzBqh2vgZqTgtPohh7XZF4xwFoKpd1E 3FaMplPuJgLUXmWLqnkS9U27REiWXld4j+087dsuY8fsjEMsFey6QMtND7Ay2T3fIkrB vvMz5Co4KJoQzxKV8FD5pb5NyFHAxDe1z6e4A9ayYqa1J+bl+ulTBj7IgroWSghMuHc2 4BTlpmqB86SdiyLUIopq8D6f6HOXS/YrznfvKgdSEnfBLw40kJ05qhW0ltgESGOt2Pdk Gb0Snqa6jH4RVbPWE1yiew26FgJwrDPgghxjSo4qLbp1LbXsdMkX8FF4A9oXF6fx1LWE jAlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732824922; x=1733429722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ONBBnO5spdOxnYQqxE80/N6XLVKqgeL1XxIVJJ/xyUo=; b=bX9IBuJlkKtT3fsI3LTVFNVq7zmpcBi/JrZKk1v/iwinLu2ArMvd14iuf4qWG/wnaG fEkIhcyMY1HngecXSYNv9vrOK8kYQzqhTPq1lCsuiJSQnBKbXiA7Ngo3ptfQI7Xbr3AS nZQRwiXAuErfRhgVhSHza7EvlMV0XHphaqyozLolfLrQuqIfpNPy8/TdNXI6c3WyG2TE RITw8FcVD9//DTI6BnugTBKhbg6wLXmWFjygfvYj12hcjv7ghsMIqDEHhkOS/nsWSaq5 GaPpXI4vAQf47hq3csoClsrIlF60SFFrv2cHSPXR9OpsMa359a0B06jbBKwNAyO4oQkc tsgw== X-Gm-Message-State: AOJu0Ywti3HP0Lj/h36Zf/W3XvL4PJI78tyF0XnI6pyUhq7rUSrkq5/Z 66Bf8wvWDF0V1UoVdoI3iTGCg7oWtITuyIVoBxnFbum6+HUDHWXgN08j50rBXmx8o0Mszn/aZJe EwKc= X-Gm-Gg: ASbGncv1r/nwXYHB0YiEjdJMDO3/jpev1SJqGP0dXWmfIyMMbnvwcK/GisA9ZJXrY8n UmfQ0CZ6/afV/hy/JcbdpAsz1kplpi5V3RFq2fwpfizLKWs89RwgafwVxxv5QCWhVGzke1ZGLq3 juePQo9hLZTlZ04eTbVF4f4suIIbnQ3CSw9RsEzUR2s8qiJPUDyhOsP/35Xv+jR3cRc5cM917qS O9KwczDa7eHiPx8C2zKB0a07451cg4ZRqYnyIp2nhuHNobVAibWF36cZJiNOUP+Cw1rhGeU4DTx P5ivAQdUbgT0Gg== X-Received: by 2002:a17:90b:54c4:b0:2ea:6f19:1815 with SMTP id 98e67ed59e1d1-2ee095c0028mr11247829a91.24.1732824922167; Thu, 28 Nov 2024 12:15:22 -0800 (PST) Received: from linaro.. (216-180-64-156.dyn.novuscom.net. [216.180.64.156]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ee0fb10049sm3912861a91.43.2024.11.28.12.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 12:15:21 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Paolo Bonzini , Thomas Huth , =?utf-8?q?Alex_Benn=C3=A9e?= , Mahmoud Mandour , Alexandre Iooss , Markus Armbruster , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Stefano Garzarella Subject: [PATCH v3 1/3] win32: remove usage of attribute gcc_struct Date: Thu, 28 Nov 2024 12:15:08 -0800 Message-Id: <20241128201510.869974-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241128201510.869974-1-pierrick.bouvier@linaro.org> References: <20241128201510.869974-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This attribute is not recognized by clang. An investigation has been performed to ensure this attribute has no effect on layout of structures we use in QEMU [1], so it's safe to remove now. In the future, we'll forbid introducing new bitfields in packed struct, as they are the one potentially impacted by this change. [1] https://lore.kernel.org/qemu-devel/66c346de-7e20-4831-b3eb-1cda83240af9@linaro.org/ Reviewed-by: Thomas Huth Acked-by: Stefano Garzarella Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- meson.build | 5 ----- include/qemu/compiler.h | 7 +------ scripts/cocci-macro-file.h | 6 +----- subprojects/libvhost-user/libvhost-user.h | 6 +----- 4 files changed, 3 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index a290dbfa331..97cefb7cdd7 100644 --- a/meson.build +++ b/meson.build @@ -354,11 +354,6 @@ elif host_os == 'sunos' qemu_common_flags += '-D__EXTENSIONS__' elif host_os == 'haiku' qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC'] -elif host_os == 'windows' - if not compiler.compiles('struct x { int y; } __attribute__((gcc_struct));', - args: '-Werror') - error('Your compiler does not support __attribute__((gcc_struct)) - please use GCC instead of Clang') - endif endif # Choose instruction set (currently x86-only) diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index c06954ccb41..d904408e5ed 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -22,12 +22,7 @@ #define QEMU_EXTERN_C extern #endif -#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) -# define QEMU_PACKED __attribute__((gcc_struct, packed)) -#else -# define QEMU_PACKED __attribute__((packed)) -#endif - +#define QEMU_PACKED __attribute__((packed)) #define QEMU_ALIGNED(X) __attribute__((aligned(X))) #ifndef glue diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h index d247a5086e9..c64831d5408 100644 --- a/scripts/cocci-macro-file.h +++ b/scripts/cocci-macro-file.h @@ -23,11 +23,7 @@ #define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #define G_GNUC_NULL_TERMINATED __attribute__((sentinel)) -#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) -# define QEMU_PACKED __attribute__((gcc_struct, packed)) -#else -# define QEMU_PACKED __attribute__((packed)) -#endif +#define QEMU_PACKED __attribute__((packed)) #define cat(x,y) x ## y #define cat2(x,y) cat(x,y) diff --git a/subprojects/libvhost-user/libvhost-user.h b/subprojects/libvhost-user/libvhost-user.h index deb40e77b3f..2ffc58c11b1 100644 --- a/subprojects/libvhost-user/libvhost-user.h +++ b/subprojects/libvhost-user/libvhost-user.h @@ -186,11 +186,7 @@ typedef struct VhostUserShared { unsigned char uuid[UUID_LEN]; } VhostUserShared; -#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__)) -# define VU_PACKED __attribute__((gcc_struct, packed)) -#else -# define VU_PACKED __attribute__((packed)) -#endif +#define VU_PACKED __attribute__((packed)) typedef struct VhostUserMsg { int request; From patchwork Thu Nov 28 20:15:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 845957 Delivered-To: patch@linaro.org Received: by 2002:adf:f2c4:0:b0:382:43a8:7b94 with SMTP id d4csp447121wrp; Thu, 28 Nov 2024 12:16:15 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVkMXyLyrhM5VZeWybZBRFapIQT6idyP67mQLP9+ZKXhAIn/iRUExQqBuda8u8PWey8RDM4Tg==@linaro.org X-Google-Smtp-Source: AGHT+IH8ey/eQS9X9VNSWsiuwKemJ+GORSQoJAgZu7TVCQnf5HgkR2uAUBlqJah6vA0U0JvMVH/G X-Received: by 2002:a05:6102:4bc6:b0:4af:f45:d360 with SMTP id ada2fe7eead31-4af555ecd66mr6700773137.5.1732824975499; Thu, 28 Nov 2024 12:16:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732824975; cv=none; d=google.com; s=arc-20240605; b=VuUvzUrBtBAFHInrGhvIDyHXfB7Efn+EPGh91BCl1JjhYMJjjaehNxV4XpszzD1dvi fFP4vHUxsc9MlTWAkF3euI5DjCPT79l45w96l2n2Ujuw+NpD4x4Vm7yEhBGF1iTvQL4r VR2GdMUfe4yGBjEnpeRIR/3mDoqALj68l5Zdf7OUWIrsxt7qvw/Bp+n++RBHaDGlEkkn jH26Ug0bg+iyd+xqQUuQKvi8ifw0Ke1r41+Br7D1RSPWD1t4i0zpZbYWg2z2rE2In4XI ApTEcyTxu8D5G8TxV9tIFkRsYhfBpoRYQiaVgukP5t9lqhe6G7jM41TTUanykvKJQ23t Kgfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cw+i/RTnE1TOqvWRDHCHN95wIYPbil6+hZz5wFKKxjY=; fh=OrmH+MZV3V0n4Ue2VMCDM+kSAfQpbYLvWXqE3FZ9q3E=; b=dTh9DSdLrhXp2llubAjnr3lh1Xh1RFiGqarrvjbNXiBm5hg9YbeLq0oitKOwM6GVZJ wV9F/WkSTs2ebluCCEr7Ug97xbvjXKZ0odM9GyFuCggqQ933Tcjmduw78Zz0FGoRhyxz WqzJE6aviR6vIsLpSLT7qYTgpN7tvJ06PYhdm0/ujKls3roEWd8/xyc5pC783gO7UgvZ wcjVPdJhrlmSuCGBW/soQ+ahHGLh7wp0mNkOiPukyEIHXd4kxXEa140zLxqRgfdwuQVL A035pv9nmvsv67EMQq5PBzjvL35O79qW53SSa/p4xXS/pTaZUaGgd+kRX9ZiYVYs4BbW jz+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JgoxDV4W; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-85b82b2f012si841918241.89.2024.11.28.12.16.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Nov 2024 12:16:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JgoxDV4W; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkvC-0001Io-0i; Thu, 28 Nov 2024 15:15:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkv9-0001Ft-5M for qemu-devel@nongnu.org; Thu, 28 Nov 2024 15:15:27 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tGkv6-0001mJ-KI for qemu-devel@nongnu.org; Thu, 28 Nov 2024 15:15:26 -0500 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2ee50ffcf14so131938a91.0 for ; Thu, 28 Nov 2024 12:15:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732824923; x=1733429723; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cw+i/RTnE1TOqvWRDHCHN95wIYPbil6+hZz5wFKKxjY=; b=JgoxDV4WyTSsbUyHbjbeA4eV9g0A6v+lWKpsUMZcsrJDxgBxL8eLqLuWi3wTvEDAoW ropXzZj5X64w4h8838Kqmp7Jkx98SHIJEmsG7j4OnMOKBEa2/1AxFXbIJJTkLxqMdV6E h1pvFGJI8BThcNSSIRTt7sRxfm5lU8HhdXmJBfkWlTIjiZ9tRSs5m80JflGH47OBXML0 UqdEmv9vkNvtGc98qkpOzPJQ++A6wxMttGCXrlQVM5uhVb5OflKQWoILcn8t+hlTIeuR EGtnySWJU22ariCQRAHKKlbJ4ecmRbv4VQuBgEvZ0k/OOuxTXAC4BqCxPLP5B8Ed0uoq 74HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732824923; x=1733429723; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cw+i/RTnE1TOqvWRDHCHN95wIYPbil6+hZz5wFKKxjY=; b=FfDPfCXvLwvbx+FCFJ2Mz38jmwhFBNlv/9s8ESdM/Caonn6BgCD9ZFIxSbBUKQOzxA eBqf+4chG8oSmz7q6t91nbbKS/vVy0CxPhIBRFjuVL92TvVU5zX+WDnT+lnAccEWJjWg QK1ymXMTWow/ainp9WTywXpORzAgpN1htv051MJcCS13GqKeTkDyYPAdbwmxxpflLWNJ eY242cCOWHv9SZB6O8CzGiRG3V7oQDzsfh72KlieVyZ7cIhMbJTbKob94TwTxz60NEfJ oAStHs6HaGlOpMNIxwvNHk/Um2GOKcWl3myI9JvZVAQTO/Vv7o2Ly5++VdNv7KrfANce x8TA== X-Gm-Message-State: AOJu0YzYr69NpbOiKQ0AgcBbcDIMfxy3AnVjGe5S7llIv5s1FwRPKodE mih0cd/XNpXMVR8bUdfPZ864pIjGmATkXbrI+nUUC8COdy/Khzh/X3qRVHxKy8iWRitJZ38TPfm xUMY= X-Gm-Gg: ASbGncvKGRdFIxlVa+TFGkINtRcCRf4rXcTwWSlrFKsmmT1VFkyA/porlfceaco9vvN xUe4KSYkC7o3R4wNgu4TkUpBN3jf1OX0Yx1r3ZJwmUMekxF7zK52Aj8tMs8P7HTa0CFfT9KC/hQ FppQ71JDxj1An2bIBICUeTCN5gG/z1T0rArE+1w4Q+uZ0UTj5vj8RTAqda00aFavMhw7fDxTTw1 fcnSSHEDhhnurYC6Qb7TAXxMXY3S16sKyqDjgJUeNnM8LVUxlYSf/fTUHpTYOSUjfFWjv/izBcK i/3Fg1eU2xATHg== X-Received: by 2002:a17:90b:38cd:b0:2ea:8f02:719d with SMTP id 98e67ed59e1d1-2ee25b0875amr6470479a91.16.1732824923125; Thu, 28 Nov 2024 12:15:23 -0800 (PST) Received: from linaro.. (216-180-64-156.dyn.novuscom.net. [216.180.64.156]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ee0fb10049sm3912861a91.43.2024.11.28.12.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 12:15:22 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Paolo Bonzini , Thomas Huth , =?utf-8?q?Alex_Benn=C3=A9e?= , Mahmoud Mandour , Alexandre Iooss , Markus Armbruster , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Stefano Garzarella Subject: [PATCH v3 2/3] docs/devel/style: add a section about bitfield, and disallow them for packed structures Date: Thu, 28 Nov 2024 12:15:09 -0800 Message-Id: <20241128201510.869974-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241128201510.869974-1-pierrick.bouvier@linaro.org> References: <20241128201510.869974-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- docs/devel/style.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/devel/style.rst b/docs/devel/style.rst index 2f68b500798..2d73e6a8f7a 100644 --- a/docs/devel/style.rst +++ b/docs/devel/style.rst @@ -416,6 +416,26 @@ definitions instead of typedefs in headers and function prototypes; this avoids problems with duplicated typedefs and reduces the need to include headers from other headers. +Bitfields +--------- + +C bitfields can be a cause of non-portability issues, especially under windows +where `MSVC has a different way to lay them out than gcc +`_, and on big and +little endian hosts. + +For this reason, we disallow usage of bitfields in packed structures and in any +structures which are supposed to exactly match a specific layout in guest +memory. Some existing code may use it, and we carefully ensured the layout was +the one expected. + +We also suggest avoiding bitfields even in structures where the exact +layout does not matter, unless you can show that they provide a significant +memory usage or usability benefit. + +We encourage the usage of ``include/hw/registerfields.h`` as a safe replacement +for bitfields. + Reserved namespaces in C and POSIX ---------------------------------- From patchwork Thu Nov 28 20:15:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 845958 Delivered-To: patch@linaro.org Received: by 2002:adf:f2c4:0:b0:382:43a8:7b94 with SMTP id d4csp447129wrp; Thu, 28 Nov 2024 12:16:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXiE8rLAnCrEjeHOOCgGwlGZK8TnGS6rf/wGIzkAY8QvELzi2H8MreILOwvZ7AgYHBEYKcuLw==@linaro.org X-Google-Smtp-Source: AGHT+IFXrycb1kGOZf2+zNjmbcjihiRRcZWuZvbCVK6xzz4SI/IUc1+0cUlI7VqG11UCtfxcfM45 X-Received: by 2002:ac8:5811:0:b0:460:e9d3:e989 with SMTP id d75a77b69052e-466b34d31c1mr105574451cf.8.1732824976160; Thu, 28 Nov 2024 12:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732824976; cv=none; d=google.com; s=arc-20240605; b=WNINz//qPeQIdPSTS5Y0+nJSEOHhJTvIzJr+9DaEv9WLu0IQvcmOpe9DMQR5r3BnEG ilwZHHcahcuQPj/EWlGdrSylxzcHVbIJdZ3a9K3jHj3uElhxzaUmnLFFIjGbnvIfaysp 9mWH/EB4E5Vif7iXUMUEDhJ8tnr/hkwMTyg3Szl4GcFSOvp45TZMqAgWH5BeEGShSbo5 WE8Tzn0SysyhVFFIZotpeJeha04r4KDpgHfbZgJI73nrj4MNhkY83zP0fcRivv48Hwqj hcRPF05H8a1gZ5+UFYj22AzJfs9g/1w4pPmXCfcxonAbi+dp2VncbnQt/2OcwRJFCyih exYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D/WE4DdwfNtGJC4bBQHDV6Up1JyJz8d62bKAZjE6uOc=; fh=OrmH+MZV3V0n4Ue2VMCDM+kSAfQpbYLvWXqE3FZ9q3E=; b=DNcqYkxeNbNc/YriD8tQOTHXcxQC+8MWzu9QXxRaDkyDJM7UtHnYLcousvAojWZnK1 5EoNtxWVw86XzMSwzn1wkQFmp4O94tSST+mXkWMhHw54ugu+icRFwATIC7i/vbWYfmG3 ZAY3oRF3Pyt9Hu6gmtjddKVETEZYlhXx/HUPmINOLFmuHSp5mKtu7kRQaveRlKyvAooD sEwcl+zB5nFDdJvIAYtWHSzq20+kkCMRGmZAd0uQBwGQ2gS9h3X7htiHCj+yeZVn5lW7 bD/m8oa2l7PdYqnUn33CNIdhZRaM2jorbJj8R0FkzUw5+7KNfxyJc4ORvaih0euctSAM ocEg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AQdOrZSw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-466c4225abcsi27101131cf.485.2024.11.28.12.16.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Nov 2024 12:16:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AQdOrZSw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkvO-0001NK-Ja; Thu, 28 Nov 2024 15:15:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkvB-0001Ij-Ip for qemu-devel@nongnu.org; Thu, 28 Nov 2024 15:15:29 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tGkv7-0001mf-KJ for qemu-devel@nongnu.org; Thu, 28 Nov 2024 15:15:29 -0500 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2ea45dac86eso927555a91.3 for ; Thu, 28 Nov 2024 12:15:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732824924; x=1733429724; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D/WE4DdwfNtGJC4bBQHDV6Up1JyJz8d62bKAZjE6uOc=; b=AQdOrZSwBgh7kGOZQvr/cSxqvFk/QeVW+U0DcTekW4TJsg5xU24tQJNezPBLRfJsCX 1umzAkPDaQ0PMbF/7To6kYQqO9rr2KZkBIQkSz8MoaWfhXIE7YKnk5h5qJzLJRVajxQy jMM/Obe7R6keL7aKYUqDW9sGTpl9BtQCgTxXBIDwfBBh0dBVJtYZOjZaEMc0iCCMqHnI mcxYQzVWCbBYUH7+Ao9Ddfq7TrGJJH3XchcPjjRtwxh4fAWX+r0mfHmFJvhrCyeGPfgw +iLK3rfpl3YuroSuJf/jXjob8pzBJWDg2/0voMhlAD7mPK05ISTDckUBRG0SYBG0Y0/q VevA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732824924; x=1733429724; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D/WE4DdwfNtGJC4bBQHDV6Up1JyJz8d62bKAZjE6uOc=; b=gEfil7Ol0gOZTaGQLIVAaCJxeiGLj6msjaSOi3jabZISecGlpf4Qzlf1VO8OO53N7Q +paQXdo5OuGNmFdoG3EP52tZDX5r2Gz8IKK7lE0BueAsTojXIaLt1/6JU7a2pXkNM6JR ZeX4NrC7ttDvnoqyQXscoZ3EkD6RGPCG67FCE5IPvNZunahUcAwosHJ5NCH3DF5TyWwy v8Qi8AeedINXy9EfK+V1tEWIYPvPKiOBNtYOvehF4yI9Sbq81detoCFv43WdOyFrxRQF eDF0ca2zpC4VZ85h91DttbJbfiuWa1ugbXI0fNOikAI6Qi6cN6M7fCztRXeI9QkOQk05 eBfQ== X-Gm-Message-State: AOJu0Yx41L58ScMaApfq866HN7rSkRK5NMbKfq1JsceJLiQuSJ0owFZh pKDOPYTUs+q13AFBs+PZBNsRrfjOWZdoibOfLtVEZKfR2NXNufHDpkIyth5CmF/F9BNLoRs5fxa I2sQ= X-Gm-Gg: ASbGncsoOzzaBajEvf7Zq8ZB187//gykDCCK9RK9YH9nFIhkDnlBT1gdP/ZSrNs7HCJ dooQg56ZLBPssv3p6HJKQZf9ET+q6yLCjolg4WmDj1plTzK46P1CWXtcFS17hyfRCwPg9rgRtqt ZPrGO+qDl7ehjqui+7sRE5LqGrfgfKMQzyPTvp9TUp9svCEdcIuZrqGjm4fsPMXt7KuTPV5kv1w 1b1M6HXIMDCBtchbgK5SGbOKBLTs/5N1YyVeiYjXXTsnsScvIugcxpiLnmDPXjipXjdQEBzHiaS k8HGlTs6kVgzGQ== X-Received: by 2002:a17:90b:3e86:b0:2ea:9309:757e with SMTP id 98e67ed59e1d1-2ee08e9fa32mr10969501a91.9.1732824924110; Thu, 28 Nov 2024 12:15:24 -0800 (PST) Received: from linaro.. (216-180-64-156.dyn.novuscom.net. [216.180.64.156]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ee0fb10049sm3912861a91.43.2024.11.28.12.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 12:15:23 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Paolo Bonzini , Thomas Huth , =?utf-8?q?Alex_Benn=C3=A9e?= , Mahmoud Mandour , Alexandre Iooss , Markus Armbruster , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Stefano Garzarella Subject: [PATCH v3 3/3] plugins: enable linking with clang/lld Date: Thu, 28 Nov 2024 12:15:10 -0800 Message-Id: <20241128201510.869974-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241128201510.869974-1-pierrick.bouvier@linaro.org> References: <20241128201510.869974-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Windows uses a special mechanism to enable plugins to work (DLL delay loading). Option for lld is different than ld. MSYS2 clang based environment use lld by default, so restricting to this config on Windows is safe, and will avoid false bug reports. Signed-off-by: Pierrick Bouvier --- meson.build | 5 +++++ contrib/plugins/meson.build | 2 +- plugins/meson.build | 24 ++++++++++++++++++++---- tests/tcg/plugins/meson.build | 3 +-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 97cefb7cdd7..f286fb4f4a0 100644 --- a/meson.build +++ b/meson.build @@ -354,6 +354,11 @@ elif host_os == 'sunos' qemu_common_flags += '-D__EXTENSIONS__' elif host_os == 'haiku' qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC'] +elif host_os == 'windows' + # plugins use delaylib, and clang needs to be used with lld to make it work. + if compiler.get_id() == 'clang' and compiler.get_linker_id() != 'ld.lld' + error('On windows, you need to use lld with clang - use msys2 clang64/clangarm64 env') + endif endif # Choose instruction set (currently x86-only) diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build index 63a32c2b4f0..484b9a808c8 100644 --- a/contrib/plugins/meson.build +++ b/contrib/plugins/meson.build @@ -12,7 +12,7 @@ if get_option('plugins') t += shared_module(i, files(i + '.c') + 'win32_linker.c', include_directories: '../../include/qemu', link_depends: [win32_qemu_plugin_api_lib], - link_args: ['-Lplugins', '-lqemu_plugin_api'], + link_args: win32_qemu_plugin_api_link_flags, dependencies: glib) else t += shared_module(i, files(i + '.c'), diff --git a/plugins/meson.build b/plugins/meson.build index 98542e926f8..d60be2a4d6d 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -17,14 +17,15 @@ if not enable_modules capture: true, command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', '@INPUT@']) emulator_link_args += ['-Wl,-exported_symbols_list,plugins/qemu-plugins-ld64.symbols'] + elif host_os == 'windows' and meson.get_compiler('c').get_id() == 'clang' + # LLVM/lld does not support exporting specific symbols. However, it works + # out of the box with dllexport/dllimport attribute we set in the code. else emulator_link_args += ['-Xlinker', '--dynamic-list=' + qemu_plugin_symbols.full_path()] endif endif if host_os == 'windows' - dlltool = find_program('dlltool', required: true) - # Generate a .lib file for plugins to link against. # First, create a .def file listing all the symbols a plugin should expect to have # available in qemu @@ -33,12 +34,27 @@ if host_os == 'windows' output: 'qemu_plugin_api.def', capture: true, command: ['sed', '-e', '0,/^/s//EXPORTS/; s/[{};]//g', '@INPUT@']) + # then use dlltool to assemble a delaylib. + # The delaylib will have an "imaginary" name (qemu.exe), that is used by the + # linker file we add with plugins (win32_linker.c) to identify that we want + # to find missing symbols in current program. + win32_qemu_plugin_api_link_flags = ['-Lplugins', '-lqemu_plugin_api'] + if meson.get_compiler('c').get_id() == 'clang' + # With LLVM/lld, delaylib is specified at link time (-delayload) + dlltool = find_program('llvm-dlltool', required: true) + dlltool_cmd = [dlltool, '-d', '@INPUT@', '-l', '@OUTPUT@', '-D', 'qemu.exe'] + win32_qemu_plugin_api_link_flags += ['-Wl,-delayload=qemu.exe'] + else + # With gcc/ld, delay lib is built with a specific delay parameter. + dlltool = find_program('dlltool', required: true) + dlltool_cmd = [dlltool, '--input-def', '@INPUT@', + '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe'] + endif win32_qemu_plugin_api_lib = configure_file( input: win32_plugin_def, output: 'libqemu_plugin_api.a', - command: [dlltool, '--input-def', '@INPUT@', - '--output-delaylib', '@OUTPUT@', '--dllname', 'qemu.exe'] + command: dlltool_cmd ) endif specific_ss.add(files( diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build index f847849b1b7..87a17d67bd4 100644 --- a/tests/tcg/plugins/meson.build +++ b/tests/tcg/plugins/meson.build @@ -5,9 +5,8 @@ if get_option('plugins') t += shared_module(i, files(i + '.c') + '../../../contrib/plugins/win32_linker.c', include_directories: '../../../include/qemu', link_depends: [win32_qemu_plugin_api_lib], - link_args: ['-Lplugins', '-lqemu_plugin_api'], + link_args: win32_qemu_plugin_api_link_flags, dependencies: glib) - else t += shared_module(i, files(i + '.c'), include_directories: '../../../include/qemu',