Fixes build with gcc 11+

Signed-off-by: Khem Raj <[email protected]>
---
 .../0001-winpthreads-Add-__udivmoddi4.patch   | 52 +++++++++++++++++++
 .../nativesdk-mingw-w64-winpthreads_8.0.0.bb  |  2 +
 2 files changed, 54 insertions(+)
 create mode 100644 
recipes-devtools/mingw-w64/files/0001-winpthreads-Add-__udivmoddi4.patch

diff --git 
a/recipes-devtools/mingw-w64/files/0001-winpthreads-Add-__udivmoddi4.patch 
b/recipes-devtools/mingw-w64/files/0001-winpthreads-Add-__udivmoddi4.patch
new file mode 100644
index 0000000..3eb298e
--- /dev/null
+++ b/recipes-devtools/mingw-w64/files/0001-winpthreads-Add-__udivmoddi4.patch
@@ -0,0 +1,52 @@
+From 3b0af7327446ae179dc93b6a6ab1074251d348d0 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Fri, 30 Apr 2021 16:50:36 -0700
+Subject: [PATCH] winpthreads: Add __udivmoddi4
+
+Newer GCC ( 11.1.0+ ) is generating calls to __udivmoddi4 on i686
+architecture, therefore provide an implementation to avoid undefined
+references
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+---
+ .../winpthreads/src/libgcc/dll_math.c            | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/mingw-w64-libraries/winpthreads/src/libgcc/dll_math.c 
b/mingw-w64-libraries/winpthreads/src/libgcc/dll_math.c
+index aeec068..d170967 100644
+--- a/mingw-w64-libraries/winpthreads/src/libgcc/dll_math.c
++++ b/mingw-w64-libraries/winpthreads/src/libgcc/dll_math.c
+@@ -121,6 +121,7 @@ u_quad_t   __udivdi3(u_quad_t a, u_quad_t b);
+ u_quad_t      __umoddi3(u_quad_t a, u_quad_t b);
+ int           __ucmpdi2(u_quad_t a, u_quad_t b);
+ quad_t        __divmoddi4(quad_t a, quad_t b, quad_t *rem);
++u_quad_t      __udivmoddi4(u_quad_t a, u_quad_t b, u_quad_t *rem);
+ 
+ #endif /* !_LIBKERN_QUAD_H_ */
+ 
+@@ -573,7 +574,20 @@ __divmoddi4(a, b, rem)
+       return (negq ? -uq : uq);
+ }
+ 
++/*
++ * Divide two unsigned quads.
++ * This function is new in GCC 7.
++ */
++u_quad_t
++__udivmoddi4(a, b, rem)
++      u_quad_t a, b, *rem;
++{
++      u_quad_t q = __udivdi3(a, b);
++      if (rem)
++              *rem = a - b * q;
++      return q;
++}
++
+ #else
+ static int __attribute__((unused)) dummy;
+ #endif /*deined (_X86_) && !defined (__x86_64__)*/
+-
+-- 
+2.31.1
+
diff --git 
a/recipes-devtools/mingw-w64/nativesdk-mingw-w64-winpthreads_8.0.0.bb 
b/recipes-devtools/mingw-w64/nativesdk-mingw-w64-winpthreads_8.0.0.bb
index e694e5b..814268d 100644
--- a/recipes-devtools/mingw-w64/nativesdk-mingw-w64-winpthreads_8.0.0.bb
+++ b/recipes-devtools/mingw-w64/nativesdk-mingw-w64-winpthreads_8.0.0.bb
@@ -2,6 +2,8 @@ DESCRIPTION = "Winpthreads runtime libraries from MinGW-w64 
project"
 
 require mingw-w64.inc
 
+SRC_URI += "file://0001-winpthreads-Add-__udivmoddi4.patch;striplevel=3"
+
 S = "${WORKDIR}/mingw-w64-v${PV}/mingw-w64-libraries/winpthreads"
 B = "${WORKDIR}/build-${TARGET_SYS}"
 
-- 
2.31.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#53340): https://lists.yoctoproject.org/g/yocto/message/53340
Mute This Topic: https://lists.yoctoproject.org/mt/82495106/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to