about summary refs log tree commit diff
path: root/pkgs/development/compilers/gcc/common/dependencies.nix
blob: fd9036c23ac6cfa3276aeb42f0c1ff7300642750 (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
{ lib
, stdenv
, version
, buildPackages
, targetPackages
, texinfo
, which
, gettext
, pkg-config ? null
, gnused
, patchelf
, gmp
, mpfr
, libmpc
, libucontext ? null
, libxcrypt ? null
, cloog ? null
, darwin ? null
, isl ? null
, zlib ? null
, gnat-bootstrap ? null
, flex ? null
, boehmgc ? null
, zip ? null
, unzip ? null
, gtk2 ? null
, libart_lgpl ? null
, perl ? null
, xlibs ? null
, langJava ? false
, javaAwtGtk ? false
, langAda ? false
, langGo ? false
, withoutTargetLibc ? null
, threadsCross ? null
}:

let
  inherit (lib) optionals;
  inherit (stdenv) buildPlatform hostPlatform targetPlatform;
in

{
  # same for all gcc's
  depsBuildBuild = [ buildPackages.stdenv.cc ];

  nativeBuildInputs = [
    texinfo
    which
    gettext
  ]
  ++ optionals (perl != null) [ perl ]
  ++ optionals javaAwtGtk [ pkg-config ]
  ++ optionals (with stdenv.targetPlatform; isVc4 || isRedox && flex != null) [ flex ]
  ++ optionals langAda [ gnat-bootstrap ]
  # The builder relies on GNU sed (for instance, Darwin's `sed' fails with
  # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it.
  ++ optionals buildPlatform.isDarwin [ gnused ]
  ;

  # For building runtime libs
  # same for all gcc's
  depsBuildTarget =
    (
      if hostPlatform == buildPlatform then [
        targetPackages.stdenv.cc.bintools # newly-built gcc will be used
      ] else assert targetPlatform == hostPlatform; [
        # build != host == target
        stdenv.cc
      ]
    )
    ++ optionals targetPlatform.isLinux [ patchelf ];

  buildInputs = [
    gmp
    mpfr
    libmpc
  ]
  ++ optionals (lib.versionAtLeast version "10") [ libxcrypt ]
  ++ [
    targetPackages.stdenv.cc.bintools # For linking code at run-time
  ]
  ++ optionals (lib.versionOlder version "5" && cloog != null) [ cloog ]
  ++ optionals (isl != null) [ isl ]
  ++ optionals (zlib != null) [ zlib ]
  ++ optionals langJava [ boehmgc zip unzip ]
  ++ optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)
  ++ optionals (langGo && stdenv.hostPlatform.isMusl) [ libucontext ]
  ++ optionals (lib.versionAtLeast version "14" && stdenv.hostPlatform.isDarwin) [ darwin.apple_sdk.frameworks.CoreServices ]
  ;

  # threadsCross.package after gcc6 so i assume its okay for 4.8 and 4.9 too
  depsTargetTarget = optionals (!withoutTargetLibc && threadsCross != { } && threadsCross.package != null) [ threadsCross.package ];
}