Skip to contentSkip to conversation

libxcrypt: fixed some build error for nativesdk with mingw

PATCH New Kang Wenlin 1 participant 1 message Nov 21, 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 +++++++++++++++++++
 meta/recipes-core/libxcrypt/libxcrypt.inc     |  4 ++
 3 files changed, 88 insertions(+)
 create mode 100644 meta/recipes-core/libxcrypt/files/0001-Fix-for-compilation-on-Windows.patch
 create mode 100644 meta/recipes-core/libxcrypt/files/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch
meta/recipes-core/libxcrypt/files/0001-Fix-for-compilation-on-Windows.patch new file +37 -0
new file mode 100644
index 0000000000..5760ee09cc
@@ -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
+
meta/recipes-core/libxcrypt/files/0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch new file +47 -0

47 lines not on this page · raw message

meta/recipes-core/libxcrypt/libxcrypt.inc +4 -0
index 342cbd0d06..2b3cd31c2a 100644
@@ -16,6 +16,8 @@ SRCBRANCH ?= "master"
 SRC_URI += "file://fix_cflags_handling.patch \
     file://0001-Make-BuildCommon.pm-compatible-with-latest-perl.patch \
     file://0002-Remove-smartmatch-usage-from-gen-crypt-h.patch \
+    file://0001-Fix-for-compilation-on-Windows.patch \
+    file://0001-lib-util-get-random-bytes.c-fixed-conversion-error-w.patch \
 "
 
 PROVIDES = "virtual/crypt"
@@ -29,4 +31,6 @@ CPPFLAGS:append:class-nativesdk = " -Wno-error"
 API = "--disable-obsolete-api"
 EXTRA_OECONF += "${API}"
 
+CFLAGS:append:class-nativesdk = " -Wno-pedantic"
+
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.39.0