Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cygwin: add as a cross-compilation target, and get bash.exe to compile #354137

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions pkgs/development/compilers/gcc/common/configure-flags.nix
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ let
# cc1: error: fp software completion requires '-mtrap-precision=i' [-Werror]
"--disable-werror"
]
++ lib.optionals targetPlatform.isCygwin [
# doesn't cross-compile under Cygwin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean "for Cygwin" (when running under some other platform)? Otherwise the check is wrong.

"--disable-libvtv"
]
;

in configureFlags
40 changes: 40 additions & 0 deletions pkgs/os-specific/windows/cygwin/headers.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
lib,
stdenvNoCC,
fetchFromGitHub,
fetchpatch,
mingw_w64_headers,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
pname = "cygwin-headers";
version = "3.5.4";

src = fetchFromGitHub {
owner = "mirror";
repo = "newlib-cygwin";
rev = "cygwin-${finalAttrs.version}";
hash = "sha256-ZfT6JhOXLCJOY0vSVz6aKShmtuTN9/0NZ1k1RMSZX4Q=";
};

patches = [
(fetchpatch {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a static file, so there's no need for patch normalization and fetchurl can be used.

url = "https://raw.githubusercontent.com/Windows-on-ARM-Experiments/mingw-woarm64-build/371102dfa23b3e56b6759e1a44026d0640d55223/patches/cygwin/0001-before-autogen.patch";
sha256 = "sha256-1JsbfYAPpsQSjknZcKfJOHA0RcdmgzkzAI4RcHG1kpA=";
})
];

dontConfigure = true;
dontBuild = true;

installPhase = ''
mkdir -p $out/include/
ln -s ${mingw_w64_headers}/include/w32api $out/include/
cp -r newlib/libc/include/* $out/include/
cp -r winsup/cygwin/include/* $out/include/
'';

meta = {
platforms = lib.platforms.windows;
};
Comment on lines +37 to +39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be folded to just meta.platforms but it might be good to fill in the rest of the typical metadata.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This had been marked as resolved but doesn't seem to have actually been?

})
1 change: 1 addition & 0 deletions pkgs/os-specific/windows/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lib.makeScope newScope (
dlfcn = callPackage ./dlfcn { };

w32api = callPackage ./w32api { };
cygwin_headers = callPackage ./cygwin/headers.nix { };

mingwrt = callPackage ./mingwrt { };
mingw_runtime = mingwrt;
Expand Down
2 changes: 2 additions & 0 deletions pkgs/os-specific/windows/mingw-w64/headers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ stdenvNoCC.mkDerivation (finalAttrs: {
cd mingw-w64-headers
'';

configureFlags = lib.optionals stdenvNoCC.targetPlatform.isCygwin [ "--enable-w32api" ];

meta = {
platforms = lib.platforms.windows;
};
Expand Down
1 change: 1 addition & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19546,6 +19546,7 @@ with pkgs;
preLibcCrossHeaders = let
inherit (stdenv.targetPlatform) libc;
in if stdenv.targetPlatform.isMinGW then targetPackages.windows.mingw_w64_headers or windows.mingw_w64_headers
else if stdenv.targetPlatform.isCygwin then targetPackages.windows.cygwin_headers or windows.cygwin_headers
else if libc == "nblibc" then targetPackages.netbsd.headers or netbsd.headers
else null;

Expand Down