about summary refs log tree commit diff
path: root/pkgs/development/compilers/julia/1.8.nix
blob: 1c614103bdece3e60d2c602c0b93f9494925783c (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
{ lib
, stdenv
, fetchurl
, fetchpatch
, which
, python3
, gfortran
, gcc
, cmake
, perl
, gnum4
, libwhich
, libxml2
, libunwind
, libgit2
, curl
, nghttp2
, mbedtls
, libssh2
, gmp
, mpfr
, suitesparse
, utf8proc
, zlib
, p7zip
, ncurses
, pcre2
}:

stdenv.mkDerivation rec {
  pname = "julia";
  version = "1.8.3";

  src = fetchurl {
    url = "https://github.com/JuliaLang/julia/releases/download/v${version}/julia-${version}-full.tar.gz";
    hash = "sha256-UraJWp1K0v422yYe6MTIzJISuDehL5MAL6r1N6IVH1A=";
  };

  patches =
    let
      path = name: "https://raw.githubusercontent.com/archlinux/svntogit-community/6fd126d089d44fdc875c363488a7c7435a223cec/trunk/${name}";
    in
    [
      # Pull upstream fix to fix tests mpfr-4.1.1
      #   https://github.com/JuliaLang/julia/pull/47659
      (fetchpatch {
        name = "mfr-4.1.1.patch";
        url = "https://github.com/JuliaLang/julia/commit/59965205ccbdffb4e25e1b60f651ca9df79230a4.patch";
        hash = "sha256-QJ5wxZMhz+or8BqcYv/5fNSTxDAvdSizTYqt7630kcw=";
        includes = [ "stdlib/MPFR_jll/test/runtests.jl" ];
      })

      (fetchurl {
        url = path "julia-hardcoded-libs.patch";
        sha256 = "sha256-kppSpVA7bRohd0wXDs4Jgct9ocHnpbeiiSz7ElFom1U=";
      })
      (fetchurl {
        url = path "julia-libunwind-1.6.patch";
        sha256 = "sha256-zqMh9+Fjgd15XuINe9Xtpk+bRTwB0T6WCWLrJyOQfiQ=";
      })
      ./patches/1.8/0001-skip-symlink-system-libraries.patch
      ./patches/1.8/0002-skip-building-doc.patch
      ./patches/1.8/0003-skip-failing-tests.patch
      ./patches/1.8/0004-ignore-absolute-path-when-loading-library.patch
    ];

  nativeBuildInputs = [
    which
    python3
    gfortran
    cmake
    perl
    gnum4
    libwhich
  ];

  buildInputs = [
    libxml2
    libunwind
    libgit2
    curl
    nghttp2
    mbedtls
    libssh2
    gmp
    mpfr
    utf8proc
    zlib
    p7zip
    pcre2
  ];

  JULIA_RPATH = lib.makeLibraryPath (buildInputs ++ [ stdenv.cc.cc gfortran.cc ncurses ]);

  dontUseCmakeConfigure = true;

  postPatch = ''
    patchShebangs .
  '';

  LDFLAGS = "-Wl,-rpath,${JULIA_RPATH}";

  makeFlags = [
    "prefix=$(out)"
    "USE_BINARYBUILDER=0"
    "USE_SYSTEM_CSL=1"
    "USE_SYSTEM_LLVM=0" # a patched version is required
    "USE_SYSTEM_LIBUNWIND=1"
    "USE_SYSTEM_PCRE=1"
    "USE_SYSTEM_LIBM=0"
    "USE_SYSTEM_OPENLIBM=0"
    "USE_SYSTEM_DSFMT=0" # not available in nixpkgs
    "USE_SYSTEM_LIBBLASTRAMPOLINE=0" # not available in nixpkgs
    "USE_SYSTEM_BLAS=0" # test failure
    "USE_SYSTEM_LAPACK=0" # test failure
    "USE_SYSTEM_GMP=1"
    "USE_SYSTEM_MPFR=1"
    "USE_SYSTEM_LIBSUITESPARSE=0" # test failure
    "USE_SYSTEM_LIBUV=0" # a patched version is required
    "USE_SYSTEM_UTF8PROC=1"
    "USE_SYSTEM_MBEDTLS=1"
    "USE_SYSTEM_LIBSSH2=1"
    "USE_SYSTEM_NGHTTP2=1"
    "USE_SYSTEM_CURL=1"
    "USE_SYSTEM_LIBGIT2=1"
    "USE_SYSTEM_PATCHELF=1"
    "USE_SYSTEM_LIBWHICH=1"
    "USE_SYSTEM_ZLIB=1"
    "USE_SYSTEM_P7ZIP=1"

    "PCRE_INCL_PATH=${pcre2.dev}/include/pcre2.h"
  ];

  doInstallCheck = true;
  installCheckTarget = "testall";

  preInstallCheck = ''
    export HOME="$TMPDIR"
    export JULIA_TEST_USE_MULTIPLE_WORKERS="true"
  '';

  dontStrip = true;

  postFixup = ''
    for file in $out/bin/julia $out/lib/libjulia.so $out/lib/julia/libjulia-internal.so $out/lib/julia/libjulia-codegen.so; do
      patchelf --set-rpath "$out/lib:$out/lib/julia:${JULIA_RPATH}" $file
    done
  '';

  enableParallelBuilding = true;

  meta = with lib; {
    description = "High-level performance-oriented dynamical language for technical computing";
    homepage = "https://julialang.org/";
    license = licenses.mit;
    maintainers = with maintainers; [ nickcao ];
    platforms = [ "x86_64-linux" "aarch64-linux" ];
  };
}