summary refs log tree commit diff
path: root/pkgs/development/compilers/coreclr/default.nix
blob: 558cfa35adad8a8ec5ec8f5e084fa294a60f3301 (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
{ stdenv
, fetchFromGitHub
, which
, cmake
, clang
, llvmPackages
, libunwind
, gettext
, openssl
, python2
, icu
, lttng-ust
, liburcu
, libuuid
, ed
, debug ? false
}:

stdenv.mkDerivation rec {
  name = "coreclr-${version}";
  version = "1.0.4";

  src = fetchFromGitHub {
    owner  = "dotnet";
    repo   = "coreclr";
    rev    = "v${version}";
    sha256 = "1wpig71q0kh2yrq162d32x00zlwrrs1wymkgijh49cqkn4cwkh91";
  };

  buildInputs = [
    which
    cmake
    clang
    llvmPackages.llvm
    llvmPackages.lldb
    libunwind
    gettext
    openssl
    python2
    icu
    lttng-ust
    liburcu
    libuuid
    ed
  ];

  configurePhase = ''
    # Prevent clang-3.5 (rather than just clang) from being selected as the compiler as that's
    # not wrapped
    # substituteInPlace src/pal/tools/gen-buildsys-clang.sh --replace "which \"clang-\$" "which \"clang-DoNotFindThisOne\$"

    patchShebangs build.sh
    patchShebangs src/pal/tools/gen-buildsys-clang.sh

    # See https://github.com/dotnet/coreclr/issues/7573#issuecomment-253081323
    ed -v ./src/pal/src/include/pal/palinternal.h << EOF
    /^#undef memcpy
    -1
    d
    +1
    d
    w
    EOF
  '';

  BuildArch = if stdenv.is64bit then "x64" else "x86";
  BuildType = if debug then "Debug" else "Release";

  hardeningDisable = [ "strictoverflow" "format" ];
  NIX_CFLAGS_COMPILE = [
    "-Wno-error=unused-result" "-Wno-error=delete-non-virtual-dtor"
    "-Wno-error=null-dereference"
  ];

  buildPhase = ''
    ./build.sh $BuildArch $BuildType

    # Try to make some sensible hierarchy out of the output
    pushd bin/Product/Linux.$BuildArch.$BuildType
    mkdir lib2
    mv *.so *.so.dbg lib2
    mv bin lib3
    mkdir lib4
    mv Loader lib4
    mv inc include
    mv gcinfo include
    mkdir bin
    mkdir -p share/doc
    mv sosdocsunix.txt share/doc
    for f in * ; do test -f $f && mv -v $f bin; done
    popd
  '';

  installPhase = ''
    mkdir -p $out
    cp -rv bin/Product/Linux.$BuildArch.$BuildType/* $out
  '';

  meta = {
    homepage = http://dotnet.github.io/core/;
    description = ".NET is a general purpose development platform";
    platforms = [ "x86_64-linux" ];
    maintainers = with stdenv.lib.maintainers; [ obadz ];
    license = stdenv.lib.licenses.mit;
  };
}