mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-31 06:31:20 +00:00
lib platform parsing: Fix windows
There is no more `cygwin` OS, but instead a `cygnus` abi. "win32" and "mingw32" parse as `windows`. Add a 3-part hack because autotools breaks on explicit abi with windows-like (e.g. "i686-pc-windows-gnu"). Also change cross triples to conform
This commit is contained in:
parent
7d546d7771
commit
fcde869e7e
@ -30,7 +30,7 @@ in rec {
|
|||||||
mips = filterDoubles (matchAttrs { cpu = { family = "mips"; }; });
|
mips = filterDoubles (matchAttrs { cpu = { family = "mips"; }; });
|
||||||
x86_64 = filterDoubles parse.isx86_64;
|
x86_64 = filterDoubles parse.isx86_64;
|
||||||
|
|
||||||
cygwin = filterDoubles (matchAttrs { kernel = parse.kernels.cygwin; });
|
cygwin = filterDoubles parse.isCygwin;
|
||||||
darwin = filterDoubles parse.isDarwin;
|
darwin = filterDoubles parse.isDarwin;
|
||||||
freebsd = filterDoubles (matchAttrs { kernel = parse.kernels.freebsd; });
|
freebsd = filterDoubles (matchAttrs { kernel = parse.kernels.freebsd; });
|
||||||
gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; }); # Should be better
|
gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; }); # Should be better
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Define the list of system with their properties. Only systems tested for
|
# Define the list of system with their properties.
|
||||||
# Nixpkgs are listed below
|
#
|
||||||
|
# See https://clang.llvm.org/docs/CrossCompilation.html and
|
||||||
|
# http://llvm.org/docs/doxygen/html/Triple_8cpp_source.html especially
|
||||||
|
# Triple::normalize. Parsing should essentially act as a more conservative
|
||||||
|
# version of that last function.
|
||||||
|
|
||||||
with import ../lists.nix;
|
with import ../lists.nix;
|
||||||
with import ../types.nix;
|
with import ../types.nix;
|
||||||
@ -23,7 +27,6 @@ rec {
|
|||||||
littleEndian = {};
|
littleEndian = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
isCpuType = isType "cpu-type";
|
isCpuType = isType "cpu-type";
|
||||||
cpuTypes = with significantBytes; setTypesAssert "cpu-type"
|
cpuTypes = with significantBytes; setTypesAssert "cpu-type"
|
||||||
(x: elem x.bits [8 16 32 64 128]
|
(x: elem x.bits [8 16 32 64 128]
|
||||||
@ -47,6 +50,7 @@ rec {
|
|||||||
vendors = setTypes "vendor" {
|
vendors = setTypes "vendor" {
|
||||||
apple = {};
|
apple = {};
|
||||||
pc = {};
|
pc = {};
|
||||||
|
|
||||||
unknown = {};
|
unknown = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -56,6 +60,7 @@ rec {
|
|||||||
elf = {};
|
elf = {};
|
||||||
macho = {};
|
macho = {};
|
||||||
pe = {};
|
pe = {};
|
||||||
|
|
||||||
unknown = {};
|
unknown = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,15 +68,12 @@ rec {
|
|||||||
kernelFamilies = setTypes "kernel-family" {
|
kernelFamilies = setTypes "kernel-family" {
|
||||||
bsd = {};
|
bsd = {};
|
||||||
unix = {};
|
unix = {};
|
||||||
windows-nt = {};
|
|
||||||
dos = {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
isKernel = x: isType "kernel" x;
|
isKernel = x: isType "kernel" x;
|
||||||
kernels = with execFormats; with kernelFamilies; setTypesAssert "kernel"
|
kernels = with execFormats; with kernelFamilies; setTypesAssert "kernel"
|
||||||
(x: isExecFormat x.execFormat && all isKernelFamily (attrValues x.families))
|
(x: isExecFormat x.execFormat && all isKernelFamily (attrValues x.families))
|
||||||
{
|
{
|
||||||
cygwin = { execFormat = pe; families = { inherit /*unix*/ windows-nt; }; };
|
|
||||||
darwin = { execFormat = macho; families = { inherit unix; }; };
|
darwin = { execFormat = macho; families = { inherit unix; }; };
|
||||||
freebsd = { execFormat = elf; families = { inherit unix bsd; }; };
|
freebsd = { execFormat = elf; families = { inherit unix bsd; }; };
|
||||||
linux = { execFormat = elf; families = { inherit unix; }; };
|
linux = { execFormat = elf; families = { inherit unix; }; };
|
||||||
@ -79,18 +81,21 @@ rec {
|
|||||||
none = { execFormat = unknown; families = { inherit unix; }; };
|
none = { execFormat = unknown; families = { inherit unix; }; };
|
||||||
openbsd = { execFormat = elf; families = { inherit unix bsd; }; };
|
openbsd = { execFormat = elf; families = { inherit unix bsd; }; };
|
||||||
solaris = { execFormat = elf; families = { inherit unix; }; };
|
solaris = { execFormat = elf; families = { inherit unix; }; };
|
||||||
win32 = { execFormat = pe; families = { inherit dos; }; };
|
windows = { execFormat = pe; families = { }; };
|
||||||
|
} // { # aliases
|
||||||
|
win32 = kernels.windows;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
isAbi = isType "abi";
|
isAbi = isType "abi";
|
||||||
abis = setTypes "abi" {
|
abis = setTypes "abi" {
|
||||||
|
cygnus = {};
|
||||||
gnu = {};
|
gnu = {};
|
||||||
msvc = {};
|
msvc = {};
|
||||||
eabi = {};
|
eabi = {};
|
||||||
androideabi = {};
|
androideabi = {};
|
||||||
gnueabi = {};
|
gnueabi = {};
|
||||||
gnueabihf = {};
|
gnueabihf = {};
|
||||||
|
|
||||||
unknown = {};
|
unknown = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -109,19 +114,25 @@ rec {
|
|||||||
isDarwin = matchAttrs { kernel = kernels.darwin; };
|
isDarwin = matchAttrs { kernel = kernels.darwin; };
|
||||||
isLinux = matchAttrs { kernel = kernels.linux; };
|
isLinux = matchAttrs { kernel = kernels.linux; };
|
||||||
isUnix = matchAttrs { kernel = { families = { inherit (kernelFamilies) unix; }; }; };
|
isUnix = matchAttrs { kernel = { families = { inherit (kernelFamilies) unix; }; }; };
|
||||||
isWindows = s: matchAttrs { kernel = { families = { inherit (kernelFamilies) windows-nt; }; }; } s
|
isWindows = matchAttrs { kernel = kernels.windows; };
|
||||||
|| matchAttrs { kernel = { families = { inherit (kernelFamilies) dos; }; }; } s;
|
isCygwin = matchAttrs { kernel = kernels.windows; abi = abis.cygnus; };
|
||||||
|
isMinGW = matchAttrs { kernel = kernels.windows; abi = abis.gnu; };
|
||||||
|
|
||||||
|
|
||||||
mkSkeletonFromList = l: {
|
mkSkeletonFromList = l: {
|
||||||
"2" = { cpu = elemAt l 0; kernel = elemAt l 1; };
|
"2" = # We only do 2-part hacks for things Nix already supports
|
||||||
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
|
if elemAt l 1 == "cygwin"
|
||||||
|
then { cpu = elemAt l 0; kernel = "windows"; abi = "cygnus"; }
|
||||||
|
else { cpu = elemAt l 0; kernel = elemAt l 1; };
|
||||||
"3" = # Awkwards hacks, beware!
|
"3" = # Awkwards hacks, beware!
|
||||||
if elemAt l 1 == "apple"
|
if elemAt l 1 == "apple"
|
||||||
then { cpu = elemAt l 0; vendor = "apple"; kernel = elemAt l 2; }
|
then { cpu = elemAt l 0; vendor = "apple"; kernel = elemAt l 2; }
|
||||||
else if (elemAt l 1 == "linux") || (elemAt l 2 == "gnu")
|
else if (elemAt l 1 == "linux") || (elemAt l 2 == "gnu")
|
||||||
then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; }
|
then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; }
|
||||||
|
else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window
|
||||||
|
then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; abi = "gnu"; }
|
||||||
else throw "Target specification with 3 components is ambiguous";
|
else throw "Target specification with 3 components is ambiguous";
|
||||||
|
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
|
||||||
}.${toString (length l)}
|
}.${toString (length l)}
|
||||||
or (throw "system string has invalid number of hyphen-separated components");
|
or (throw "system string has invalid number of hyphen-separated components");
|
||||||
|
|
||||||
@ -134,18 +145,10 @@ rec {
|
|||||||
, # Also inferred below
|
, # Also inferred below
|
||||||
abi ? assert false; null
|
abi ? assert false; null
|
||||||
} @ args: let
|
} @ args: let
|
||||||
getCpu = name:
|
getCpu = name: cpuTypes.${name} or (throw "Unknown CPU type: ${name}");
|
||||||
attrByPath [name] (throw "Unknown CPU type: ${name}")
|
getVendor = name: vendors.${name} or (throw "Unknown vendor: ${name}");
|
||||||
cpuTypes;
|
getKernel = name: kernels.${name} or (throw "Unknown kernel: ${name}");
|
||||||
getVendor = name:
|
getAbi = name: abis.${name} or (throw "Unknown ABI: ${name}");
|
||||||
attrByPath [name] (throw "Unknown vendor: ${name}")
|
|
||||||
vendors;
|
|
||||||
getKernel = name:
|
|
||||||
attrByPath [name] (throw "Unknown kernel: ${name}")
|
|
||||||
kernels;
|
|
||||||
getAbi = name:
|
|
||||||
attrByPath [name] (throw "Unknown ABI: ${name}")
|
|
||||||
abis;
|
|
||||||
|
|
||||||
system = rec {
|
system = rec {
|
||||||
cpu = getCpu args.cpu;
|
cpu = getCpu args.cpu;
|
||||||
@ -166,7 +169,10 @@ rec {
|
|||||||
|
|
||||||
mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
|
mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));
|
||||||
|
|
||||||
doubleFromSystem = { cpu, vendor, kernel, abi, ... }: "${cpu.name}-${kernel.name}";
|
doubleFromSystem = { cpu, vendor, kernel, abi, ... }:
|
||||||
|
if vendor == kernels.windows && abi == abis.cygnus
|
||||||
|
then "${cpu.name}-cygwin"
|
||||||
|
else "${cpu.name}-${kernel.name}";
|
||||||
|
|
||||||
tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let
|
tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let
|
||||||
optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}";
|
optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}";
|
||||||
|
@ -5010,7 +5010,8 @@ with pkgs;
|
|||||||
|
|
||||||
# XXX: We have troubles cross-compiling libstdc++ on MinGW (see
|
# XXX: We have troubles cross-compiling libstdc++ on MinGW (see
|
||||||
# <http://hydra.nixos.org/build/4268232>), so don't even try.
|
# <http://hydra.nixos.org/build/4268232>), so don't even try.
|
||||||
langCC = targetPlatform.config != "i686-pc-mingw32";
|
langCC = !(lib.systems.parse.isi686 targetPlatform.parsed &&
|
||||||
|
lib.systems.parse.isMinGW targetPlatform.parsed);
|
||||||
# Why is this needed?
|
# Why is this needed?
|
||||||
inherit (forcedNativePackages) binutils;
|
inherit (forcedNativePackages) binutils;
|
||||||
};
|
};
|
||||||
|
@ -20,12 +20,27 @@ let
|
|||||||
/* Basic list of packages to be natively built,
|
/* Basic list of packages to be natively built,
|
||||||
but need a crossSystem defined to get meaning */
|
but need a crossSystem defined to get meaning */
|
||||||
basicNativeDrv = {
|
basicNativeDrv = {
|
||||||
|
buildPackages.binutils = nativePlatforms;
|
||||||
buildPackages.gccCrossStageFinal = nativePlatforms;
|
buildPackages.gccCrossStageFinal = nativePlatforms;
|
||||||
buildPackages.gdbCross = nativePlatforms;
|
buildPackages.gdbCross = nativePlatforms;
|
||||||
};
|
};
|
||||||
|
|
||||||
basic = basicCrossDrv // basicNativeDrv;
|
basic = basicCrossDrv // basicNativeDrv;
|
||||||
|
|
||||||
|
windows = {
|
||||||
|
buildPackages.binutils = nativePlatforms;
|
||||||
|
buildPackages.gccCrossStageFinal = nativePlatforms;
|
||||||
|
|
||||||
|
coreutils = nativePlatforms;
|
||||||
|
boehmgc = nativePlatforms;
|
||||||
|
gmp = nativePlatforms;
|
||||||
|
guile_1_8 = nativePlatforms;
|
||||||
|
libffi = nativePlatforms;
|
||||||
|
libtool = nativePlatforms;
|
||||||
|
libunistring = nativePlatforms;
|
||||||
|
windows.wxMSW = nativePlatforms;
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -89,42 +104,24 @@ in
|
|||||||
/* Test some cross builds on 32 bit mingw-w64 */
|
/* Test some cross builds on 32 bit mingw-w64 */
|
||||||
crossMingw32 = let
|
crossMingw32 = let
|
||||||
crossSystem = {
|
crossSystem = {
|
||||||
config = "i686-w64-mingw32";
|
config = "i686-pc-mingw32";
|
||||||
arch = "x86"; # Irrelevant
|
arch = "x86"; # Irrelevant
|
||||||
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
|
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
|
||||||
platform = {};
|
platform = {};
|
||||||
};
|
};
|
||||||
in mapTestOnCross crossSystem {
|
in mapTestOnCross crossSystem windows;
|
||||||
coreutils = nativePlatforms;
|
|
||||||
boehmgc = nativePlatforms;
|
|
||||||
gmp = nativePlatforms;
|
|
||||||
guile_1_8 = nativePlatforms;
|
|
||||||
libffi = nativePlatforms;
|
|
||||||
libtool = nativePlatforms;
|
|
||||||
libunistring = nativePlatforms;
|
|
||||||
windows.wxMSW = nativePlatforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* Test some cross builds on 64 bit mingw-w64 */
|
/* Test some cross builds on 64 bit mingw-w64 */
|
||||||
crossMingwW64 = let
|
crossMingwW64 = let
|
||||||
crossSystem = {
|
crossSystem = {
|
||||||
# That's the triplet they use in the mingw-w64 docs.
|
# That's the triplet they use in the mingw-w64 docs.
|
||||||
config = "x86_64-w64-mingw32";
|
config = "x86_64-pc-mingw32";
|
||||||
arch = "x86_64"; # Irrelevant
|
arch = "x86_64"; # Irrelevant
|
||||||
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
|
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
|
||||||
platform = {};
|
platform = {};
|
||||||
};
|
};
|
||||||
in mapTestOnCross crossSystem {
|
in mapTestOnCross crossSystem windows;
|
||||||
coreutils = nativePlatforms;
|
|
||||||
boehmgc = nativePlatforms;
|
|
||||||
gmp = nativePlatforms;
|
|
||||||
guile_1_8 = nativePlatforms;
|
|
||||||
libffi = nativePlatforms;
|
|
||||||
libtool = nativePlatforms;
|
|
||||||
libunistring = nativePlatforms;
|
|
||||||
windows.wxMSW = nativePlatforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* Linux on the fuloong */
|
/* Linux on the fuloong */
|
||||||
|
Loading…
Reference in New Issue
Block a user