cygwin: init as a target toolchain

The old cygwin support used -pc-windows-cygnus as the config. This is
supported by LLVM, but not by GNU. This will change it to -pc-cygwin,
which is more generally supported.

Because the kernel is now 'cygwin' rather than 'windows', isWindows will
return false. There are lots of different reasons isWindows is used in
nixpkgs, but in my experience they often have to do with posix
compatibility and don't apply to cygwin.

Co-authored-by: Brian McKenna <brian@brianmckenna.org>

Changed files
+31 -20
lib
+6 -3
lib/systems/default.nix
···
"ucrt"
else if final.isMinGW then
"msvcrt"
else if final.isWasi then
"wasilibc"
else if final.isWasm && !final.isWasi then
···
sharedLibrary =
if final.isDarwin then
".dylib"
-
else if final.isWindows then
".dll"
else
".so";
···
// {
staticLibrary = if final.isWindows then ".lib" else ".a";
library = if final.isStatic then final.extensions.staticLibrary else final.extensions.sharedLibrary;
-
executable = if final.isWindows then ".exe" else "";
};
# Misc boolean options
useAndroidPrebuilt = false;
···
{
linux = "Linux";
windows = "Windows";
darwin = "Darwin";
netbsd = "NetBSD";
freebsd = "FreeBSD";
···
"openbsd"
else if final.isSunOS then
"sunos"
-
else if final.isWindows then
"win32"
else
null;
···
"ucrt"
else if final.isMinGW then
"msvcrt"
+
else if final.isCygwin then
+
"cygwin"
else if final.isWasi then
"wasilibc"
else if final.isWasm && !final.isWasi then
···
sharedLibrary =
if final.isDarwin then
".dylib"
+
else if (final.isWindows || final.isCygwin) then
".dll"
else
".so";
···
// {
staticLibrary = if final.isWindows then ".lib" else ".a";
library = if final.isStatic then final.extensions.staticLibrary else final.extensions.sharedLibrary;
+
executable = if (final.isWindows || final.isCygwin) then ".exe" else "";
};
# Misc boolean options
useAndroidPrebuilt = false;
···
{
linux = "Linux";
windows = "Windows";
+
cygwin = "CYGWIN_NT";
darwin = "Darwin";
netbsd = "NetBSD";
freebsd = "FreeBSD";
···
"openbsd"
else if final.isSunOS then
"sunos"
+
else if (final.isWindows || final.isCygwin) then
"win32"
else
null;
+4
lib/systems/examples.nix
···
useLLVM = true;
};
# BSDs
aarch64-freebsd = {
···
useLLVM = true;
};
+
x86_64-cygwin = {
+
config = "x86_64-pc-cygwin";
+
};
+
# BSDs
aarch64-freebsd = {
+1 -2
lib/systems/inspect.nix
···
kernel = kernels.windows;
};
isCygwin = {
-
kernel = kernels.windows;
-
abi = abis.cygnus;
};
isMinGW = {
kernel = kernels.windows;
···
kernel = kernels.windows;
};
isCygwin = {
+
kernel = kernels.cygwin;
};
isMinGW = {
kernel = kernels.windows;
+19 -13
lib/systems/parse.nix
···
isLinux
isPower64
isWindows
;
inherit (lib.types)
···
execFormat = pe;
families = { };
};
ghcjs = {
execFormat = unknown;
families = { };
···
types.abi = enum (attrValues abis);
abis = setTypes types.openAbi {
-
cygnus = { };
msvc = { };
# Note: eabi is specific to ARM and PowerPC.
···
throw "system string '${lib.concatStringsSep "-" l}' with 1 component is ambiguous";
"2" = # We only do 2-part hacks for things Nix already supports
if elemAt l 1 == "cygwin" then
-
{
-
cpu = elemAt l 0;
-
kernel = "windows";
-
abi = "cygnus";
-
}
# MSVC ought to be the default ABI so this case isn't needed. But then it
# becomes difficult to handle the gnu* variants for Aarch32 correctly for
# minGW. So it's easier to make gnu* the default for the MinGW, but
···
else
elemAt l 2;
}
else
throw "system string '${lib.concatStringsSep "-" l}' with 3 components is ambiguous";
"4" = {
···
getVendor args.vendor
else if isDarwin parsed then
vendors.apple
-
else if isWindows parsed then
vendors.pc
else
vendors.unknown;
···
abi,
...
}:
-
if abi == abis.cygnus then
-
"${cpu.name}-cygwin"
-
else if kernel.families ? darwin then
-
"${cpu.name}-darwin"
-
else
-
"${cpu.name}-${kernelName kernel}";
tripleFromSystem =
{
···
isLinux
isPower64
isWindows
+
isCygwin
;
inherit (lib.types)
···
execFormat = pe;
families = { };
};
+
cygwin = {
+
execFormat = pe;
+
families = { };
+
};
ghcjs = {
execFormat = unknown;
families = { };
···
types.abi = enum (attrValues abis);
abis = setTypes types.openAbi {
msvc = { };
# Note: eabi is specific to ARM and PowerPC.
···
throw "system string '${lib.concatStringsSep "-" l}' with 1 component is ambiguous";
"2" = # We only do 2-part hacks for things Nix already supports
if elemAt l 1 == "cygwin" then
+
mkSkeletonFromList [
+
(elemAt l 0)
+
"pc"
+
"cygwin"
+
]
# MSVC ought to be the default ABI so this case isn't needed. But then it
# becomes difficult to handle the gnu* variants for Aarch32 correctly for
# minGW. So it's easier to make gnu* the default for the MinGW, but
···
else
elemAt l 2;
}
+
# lots of tools expect a triplet for Cygwin, even though the vendor is just "pc"
+
else if elemAt l 2 == "cygwin" then
+
{
+
cpu = elemAt l 0;
+
vendor = elemAt l 1;
+
kernel = "cygwin";
+
}
else
throw "system string '${lib.concatStringsSep "-" l}' with 3 components is ambiguous";
"4" = {
···
getVendor args.vendor
else if isDarwin parsed then
vendors.apple
+
else if (isWindows parsed || isCygwin parsed) then
vendors.pc
else
vendors.unknown;
···
abi,
...
}:
+
if kernel.families ? darwin then "${cpu.name}-darwin" else "${cpu.name}-${kernelName kernel}";
tripleFromSystem =
{
+1 -2
lib/tests/systems.nix
···
++ illumos
++ wasi
++ windows
++ embedded
++ mmix
++ js
···
"x86_64-openbsd"
];
testwindows = mseteq windows [
-
"i686-cygwin"
-
"x86_64-cygwin"
"aarch64-windows"
"i686-windows"
"x86_64-windows"
···
++ illumos
++ wasi
++ windows
+
++ cygwin
++ embedded
++ mmix
++ js
···
"x86_64-openbsd"
];
testwindows = mseteq windows [
"aarch64-windows"
"i686-windows"
"x86_64-windows"