lol

Merge pull request #27743 from ThomasMader/master

Updating, fixing and improving dmd

authored by

Frederik Rietdijk and committed by
GitHub
1eb48d3b 4c623b3d

+222 -58
+112 -32
pkgs/development/compilers/dmd/2.067.1.nix
··· 1 - { stdenv, fetchurl, unzip, makeWrapper }: 1 + { stdenv, fetchFromGitHub 2 + , makeWrapper, unzip, which 3 + , curl, tzdata 4 + }: 2 5 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"; 5 13 6 - src = fetchurl { 7 - url = http://downloads.dlang.org/releases/2015/dmd.2.067.1.zip; 8 - sha256 = "0ny99vfllvvgcl79pwisxcdnb3732i827k9zg8c0j4s0n79k5z94"; 9 - }; 14 + srcs = [ 15 + (fetchFromGitHub { 16 + owner = "dlang"; 17 + repo = "dmd"; 18 + rev = "v${version}"; 19 + sha256 = "0fm29lg8axfmzdaj0y6vg70lhwb5d9rv4aavnvdd15xjschinlcz"; 20 + }) 21 + (fetchFromGitHub { 22 + owner = "dlang"; 23 + repo = "druntime"; 24 + rev = "v${version}"; 25 + sha256 = "1n2qfw9kmnql0fk2nxikispqs7vh85nhvyyr00fk227n9lgnqf02"; 26 + }) 27 + (fetchFromGitHub { 28 + owner = "dlang"; 29 + repo = "phobos"; 30 + rev = "v${version}"; 31 + sha256 = "0fywgds9xvjcgnqxmpwr67p3wi2m535619pvj159cgwv5y0nr3p1"; 32 + }) 33 + ]; 10 34 11 - nativeBuildInputs = [ unzip makeWrapper ]; 35 + sourceRoot = "."; 12 36 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_ 37 + postUnpack = '' 38 + mv dmd-v${version}-src dmd 39 + mv druntime-v${version}-src druntime 40 + mv phobos-v${version}-src phobos 41 + ''; 18 42 19 - # Was not able to compile on darwin due to "__inline_isnanl" 20 - # being undefined. 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 45 + usePIC = "-fPIC"; 46 + 47 + postPatch = '' 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 52 + 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/ 57 + 58 + substituteInPlace druntime/test/shared/Makefile \ 59 + --replace "DFLAGS:=" "DFLAGS:=${usePIC} " 60 + 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" 64 + 65 + # Use proper C++ compiler 66 + substituteInPlace dmd/src/posix.mak \ 67 + --replace g++ $CXX 22 68 '' 23 - + stdenv.lib.optionalString stdenv.isLinux '' 24 - substituteInPlace src/dmd/root/port.c \ 69 + 70 + + stdenv.lib.optionalString stdenv.hostPlatform.isLinux '' 71 + substituteInPlace dmd/src/root/port.c \ 25 72 --replace "#include <bits/mathdef.h>" "#include <complex.h>" 26 - ''; 73 + '' 74 + 75 + + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin '' 76 + substituteInPlace dmd/src/posix.mak \ 77 + --replace MACOSX_DEPLOYMENT_TARGET MACOSX_DEPLOYMENT_TARGET_ 78 + 79 + # Was not able to compile on darwin due to "__inline_isnanl" 80 + # being undefined. 81 + substituteInPlace dmd/src/root/port.c --replace __inline_isnanl __inline_isnan 82 + ''; 83 + 84 + nativeBuildInputs = [ makeWrapper unzip which ]; 85 + buildInputs = [ curl tzdata ]; 27 86 28 87 # Buid and install are based on http://wiki.dlang.org/Building_DMD 29 88 buildPhase = '' 30 - cd src/dmd 89 + cd dmd 31 90 make -f posix.mak INSTALL_DIR=$out 32 - export DMD=$PWD/dmd 91 + export DMD=$PWD/src/dmd 33 92 cd ../druntime 34 - make -f posix.mak INSTALL_DIR=$out DMD=$DMD 93 + make -f posix.mak PIC=${usePIC} INSTALL_DIR=$out DMD=$DMD 35 94 cd ../phobos 36 - make -f posix.mak INSTALL_DIR=$out DMD=$DMD 37 - cd ../.. 95 + make -f posix.mak PIC=${usePIC} INSTALL_DIR=$out DMD=$DMD 96 + cd .. 97 + ''; 98 + 99 + doCheck = true; 100 + 101 + checkPhase = '' 102 + cd dmd 103 + export DMD=$PWD/src/dmd 104 + cd ../druntime 105 + make -f posix.mak unittest PIC=${usePIC} DMD=$DMD BUILD=release 106 + cd ../phobos 107 + make -f posix.mak unittest PIC=${usePIC} DMD=$DMD BUILD=release 108 + cd .. 38 109 ''; 39 110 40 111 installPhase = '' 41 - cd src/dmd 112 + cd dmd 42 113 mkdir $out 43 114 mkdir $out/bin 44 - cp dmd $out/bin 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/ 45 120 46 121 cd ../druntime 47 122 mkdir $out/include ··· 50 125 51 126 cd ../phobos 52 127 mkdir $out/lib 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" 128 + ${ 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" 56 133 } 57 134 58 135 cp -r std $out/include/d2 ··· 65 142 cd $out/bin 66 143 tee dmd.conf << EOF 67 144 [Environment] 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 69 146 EOF 70 147 ''; 71 148 72 149 meta = with stdenv.lib; { 73 - description = "D language compiler"; 150 + description = "Official reference compiler for the D language"; 74 151 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; 76 155 platforms = platforms.unix; 77 156 }; 78 157 } 158 +
+110 -26
pkgs/development/compilers/dmd/default.nix
··· 1 - { stdenv, fetchurl 1 + { stdenv, fetchFromGitHub 2 2 , makeWrapper, unzip, which 3 - 3 + , curl, tzdata 4 4 # Versions 2.070.2 and up require a working dmd compiler to build: 5 5 , bootstrapDmd }: 6 6 7 7 stdenv.mkDerivation rec { 8 8 name = "dmd-${version}"; 9 - version = "2.070.2"; 9 + version = "2.075.1"; 10 10 11 - src = fetchurl { 12 - url = "http://downloads.dlang.org/releases/2.x/${version}/dmd.${version}.zip"; 13 - sha256 = "1pbhxxf41v816j0aky3q2pcd8a6phy3363l7vr5r5pg8ps3gl701"; 14 - }; 11 + srcs = [ 12 + (fetchFromGitHub { 13 + owner = "dlang"; 14 + repo = "dmd"; 15 + rev = "v${version}"; 16 + sha256 = "0kq6r8rcghvzk5jcphg89l85rg734s29bssd2rcw3fygx0k9a9k5"; 17 + }) 18 + (fetchFromGitHub { 19 + owner = "dlang"; 20 + repo = "druntime"; 21 + rev = "v${version}"; 22 + sha256 = "0idn2v1lmp7hl637g3i7pdfj9mjk4sclkz4cm77nl8873k2fhk8j"; 23 + }) 24 + (fetchFromGitHub { 25 + owner = "dlang"; 26 + repo = "phobos"; 27 + rev = "v${version}"; 28 + sha256 = "1a7q5fd15yspgs5plxgx54jyrcwgzlyw3rahmz04jd2s5h56dj04"; 29 + }) 30 + ]; 15 31 16 - nativeBuildInputs = [ bootstrapDmd makeWrapper unzip which ]; 32 + sourceRoot = "."; 17 33 18 - postPatch = stdenv.lib.optionalString stdenv.isDarwin '' 19 - # Allow to use "clang++", commented in Makefile 20 - substituteInPlace src/dmd/posix.mak \ 21 - --replace g++ clang++ \ 22 - --replace MACOSX_DEPLOYMENT_TARGET MACOSX_DEPLOYMENT_TARGET_ 34 + postUnpack = '' 35 + mv dmd-v${version}-src dmd 36 + mv druntime-v${version}-src druntime 37 + mv phobos-v${version}-src phobos 23 38 ''; 24 39 40 + # Compile with PIC to prevent colliding modules with binutils 2.28. 41 + # https://issues.dlang.org/show_bug.cgi?id=17375 42 + usePIC = "-fPIC"; 43 + 44 + postPatch = '' 45 + # Ugly hack so the dlopen call has a chance to succeed. 46 + # https://issues.dlang.org/show_bug.cgi?id=15391 47 + substituteInPlace phobos/std/net/curl.d \ 48 + --replace libcurl.so ${curl.out}/lib/libcurl.so 49 + 50 + # Ugly hack to fix the hardcoded path to zoneinfo in the source file. 51 + # https://issues.dlang.org/show_bug.cgi?id=15391 52 + substituteInPlace phobos/std/datetime/timezone.d \ 53 + --replace /usr/share/zoneinfo/ ${tzdata}/share/zoneinfo/ 54 + 55 + substituteInPlace druntime/test/common.mak \ 56 + --replace "DFLAGS:=" "DFLAGS:=${usePIC} " 57 + 58 + # phobos uses curl, so we need to patch the path to the lib. 59 + substituteInPlace phobos/posix.mak \ 60 + --replace "-soname=libcurl.so.4" "-soname=${curl.out}/lib/libcurl.so.4" 61 + 62 + # Use proper C++ compiler 63 + substituteInPlace dmd/posix.mak \ 64 + --replace g++ $CXX 65 + '' 66 + 67 + + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin '' 68 + substituteInPlace dmd/posix.mak \ 69 + --replace MACOSX_DEPLOYMENT_TARGET MACOSX_DEPLOYMENT_TARGET_ 70 + ''; 71 + 72 + nativeBuildInputs = [ bootstrapDmd makeWrapper unzip which ]; 73 + buildInputs = [ curl tzdata ]; 74 + 25 75 # Buid and install are based on http://wiki.dlang.org/Building_DMD 26 76 buildPhase = '' 27 - cd src/dmd 77 + cd dmd 28 78 make -f posix.mak INSTALL_DIR=$out 29 - export DMD=$PWD/dmd 79 + ${ 80 + let bits = builtins.toString stdenv.hostPlatform.parsed.cpu.bits; 81 + osname = if stdenv.hostPlatform.isDarwin then "osx" else stdenv.hostPlatform.parsed.kernel.name; in 82 + "export DMD=$PWD/generated/${osname}/release/${bits}/dmd" 83 + } 30 84 cd ../druntime 31 - make -f posix.mak INSTALL_DIR=$out DMD=$DMD 85 + make -f posix.mak PIC=${usePIC} INSTALL_DIR=$out DMD=$DMD 32 86 cd ../phobos 33 - make -f posix.mak INSTALL_DIR=$out DMD=$DMD 34 - cd ../.. 87 + make -f posix.mak PIC=${usePIC} INSTALL_DIR=$out DMD=$DMD 88 + cd .. 89 + ''; 90 + 91 + doCheck = true; 92 + 93 + checkPhase = '' 94 + cd dmd 95 + ${ 96 + let bits = builtins.toString stdenv.hostPlatform.parsed.cpu.bits; 97 + osname = if stdenv.hostPlatform.isDarwin then "osx" else stdenv.hostPlatform.parsed.kernel.name; in 98 + "export DMD=$PWD/generated/${osname}/release/${bits}/dmd" 99 + } 100 + cd ../druntime 101 + make -f posix.mak unittest PIC=${usePIC} DMD=$DMD BUILD=release 102 + cd ../phobos 103 + make -f posix.mak unittest PIC=${usePIC} DMD=$DMD BUILD=release 104 + cd .. 35 105 ''; 36 106 37 107 installPhase = '' 38 - cd src/dmd 108 + cd dmd 39 109 mkdir $out 40 110 mkdir $out/bin 41 - cp dmd $out/bin 111 + ${ 112 + let bits = builtins.toString stdenv.hostPlatform.parsed.cpu.bits; 113 + osname = if stdenv.hostPlatform.isDarwin then "osx" else stdenv.hostPlatform.parsed.kernel.name; in 114 + "cp $PWD/generated/${osname}/release/${bits}/dmd $out/bin" 115 + } 116 + 117 + mkdir -p $out/share/man/man1 118 + mkdir -p $out/share/man/man5 119 + cp -r docs/man/man1/* $out/share/man/man1/ 120 + cp -r docs/man/man5/* $out/share/man/man5/ 42 121 43 122 cd ../druntime 44 123 mkdir $out/include ··· 47 126 48 127 cd ../phobos 49 128 mkdir $out/lib 50 - ${let bits = if stdenv.is64bit then "64" else "32"; 51 - osname = if stdenv.isDarwin then "osx" else "linux"; in 52 - "cp generated/${osname}/release/${bits}/libphobos2.a $out/lib" 129 + ${ 130 + let bits = builtins.toString stdenv.hostPlatform.parsed.cpu.bits; 131 + osname = if stdenv.hostPlatform.isDarwin then "osx" else stdenv.hostPlatform.parsed.kernel.name; 132 + extension = if stdenv.hostPlatform.isDarwin then "a" else "{a,so}"; in 133 + "cp generated/${osname}/release/${bits}/libphobos2.${extension} $out/lib" 53 134 } 54 135 55 136 cp -r std $out/include/d2 ··· 62 143 cd $out/bin 63 144 tee dmd.conf << EOF 64 145 [Environment] 65 - DFLAGS=-I$out/include/d2 -L-L$out/lib ${stdenv.lib.optionalString (!stdenv.cc.isClang) "-L--no-warn-search-mismatch -L--export-dynamic"} 146 + DFLAGS=-I$out/include/d2 -L-L$out/lib ${stdenv.lib.optionalString (!stdenv.cc.isClang) "-L--export-dynamic"} -fPIC 66 147 EOF 67 148 ''; 68 149 69 150 meta = with stdenv.lib; { 70 - description = "D language compiler"; 151 + description = "Official reference compiler for the D language"; 71 152 homepage = http://dlang.org/; 72 - license = licenses.free; # parts under different licenses 153 + # Everything is now Boost licensed, even the backend. 154 + # https://github.com/dlang/dmd/pull/6680 155 + license = licenses.boost; 73 156 platforms = platforms.unix; 74 157 }; 75 158 } 159 +