Skip to contentSkip to conversation

libxcrypt: fixed some build error for nativesdk with mingw

PATCH In review Kang Wenlin 2 participants 4 messages Nov 30, 2023 – Dec 1, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxcrypt: fixed some build error for nativesdk with mingw

From: Wenlin Kang <[email protected]>

Steps to reproduce
1) add layer meta-mingw
2) add line in local.conf

     SDKMACHINE = "x86_64-mingw32"

3) bitbake nativesdk-libxcrypt

Fixed:
1. .symver error
| {standard input}: Assembler messages:
| {standard input}:4: Error: unknown pseudo-op: `.symver'

2. pedantic error

  | ../git/lib/crypt.c:316:24: error: ISO C does not allow extra ';' outside of a function [-Werror=pedantic]
  |   316 | SYMVER_crypt_gensalt_rn;
  |       |

3. conversion error

  | ../git/lib/util-get-random-bytes.c: In function '_crypt_get_random_bytes':
  | ../git/lib/util-get-random-bytes.c:140:42: error: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Werror=conversion]
  |   140 |           ssize_t nread = read (fd, buf, buflen);
---
 .../0001-Fix-for-compilation-on-Windows.patch | 37 +++++++++++++++
 ...dom-bytes.c-fixed-conversion-error-w.patch | 47 +++++++++++++++++++
 recipes-core/libxcrypt/libxcrypt_%.bbappend   |  7 +++
 3 files changed, 91 insertions(+)
 create mode 100644 recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch
 create mode 100644 recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch
 create mode 100644 recipes-core/libxcrypt/libxcrypt_%.bbappend
recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch new file +37 -0
new file mode 100644
index 0000000..5760ee0
@@ -0,0 +1,37 @@
+From a507b628a5a5d4e4f1cf0f0a9a72967470ee7624 Mon Sep 17 00:00:00 2001
+From: Brecht Sanders <[email protected]>
+Date: Fri, 3 Feb 2023 08:44:49 +0100
+Subject: [PATCH] Fix for compilation on Windows
+
+This fix allows the library to build on Windows (at least with MinGW-w64).
+
+`.symver` is only supported for ELF format but Windows uses COFF/PE.
+
+Workaround dummy define of `symver_set()`
+
+Upstream-Status: Backport [https://github.com/besser82/libxcrypt/commit/a507b628a5a5d4e4f1cf0f0a9a72967470ee7624]
+
+Signed-off-by: Wenlin Kang <[email protected]>
+---
+ lib/crypt-port.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/crypt-port.h b/lib/crypt-port.h
+index f06ca24..a707939 100644
+--- a/lib/crypt-port.h
++++ b/lib/crypt-port.h
+@@ -201,6 +201,11 @@ extern size_t strcpy_or_abort (void *dst, size_t d_size, const void *src);
+   __asm__(".globl _" extstr);                           \
+   __asm__(".set _" extstr ", _" #intname)
+ 
++#elif defined _WIN32
++
++/* .symver is only supported for ELF format, Windows uses COFF/PE */
++# define symver_set(extstr, intname, version, mode)
++
+ #elif defined __GNUC__ && __GNUC__ >= 3
+ 
+ # define _strong_alias(name, aliasname) \
+-- 
+2.34.1
+
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +47 -0

47 lines not on this page · raw message

recipes-core/libxcrypt/libxcrypt_%.bbappend new file +7 -0
new file mode 100644
index 0000000..cb9c45e
@@ -0,0 +1,7 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI:append:mingw32 = "file://0001-Fix-for-compilation-on-Windows.patch \
+                          file://0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch \
+"
+
+CFLAGS:append:class-nativesdk:mingw32 = " -Wno-pedantic"
Signature · 1 line
2.39.0
#1 lore raw
Quoted 114 lines · On Thu, Nov 30, 2023 at 12:31 AM [email protected] via…

From: Wenlin Kang <[email protected]>

Steps to reproduce
1) add layer meta-mingw
2) add line in local.conf

     SDKMACHINE = "x86_64-mingw32"

3) bitbake nativesdk-libxcrypt

Fixed:
1. .symver error
| {standard input}: Assembler messages:
| {standard input}:4: Error: unknown pseudo-op: `.symver'

2. pedantic error

  | ../git/lib/crypt.c:316:24: error: ISO C does not allow extra ';' outside of a function [-Werror=pedantic]
  |   316 | SYMVER_crypt_gensalt_rn;
  |       |

3. conversion error

  | ../git/lib/util-get-random-bytes.c: In function '_crypt_get_random_bytes':
  | ../git/lib/util-get-random-bytes.c:140:42: error: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Werror=conversion]
  |   140 |           ssize_t nread = read (fd, buf, buflen);
---
 .../0001-Fix-for-compilation-on-Windows.patch | 37 +++++++++++++++
 ...dom-bytes.c-fixed-conversion-error-w.patch | 47 +++++++++++++++++++
 recipes-core/libxcrypt/libxcrypt_%.bbappend   |  7 +++
 3 files changed, 91 insertions(+)
 create mode 100644 recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch
 create mode 100644 recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch
 create mode 100644 recipes-core/libxcrypt/libxcrypt_%.bbappend
recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch new file +37 -0
new file mode 100644
index 0000000..5760ee0
@@ -0,0 +1,37 @@
+From a507b628a5a5d4e4f1cf0f0a9a72967470ee7624 Mon Sep 17 00:00:00 2001
+From: Brecht Sanders <[email protected]>
+Date: Fri, 3 Feb 2023 08:44:49 +0100
+Subject: [PATCH] Fix for compilation on Windows
+
+This fix allows the library to build on Windows (at least with MinGW-w64).
+
+`.symver` is only supported for ELF format but Windows uses COFF/PE.
+
+Workaround dummy define of `symver_set()`
+
+Upstream-Status: Backport [https://github.com/besser82/libxcrypt/commit/a507b628a5a5d4e4f1cf0f0a9a72967470ee7624]
+
+Signed-off-by: Wenlin Kang <[email protected]>
+---
+ lib/crypt-port.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/crypt-port.h b/lib/crypt-port.h
+index f06ca24..a707939 100644
+--- a/lib/crypt-port.h
++++ b/lib/crypt-port.h
+@@ -201,6 +201,11 @@ extern size_t strcpy_or_abort (void *dst, size_t d_size, const void *src);
+   __asm__(".globl _" extstr);                           \
+   __asm__(".set _" extstr ", _" #intname)
+
++#elif defined _WIN32
++
++/* .symver is only supported for ELF format, Windows uses COFF/PE */
++# define symver_set(extstr, intname, version, mode)
++
+ #elif defined __GNUC__ && __GNUC__ >= 3
+
+ # define _strong_alias(name, aliasname) \
+--
+2.34.1
+
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +31 -0
new file mode 100644
index 0000000..3846f76
@@ -0,0 +1,47 @@
+From ff99091eb8a6b9e6edc567f6d2552183fbaacec3 Mon Sep 17 00:00:00 2001
+From: Wenlin Kang <[email protected]>
+Date: Mon, 6 Nov 2023 14:43:28 +0800
+Subject: [PATCH] lib/util-get-random-bytes.c: fixed conversion error with
+ mingw
+
+With x86_64-w64-mingw32-gcc. get below error:
+| ../git/lib/util-get-random-bytes.c: In function '_crypt_get_random_bytes':
+| ../git/lib/util-get-random-bytes.c:140:42: error: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Werror=conversion]
+|   140 |           ssize_t nread = read (fd, buf, buflen);
+|       |                                          ^~~~~~
+
+In util-get-random-bytes.c, has get_random_bytes(void *buf, size_t buflen),
+but in mingw-w64-mingw-w64/mingw-w64-headers/crt/io.h, read() has "unsigned int"
+read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount), and has:
+ #ifdef _WIN64
+   __MINGW_EXTENSION typedef unsigned __int64 size_t;
+ #else
+   typedef unsigned int size_t;
+ #endif /* _WIN64 */
+
+Upstream-Status: Pending
+
+Signed-off-by: Wenlin Kang <[email protected]>
+---
+ lib/util-get-random-bytes.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/lib/util-get-random-bytes.c b/lib/util-get-random-bytes.c
+index 79816db..68cd378 100644
+--- a/lib/util-get-random-bytes.c

recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch line 41

Quoted 10 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +10 -0
++++ b/lib/util-get-random-bytes.c
+@@ -137,7 +137,11 @@ get_random_bytes(void *buf, size_t buflen)
+         dev_urandom_doesnt_work = true;
+       else
+         {
++#ifdef _WIN64
++          ssize_t nread = read (fd, buf, (unsigned int)buflen);
++#else
+           ssize_t nread = read (fd, buf, buflen);
++#endif

read is system API and I wonder why we are not getting right API signature here as I think
size_t should already be defined based on _WIN64 in system headers.

Quoted 32 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +6 -0
+           if (nread < 0 || (size_t)nread < buflen)
+             dev_urandom_doesnt_work = true;
+
+--
+2.25.1
+
recipes-core/libxcrypt/libxcrypt_%.bbappend new file +7 -1
new file mode 100644
index 0000000..cb9c45e
@@ -0,0 +1,7 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI:append:mingw32 = "file://0001-Fix-for-compilation-on-Windows.patch \
+                          file://0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch \
+"
+
+CFLAGS:append:class-nativesdk:mingw32 = " -Wno-pedantic"
--

2.39.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#61775): https://lists.yoctoproject.org/g/yocto/message/61775
Mute This Topic: https://lists.yoctoproject.org/mt/102890384/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 124 lines · Khem Raj

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 118 lines · On Thu, Nov 30, 2023 at 12:31 AM [email protected] via…

From: Wenlin Kang <[email protected]>

Steps to reproduce
1) add layer meta-mingw
2) add line in local.conf

      SDKMACHINE = "x86_64-mingw32"

3) bitbake nativesdk-libxcrypt

Fixed:
1. .symver error
| {standard input}: Assembler messages:
| {standard input}:4: Error: unknown pseudo-op: `.symver'

2. pedantic error

   | ../git/lib/crypt.c:316:24: error: ISO C does not allow extra ';' outside of a function [-Werror=pedantic]
   |   316 | SYMVER_crypt_gensalt_rn;
   |       |

3. conversion error

   | ../git/lib/util-get-random-bytes.c: In function '_crypt_get_random_bytes':
   | ../git/lib/util-get-random-bytes.c:140:42: error: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Werror=conversion]
   |   140 |           ssize_t nread = read (fd, buf, buflen);
---
  .../0001-Fix-for-compilation-on-Windows.patch | 37 +++++++++++++++
  ...dom-bytes.c-fixed-conversion-error-w.patch | 47 +++++++++++++++++++
  recipes-core/libxcrypt/libxcrypt_%.bbappend   |  7 +++
  3 files changed, 91 insertions(+)

create mode 100644 recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch create mode 100644 recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch create mode 100644 recipes-core/libxcrypt/libxcrypt_%.bbappend

recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch new file +37 -0
new file mode 100644
index 0000000..5760ee0
@@ -0,0 +1,37 @@
+From a507b628a5a5d4e4f1cf0f0a9a72967470ee7624 Mon Sep 17 00:00:00 2001
+From: Brecht Sanders <[email protected]>
+Date: Fri, 3 Feb 2023 08:44:49 +0100
+Subject: [PATCH] Fix for compilation on Windows
+
+This fix allows the library to build on Windows (at least with MinGW-w64).
+
+`.symver` is only supported for ELF format but Windows uses COFF/PE.
+
+Workaround dummy define of `symver_set()`
+
+Upstream-Status: Backport [https://github.com/besser82/libxcrypt/commit/a507b628a5a5d4e4f1cf0f0a9a72967470ee7624]
+
+Signed-off-by: Wenlin Kang <[email protected]>
+---
+ lib/crypt-port.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/crypt-port.h b/lib/crypt-port.h
+index f06ca24..a707939 100644
+--- a/lib/crypt-port.h
++++ b/lib/crypt-port.h
+@@ -201,6 +201,11 @@ extern size_t strcpy_or_abort (void *dst, size_t d_size, const void *src);
+   __asm__(".globl _" extstr);                           \
+   __asm__(".set _" extstr ", _" #intname)
+
++#elif defined _WIN32
++
++/* .symver is only supported for ELF format, Windows uses COFF/PE */
++# define symver_set(extstr, intname, version, mode)
++
+ #elif defined __GNUC__ && __GNUC__ >= 3
+
+ # define _strong_alias(name, aliasname) \
+--
+2.34.1
+
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +36 -0
new file mode 100644
index 0000000..3846f76
@@ -0,0 +1,47 @@
+From ff99091eb8a6b9e6edc567f6d2552183fbaacec3 Mon Sep 17 00:00:00 2001
+From: Wenlin Kang <[email protected]>
+Date: Mon, 6 Nov 2023 14:43:28 +0800
+Subject: [PATCH] lib/util-get-random-bytes.c: fixed conversion error with
+ mingw
+
+With x86_64-w64-mingw32-gcc. get below error:
+| ../git/lib/util-get-random-bytes.c: In function '_crypt_get_random_bytes':
+| ../git/lib/util-get-random-bytes.c:140:42: error: conversion from 'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Werror=conversion]
+|   140 |           ssize_t nread = read (fd, buf, buflen);
+|       |                                          ^~~~~~
+
+In util-get-random-bytes.c, has get_random_bytes(void *buf, size_t buflen),
+but in mingw-w64-mingw-w64/mingw-w64-headers/crt/io.h, read() has "unsigned int"
+read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount), and has:
+ #ifdef _WIN64
+   __MINGW_EXTENSION typedef unsigned __int64 size_t;
+ #else
+   typedef unsigned int size_t;
+ #endif /* _WIN64 */
+
+Upstream-Status: Pending
+
+Signed-off-by: Wenlin Kang <[email protected]>
+---
+ lib/util-get-random-bytes.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/lib/util-get-random-bytes.c b/lib/util-get-random-bytes.c
+index 79816db..68cd378 100644
+--- a/lib/util-get-random-bytes.c
++++ b/lib/util-get-random-bytes.c
+@@ -137,7 +137,11 @@ get_random_bytes(void *buf, size_t buflen)
+         dev_urandom_doesnt_work = true;
+       else
+         {
Quoted 8 lines

recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch line 41

Quoted 5 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +5 -0
++#ifdef _WIN64
++          ssize_t nread = read (fd, buf, (unsigned int)buflen);
++#else
+           ssize_t nread = read (fd, buf, buflen);
++#endif

read is system API and I wonder why we are not getting right API signature here as I think
size_t should already be defined based on _WIN64 in system headers.

1. read() is declared in https://sourceforge.net/p/mingw-w64/code/HEAD/tree/trunk/mingw-w64-headers/crt/io.h, but it has only a declaration for 32-bit,  with 64-bit, it can't be found

2. for size_t, it has:

#ifdef _WIN64
  __MINGW_EXTENSION typedef __int64 ssize_t;
#else
  typedef int ssize_t;
#endif /* _WIN64 */

Quoted 33 lines
Quoted 33 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +6 -0
+           if (nread < 0 || (size_t)nread < buflen)
+             dev_urandom_doesnt_work = true;
+
+--
+2.25.1
+
recipes-core/libxcrypt/libxcrypt_%.bbappend new file +7 -1
new file mode 100644
index 0000000..cb9c45e
@@ -0,0 +1,7 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI:append:mingw32 = "file://0001-Fix-for-compilation-on-Windows.patch \
+                          file://0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch \
+"
+
+CFLAGS:append:class-nativesdk:mingw32 = " -Wno-pedantic"
--

2.39.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#61775): https://lists.yoctoproject.org/g/yocto/message/61775
Mute This Topic: https://lists.yoctoproject.org/mt/102890384/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
--
Thanks
Wenlin Kang
#3 lore raw
Quoted 160 lines · Kang Wenlin
Quoted 2 lines · Khem Raj

CAUTION: This email comes from a non Wind River email account! Do not click links or open attachments unless you recognize the sender

and know the content is safe.

Quoted 12 lines
Quoted 8 lines · On Thu, Nov 30, 2023 at 12:31 AM [email protected] via…

From: Wenlin Kang <[email protected]>

Steps to reproduce
1) add layer meta-mingw
2) add line in local.conf

      SDKMACHINE = "x86_64-mingw32"

3) bitbake nativesdk-libxcrypt

Quoted 7 lines
Quoted 7 lines

Fixed:
1. .symver error
| {standard input}: Assembler messages:
| {standard input}:4: Error: unknown pseudo-op: `.symver'

2. pedantic error
| ../git/lib/crypt.c:316:24: error: ISO C does not allow extra ';'

outside of a function [-Werror=pedantic]

Quoted 5 lines
Quoted 5 lines
   |   316 | SYMVER_crypt_gensalt_rn;
   |       |

3. conversion error
| ../git/lib/util-get-random-bytes.c: In function

'_crypt_get_random_bytes':

Quoted 1 line
Quoted 1 line
   | ../git/lib/util-get-random-bytes.c:140:42: error: conversion from

'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Werror=conversion]

Quoted 9 lines
Quoted 9 lines
   |   140 |           ssize_t nread = read (fd, buf, buflen);
---
  .../0001-Fix-for-compilation-on-Windows.patch | 37 +++++++++++++++
  ...dom-bytes.c-fixed-conversion-error-w.patch | 47 +++++++++++++++++++
  recipes-core/libxcrypt/libxcrypt_%.bbappend   |  7 +++
  3 files changed, 91 insertions(+)

create mode 100644

recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch

Quoted 1 line
Quoted 1 line

create mode 100644

recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch

Quoted 3 lines
Quoted 3 lines

create mode 100644 recipes-core/libxcrypt/libxcrypt_%.bbappend

diff --git

a/recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch b/recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 0000000..5760ee0
--- /dev/null
+++

b/recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch

Quoted 7 lines

recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch line 6

Quoted 7 lines
recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch new file +6 -0
@@ -0,0 +1,37 @@
+From a507b628a5a5d4e4f1cf0f0a9a72967470ee7624 Mon Sep 17 00:00:00 2001
+From: Brecht Sanders <[email protected]>
+Date: Fri, 3 Feb 2023 08:44:49 +0100
+Subject: [PATCH] Fix for compilation on Windows
+
+This fix allows the library to build on Windows (at least with

MinGW-w64).

Quoted 6 lines

recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch

Quoted 6 lines
recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch new file +6 -0
+
+`.symver` is only supported for ELF format but Windows uses COFF/PE.
+
+Workaround dummy define of `symver_set()`
+
+Upstream-Status: Backport [

https://github.com/besser82/libxcrypt/commit/a507b628a5a5d4e4f1cf0f0a9a72967470ee7624
]

Quoted 11 lines

recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch

Quoted 11 lines
recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch new file +11 -0
+
+Signed-off-by: Wenlin Kang <[email protected]>
+---
+ lib/crypt-port.h | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/crypt-port.h b/lib/crypt-port.h
+index f06ca24..a707939 100644
+--- a/lib/crypt-port.h
++++ b/lib/crypt-port.h
+@@ -201,6 +201,11 @@ extern size_t strcpy_or_abort (void *dst, size_t

d_size, const void *src);

Quoted 7 lines
Quoted 7 lines
recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch new file +7 -0
+   __asm__(".globl _" extstr);                           \
+   __asm__(".set _" extstr ", _" #intname)
+
++#elif defined _WIN32
++
++/* .symver is only supported for ELF format, Windows uses COFF/PE */
++# define symver_set(extstr, intname, version, mode)
Quoted 8 lines
Quoted 8 lines
recipes-core/libxcrypt/libxcrypt/0001-Fix-for-compilation-on-Windows.patch new file +7 -0
++
+ #elif defined __GNUC__ && __GNUC__ >= 3
+
+ # define _strong_alias(name, aliasname) \
+--
+2.34.1
+

diff --git

a/recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch b/recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 0000000..3846f76
--- /dev/null
+++

b/recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch

Quoted 5 lines

recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch line 4

Quoted 5 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +4 -0
@@ -0,0 +1,47 @@
+From ff99091eb8a6b9e6edc567f6d2552183fbaacec3 Mon Sep 17 00:00:00 2001
+From: Wenlin Kang <[email protected]>
+Date: Mon, 6 Nov 2023 14:43:28 +0800
+Subject: [PATCH] lib/util-get-random-bytes.c: fixed conversion error

with

Quoted 4 lines

recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch

Quoted 4 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +4 -0
+ mingw
+
+With x86_64-w64-mingw32-gcc. get below error:
+| ../git/lib/util-get-random-bytes.c: In function

'_crypt_get_random_bytes':

Quoted 1 line

Review line 9

Quoted 1 line
(quoted diff) +1 -0
+| ../git/lib/util-get-random-bytes.c:140:42: error: conversion from

'size_t' {aka 'long long unsigned int'} to 'unsigned int' may change value [-Werror=conversion]

Quoted 4 lines

recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch

Quoted 4 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +4 -0
+|   140 |           ssize_t nread = read (fd, buf, buflen);
+|       |                                          ^~~~~~
+
+In util-get-random-bytes.c, has get_random_bytes(void *buf, size_t

buflen),

Quoted 1 line

Review line 14

Quoted 1 line
(quoted diff) +1 -0
+but in mingw-w64-mingw-w64/mingw-w64-headers/crt/io.h, read() has

"unsigned int"

Quoted 1 line

Review line 15

Quoted 1 line
(quoted diff) +1 -0
+read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount), and

has:

Quoted 21 lines
Quoted 21 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +21 -0
+ #ifdef _WIN64
+   __MINGW_EXTENSION typedef unsigned __int64 size_t;
+ #else
+   typedef unsigned int size_t;
+ #endif /* _WIN64 */
+
+Upstream-Status: Pending
+
+Signed-off-by: Wenlin Kang <[email protected]>
+---
+ lib/util-get-random-bytes.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/lib/util-get-random-bytes.c b/lib/util-get-random-bytes.c
+index 79816db..68cd378 100644
+--- a/lib/util-get-random-bytes.c
++++ b/lib/util-get-random-bytes.c
+@@ -137,7 +137,11 @@ get_random_bytes(void *buf, size_t buflen)
+         dev_urandom_doesnt_work = true;
+       else
+         {
Quoted 8 lines

recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch line 41

Quoted 5 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +5 -0
++#ifdef _WIN64
++          ssize_t nread = read (fd, buf, (unsigned int)buflen);
++#else
+           ssize_t nread = read (fd, buf, buflen);
++#endif

read is system API and I wonder why we are not getting right API signature here as I think
size_t should already be defined based on _WIN64 in system headers.

Quoted 5 lines

1. read() is declared in

https://sourceforge.net/p/mingw-w64/code/HEAD/tree/trunk/mingw-w64-headers/crt/io.h,

but it has only a declaration for 32-bit, with 64-bit, it can't be found

Ok it will be good to bring this to upstream’s notice

Quoted 55 lines

2. for size_t, it has:

#ifdef _WIN64
   __MINGW_EXTENSION typedef __int64 ssize_t;
#else
   typedef int ssize_t;

#endif /* _WIN64 */

Quoted 8 lines

Review

Quoted 8 lines
recipes-core/libxcrypt/libxcrypt/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +6 -0
+           if (nread < 0 || (size_t)nread < buflen)
+             dev_urandom_doesnt_work = true;
+
+--
+2.25.1
+
(quoted diff) +0 -0

b/recipes-core/libxcrypt/libxcrypt_%.bbappend

Quoted 8 lines

recipes-core/libxcrypt/libxcrypt_%.bbappend line 3

Quoted 8 lines

new file mode 100644
index 0000000..cb9c45e

recipes-core/libxcrypt/libxcrypt_%.bbappend new file +3 -0
@@ -0,0 +1,7 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI:append:mingw32 =

"file://0001-Fix-for-compilation-on-Windows.patch \

Quoted 1 line

recipes-core/libxcrypt/libxcrypt_%.bbappend line 4

Quoted 1 line
recipes-core/libxcrypt/libxcrypt_%.bbappend new file +1 -0
+

file://0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch \

Quoted 11 lines
Quoted 11 lines
recipes-core/libxcrypt/libxcrypt_%.bbappend new file +3 -1
+"
+
+CFLAGS:append:class-nativesdk:mingw32 = " -Wno-pedantic"
--

2.39.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. You automatically follow any topics you start or reply to. View/Reply Online (#61775):

https://lists.yoctoproject.org/g/yocto/message/61775

Quoted 3 lines
Quoted 3 lines

Mute This Topic: https://lists.yoctoproject.org/mt/102890384/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [

[email protected]]

Quoted 2 lines
Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

--
--
Thanks
Wenlin Kang