cygwin.newlib-cygwin{,-nobin}: init at 3.6.4

This commit is contained in:
David McFarland
2025-09-27 21:21:47 -03:00
parent 0db0ac301a
commit 1acd8658f0
7 changed files with 301 additions and 40 deletions
+4 -1
View File
@@ -17,6 +17,9 @@ makeScopeWithSplicing' {
w32api = callPackage ./w32api { };
w32api-headers = callPackage ./w32api { headersOnly = true; };
newlib-cygwin-headers = callPackage ./newlib-cygwin { };
newlib-cygwin = callPackage ./newlib-cygwin { };
# this is here to avoid symlinks being made to cygwin1.dll in /nix/store
newlib-cygwin-nobin = callPackage ./newlib-cygwin/nobin.nix { };
newlib-cygwin-headers = callPackage ./newlib-cygwin { headersOnly = true; };
};
}
+141 -38
View File
@@ -1,48 +1,151 @@
{
lib,
stdenv,
stdenvNoCC,
stdenvNoLibc,
autoreconfHook,
bison,
buildPackages,
fetchurl,
cocom-tool-set,
flex,
perl,
w32api,
w32api-headers,
headersOnly ? false,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "newlib-cygwin-headers";
version = "3.6.4";
(if headersOnly then stdenvNoCC else stdenvNoLibc).mkDerivation (
finalAttrs:
{
pname = "newlib-cygwin${lib.optionalString headersOnly "-headers"}";
version = "3.6.4";
src = buildPackages.fetchgit {
url = "https://cygwin.com/git/newlib-cygwin.git";
rev = "cygwin-${finalAttrs.version}";
hash = "sha256-+WYKwqcDAc7286GzbgKKAxNJCOf3AeNnF8XEVPoor+g=";
};
src = buildPackages.fetchgit {
url = "https://cygwin.com/git/newlib-cygwin.git";
rev = "cygwin-${finalAttrs.version}";
hash = "sha256-+WYKwqcDAc7286GzbgKKAxNJCOf3AeNnF8XEVPoor+g=";
};
patches = [
# newer versions of gcc don't like struct winsize being used before being
# declared.
./fix-winsize.patch
];
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/include/
cp -r newlib/libc/include/* $out/include/
cp -r winsup/cygwin/include/* $out/include/
'';
passthru.w32api = w32api-headers;
meta = {
homepage = "https://cygwin.com/";
description = "A DLL which provides substantial POSIX API functionality on Windows.";
license = with lib.licenses; [
# newlib
gpl2
# winsup
gpl3
outputs = [
"out"
]
++ lib.optionals (!headersOnly) [
"bin"
"dev"
"man"
];
platforms = lib.platforms.cygwin;
maintainers = [ lib.maintainers.corngood ];
};
})
patches = [
# Newer versions of gcc don't like struct winsize being used before being
# declared. Backport of https://cygwin.com/cgit/newlib-cygwin/commit/?id=73600d68227e125af24b7de7c3fccbd4eb66ee03
./fix-winsize.patch
]
# After cygwin hosted builds are working, we should upstream this
++ lib.optional (
!headersOnly && stdenvNoLibc.hostPlatform != stdenvNoLibc.buildPlatform
) ./fix-cross.patch;
passthru.w32api = if headersOnly then w32api-headers else w32api;
meta = {
homepage = "https://cygwin.com/";
description = "A DLL which provides substantial POSIX API functionality on Windows.";
license = with lib.licenses; [
# newlib
gpl2
# winsup
gpl3
];
platforms = lib.platforms.cygwin;
maintainers = [ lib.maintainers.corngood ];
};
}
// (
if headersOnly then
{
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/include/
cp -r newlib/libc/include/* $out/include/
cp -r winsup/cygwin/include/* $out/include/
'';
}
else
{
postPatch = ''
patchShebangs --build winsup/cygwin/scripts
'';
autoreconfFlags = [
"winsup"
]
# Only reconfigure root when fix-cross.patch is applied. Otherwise the
# autoconf version check will fail.
++ lib.optional (stdenvNoLibc.hostPlatform != stdenvNoLibc.buildPlatform) ".";
env =
let
libflag = "-Wl,-L${lib.getLib w32api}${w32api.libdir or "/lib/w32api"}";
in
{
CFLAGS_FOR_TARGET = toString [
libflag
];
CXXFLAGS_FOR_TARGET = toString [
"-Wno-error=register"
libflag
];
};
strictDeps = true;
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [
autoreconfHook
bison
cocom-tool-set
flex
perl
];
buildInputs = [ w32api ];
makeFlags = [
"tooldir=${placeholder "out"}"
];
enableParallelBuilding = true;
# this is explicitly -j1 in cygwin.cygport
# without it the install order is non-deterministic
enableParallelInstalling = false;
hardeningDisable = [
# conflicts with internal definition of 'bzero'
"fortify"
"stackprotector"
];
configurePlatforms = [
"build"
"target"
];
configureFlags = [
"--disable-shared"
"--disable-doc"
"--enable-static"
"--disable-dumper"
"--with-cross-bootstrap"
]
++ lib.optional (stdenvNoLibc.hostPlatform != stdenvNoLibc.buildPlatform) [
"ac_cv_prog_CC=gcc"
];
}
)
)
@@ -0,0 +1,55 @@
Disable strict autoconf version check so we can autoreconf in nixpkgs.
diff --git a/config/override.m4 b/config/override.m4
index 8b954d3cb..60c4cfd12 100644
--- a/config/override.m4
+++ b/config/override.m4
@@ -44,7 +44,6 @@ AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
[m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
])
m4_define([AC_INIT], m4_defn([AC_INIT])[
-_GCC_AUTOCONF_VERSION_CHECK
])
This is needed for target linking to find e.g. crt0.o.
diff --git a/configure.ac b/configure.ac
index 05ddf6987..f5bbd5c72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3166,7 +3166,7 @@ case " $target_configdirs " in
*" --with-newlib "*)
case "$target" in
*-cygwin*)
- FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -L$$r/$(TARGET_SUBDIR)/winsup/cygwin -isystem $$s/winsup/cygwin/include'
+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$$r/$(TARGET_SUBDIR)/winsup/cygwin -isystem $$s/winsup/cygwin/include'
;;
esac
Autoconf clears EXEEXT= in cross, which breaks installation of utils/cygserver.
AC_CHECK_LIB is disabled in cross after AC_NO_EXECUTABLES.
diff --git a/winsup/configure.ac b/winsup/configure.ac
index e7ac814b1..14b56e130 100644
--- a/winsup/configure.ac
+++ b/winsup/configure.ac
@@ -40,6 +40,8 @@ AM_PROG_AS
AC_LANG(C)
AC_LANG(C++)
+EXEEXT=.exe
+
AC_ARG_WITH([cross-bootstrap],[AS_HELP_STRING([--with-cross-bootstrap],[do not build programs using the MinGW toolchain or check for MinGW libraries (useful for bootstrapping a cross-compiler)])],[],[with_cross_bootstrap=no])
AC_CYGWIN_INCLUDES
@@ -135,8 +137,6 @@ AM_CONDITIONAL(BUILD_DUMPER, [test "x$build_dumper" = "xyes"])
# libbfd.a doesn't have a pkgconfig file, so we guess what it's dependencies
# are, based on what's present in the build environment
BFD_LIBS="-lintl -liconv -liberty -lz"
-AC_CHECK_LIB([sframe], [sframe_decode], [BFD_LIBS="${BFD_LIBS} -lsframe"])
-AC_CHECK_LIB([zstd], [ZSTD_isError], [BFD_LIBS="${BFD_LIBS} -lzstd"])
AC_SUBST([BFD_LIBS])
AC_CONFIG_FILES([
@@ -0,0 +1,9 @@
{
emptyDirectory,
newlib-cygwin,
}:
newlib-cygwin
// {
bin = emptyDirectory;
}
@@ -0,0 +1,88 @@
From cc95494ed527e64fcd1ade7ed7ae44f9e0a6fa8a Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Tue, 9 Sep 2025 15:04:45 -0300
Subject: [PATCH] remove definitions that conflict with mingw
---
winsup/cygwin/fhandler/socket_inet.cc | 2 ++
winsup/cygwin/fhandler/socket_local.cc | 2 ++
winsup/cygwin/local_includes/ntdll.h | 20 --------------------
winsup/cygwin/net.cc | 2 ++
4 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/winsup/cygwin/fhandler/socket_inet.cc b/winsup/cygwin/fhandler/socket_inet.cc
index 63cc498f1..03681c07b 100644
--- a/winsup/cygwin/fhandler/socket_inet.cc
+++ b/winsup/cygwin/fhandler/socket_inet.cc
@@ -20,7 +20,9 @@
#undef u_long
#define u_long __ms_u_long
#include <w32api/ws2tcpip.h>
+#define cmsghdr __ms_cmsghdr
#include <w32api/mswsock.h>
+#undef cmsghdr
#include <w32api/mstcpip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
diff --git a/winsup/cygwin/fhandler/socket_local.cc b/winsup/cygwin/fhandler/socket_local.cc
index e4a88169b..b832d8a84 100644
--- a/winsup/cygwin/fhandler/socket_local.cc
+++ b/winsup/cygwin/fhandler/socket_local.cc
@@ -21,7 +21,9 @@
#define u_long __ms_u_long
#include "ntsecapi.h"
#include <w32api/ws2tcpip.h>
+#define cmsghdr __ms_cmsghdr
#include <w32api/mswsock.h>
+#undef cmsghdr
#include <unistd.h>
#include <asm/byteorder.h>
#include <sys/socket.h>
diff --git a/winsup/cygwin/local_includes/ntdll.h b/winsup/cygwin/local_includes/ntdll.h
index 4497fe53f..bf86a8293 100644
--- a/winsup/cygwin/local_includes/ntdll.h
+++ b/winsup/cygwin/local_includes/ntdll.h
@@ -489,26 +489,6 @@ typedef struct _FILE_DISPOSITION_INFORMATION_EX // 64
ULONG Flags;
} FILE_DISPOSITION_INFORMATION_EX, *PFILE_DISPOSITION_INFORMATION_EX;
-typedef struct _FILE_STAT_INFORMATION // 68
-{
- LARGE_INTEGER FileId;
- LARGE_INTEGER CreationTime;
- LARGE_INTEGER LastAccessTime;
- LARGE_INTEGER LastWriteTime;
- LARGE_INTEGER ChangeTime;
- LARGE_INTEGER AllocationSize;
- LARGE_INTEGER EndOfFile;
- ULONG FileAttributes;
- ULONG ReparseTag;
- ULONG NumberOfLinks;
- ACCESS_MASK EffectiveAccess;
-} FILE_STAT_INFORMATION, *PFILE_STAT_INFORMATION;
-
-typedef struct _FILE_CASE_SENSITIVE_INFORMATION // 71
-{
- ULONG Flags;
-} FILE_CASE_SENSITIVE_INFORMATION, *PFILE_CASE_SENSITIVE_INFORMATION;
-
enum {
FILE_LINK_REPLACE_IF_EXISTS = 0x01,
FILE_LINK_POSIX_SEMANTICS = 0x02,
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 737e494f8..6a1a0d079 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -18,7 +18,9 @@ details. */
#undef u_long
#define u_long __ms_u_long
#include <w32api/ws2tcpip.h>
+#define cmsghdr __ms_cmsghdr
#include <w32api/mswsock.h>
+#undef cmsghdr
#include <w32api/iphlpapi.h>
#define gethostname cygwin_gethostname
#include <unistd.h>
--
2.50.1
+1
View File
@@ -7,6 +7,7 @@
newScope,
overrideCC,
stdenvNoLibc,
emptyDirectory,
}:
lib.makeScope newScope (
+3 -1
View File
@@ -4867,7 +4867,7 @@ with pkgs;
isl = if !stdenv.hostPlatform.isDarwin then isl_0_20 else null;
withoutTargetLibc = true;
langCC = false;
langCC = stdenv.targetPlatform.isCygwin; # can't compile libcygwin1.a without C++
libcCross = libc1;
targetPackages.stdenv.cc.bintools = binutilsNoLibc;
enableShared =
@@ -7632,6 +7632,8 @@ with pkgs;
if stdenv.hostPlatform.isMinGW then windows.mingw_w64 else windows.sdk
else if libc == "ucrt" then
if stdenv.hostPlatform.isMinGW then windows.mingw_w64 else windows.sdk
else if libc == "cygwin" then
cygwin.newlib-cygwin-nobin
else if libc == "libSystem" then
if stdenv.hostPlatform.useiOSPrebuilt then darwin.iosSdkPkgs.libraries else darwin.libSystem
else if libc == "fblibc" then