Skip to content

Commit

Permalink
Revert "Merge pull request NixOS#25275 from Ericson2314/platform-norm…
Browse files Browse the repository at this point in the history
…alize"

This reverts commit 2282a57, reversing
changes made to 14adea9.

The lib tests are bloking nixpkgs-unstable, and I don't like debugging
it soon enough.
  • Loading branch information
vcunat committed May 6, 2017
1 parent 37a48c9 commit b70924b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion lib/systems/doubles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ in rec {
mips = filterDoubles (matchAttrs { cpu = { family = "mips"; }; });
x86_64 = filterDoubles parse.isx86_64;

cygwin = filterDoubles parse.isCygwin;
cygwin = filterDoubles (matchAttrs { kernel = parse.kernels.cygwin; });
darwin = filterDoubles parse.isDarwin;
freebsd = filterDoubles (matchAttrs { kernel = parse.kernels.freebsd; });
gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; }); # Should be better
Expand Down
58 changes: 26 additions & 32 deletions lib/systems/parse.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Define the list of system with their properties.
#
# 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.
# Define the list of system with their properties. Only systems tested for
# Nixpkgs are listed below

with import ../lists.nix;
with import ../types.nix;
Expand All @@ -13,7 +9,7 @@ let
lib = import ../default.nix;
setTypesAssert = type: pred:
mapAttrs (name: value:
assert pred value;
#assert pred value;
setType type ({ inherit name; } // value));
setTypes = type: setTypesAssert type (_: true);

Expand All @@ -27,6 +23,7 @@ rec {
littleEndian = {};
};


isCpuType = isType "cpu-type";
cpuTypes = with significantBytes; setTypesAssert "cpu-type"
(x: elem x.bits [8 16 32 64 128]
Expand All @@ -50,7 +47,6 @@ rec {
vendors = setTypes "vendor" {
apple = {};
pc = {};

unknown = {};
};

Expand All @@ -60,42 +56,41 @@ rec {
elf = {};
macho = {};
pe = {};

unknown = {};
};

isKernelFamily = isType "kernel-family";
kernelFamilies = setTypes "kernel-family" {
bsd = {};
unix = {};
windows-nt = {};
dos = {};
};

isKernel = x: isType "kernel" x;
kernels = with execFormats; with kernelFamilies; setTypesAssert "kernel"
(x: isExecFormat x.execFormat && all isKernelFamily (attrValues x.families))
{
cygwin = { execFormat = pe; families = { inherit /*unix*/ windows-nt; }; };
darwin = { execFormat = macho; families = { inherit unix; }; };
freebsd = { execFormat = elf; families = { inherit unix bsd; }; };
linux = { execFormat = elf; families = { inherit unix; }; };
netbsd = { execFormat = elf; families = { inherit unix bsd; }; };
none = { execFormat = unknown; families = { inherit unix; }; };
openbsd = { execFormat = elf; families = { inherit unix bsd; }; };
solaris = { execFormat = elf; families = { inherit unix; }; };
windows = { execFormat = pe; families = { }; };
} // { # aliases
win32 = kernels.windows;
win32 = { execFormat = pe; families = { inherit dos; }; };
};


isAbi = isType "abi";
abis = setTypes "abi" {
cygnus = {};
gnu = {};
msvc = {};
eabi = {};
androideabi = {};
gnueabi = {};
gnueabihf = {};

unknown = {};
};

Expand All @@ -114,25 +109,19 @@ rec {
isDarwin = matchAttrs { kernel = kernels.darwin; };
isLinux = matchAttrs { kernel = kernels.linux; };
isUnix = matchAttrs { kernel = { families = { inherit (kernelFamilies) unix; }; }; };
isWindows = matchAttrs { kernel = kernels.windows; };
isCygwin = matchAttrs { kernel = kernels.windows; abi = abis.cygnus; };
isMinGW = matchAttrs { kernel = kernels.windows; abi = abis.gnu; };
isWindows = s: matchAttrs { kernel = { families = { inherit (kernelFamilies) windows-nt; }; }; } s
|| matchAttrs { kernel = { families = { inherit (kernelFamilies) dos; }; }; } s;


mkSkeletonFromList = l: {
"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"; }
else { cpu = elemAt l 0; kernel = elemAt l 1; };
"2" = { cpu = elemAt l 0; kernel = elemAt l 1; };
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
"3" = # Awkwards hacks, beware!
if elemAt l 1 == "apple"
then { cpu = elemAt l 0; vendor = "apple"; kernel = elemAt l 2; }
else if (elemAt l 1 == "linux") || (elemAt l 2 == "gnu")
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";
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
}.${toString (length l)}
or (throw "system string has invalid number of hyphen-separated components");

Expand All @@ -145,10 +134,18 @@ rec {
, # Also inferred below
abi ? assert false; null
} @ args: let
getCpu = name: cpuTypes.${name} or (throw "Unknown CPU type: ${name}");
getVendor = name: vendors.${name} or (throw "Unknown vendor: ${name}");
getKernel = name: kernels.${name} or (throw "Unknown kernel: ${name}");
getAbi = name: abis.${name} or (throw "Unknown ABI: ${name}");
getCpu = name:
attrByPath [name] (throw "Unknown CPU type: ${name}")
cpuTypes;
getVendor = 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 {
cpu = getCpu args.cpu;
Expand All @@ -169,10 +166,7 @@ rec {

mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s));

doubleFromSystem = { cpu, vendor, kernel, abi, ... }:
if vendor == kernels.windows && abi == abis.cygnus
then "${cpu.name}-cygwin"
else "${cpu.name}-${kernel.name}";
doubleFromSystem = { cpu, vendor, kernel, abi, ... }: "${cpu.name}-${kernel.name}";

tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let
optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}";
Expand Down
3 changes: 3 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,9 @@ with pkgs;
cross = targetPlatform;
crossStageStatic = false;

# XXX: We have troubles cross-compiling libstdc++ on MinGW (see
# <http://hydra.nixos.org/build/4268232>), so don't even try.
langCC = targetPlatform.config != "i686-pc-mingw32";
# Why is this needed?
inherit (forcedNativePackages) binutils;
};
Expand Down
43 changes: 23 additions & 20 deletions pkgs/top-level/release-cross.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,12 @@ let
/* Basic list of packages to be natively built,
but need a crossSystem defined to get meaning */
basicNativeDrv = {
buildPackages.binutils = nativePlatforms;
buildPackages.gccCrossStageFinal = nativePlatforms;
buildPackages.gdbCross = nativePlatforms;
};

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

{
Expand Down Expand Up @@ -104,30 +89,48 @@ in
/* Test some cross builds on 32 bit mingw-w64 */
crossMingw32 = let
crossSystem = {
config = "i686-pc-mingw32";
config = "i686-w64-mingw32";
arch = "x86"; # Irrelevant
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
platform = {};
};
in mapTestOnCross crossSystem windows;
in mapTestOnCross crossSystem {
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 */
crossMingwW64 = let
crossSystem = {
# That's the triplet they use in the mingw-w64 docs.
config = "x86_64-pc-mingw32";
config = "x86_64-w64-mingw32";
arch = "x86_64"; # Irrelevant
libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
platform = {};
};
in mapTestOnCross crossSystem windows;
in mapTestOnCross crossSystem {
coreutils = nativePlatforms;
boehmgc = nativePlatforms;
gmp = nativePlatforms;
guile_1_8 = nativePlatforms;
libffi = nativePlatforms;
libtool = nativePlatforms;
libunistring = nativePlatforms;
windows.wxMSW = nativePlatforms;
};


/* Linux on the fuloong */
fuloongminipc = let
crossSystem = {
config = "mips64el-unknown-linux-gnu";
config = "mips64el-unknown-linux";
bigEndian = false;
arch = "mips";
float = "hard";
Expand Down

0 comments on commit b70924b

Please sign in to comment.