···
1
-
{ stdenv, fetchurl, unzip, makeWrapper }:
1
+
{ stdenv, fetchFromGitHub
2
+
, makeWrapper, unzip, which
3
-
stdenv.mkDerivation {
4
-
name = "dmd-2.067.1";
6
+
stdenv.mkDerivation rec {
7
+
name = "dmd-${version}";
8
+
# This is the last version of dmd which is buildable without a D compiler.
9
+
# So we use this as a bootstrap version.
10
+
# The DMD frontend has been ported to D in 2.069.0 but idgen was already
11
+
# ported in 2.068.0.
12
+
version = "2.067.1";
7
-
url = http://downloads.dlang.org/releases/2015/dmd.2.067.1.zip;
8
-
sha256 = "0ny99vfllvvgcl79pwisxcdnb3732i827k9zg8c0j4s0n79k5z94";
18
+
rev = "v${version}";
19
+
sha256 = "0fm29lg8axfmzdaj0y6vg70lhwb5d9rv4aavnvdd15xjschinlcz";
24
+
rev = "v${version}";
25
+
sha256 = "1n2qfw9kmnql0fk2nxikispqs7vh85nhvyyr00fk227n9lgnqf02";
30
+
rev = "v${version}";
31
+
sha256 = "0fywgds9xvjcgnqxmpwr67p3wi2m535619pvj159cgwv5y0nr3p1";
11
-
nativeBuildInputs = [ unzip makeWrapper ];
13
-
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
14
-
# Allow to use "clang++", commented in Makefile
15
-
substituteInPlace src/dmd/posix.mak \
16
-
--replace g++ clang++ \
17
-
--replace MACOSX_DEPLOYMENT_TARGET MACOSX_DEPLOYMENT_TARGET_
38
+
mv dmd-v${version}-src dmd
39
+
mv druntime-v${version}-src druntime
40
+
mv phobos-v${version}-src phobos
19
-
# Was not able to compile on darwin due to "__inline_isnanl"
21
-
substituteInPlace src/dmd/root/port.c --replace __inline_isnanl __inline_isnan
43
+
# Compile with PIC to prevent colliding modules with binutils 2.28.
44
+
# https://issues.dlang.org/show_bug.cgi?id=17375
48
+
# Ugly hack so the dlopen call has a chance to succeed.
49
+
# https://issues.dlang.org/show_bug.cgi?id=15391
50
+
substituteInPlace phobos/std/net/curl.d \
51
+
--replace libcurl.so ${curl.out}/lib/libcurl.so
53
+
# Ugly hack to fix the hardcoded path to zoneinfo in the source file.
54
+
# https://issues.dlang.org/show_bug.cgi?id=15391
55
+
substituteInPlace phobos/std/datetime.d \
56
+
--replace /usr/share/zoneinfo/ ${tzdata}/share/zoneinfo/
58
+
substituteInPlace druntime/test/shared/Makefile \
59
+
--replace "DFLAGS:=" "DFLAGS:=${usePIC} "
61
+
# phobos uses curl, so we need to patch the path to the lib.
62
+
substituteInPlace phobos/posix.mak \
63
+
--replace "-soname=libcurl.so.4" "-soname=${curl.out}/lib/libcurl.so.4"
65
+
# Use proper C++ compiler
66
+
substituteInPlace dmd/src/posix.mak \
23
-
+ stdenv.lib.optionalString stdenv.isLinux ''
24
-
substituteInPlace src/dmd/root/port.c \
70
+
+ stdenv.lib.optionalString stdenv.hostPlatform.isLinux ''
71
+
substituteInPlace dmd/src/root/port.c \
--replace "#include <bits/mathdef.h>" "#include <complex.h>"
75
+
+ stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
76
+
substituteInPlace dmd/src/posix.mak \
77
+
--replace MACOSX_DEPLOYMENT_TARGET MACOSX_DEPLOYMENT_TARGET_
79
+
# Was not able to compile on darwin due to "__inline_isnanl"
81
+
substituteInPlace dmd/src/root/port.c --replace __inline_isnanl __inline_isnan
84
+
nativeBuildInputs = [ makeWrapper unzip which ];
85
+
buildInputs = [ curl tzdata ];
# Buid and install are based on http://wiki.dlang.org/Building_DMD
make -f posix.mak INSTALL_DIR=$out
91
+
export DMD=$PWD/src/dmd
34
-
make -f posix.mak INSTALL_DIR=$out DMD=$DMD
93
+
make -f posix.mak PIC=${usePIC} INSTALL_DIR=$out DMD=$DMD
36
-
make -f posix.mak INSTALL_DIR=$out DMD=$DMD
95
+
make -f posix.mak PIC=${usePIC} INSTALL_DIR=$out DMD=$DMD
103
+
export DMD=$PWD/src/dmd
105
+
make -f posix.mak unittest PIC=${usePIC} DMD=$DMD BUILD=release
107
+
make -f posix.mak unittest PIC=${usePIC} DMD=$DMD BUILD=release
115
+
cp $PWD/src/dmd $out/bin
116
+
mkdir -p $out/share/man/man1
117
+
mkdir -p $out/share/man/man5
118
+
cp -r docs/man/man1/* $out/share/man/man1/
119
+
cp -r docs/man/man5/* $out/share/man/man5/
···
53
-
${let bits = if stdenv.is64bit then "64" else "32";
54
-
osname = if stdenv.isDarwin then "osx" else "linux"; in
55
-
"cp generated/${osname}/release/${bits}/libphobos2.a $out/lib"
129
+
let bits = builtins.toString stdenv.hostPlatform.parsed.cpu.bits;
130
+
osname = if stdenv.hostPlatform.isDarwin then "osx" else stdenv.hostPlatform.parsed.kernel.name;
131
+
extension = if stdenv.hostPlatform.isDarwin then "a" else "{a,so}"; in
132
+
"cp generated/${osname}/release/${bits}/libphobos2.${extension} $out/lib"
cp -r std $out/include/d2
···
68
-
DFLAGS=-I$out/include/d2 -L-L$out/lib ${stdenv.lib.optionalString (!stdenv.cc.isClang) "-L--no-warn-search-mismatch -L--export-dynamic"}
145
+
DFLAGS=-I$out/include/d2 -L-L$out/lib ${stdenv.lib.optionalString (!stdenv.cc.isClang) "-L--export-dynamic"} -fPIC
meta = with stdenv.lib; {
73
-
description = "D language compiler";
150
+
description = "Official reference compiler for the D language";
homepage = http://dlang.org/;
75
-
license = licenses.free; # parts under different licenses
152
+
# Everything is now Boost licensed, even the backend.
153
+
# https://github.com/dlang/dmd/pull/6680
154
+
license = licenses.boost;
platforms = platforms.unix;