diff mbox series

[08/11] ovmf: Fix memcpy alias prototype for clang 23

Message ID 20260830125853.1139807-9-sunilkumar.dora@windriver.com
State New
Headers show
Series clang/llvm: Upgrade to 23.1.0 | expand

Commit Message

Dora, Sunil Kumar Aug. 30, 2026, 12:58 p.m. UTC
From: Sunil Dora <sunilkumar.dora@windriver.com>

The memcpy alias in CryptoPkg's IntrinsicLib declares its size
parameter as unsigned int while the aliasee uses size_t. clang 23
diagnoses that through the new -Wattribute-alias, which the CLANGDWARF
build's -Werror turns into

  CopyMem.c:29:17: error: alias and aliasee have different types
  'void *(void *, const void *, unsigned int)' and
  'void *(void *, const void *, size_t)' [-Werror,-Wattribute-alias]

Declare the alias with size_t to match.

Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
---
 ...sicLib-fix-memcpy-alias-prototype-fo.patch | 35 +++++++++++++++++++
 meta/recipes-core/ovmf/ovmf_git.bb            |  1 +
 2 files changed, 36 insertions(+)
 create mode 100644 meta/recipes-core/ovmf/ovmf/0005-CryptoPkg-IntrinsicLib-fix-memcpy-alias-prototype-fo.patch
diff mbox series

Patch

diff --git a/meta/recipes-core/ovmf/ovmf/0005-CryptoPkg-IntrinsicLib-fix-memcpy-alias-prototype-fo.patch b/meta/recipes-core/ovmf/ovmf/0005-CryptoPkg-IntrinsicLib-fix-memcpy-alias-prototype-fo.patch
new file mode 100644
index 0000000000..0921f21347
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/0005-CryptoPkg-IntrinsicLib-fix-memcpy-alias-prototype-fo.patch
@@ -0,0 +1,35 @@ 
+From: Sunil Dora <sunilkumar.dora@windriver.com>
+Date: Wed, 20 Aug 2026 10:45:00 +0530
+Subject: [PATCH] CryptoPkg/IntrinsicLib: fix memcpy alias prototype for clang
+
+The clang-only memcpy alias declares its size parameter as unsigned int
+while the __memcpy aliasee uses size_t (UINTN, unsigned long long on
+X64). clang 23 diagnoses mismatched alias/aliasee types via the new
+-Wattribute-alias warning, which the CLANGDWARF build's -Werror turns
+into a hard error:
+
+  CopyMem.c:29:17: error: alias and aliasee have different types
+  'void *(void *, const void *, unsigned int)' and
+  'void *(void *, const void *, size_t)' [-Werror,-Wattribute-alias]
+
+Declare the alias with size_t, matching the aliasee on every
+architecture (UINTN is unsigned int on IA32, unsigned long long on X64).
+
+Upstream-Status: Submitted [https://github.com/tianocore/edk2/pull/13038]
+Signed-off-by: Sunil Dora <sunilkumar.dora@windriver.com>
+---
+--- a/CryptoPkg/Library/IntrinsicLib/CopyMem.c
++++ b/CryptoPkg/Library/IntrinsicLib/CopyMem.c
+@@ -29,9 +29,9 @@
+ __attribute__ ((__alias__ ("__memcpy")))
+ void *
+ memcpy (
+-  void          *dest,
+-  const void    *src,
+-  unsigned int  count
++  void        *dest,
++  const void  *src,
++  size_t      count
+   );
+ 
+ #else
diff --git a/meta/recipes-core/ovmf/ovmf_git.bb b/meta/recipes-core/ovmf/ovmf_git.bb
index 660aefcf46..bf69108f0a 100644
--- a/meta/recipes-core/ovmf/ovmf_git.bb
+++ b/meta/recipes-core/ovmf/ovmf_git.bb
@@ -19,6 +19,7 @@  SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https;ta
            file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \
            file://0003-debug-prefix-map.patch \
            file://0004-reproducible.patch \
+           file://0005-CryptoPkg-IntrinsicLib-fix-memcpy-alias-prototype-fo.patch \
            "
 
 PV = "edk2-stable202605"