From patchwork Fri Jan 10 20:33:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 856288 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp416260wrc; Fri, 10 Jan 2025 12:35:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW2h+f6N1lQPWD7rbiPgRN4XiqCEUazW9Drr+kF/TuTLPMf3GnhAIdPMzgTH7+mPQp88dANiQ==@linaro.org X-Google-Smtp-Source: AGHT+IFM24b71GDEC+YHrb5OlTKtLDtznB6lsM6la0Oln0siyOXUrhBqv3lkQFJYRlgLTdYflZbH X-Received: by 2002:a05:6214:570b:b0:6dc:d101:2bb2 with SMTP id 6a1803df08f44-6df9b0ee9b8mr198519806d6.0.1736541323605; Fri, 10 Jan 2025 12:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736541323; cv=none; d=google.com; s=arc-20240605; b=lM6OuhWYRZ4OkCazssTjKvQxwGD6b1QwULYBHPKas2z1xEtQiQKhFxq0jWMuu7Al1i oFT2JlaxqOI5J39GJi12K/tgH76abdz58Jmg+u2Ic+PYhS5uccfUfHtOjkV9ZEi5CIbI V9eWNmoA9uhp001wpQL0+tD5GJ4xPAvWRvdSIzsmYJrotGfVsx23T+7EbOR8DijMIYgw 3nUUQi51EYKW2xZW/v2JK+nRnOFUcClEg+WBa05/mIr7vdsgCTVIci9lTnl6v1IOLnjs cRjyCf45zc9zM9FqXSIJOfNvIC751RPCyr9mnrTAbeJsQMGLsqLQeCrmwpbE8DPr29ma nLLg== 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=CZZWVjzYh3oSJqK7qwXbLdnBf+l62UVrcXWqFU7n58A=; fh=osDf24rzdulpcwbZBTbZONJdn+PQhsfeRkrfsSE4xK0=; b=hPG5J8SBhCbnTXAa5jvGdzUIdw2+uyDJsD63Prg2771XPJ3HQXbXXrjrwcHEfURjZb bvJeoV/reKlW4xavH+JrUKyQkHgfJzphpc9voHs0vWaGnKo1QywhPluna+31U/71dWNI uKrfJ+OtwSepD70yUT+Sai8EY9i/XkdzLV7ulWQmXZXNresGmsUuhozffXlxWzdm4NKv oFAlIK9pG5VeT8u9MTlR9G8lPkKuXPelct9NTWLSW9FHRQdkkVaKXagahTXtKyYbm+cX slYv+3HlLjb76qivwLGamoHCYLS4+AL0oh9z7sGHHFQEQH8LUs/umF4p7rcG1rBo7e8z xJ/g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZtJLJF/s"; 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 6a1803df08f44-6dfadecdc81si30722636d6.278.2025.01.10.12.35.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jan 2025 12:35:23 -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="ZtJLJF/s"; 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 1tWLhz-0000WC-JP; Fri, 10 Jan 2025 15:34:19 -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 1tWLhx-0000VR-96 for qemu-devel@nongnu.org; Fri, 10 Jan 2025 15:34:17 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tWLht-0005ex-TI for qemu-devel@nongnu.org; Fri, 10 Jan 2025 15:34:16 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-2166022c5caso39480935ad.2 for ; Fri, 10 Jan 2025 12:34:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736541252; x=1737146052; 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=CZZWVjzYh3oSJqK7qwXbLdnBf+l62UVrcXWqFU7n58A=; b=ZtJLJF/sdiQduEcA3HnIbwqcStbqBStAfAbynBpqHwLBOh0a5jNHW/KMqiWiuJBQNS gdanlAie4zClc0O1n1hIrIFLUkJ8EnIhpnEAchHpCfjY2kS1jxQD3COemD6S7baaQPj4 ucNsGG3LdJ8lfe7JDYIB2XKc9U/b9sIwrpGn7ogW5yovlYr7qI8u/EXWrreHbHu11H38 KOZclF9BIaljV72XDI+ku3/GKrten1M4Fv2bXip5PVzFJjKZnW7m0ytkbWmtyqHpe200 i795TVYhNlt6PvqV5+1rJDv2Wk6ARv09me25ZAJTbgOspphyxp6fWRC4zUn/NVZWjCEU LLFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736541252; x=1737146052; 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=CZZWVjzYh3oSJqK7qwXbLdnBf+l62UVrcXWqFU7n58A=; b=RUzN57NGOw7s1Pqqhjjs51que/8wXIGX7IpnM4nF3dDk1R+Y476gvPVGAfGkSVuUJ8 SqgQvDVEGKy4Uu7IjT+3rEbGb2BFnKAnNi1Y7RJ4KcuggAKRNY9Ukau9AYcfrfCMVlvm KWhUUMghuOUo+Zk60t9iqOw+ANg6wyJnzk4ZVjDgLGRTpMoapPC+2jBdxOLsvRnXvajd XPsvxYDrPVRStQybgtQEOFjl3Q7N+S3D32pLKWFMQ2M68bf3XONXDw3g/bONx6+wowlG 2M+VYaOzRgsyBq8zHqhbPZTs71AowanDPHHZ2cYvdBIiJ+0T83hXvqSbhRKnP+idywMa gTJQ== X-Gm-Message-State: AOJu0YwvuNrXi+JFLEHTrQJ031XIs5ANqPJl+WY1twuOTWq0ufooMwS9 XrrMTV478+dR03mIR1O89C4GL4Cdl6YSlfVTN4w8tfOGw0C1Zlk5J6NFCI73omllkTCgGDJ/fSl wOvbNxg== X-Gm-Gg: ASbGncsTFtp5ACAQIE/gXbMtYvYudnSo87V2hd3UkAiK8vm5a6xoppo90SLl1A3487l NRVgTqPDxg+3pFd/MTk9WiaEDyU22Z1D9tdraBY/tfv/RKU6DlKuNLDj7VNS4x4enwAB/zUVhN3 yVBl8otxmP2A+9GTPDh/y4MqFIS7bJ66pv4eeTmbpF4zqaNbbLZMM3eip5MBoZ2brtZFQGZJXD+ OaUQzTghGGR+VpwIFSBFPV76JNPMIVsoGWUpTUjCd8nuFlCuLJ8BpHl X-Received: by 2002:a17:902:ec83:b0:215:7ce4:57bc with SMTP id d9443c01a7336-21a83f54a5cmr175214205ad.16.1736541252281; Fri, 10 Jan 2025 12:34:12 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-a318e8ecacfsm3215947a12.38.2025.01.10.12.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 12:34:11 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Markus Armbruster , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , Paolo Bonzini , Pierrick Bouvier , Stefano Garzarella , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Alexandre Iooss , Richard Henderson Subject: [PATCH v4 1/3] win32: remove usage of attribute gcc_struct Date: Fri, 10 Jan 2025 12:33:59 -0800 Message-Id: <20250110203401.178532-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250110203401.178532-1-pierrick.bouvier@linaro.org> References: <20250110203401.178532-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x630.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 Reviewed-by: Richard Henderson Acked-by: Stefano Garzarella Signed-off-by: Pierrick Bouvier --- 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 d06f59095c6..da279cc1124 100644 --- a/meson.build +++ b/meson.build @@ -377,11 +377,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 Fri Jan 10 20:34:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 856287 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp416259wrc; Fri, 10 Jan 2025 12:35:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW0jFw2O+LbhbtrXH+04njwQYa9n8rXI8fmIO8rqu/Yo1H9/NRrPXeRRe5QwLBNVnVJ6J81dA==@linaro.org X-Google-Smtp-Source: AGHT+IFvCd/s1NMxxkg2JSgPxxm4ntBC2DYdShmKYZ8FRqTQiygKxZ1rDt9tOQ6ewwRM8F/Z7LLH X-Received: by 2002:ac8:580a:0:b0:466:ad0d:f0ca with SMTP id d75a77b69052e-46c7108edb5mr230586221cf.50.1736541323516; Fri, 10 Jan 2025 12:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736541323; cv=none; d=google.com; s=arc-20240605; b=GeUIn25jSnQsXT1LVP9WFGJ5Smii8b4/NjGGbarcGeavGgjHRznIL9LSiDXyZwPLA/ qdLSzo0W1lPrbmQuWyo7nIwv3uUS48xgwaVVUk7cgVH+42bPAj4HlavuzE6QCZBow3Nf SNLsrxqrP4g7O/+3jFF9VNh7kpbJpz8kyYs/5w1xWCF74dYfYvMCYEnQEr7jJ2x3CaeI DltoG9ambVcOUSdObUDIj31L7pI2Qli6IWPFH86KD78zxBGUgCt0tcYrloyVFB5FaWvy DNRPeNRR3qZs7Ak8xBEKOHIfZSS9wWep9UjjQKQFK8jVL17GT6huKaDBLX9b5VSs8uZ1 UI5Q== 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=g9R9dQpF5UbzJZ6Kb11hyvYzYtKnLXxRBjcuMGn4NXM=; fh=osDf24rzdulpcwbZBTbZONJdn+PQhsfeRkrfsSE4xK0=; b=D9S+OHZkLgeQb+nSZHawvYbFOk6mPBNMHNs01nPR0RmebitfyBkxvZcAS5GXqeftfN Qi5GkVsqcyBS8Mb3ODaM3KqeT8TGoCWmsQehWAa6ycJkT3DNLbXkIDMXkvnzZNsGs1BY ZWaJCrvIVckOmJ+IkvnZ5XU5yUNHsx0Ud2s5a5U1ydhFXK3OP9j1p4qe/d+fFKXap158 sxW2rzzTMGkBY6p258SVdIAcDf9F9bey6vT2c4Tvp8uq6iAhQNwBgp37l7Qzer9kIRv2 W3RD2+ELi6JOFWESjrF2Jl0fAHwMaVKIgMUpcrP0MY0dB9LFY5bs32QHyCZfzE4cRm8L y2rQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VtIpE3p5; 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-46c873fae64si31131281cf.384.2025.01.10.12.35.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jan 2025 12:35:23 -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=VtIpE3p5; 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 1tWLhz-0000WE-S4; Fri, 10 Jan 2025 15:34:19 -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 1tWLhw-0000VK-Tv for qemu-devel@nongnu.org; Fri, 10 Jan 2025 15:34:16 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tWLhv-0005f2-4Z for qemu-devel@nongnu.org; Fri, 10 Jan 2025 15:34:16 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2165cb60719so44203015ad.0 for ; Fri, 10 Jan 2025 12:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736541253; x=1737146053; 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=g9R9dQpF5UbzJZ6Kb11hyvYzYtKnLXxRBjcuMGn4NXM=; b=VtIpE3p59kQ0rOFVvsvhaAI+1nZgwi+N18g5A94+9znPjDvH9aWuheNf3HW896hPFJ FjAOibPt0pYM3F8aTPp/NJqg/oShxQs+kUeSFStQS/CYtCEAgZBSWKCICA/HtTURvaCR 6GGR3bKZp46zX/60Mw0GYsbTg+RJYfG6/C9S7XjcpHzOdZguJzKVCNV0KG3Lji5oL0+Z G9qNQIJ8iu/9n7NOVZGs864I2EbQHx07utJydSJvORos2dtnFz3odLzbcovAEV5lOZcg ZBiEtROVJwIX1LOFy4QDzeSAmNQSc0kWuGEHMu052IaGa2/Z0zzdYDamVwVW8VFqumcs ipiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736541253; x=1737146053; 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=g9R9dQpF5UbzJZ6Kb11hyvYzYtKnLXxRBjcuMGn4NXM=; b=X20JFfmV5aWRlwpLwHZAbhEf15tpts1uWQACgjnv9D90H4M4bzaDeuB4TZpWloWDHA 6tO1EyxNmLVC+ud0KXPIoOQ2rTRe5ixMUH/vckyFTqsb5BCTDTI9OMIrXAR1AMTiBjJK 7ROFQ7N5deTFEbbjE9Hvd/hiDLxWMh/MmsISdyVfUwO69XV8Cba39LJHghrOQvTmUxxK pjepPhkhG7a/QDx1FQIwhaCi2fdWDH+jHXn5G3ptgyWl0ermTyVCbkETIf/nTGGCUsCf jj5k0sLOnAfwoFWfHSnkgKN1irFuyBvzunpywAkc3rt9EZYLJYDfCBGXw7lilBfWXgX+ FgMA== X-Gm-Message-State: AOJu0Yw/1OzLZw1ks9rFCmMUdbQmUgaf0n9xCsiMDi169wWC6hVTlklE K1UVlFHORw6gEeRIWVoHhxnTbiC2vjN5IkR7w3NqmkpD1ZP91t2wDvTOjk20K8o4WvkSVhWdyx1 ujwVCgA== X-Gm-Gg: ASbGncs0q0UM1DisrQSLMpnk6/IYSmS7zyiDsUxl4ecp9TiiIyJZ0JBs+u1K0Cfqr3V jli9Kgl6siQb1w5c8r4ArGFZa6Q6Ec+7dJ44kmhkkO2CVejMhwSoSHil62vFQ7WVQbPZrMaOOH7 l6Jtsq6N2g8EXJ9qJeDZhbfRBgHuBWb0tFU1Dx+ItyoOzs/j1Ua3q0SFuM1WYfnz+hTaTikBnhZ mGv/Fo3g4VM92v1hNlwQYfGdtuqLveV6B8Ncl/+YTJss+4qgaD1eWvQ X-Received: by 2002:aa7:88cd:0:b0:725:f097:ed21 with SMTP id d2e1a72fcca58-72d21f471d6mr17088257b3a.15.1736541253266; Fri, 10 Jan 2025 12:34:13 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-a318e8ecacfsm3215947a12.38.2025.01.10.12.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 12:34:12 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Markus Armbruster , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , Paolo Bonzini , Pierrick Bouvier , Stefano Garzarella , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Alexandre Iooss , Richard Henderson Subject: [PATCH v4 2/3] docs/devel/style: add a section about bitfield, and disallow them for packed structures Date: Fri, 10 Jan 2025 12:34:00 -0800 Message-Id: <20250110203401.178532-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250110203401.178532-1-pierrick.bouvier@linaro.org> References: <20250110203401.178532-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62c.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 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- docs/devel/style.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/devel/style.rst b/docs/devel/style.rst index 2f68b500798..d025933808e 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 +`_, or where +endianness matters. + +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 +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 Fri Jan 10 20:34:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 856286 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp416246wrc; Fri, 10 Jan 2025 12:35:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUwEg7YCB0NrlaO4E2l0xLqHZ/xDuMqfCEff3YOkk64fUo1ZqLn6x90qQ98tAohxEVD5MFbzg==@linaro.org X-Google-Smtp-Source: AGHT+IG3en6fRzjCsWxHO5LZDI5Z11snqKiGTsVlv321eFy8ajSsbm2Ic5vtT2XE0nqmifrDKP1X X-Received: by 2002:a05:622a:91:b0:460:8e3b:6790 with SMTP id d75a77b69052e-46c7109e694mr153120301cf.48.1736541322753; Fri, 10 Jan 2025 12:35:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736541322; cv=none; d=google.com; s=arc-20240605; b=e5lQRh3YUYqAcM9VMPE4HfAAuHRvFl0i/GPTqre7oa5ZNMV+f7gBDGkvdo60XCbuc8 9aDfdyuPIcf9JeapFvZHu100xXy6U6WcfIj5ZbAxDGk40emHlGtofPcR2CnTbVqciMIa H2fFb/LN+puTv3AJkn0NW11J9DAEOb6S9Q4Z15BgP+12Gai9I7CcI/bbSXv2wQWyiCl4 8rNGX8IINa6kyHnBShXf6cTcOk6qrwJXWoVBh663ubpjmfurTy+M2EGewpreZDtwPVNQ R3gAMz5WG8FUp/08hgRovetIyaoMnOIAEHE3MWn6YVcetxgAtsfGP8QzMTXZ4xpeid0q vAew== 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=zYJSyPKU8fgKG+LBRgRKgUriNwBs8tsNOa/EDE0vjZM=; fh=UEetNBE2p2bu6errUCGbv3jJ3gSRLYgjO+j9vdmIBjw=; b=LbgLLYjSjVsnlPIEdrXVMVuPwSDiwk0FZocbhmCUqET/iNAsyLWHfHbPC92I6Nua/r Z1sCszerw7N393+svbJ2wOxbgXsRDi3+eQHjS4BpgV0MK0otRG0Fz+kx0UDl0jaJIwFt K0/H7lm9DodfPGTI7bGxbE4APw7n2EpaPyUkvfGgijfp5mcPqKQeUMVbzn+HrcglQ7CQ IVhpz4vM3Vcv2GOyrRXMrvgXmtj8R5YRk+OrAC1pyxvTmb515wEuMKTBa12Zyqy2n16w A+3xrAjRb187lKGR/V6oPnICCT30GvmBKV8bj64Pk+xG1iq7/4bimJAa/48YAqXp9WbU 04Hw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wdUNmwt8; 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-46c873e4fb7si28427141cf.220.2025.01.10.12.35.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jan 2025 12:35:22 -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=wdUNmwt8; 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 1tWLhz-0000WH-SO; Fri, 10 Jan 2025 15:34:19 -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 1tWLhx-0000Vb-OA for qemu-devel@nongnu.org; Fri, 10 Jan 2025 15:34:17 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tWLhv-0005f4-IV for qemu-devel@nongnu.org; Fri, 10 Jan 2025 15:34:17 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21669fd5c7cso42728915ad.3 for ; Fri, 10 Jan 2025 12:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736541254; x=1737146054; 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=zYJSyPKU8fgKG+LBRgRKgUriNwBs8tsNOa/EDE0vjZM=; b=wdUNmwt8H5cyyUZzoi/iRFpqeDr8xaPftlL6DV2FKDDtyzy1icReicI2FMxq6MvoeB CWE7hxE21rCBJF5EJ7skT96ob7hn1fdlsIVIdpCvmGEaPGQEGxc6CWmIsC61fGpvV6Is pXNMA9EQ/t2tKD4LIS5u5VFAAF7Oul/PrVqE3IXMoh+8oHHOyGJGWLt75wrql2wVM+hs qTYv3hoRIGNyrP/yiVCdgTb4I64d38br3dHrsWsv77iukdv7q/dtEjOwpDdzmJQBAkN3 hh9l4DjgI7Z+Oi8vak7f2xVXjLmsNMGH6PNb7oKERcSNnxdu+jxTyAeYZSROY55XR99V jaHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736541254; x=1737146054; 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=zYJSyPKU8fgKG+LBRgRKgUriNwBs8tsNOa/EDE0vjZM=; b=UMQqlDf3zB//rBxcTdDAawhLNOreLLKG0numUfH0KsY9ezAREVWHwXrGDcXR9vgp3g pPFio/80VwgPPUWT7RNkMcyrJPzK330grEW0Zh+DmgWx30UWLzkKa1ABD9EKdpSpiQ8P Km2FdzFeqbRPgo/9zj2oVmbe/sr1wxBeE9Tb9xfoCBXxDM9aKDEO13yOxcvEf/pju3Wz S/a1PGB3+q/V6ND8zt6IXNN4yJrOXRzXZnXPi6uJ+sMnFORRj9lcqr0cGhzpivnpPCH7 zPOIfsEo5uim1WseXgkqY0DZAhXhVo7vYGpvDBMJzKXJKw+36WXh66WnW/1zwaGq/Kqu pVjg== X-Gm-Message-State: AOJu0YxVWnyo+V0y74nNMq7QkStqrVF6xocAd3a9SURLyfRQEzQVbTDd alK39W39hqYl9iUIkfr9wYw7e/Mg8LeuRzE+K1NxpxPVfErRUXMq9XH7/f6lXMOSCGfGuzZszJB jIeKAxg== X-Gm-Gg: ASbGnct5CrTOSWvb70I+e651m+RyrFlfOnHCIAY97bqm6Y/6bV+IG0TWeRSNegS0OsC wM1mAQjxKfAQBcZocy9vE/w8t70KI3A2BovMdpB5oEyNn3dn7BBlHsY0vfQM95UTkvKPnk2l2Sm QqwYtCR+szEOg9ADE8wikV6YPtlpUeJxBkiSuXWXn1F6kf35a/8uZJuhGTT+wycTKcqZDGCB6as 9yml0T8H+xaNCxj6GDemmaqRzcNn6QkV83OPoL4rO76DDrq+XQKKqyT X-Received: by 2002:a05:6a20:c999:b0:1e4:80a9:b8fa with SMTP id adf61e73a8af0-1e88cfa6fc5mr22018024637.13.1736541254214; Fri, 10 Jan 2025 12:34:14 -0800 (PST) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-a318e8ecacfsm3215947a12.38.2025.01.10.12.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 12:34:13 -0800 (PST) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Markus Armbruster , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , Paolo Bonzini , Pierrick Bouvier , Stefano Garzarella , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Alexandre Iooss Subject: [PATCH v4 3/3] plugins: enable linking with clang/lld Date: Fri, 10 Jan 2025 12:34:01 -0800 Message-Id: <20250110203401.178532-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250110203401.178532-1-pierrick.bouvier@linaro.org> References: <20250110203401.178532-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x632.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. Reviewed-by: Philippe Mathieu-Daudé 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 da279cc1124..15a066043b7 100644 --- a/meson.build +++ b/meson.build @@ -377,6 +377,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',