summaryrefslogtreecommitdiff
path: root/pkgs/development/compilers/mkcl/default.nix
blob: f5466bf43c5927bc28f19192aa42a71d91f4e77d (plain)
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchpatch,
  makeWrapper,
  gmp,
  gcc,
}:

stdenv.mkDerivation rec {
  pname = "mkcl";
  version = "1.1.11";

  src = fetchFromGitHub {
    owner = "jcbeaudoin";
    repo = "mkcl";
    rev = "v${version}";
    sha256 = "0i2bfkda20lfypis6i4m7srfz6miyf66d8knp693d6sms73m2l26";
  };

  patches = [
    # "Array sys_siglist[] never was part of the public interface. Replace it with calls to psiginfo()."
    (fetchpatch {
      name = "sys_siglist.patch";
      url = "https://github.com/jcbeaudoin/MKCL/commit/0777dd08254c88676f4f101117b10786b22111d6.patch";
      sha256 = "1dnr1jzha77nrxs22mclrcqyqvxxn6q1sfn35qjs77fi3jcinjsc";
    })

    # Pull upstream fix for -fno-common toolchins like gcc-10
    (fetchpatch {
      name = "fno-common.patch";
      url = "https://gitlab.common-lisp.net/mkcl/mkcl/-/commit/ef1981dbf4ceb1793cd6434e66e97b3db48b4ea0.patch";
      sha256 = "00y6qanwvgb1r4haaqmvz7lbqa51l4wcnns1rwlfgvcvkpjc3dif";
    })
  ];

  nativeBuildInputs = [ makeWrapper ];

  propagatedBuildInputs = [ gmp ];

  hardeningDisable = [ "format" ];

  configureFlags = [
    "GMP_CFLAGS=-I${lib.getDev gmp}/include"
    "GMP_LDFLAGS=-L${gmp.out}/lib"
  ];

  # tinycc configure flags copied from the tinycc derivation.
  postConfigure = ''
    (
      cd contrib/tinycc;
      ./configure --cc=cc \
        --elfinterp=$(< $NIX_CC/nix-support/dynamic-linker) \
        --crtprefix=${lib.getLib stdenv.cc.libc}/lib \
        --sysincludepaths=${lib.getDev stdenv.cc.libc}/include:{B}/include \
        --libpaths=${lib.getLib stdenv.cc.libc}/lib
    )
  '';

  env = {
    NIX_CFLAGS_COMPILE = "-std=gnu17";
  };

  postInstall = ''
    wrapProgram $out/bin/mkcl --prefix PATH : "${gcc}/bin" --set-default LANG "C.UTF-8"
  '';

  enableParallelBuilding = true;

  meta = {
    broken = (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
    description = "ANSI Common Lisp Implementation";
    homepage = "https://common-lisp.net/project/mkcl/";
    license = lib.licenses.lgpl2Plus;
    mainProgram = "mkcl";
    teams = [ lib.teams.lisp ];
    platforms = lib.platforms.linux;
  };
}