git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #44386 from srdqty/srd-update-mlton-compiler

mlton: refactor and adds mlton20180207Binary mlton20180207 mltonHEAD

commit0881a55f8137468a5256ec0178429ab54a409ee7 authorMatthew Bauer <mjbauer95@gmail.com> dateSun 14 Oct 2018, 16:56 (8 years ago) parent72128fcbb7ed2c
6 files changed+253−130
pkgs/development/compilers/mlton/20130715.nix+118 pkgs/development/compilers/mlton/20180207-binary.nix+57 pkgs/development/compilers/mlton/default.nix+21−129 pkgs/development/compilers/mlton/from-git-source.nix+35 pkgs/development/compilers/mlton/meta.nix+15 pkgs/top-level/all-packages.nix+7−1
pkgs/development/compilers/mlton/20130715.nixnew file+118
@@ -0,0 +1,118 @@
1+{ stdenv, fetchurl, patchelf, gmp }:
2+
3+let
4+ version = "20130715";
5+
6+ usr_prefix = if stdenv.isDarwin then "usr/local" else "usr";
7+
8+ dynamic_linker = stdenv.cc.bintools.dynamicLinker;
9+in
10+
11+stdenv.mkDerivation rec {
12+ name = "mlton-${version}";
13+
14+ binSrc =
15+ if stdenv.hostPlatform.system == "i686-linux" then (fetchurl {
16+ url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.x86-linux.tgz";
17+ sha256 = "1kxjjmnw4xk2d9hpvz43w9dvyhb3025k4zvjx785c33nrwkrdn4j";
18+ })
19+ else if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
20+ url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-linux.tgz";
21+ sha256 = "0fyhwxb4nmpirjbjcvk9f6w67gmn2gkz7xcgz0xbfih9kc015ygn";
22+ })
23+ else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl {
24+ url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-darwin.gmp-macports.tgz";
25+ sha256 = "044wnh9hhg6if886xy805683k0as347xd37r0r1yi4x7qlxzzgx9";
26+ })
27+ else throw "Architecture not supported";
28+
29+ codeSrc =
30+ fetchurl {
31+ url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}.src.tgz";
32+ sha256 = "0v1x2hrh9hiqkvnbq11kf34v4i5a2x0ffxbzqaa8skyl26nmfn11";
33+ };
34+
35+ srcs = [ binSrc codeSrc ];
36+
37+ sourceRoot = name;
38+
39+ buildInputs = [ gmp ];
40+ nativeBuildInputs = stdenv.lib.optional stdenv.isLinux patchelf;
41+
42+ makeFlags = [ "all-no-docs" ];
43+
44+ configurePhase = ''
45+ # Fix paths in the source.
46+ find . -type f | grep -v -e '\.tgz''$' | xargs sed -i "s@/usr/bin/env bash@$(type -p bash)@"
47+
48+ substituteInPlace $(pwd)/Makefile --replace '/bin/cp' $(type -p cp)
49+ substituteInPlace bin/mlton-script --replace gcc cc
50+ substituteInPlace bin/regression --replace gcc cc
51+ substituteInPlace lib/mlnlffi-lib/Makefile --replace gcc cc
52+ substituteInPlace mlnlffigen/gen-cppcmd --replace gcc cc
53+ substituteInPlace runtime/Makefile --replace gcc cc
54+ substituteInPlace ../${usr_prefix}/bin/mlton --replace gcc cc
55+
56+ # Fix paths in the binary distribution.
57+ BIN_DIST_DIR="$(pwd)/../${usr_prefix}"
58+ for f in "bin/mlton" "lib/mlton/platform" "lib/mlton/static-library" ; do
59+ substituteInPlace "$BIN_DIST_DIR/$f" --replace '/${usr_prefix}/bin/env bash' $(type -p bash)
60+ done
61+
62+ substituteInPlace $(pwd)/../${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $(pwd)/../${usr_prefix}/lib/mlton
63+ '' + stdenv.lib.optionalString stdenv.cc.isClang ''
64+ sed -i "s_ patch -s -p0 <gdtoa.hide-public-fns.patch_ patch -s -p0 <gdtoa.hide-public-fns.patch\n\tsed -i 's|printf(emptyfmt|printf(\"\"|g' ./gdtoa/arithchk.c_" ./runtime/Makefile
65+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
66+ sed -i 's|XCFLAGS += -I/usr/local/include -I/sw/include -I/opt/local/include||' ./runtime/Makefile
67+ '';
68+
69+ preBuild = ''
70+ # To build the source we have to put the binary distribution in the $PATH.
71+ export PATH="$PATH:$(pwd)/../${usr_prefix}/bin/"
72+
73+ # Let the builder execute the binary distribution.
74+ chmod u+x $(pwd)/../${usr_prefix}/bin/mllex
75+ chmod u+x $(pwd)/../${usr_prefix}/bin/mlyacc
76+ chmod u+x $(pwd)/../${usr_prefix}/bin/mlton
77+
78+ # So the builder runs the binary compiler with gmp.
79+ export LD_LIBRARY_PATH=${gmp.out}/lib:$LD_LIBRARY_PATH
80+
81+ '' + stdenv.lib.optionalString stdenv.isLinux ''
82+ # Patch ELF interpreter.
83+ patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile
84+ for e in mllex mlyacc ; do
85+ patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/bin/$e
86+ done
87+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
88+ # Patch libgmp linking
89+ install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile
90+ install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mlyacc
91+ install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mllex
92+ '';
93+
94+ doCheck = true;
95+
96+ installTargets = [ "install-no-docs" ];
97+
98+ postInstall = ''
99+ # Fix path to mlton libraries.
100+ substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $out/lib/mlton
101+
102+ # Path to libgmp.
103+ substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "-link-opt '-lm -lgmp'" "-link-opt '-lm -lgmp -L${gmp.out}/lib'"
104+
105+ # Path to gmp.h.
106+ substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "-cc-opt '-O1 -fno-common'" "-cc-opt '-O1 -fno-common -I${gmp.dev}/include'"
107+
108+ # Path to the same cc used in the build; needed at runtime.
109+ substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "gcc='gcc'" "gcc='"$(type -p cc)"'"
110+
111+ # Copy files to final positions.
112+ cp -r $(pwd)/install/${usr_prefix}/bin $out
113+ cp -r $(pwd)/install/${usr_prefix}/lib $out
114+ cp -r $(pwd)/install/${usr_prefix}/man $out
115+ '';
116+
117+ meta = import ./meta.nix;
118+}
pkgs/development/compilers/mlton/20180207-binary.nixnew file+57
@@ -0,0 +1,57 @@
1+{ stdenv, fetchurl, patchelf, gmp }:
2+let
3+ dynamic-linker = stdenv.cc.bintools.dynamicLinker;
4+in
5+stdenv.mkDerivation rec {
6+ name = "mlton-${version}";
7+ version = "20180207";
8+
9+ src = if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
10+ url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${name}-1.amd64-linux.tgz";
11+ sha256 = "0f4q575yfm5dpg4a2wsnqn4l2zrar96p6rlsk0dw10ggyfwvsjlf";
12+ })
13+ else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl {
14+ url = "https://github.com/MLton/mlton/releases/download/on-${version}-release/${name}-1.amd64-darwin.gmp-static.tgz";
15+ sha256 = "1cw7yhw48qp12q0adwf8srpjzrgkp84kmlkqw3pz8vkxz4p9hbdv";
16+ })
17+ else
18+ throw "Architecture not supported";
19+
20+ buildInputs = [ gmp ];
21+ nativeBuildInputs = stdenv.lib.optional stdenv.isLinux patchelf;
22+
23+ buildPhase = ''
24+ make update \
25+ CC="$(type -p cc)" \
26+ WITH_GMP_INC_DIR="${gmp.dev}/include" \
27+ WITH_GMP_LIB_DIR="${gmp}/lib"
28+ '';
29+
30+ installPhase = ''
31+ make install PREFIX=$out
32+ '';
33+
34+ postFixup = stdenv.lib.optionalString stdenv.isLinux ''
35+ patchelf --set-interpreter ${dynamic-linker} $out/lib/mlton/mlton-compile
36+ patchelf --set-rpath ${gmp}/lib $out/lib/mlton/mlton-compile
37+
38+ for e in mllex mlnlffigen mlprof mlyacc; do
39+ patchelf --set-interpreter ${dynamic-linker} $out/bin/$e
40+ patchelf --set-rpath ${gmp}/lib $out/bin/$e
41+ done
42+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
43+ install_name_tool -change \
44+ /opt/local/lib/libgmp.10.dylib \
45+ ${gmp}/lib/libgmp.10.dylib \
46+ $out/lib/mlton/mlton-compile
47+
48+ for e in mllex mlnlffigen mlprof mlyacc; do
49+ install_name_tool -change \
50+ /opt/local/lib/libgmp.10.dylib \
51+ ${gmp}/lib/libgmp.10.dylib \
52+ $out/bin/$e
53+ done
54+ '';
55+
56+ meta = import ./meta.nix;
57+}
pkgs/development/compilers/mlton/default.nix+21−129
@@ -1,134 +1,26 @@
1−{ stdenv, fetchurl, patchelf, gmp }:
2−
3−let
4− version = "20130715";
5−
6− usr_prefix = if stdenv.isDarwin then "usr/local" else "usr";
7−
8− dynamic_linker =
9− if stdenv.isx86_64 then "${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2"
10− else "${stdenv.glibc.out}/lib/ld-linux.so.2";
11−in
12−
13−stdenv.mkDerivation rec {
14− name = "mlton-${version}";
15−
16− binSrc =
17− if stdenv.hostPlatform.system == "i686-linux" then (fetchurl {
18− url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.x86-linux.tgz";
19− sha256 = "1kxjjmnw4xk2d9hpvz43w9dvyhb3025k4zvjx785c33nrwkrdn4j";
20− })
21− else if stdenv.hostPlatform.system == "x86_64-linux" then (fetchurl {
22− url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-linux.tgz";
23− sha256 = "0fyhwxb4nmpirjbjcvk9f6w67gmn2gkz7xcgz0xbfih9kc015ygn";
24− })
25− else if stdenv.hostPlatform.system == "x86_64-darwin" then (fetchurl {
26− url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}-1.amd64-darwin.gmp-macports.tgz";
27− sha256 = "044wnh9hhg6if886xy805683k0as347xd37r0r1yi4x7qlxzzgx9";
28− })
29− else throw "Architecture not supported";
30−
31− codeSrc =
32− fetchurl {
33− url = "mirror://sourceforge/project/mlton/mlton/${version}/${name}.src.tgz";
34− sha256 = "0v1x2hrh9hiqkvnbq11kf34v4i5a2x0ffxbzqaa8skyl26nmfn11";
35− };
36−
37− srcs = [ binSrc codeSrc ];
38−
39− sourceRoot = name;
40−
41− buildInputs = [ gmp ];
42− nativeBuildInputs = stdenv.lib.optional stdenv.isLinux patchelf;
43−
44− makeFlags = [ "all-no-docs" ];
45−
46− configurePhase = ''
47− # Fix paths in the source.
48− find . -type f | grep -v -e '\.tgz''$' | xargs sed -i "s@/usr/bin/env bash@$(type -p bash)@"
49−
50− substituteInPlace $(pwd)/Makefile --replace '/bin/cp' $(type -p cp)
51− substituteInPlace bin/mlton-script --replace gcc cc
52− substituteInPlace bin/regression --replace gcc cc
53− substituteInPlace lib/mlnlffi-lib/Makefile --replace gcc cc
54− substituteInPlace mlnlffigen/gen-cppcmd --replace gcc cc
55− substituteInPlace runtime/Makefile --replace gcc cc
56− substituteInPlace ../${usr_prefix}/bin/mlton --replace gcc cc
57−
58− # Fix paths in the binary distribution.
59− BIN_DIST_DIR="$(pwd)/../${usr_prefix}"
60− for f in "bin/mlton" "lib/mlton/platform" "lib/mlton/static-library" ; do
61− substituteInPlace "$BIN_DIST_DIR/$f" --replace '/${usr_prefix}/bin/env bash' $(type -p bash)
62− done
63−
64− substituteInPlace $(pwd)/../${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $(pwd)/../${usr_prefix}/lib/mlton
65− '' + stdenv.lib.optionalString stdenv.cc.isClang ''
66− sed -i "s_ patch -s -p0 <gdtoa.hide-public-fns.patch_ patch -s -p0 <gdtoa.hide-public-fns.patch\n\tsed -i 's|printf(emptyfmt|printf(\"\"|g' ./gdtoa/arithchk.c_" ./runtime/Makefile
67− '' + stdenv.lib.optionalString stdenv.isDarwin ''
68− sed -i 's|XCFLAGS += -I/usr/local/include -I/sw/include -I/opt/local/include||' ./runtime/Makefile
69− '';
70−
71− preBuild = ''
72− # To build the source we have to put the binary distribution in the $PATH.
73− export PATH="$PATH:$(pwd)/../${usr_prefix}/bin/"
74−
75− # Let the builder execute the binary distribution.
76− chmod u+x $(pwd)/../${usr_prefix}/bin/mllex
77− chmod u+x $(pwd)/../${usr_prefix}/bin/mlyacc
78− chmod u+x $(pwd)/../${usr_prefix}/bin/mlton
79−
80− # So the builder runs the binary compiler with gmp.
81− export LD_LIBRARY_PATH=${gmp.out}/lib:$LD_LIBRARY_PATH
82−
83− '' + stdenv.lib.optionalString stdenv.isLinux ''
84− # Patch ELF interpreter.
85− patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile
86− for e in mllex mlyacc ; do
87− patchelf --set-interpreter ${dynamic_linker} $(pwd)/../${usr_prefix}/bin/$e
88− done
89− '' + stdenv.lib.optionalString stdenv.isDarwin ''
90− # Patch libgmp linking
91− install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/lib/mlton/mlton-compile
92− install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mlyacc
93− install_name_tool -change /opt/local/lib/libgmp.10.dylib ${gmp}/lib/libgmp.10.dylib $(pwd)/../${usr_prefix}/bin/mllex
94− '';
95−
96− doCheck = true;
97−
98− installTargets = [ "install-no-docs" ];
99−
100− postInstall = ''
101− # Fix path to mlton libraries.
102− substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace '/${usr_prefix}/lib/mlton' $out/lib/mlton
103−
104− # Path to libgmp.
105− substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "-link-opt '-lm -lgmp'" "-link-opt '-lm -lgmp -L${gmp.out}/lib'"
106−
107− # Path to gmp.h.
108− substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "-cc-opt '-O1 -fno-common'" "-cc-opt '-O1 -fno-common -I${gmp.dev}/include'"
109−
110− # Path to the same cc used in the build; needed at runtime.
111− substituteInPlace $(pwd)/install/${usr_prefix}/bin/mlton --replace "gcc='gcc'" "gcc='"$(type -p cc)"'"
1+{ stdenv, fetchurl, fetchgit, patchelf, gmp }:
2+rec {
3+ mlton20130715 = import ./20130715.nix {
4+ inherit stdenv fetchurl patchelf gmp;
5+ };
1126
113− # Copy files to final positions.
114− cp -r $(pwd)/install/${usr_prefix}/bin $out
115− cp -r $(pwd)/install/${usr_prefix}/lib $out
116− cp -r $(pwd)/install/${usr_prefix}/man $out
117− '';
7+ mlton20180207Binary = import ./20180207-binary.nix {
8+ inherit stdenv fetchurl patchelf gmp;
9+ };
11810
119− meta = {
120− description = "Open-source, whole-program, optimizing Standard ML compiler";
121− longDescription = ''
122− MLton is an open source, whole-program optimizing compiler for the Standard ML programming language.
123− MLton aims to produce fast executables, and to encourage rapid prototyping and modular programming
124− by eliminating performance penalties often associated with the use of high-level language features.
125− MLton development began in 1997, and continues to this day with a growing worldwide community of
126− developers and users, who have helped to port MLton to a number of platforms.
127− Description taken from http://en.wikipedia.org/wiki/Mlton .
128− '';
11+ mlton20180207 = import ./from-git-source.nix {
12+ mltonBootstrap = mlton20180207Binary;
13+ version = "20180207";
14+ rev = "on-20180207-release";
15+ sha256 = "00rdd2di5x1dzac64il9z05m3fdzicjd3226wwjyynv631jj3q2a";
16+ inherit stdenv fetchgit gmp;
17+ };
12918
130− homepage = http://mlton.org/;
131− license = "bsd";
132− platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin"];
19+ mltonHEAD = import ./from-git-source.nix {
20+ mltonBootstrap = mlton20180207Binary;
21+ version = "HEAD";
22+ rev = "e149c9917cfbfe6aba5c986a958ed76d5cc6cfde";
23+ sha256 = "0a0j1i0f0fxw2my1309srq5j3vz0kawrrln01gxms2m5hy5dl50d";
24+ inherit stdenv fetchgit gmp;
13325 };
13426}
pkgs/development/compilers/mlton/from-git-source.nixnew file+35
@@ -0,0 +1,35 @@
1+{ fetchgit
2+, gmp
3+, mltonBootstrap
4+, url ? "https://github.com/mlton/mlton"
5+, rev
6+, sha256
7+, stdenv
8+, version
9+}:
10+
11+stdenv.mkDerivation {
12+ name = "mlton-${version}";
13+
14+ src = fetchgit {
15+ inherit url rev sha256;
16+ };
17+
18+ buildInputs = [mltonBootstrap gmp];
19+
20+ preBuild = ''
21+ find . -type f | grep -v -e '\.tgz''$' | xargs sed -i "s@/usr/bin/env bash@$(type -p bash)@"
22+
23+ makeFlagsArray=(
24+ MLTON_VERSION="${version} ${rev}"
25+ CC="$(type -p cc)"
26+ PREFIX="$out"
27+ WITH_GMP_INC_DIR="${gmp.dev}/include"
28+ WITH_GMP_LIB_DIR="${gmp}/lib"
29+ )
30+ '';
31+
32+ doCheck = true;
33+
34+ meta = import ./meta.nix;
35+}
pkgs/development/compilers/mlton/meta.nixnew file+15
@@ -0,0 +1,15 @@
1+{
2+ description = "Open-source, whole-program, optimizing Standard ML compiler";
3+ longDescription = ''
4+ MLton is an open source, whole-program optimizing compiler for the Standard ML programming language.
5+ MLton aims to produce fast executables, and to encourage rapid prototyping and modular programming
6+ by eliminating performance penalties often associated with the use of high-level language features.
7+ MLton development began in 1997, and continues to this day with a growing worldwide community of
8+ developers and users, who have helped to port MLton to a number of platforms.
9+ Description taken from http://en.wikipedia.org/wiki/Mlton .
10+ '';
11+
12+ homepage = http://mlton.org/;
13+ license = "bsd";
14+ platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin"];
15+}
pkgs/top-level/all-packages.nix+7−1
@@ -7174,7 +7174,13 @@ with pkgs;
71747174
71757175 mkcl = callPackage ../development/compilers/mkcl {};
71767176
7177− mlton = callPackage ../development/compilers/mlton { };
7177+ inherit (callPackage ../development/compilers/mlton {})
7178+ mlton20130715
7179+ mlton20180207Binary
7180+ mlton20180207
7181+ mltonHEAD;
7182+
7183+ mlton = mlton20180207;
71787184
71797185 mono = mono5;
71807186 mono5 = mono58;