summary refs log tree commit diff
path: root/pkgs/top-level/release-cross.nix
blob: f582bcf3b3234d239f007cbaf051125195fcc234 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
{ # The platforms for which we build Nixpkgs.
  supportedSystems ? [ builtins.currentSystem ]
, # Strip most of attributes when evaluating to spare memory usage
  scrubJobs ? true
}:

with import ./release-lib.nix { inherit supportedSystems scrubJobs; };

let
  inherit (pkgs) lib;

  nativePlatforms = linux;

  /* Basic list of packages to cross-build */
  basicCrossDrv = {
    gccCrossStageFinal = nativePlatforms;
    bison.crossDrv = nativePlatforms;
    busybox.crossDrv = nativePlatforms;
    coreutils.crossDrv = nativePlatforms;
    dropbear.crossDrv = nativePlatforms;
  };

  /* Basic list of packages to be natively built,
     but need a crossSystem defined to get meaning */
  basicNativeDrv = {
    gdbCross.nativeDrv = nativePlatforms;
  };

  basic = basicCrossDrv // basicNativeDrv;

in

{
  # These `nativeDrv`s should be identical to their vanilla ones --- cross
  # compiling should not affect the native derivation.
  ensureUnaffected = let
    # Absurd values are fine here, as we are not building anything. In fact,
    # there probably a good idea to try to be "more parametric" --- i.e. avoid
    # any special casing.
    crossSystem = {
      config = "foosys";
      libc = "foolibc";
    };

    # Converting to a string (drv path) before checking equality is probably a
    # good idea lest there be some irrelevant pass-through debug attrs that
    # cause false negatives.
    testEqualOne = path: system: let
      f = attrs: builtins.toString (lib.getAttrFromPath path (allPackages attrs));
    in assert f { inherit system; } == f { inherit system crossSystem; }; true;

    testEqual = path: systems: forAllSupportedSystems systems (testEqualOne path);

    mapTestEqual = lib.mapAttrsRecursive testEqual;

  in mapTestEqual {
    boehmgc = nativePlatforms;
    libffi = nativePlatforms;
    libiconv = nativePlatforms;
    libtool = nativePlatforms;
    zlib = nativePlatforms;
    readline = nativePlatforms;
    libxml2 = nativePlatforms;
    guile = nativePlatforms;
  };


  /* Test some cross builds to the Sheevaplug */
  crossSheevaplugLinux = let
    crossSystem = {
      config = "armv5tel-unknown-linux-gnueabi";
      bigEndian = false;
      arch = "arm";
      float = "soft";
      withTLS = true;
      platform = pkgs.platforms.sheevaplug;
      libc = "glibc";
      openssl.system = "linux-generic32";
    };
  in mapTestOnCross crossSystem (basic // {
    ubootSheevaplug.crossDrv = nativePlatforms;
  });


  /* Test some cross builds on 32 bit mingw-w64 */
  crossMingw32 = let
    crossSystem = {
      config = "i686-w64-mingw32";
      arch = "x86"; # Irrelevant
      libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
      platform = {};
    };
  in mapTestOnCross crossSystem {
    coreutils.crossDrv = nativePlatforms;
    boehmgc.crossDrv = nativePlatforms;
    gmp.crossDrv = nativePlatforms;
    guile_1_8.crossDrv = nativePlatforms;
    libffi.crossDrv = nativePlatforms;
    libtool.crossDrv = nativePlatforms;
    libunistring.crossDrv = nativePlatforms;
    windows.wxMSW.crossDrv = 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-w64-mingw32";
      arch = "x86_64"; # Irrelevant
      libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
      platform = {};
    };
  in mapTestOnCross crossSystem {
    coreutils.crossDrv = nativePlatforms;
    boehmgc.crossDrv = nativePlatforms;
    gmp.crossDrv = nativePlatforms;
    guile_1_8.crossDrv = nativePlatforms;
    libffi.crossDrv = nativePlatforms;
    libtool.crossDrv = nativePlatforms;
    libunistring.crossDrv = nativePlatforms;
    windows.wxMSW.crossDrv = nativePlatforms;
  };


  /* Linux on the fuloong */
  fuloongminipc = let
    crossSystem = {
      config = "mips64el-unknown-linux";
      bigEndian = false;
      arch = "mips";
      float = "hard";
      withTLS = true;
      libc = "glibc";
      platform = {
        name = "fuloong-minipc";
        kernelMajor = "2.6";
        kernelBaseConfig = "lemote2f_defconfig";
        kernelHeadersBaseConfig = "fuloong2e_defconfig";
        uboot = null;
        kernelArch = "mips";
        kernelAutoModules = false;
        kernelTarget = "vmlinux";
      };
      openssl.system = "linux-generic32";
      gcc = {
        arch = "loongson2f";
        abi = "n32";
      };
    };
  in mapTestOnCross crossSystem {
    coreutils.crossDrv = nativePlatforms;
    ed.crossDrv = nativePlatforms;
    patch.crossDrv = nativePlatforms;
  };


  /* Linux on Raspberrypi */
  rpi = let
    crossSystem = {
      config = "armv6l-unknown-linux-gnueabi";
      bigEndian = false;
      arch = "arm";
      float = "hard";
      fpu = "vfp";
      withTLS = true;
      libc = "glibc";
      platform = pkgs.platforms.raspberrypi;
      openssl.system = "linux-generic32";
      gcc = {
        arch = "armv6";
        fpu = "vfp";
        float = "softfp";
        abi = "aapcs-linux";
      };
    };
  in mapTestOnCross crossSystem {
    coreutils.crossDrv = nativePlatforms;
    ed.crossDrv = nativePlatforms;
    patch.crossDrv = nativePlatforms;
    vim.crossDrv = nativePlatforms;
    unzip.crossDrv = nativePlatforms;
    ddrescue.crossDrv = nativePlatforms;
    lynx.crossDrv = nativePlatforms;
    patchelf.crossDrv = nativePlatforms;
    binutils.crossDrv = nativePlatforms;
    mpg123.crossDrv = nativePlatforms;
  };


  /* Cross-built bootstrap tools for every supported platform */
  bootstrapTools = let
    tools = import ../stdenv/linux/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
    maintainers = [ lib.maintainers.dezgeg ];
    mkBootstrapToolsJob = drv: hydraJob' (lib.addMetaAttrs { inherit maintainers; } drv);
  in lib.mapAttrsRecursiveCond (as: !lib.isDerivation as) (name: mkBootstrapToolsJob) tools;
}