libxcrypt: fix cygwin build

This commit is contained in:
David McFarland
2025-09-29 16:00:59 -03:00
parent be8c8ea769
commit 56917caa5b
2 changed files with 35 additions and 2 deletions

View File

@@ -2,6 +2,7 @@
lib,
stdenv,
fetchurl,
fetchpatch,
perl,
# Update the enabled crypt scheme ids in passthru when the enabled hashes change
enableHashes ? "strong",
@@ -19,6 +20,11 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-cVE6McAaQovM1TZ6Mv2V8RXW2sUPtbYMd51ceUKuwHE=";
};
patches = [
# https://github.com/besser82/libxcrypt/pull/221
./fix-symver-on-non-elf.patch
];
# this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion
# necessary for FreeBSD code path in configure
postPatch = ''
@@ -36,7 +42,8 @@ stdenv.mkDerivation (finalAttrs: {
"--disable-failure-tokens"
# required for musl, android, march=native
"--disable-werror"
];
]
++ lib.optional stdenv.hostPlatform.isCygwin "--disable-symvers";
makeFlags =
let
@@ -44,7 +51,7 @@ stdenv.mkDerivation (finalAttrs: {
in
[ ]
# fixes: can't build x86_64-w64-mingw32 shared library unless -no-undefined is specified
++ lib.optionals stdenv.hostPlatform.isWindows [ "LDFLAGS+=-no-undefined" ]
++ lib.optionals stdenv.hostPlatform.isPE [ "LDFLAGS+=-no-undefined" ]
# lld 17 sets `--no-undefined-version` by default and `libxcrypt`'s
# version script unconditionally lists legacy compatibility symbols, even

View File

@@ -0,0 +1,26 @@
From 2806cc84abb7bf6aa9d9ff062944d664ab644127 Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Fri, 2 Jan 2026 13:09:02 -0400
Subject: [PATCH] Fix compilation on Cygwin
Cygwin uses COFF like Windows, so it needs the symver stub.
---
lib/crypt-port.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/crypt-port.h b/lib/crypt-port.h
index 23c7efa..0c90ade 100644
--- a/lib/crypt-port.h
+++ b/lib/crypt-port.h
@@ -205,7 +205,7 @@ 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
+#elif defined _WIN32 || defined __CYGWIN__
/* .symver is only supported for ELF format, Windows uses COFF/PE */
# define symver_set(extstr, intname, version, mode)
--
2.51.2