1{
2 lib,
3 stdenv,
4 version,
5 buildPackages,
6 targetPackages,
7 texinfo,
8 which,
9 gettext,
10 gnused,
11 patchelf,
12 gmp,
13 mpfr,
14 libmpc,
15 libucontext ? null,
16 libxcrypt ? null,
17 isSnapshot ? false,
18 isl ? null,
19 zlib ? null,
20 gnat-bootstrap ? null,
21 flex ? null,
22 perl ? null,
23 langAda ? false,
24 langGo ? false,
25 langRust ? false,
26 cargo,
27 withoutTargetLibc ? null,
28 threadsCross ? null,
29}:
30
31let
32 inherit (lib) optionals;
33 inherit (stdenv) buildPlatform hostPlatform targetPlatform;
34in
35
36{
37 # same for all gcc's
38 depsBuildBuild = [ buildPackages.stdenv.cc ];
39
40 nativeBuildInputs = [
41 texinfo
42 which
43 gettext
44 ]
45 ++ optionals (perl != null) [ perl ]
46 ++ optionals (with stdenv.targetPlatform; isVc4 || isRedox || isSnapshot && flex != null) [ flex ]
47 ++ optionals langAda [ gnat-bootstrap ]
48 ++ optionals langRust [ cargo ]
49 # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
50 # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
51 ++ optionals buildPlatform.isDarwin [ gnused ];
52
53 # For building runtime libs
54 # same for all gcc's
55 depsBuildTarget =
56 (
57 if lib.systems.equals hostPlatform buildPlatform then
58 [
59 targetPackages.stdenv.cc.bintools # newly-built gcc will be used
60 ]
61 else
62 assert lib.systems.equals targetPlatform hostPlatform;
63 [
64 # build != host == target
65 stdenv.cc
66 ]
67 )
68 ++ optionals targetPlatform.isLinux [ patchelf ];
69
70 buildInputs = [
71 gmp
72 mpfr
73 libmpc
74 libxcrypt
75 ]
76 ++ [
77 targetPackages.stdenv.cc.bintools # For linking code at run-time
78 ]
79 ++ optionals (isl != null) [ isl ]
80 ++ optionals (zlib != null) [ zlib ]
81 ++ optionals (langGo && stdenv.hostPlatform.isMusl) [ libucontext ];
82
83 depsTargetTarget = optionals (
84 !withoutTargetLibc && threadsCross != { } && threadsCross.package != null
85 ) [ threadsCross.package ];
86}