Merge pull request #44904 from ThomasMader/dlang-update

Dlang update
This commit is contained in:
Jörg Thalheim 2018-08-16 08:06:55 +02:00 committed by GitHub
commit 890c6d407d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 143 additions and 200 deletions

View file

@ -1,34 +1,15 @@
{ stdenv, fetchFromGitHub, overrideCC, gcc5
{ stdenv, fetchFromGitHub
, makeWrapper, unzip, which
, curl, tzdata, gdb, darwin
, callPackage, targetPackages
, bootstrapVersion ? false
, version ? "2.079.1"
, dmdSha256 ? "0mlk095aw94d940qkymfp85daggiz3f0xv598nlc7acgp6408kyj"
, druntimeSha256 ? "18r8gwvb54ar80j5155wx0qbqq4w56hqmbf6wap20xwijg2rw90g"
, phobosSha256 ? "1x5v1ln51nr8x2vyki864160bakdyq0acmvbfv7jcipaj2w3m9bb"
, callPackage, targetPackages, ldc
, version ? "2.081.1"
, dmdSha256 ? "1xdz7p0pdzwkn57ai93mavgdkd8xb1sr2brlc6y3c12x84h43s8z"
, druntimeSha256 ? "1vl8ag6rjvqqmc5bn5jk3yfynjb9ggy3hw1awwl7c76bq4f7nbif"
, phobosSha256 ? "0h1jdc3yai1l42bxjdlyi9hf9qadh76v925rjk2q4ibv2fzl56b7"
}:
let
bootstrapDmd = if !bootstrapVersion then
# Versions 2.070.2 and up require a working dmd compiler to build so we just
# use the last dmd without any D code to bootstrap the actual build.
callPackage ./default.nix {
stdenv = if stdenv.hostPlatform.isDarwin then
stdenv
else
# Doesn't build with gcc6 on linux
overrideCC stdenv gcc5;
bootstrapVersion = true;
version = "2.067.1";
dmdSha256 = "0fm29lg8axfmzdaj0y6vg70lhwb5d9rv4aavnvdd15xjschinlcz";
druntimeSha256 = "1n2qfw9kmnql0fk2nxikispqs7vh85nhvyyr00fk227n9lgnqf02";
phobosSha256 = "0fywgds9xvjcgnqxmpwr67p3wi2m535619pvj159cgwv5y0nr3p1";
}
else
"";
dmdBuild = stdenv.mkDerivation rec {
name = "dmdBuild-${version}";
inherit version;
@ -74,11 +55,6 @@ let
usePIC = "-fPIC";
ROOT_HOME_DIR = "$(echo ~root)";
datetimePath = if bootstrapVersion then
"phobos/std/datetime.d"
else
"phobos/std/datetime/timezone.d";
phobosPatches = ''
# Ugly hack so the dlopen call has a chance to succeed.
# https://issues.dlang.org/show_bug.cgi?id=15391
@ -89,77 +65,24 @@ let
substituteInPlace phobos/posix.mak \
--replace "-soname=libcurl.so.4" "-soname=${curl.out}/lib/libcurl.so.4"
''
+ stdenv.lib.optionalString (!bootstrapVersion) ''
# Can be removed when https://github.com/dlang/phobos/pull/6224 is included.
substituteInPlace ${datetimePath} \
--replace "foreach (DirEntry de; dirEntries(tzDatabaseDir, SpanMode.depth))" "import std.path : baseName; foreach (DirEntry de; dirEntries(tzDatabaseDir, SpanMode.depth))"
substituteInPlace ${datetimePath} \
--replace "tzName == \"leapseconds\"" "baseName(tzName) == \"leapseconds\""
''
+ stdenv.lib.optionalString (bootstrapVersion) ''
substituteInPlace ${datetimePath} \
--replace "import std.traits;" "import std.traits;import std.path;"
substituteInPlace ${datetimePath} \
--replace "tzName == \"+VERSION\"" "baseName(tzName) == \"leapseconds\" || tzName == \"+VERSION\""
# Ugly hack to fix the hardcoded path to zoneinfo in the source file.
# https://issues.dlang.org/show_bug.cgi?id=15391
substituteInPlace ${datetimePath} \
--replace /usr/share/zoneinfo/ ${tzdata}/share/zoneinfo/
''
+ stdenv.lib.optionalString (bootstrapVersion && stdenv.hostPlatform.isLinux) ''
# See https://github.com/dlang/phobos/pull/5960
substituteInPlace phobos/std/path.d \
--replace "\"/root" "\"${ROOT_HOME_DIR}"
'';
dmdPath = if bootstrapVersion then
"dmd/src"
else
"dmd";
postPatch = ''
''
+ stdenv.lib.optionalString (!bootstrapVersion) ''
substituteInPlace druntime/test/common.mak \
--replace "DFLAGS:=" "DFLAGS:=${usePIC} "
''
+ stdenv.lib.optionalString (bootstrapVersion) ''
# Use proper C++ compiler
substituteInPlace ${dmdPath}/posix.mak \
--replace g++ $CXX
substituteInPlace dmd/src/posix.mak \
--replace "DFLAGS :=" "DFLAGS += -link-defaultlib-shared=false"
''
+ phobosPatches
+ stdenv.lib.optionalString (stdenv.hostPlatform.isLinux && bootstrapVersion) ''
substituteInPlace ${dmdPath}/root/port.c \
--replace "#include <bits/mathdef.h>" "#include <complex.h>"
substituteInPlace ${dmdPath}/root/port.c \
--replace "#include <bits/nan.h>" "#include <math.h>"
''
+ stdenv.lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace ${dmdPath}/posix.mak \
substituteInPlace dmd/posix.mak \
--replace MACOSX_DEPLOYMENT_TARGET MACOSX_DEPLOYMENT_TARGET_
''
+ stdenv.lib.optionalString (stdenv.hostPlatform.isDarwin && bootstrapVersion) ''
# Was not able to compile on darwin due to "__inline_isnanl"
# being undefined.
substituteInPlace ${dmdPath}/root/port.c --replace __inline_isnanl __inline_isnan
'';
nativeBuildInputs = [ bootstrapDmd makeWrapper unzip which gdb ]
nativeBuildInputs = [ ldc makeWrapper unzip which gdb ]
++ stdenv.lib.optional stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
Foundation
@ -173,23 +96,22 @@ let
else
stdenv.hostPlatform.parsed.kernel.name;
top = "$(echo $NIX_BUILD_TOP)";
pathToDmd = if bootstrapVersion then
"${top}/dmd/src/dmd"
else
"${top}/dmd/generated/${osname}/release/${bits}/dmd";
pathToDmd = "${top}/dmd/generated/${osname}/release/${bits}/dmd";
# Buid and install are based on http://wiki.dlang.org/Building_DMD
buildPhase = ''
cd dmd
make -j$NIX_BUILD_CORES -f posix.mak INSTALL_DIR=$out
make -j$NIX_BUILD_CORES -f posix.mak INSTALL_DIR=$out BUILD=release ENABLE_RELEASE=1 PIC=1 HOST_DMD=ldmd2
cd ../druntime
make -j$NIX_BUILD_CORES -f posix.mak PIC=1 INSTALL_DIR=$out DMD=${pathToDmd}
make -j$NIX_BUILD_CORES -f posix.mak BUILD=release ENABLE_RELEASE=1 PIC=1 INSTALL_DIR=$out DMD=${pathToDmd}
cd ../phobos
make -j$NIX_BUILD_CORES -f posix.mak PIC=1 INSTALL_DIR=$out DMD=${pathToDmd} TZ_DATABASE_DIR=${tzdata}/share/zoneinfo/
make -j$NIX_BUILD_CORES -f posix.mak BUILD=release ENABLE_RELEASE=1 PIC=1 INSTALL_DIR=$out DMD=${pathToDmd} TZ_DATABASE_DIR=${tzdata}/share/zoneinfo/
cd ..
'';
doCheck = !bootstrapVersion;
# Disable tests on Darwin for now because of
# https://github.com/NixOS/nixpkgs/issues/41099
doCheck = !stdenv.hostPlatform.isDarwin;
checkPhase = ''
cd dmd
@ -198,9 +120,9 @@ let
make -j$NIX_BUILD_CORES -f posix.mak unittest PIC=1 DMD=${pathToDmd} BUILD=release
cd ..
'';
extension = if stdenv.hostPlatform.isDarwin then "a" else "{a,so}";
extension = if stdenv.hostPlatform.isDarwin then "a" else "{a,so}";
dontStrip = true;
installPhase = ''
@ -250,34 +172,40 @@ let
# Need to test Phobos in a fixed-output derivation, otherwise the
# network stuff in Phobos would fail if sandbox mode is enabled.
phobosUnittests = stdenv.mkDerivation rec {
name = "phobosUnittests-${version}";
version = dmdBuild.version;
#
# Disable tests on Darwin for now because of
# https://github.com/NixOS/nixpkgs/issues/41099
phobosUnittests = if !stdenv.hostPlatform.isDarwin then
stdenv.mkDerivation rec {
name = "phobosUnittests-${version}";
version = dmdBuild.version;
enableParallelBuilding = dmdBuild.enableParallelBuilding;
preferLocalBuild = true;
inputString = dmdBuild.outPath;
outputHashAlgo = "sha256";
outputHash = builtins.hashString "sha256" inputString;
enableParallelBuilding = dmdBuild.enableParallelBuilding;
preferLocalBuild = true;
inputString = dmdBuild.outPath;
outputHashAlgo = "sha256";
outputHash = builtins.hashString "sha256" inputString;
srcs = dmdBuild.srcs;
srcs = dmdBuild.srcs;
sourceRoot = ".";
sourceRoot = ".";
postPatch = dmdBuild.phobosPatches;
postPatch = dmdBuild.phobosPatches;
nativeBuildInputs = dmdBuild.nativeBuildInputs;
buildInputs = dmdBuild.buildInputs;
nativeBuildInputs = dmdBuild.nativeBuildInputs;
buildInputs = dmdBuild.buildInputs;
buildPhase = ''
cd phobos
make -j$NIX_BUILD_CORES -f posix.mak unittest PIC=1 DMD=${dmdBuild}/bin/dmd BUILD=release TZ_DATABASE_DIR=${tzdata}/share/zoneinfo/
'';
buildPhase = ''
cd phobos
make -j$NIX_BUILD_CORES -f posix.mak unittest BUILD=release ENABLE_RELEASE=1 PIC=1 DMD=${dmdBuild}/bin/dmd TZ_DATABASE_DIR=${tzdata}/share/zoneinfo/
'';
installPhase = ''
echo -n $inputString > $out
'';
};
installPhase = ''
echo -n $inputString > $out
'';
}
else
"";
in

View file

@ -2,8 +2,8 @@
, python, libconfig, lit, gdb, unzip, darwin, bash
, callPackage, makeWrapper, targetPackages
, bootstrapVersion ? false
, version ? "1.8.0"
, ldcSha256 ? "0zswjlibj8zcdj06nn09jjhbd99chsa5f4kps8xifzgrpgsa28g4"
, version ? "1.10.0"
, ldcSha256 ? "0wc3vlblsz4qdwa9ay9plv9nvfd07zj2byqqffaa4a5gvjwf5dlr"
}:
let
@ -155,7 +155,10 @@ let
makeFlags = [ "DMD=$DMD" ];
doCheck = true;
# Disable tests on Darwin for now because of
# https://github.com/NixOS/nixpkgs/issues/41099
# https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818
doCheck = !bootstrapVersion && !stdenv.hostPlatform.isDarwin;
checkPhase = ''
# Build and run LDC D unittests.
@ -184,65 +187,72 @@ let
# Need to test Phobos in a fixed-output derivation, otherwise the
# network stuff in Phobos would fail if sandbox mode is enabled.
ldcUnittests = stdenv.mkDerivation rec {
name = "ldcUnittests-${version}";
#
# Disable tests on Darwin for now because of
# https://github.com/NixOS/nixpkgs/issues/41099
# https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818
ldcUnittests = if (!bootstrapVersion && !stdenv.hostPlatform.isDarwin) then
stdenv.mkDerivation rec {
name = "ldcUnittests-${version}";
enableParallelBuilding = ldcBuild.enableParallelBuilding;
preferLocalBuild = true;
inputString = ldcBuild.outPath;
outputHashAlgo = "sha256";
outputHash = builtins.hashString "sha256" inputString;
enableParallelBuilding = ldcBuild.enableParallelBuilding;
preferLocalBuild = true;
inputString = ldcBuild.outPath;
outputHashAlgo = "sha256";
outputHash = builtins.hashString "sha256" inputString;
src = ldcBuild.src;
src = ldcBuild.src;
postUnpack = ldcBuild.postUnpack;
postUnpack = ldcBuild.postUnpack;
postPatch = ldcBuild.postPatch;
postPatch = ldcBuild.postPatch;
nativeBuildInputs = ldcBuild.nativeBuildInputs
nativeBuildInputs = ldcBuild.nativeBuildInputs
++ [
ldcBuild
];
++ [
ldcBuild
];
buildInputs = ldcBuild.buildInputs;
buildInputs = ldcBuild.buildInputs;
preConfigure = ''
cmakeFlagsArray=( "-DINCLUDE_INSTALL_DIR=$out/include/dlang/ldc"
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_SKIP_RPATH=ON"
"-DBUILD_SHARED_LIBS=OFF"
"-DLDC_WITH_LLD=OFF"
# Xcode 9.0.1 fixes that bug according to ldc release notes
"-DRT_ARCHIVE_WITH_LDC=OFF"
"-DD_COMPILER=${ldcBuild.out}/bin/ldmd2"
)
'';
preConfigure = ''
cmakeFlagsArray=( "-DINCLUDE_INSTALL_DIR=$out/include/dlang/ldc"
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_SKIP_RPATH=ON"
"-DBUILD_SHARED_LIBS=OFF"
"-DLDC_WITH_LLD=OFF"
# Xcode 9.0.1 fixes that bug according to ldc release notes
"-DRT_ARCHIVE_WITH_LDC=OFF"
"-DD_COMPILER=${ldcBuild.out}/bin/ldmd2"
)
'';
postConfigure = ldcBuild.postConfigure;
postConfigure = ldcBuild.postConfigure;
makeFlags = ldcBuild.makeFlags;
makeFlags = ldcBuild.makeFlags;
buildCmd = if bootstrapVersion then
"ctest -V -R \"build-druntime-ldc-unittest|build-phobos2-ldc-unittest\""
else
"make -j$NIX_BUILD_CORES DMD=${ldcBuild.out}/bin/ldc2 phobos2-test-runner phobos2-test-runner-debug";
buildCmd = if bootstrapVersion then
"ctest -V -R \"build-druntime-ldc-unittest|build-phobos2-ldc-unittest\""
else
"make -j$NIX_BUILD_CORES DMD=${ldcBuild.out}/bin/ldc2 phobos2-test-runner phobos2-test-runner-debug";
testCmd = if bootstrapVersion then
"ctest -j$NIX_BUILD_CORES --output-on-failure -E \"dmd-testsuite|lit-tests|ldc2-unittest|llvm-ir-testsuite\""
else
"ctest -j$NIX_BUILD_CORES --output-on-failure -E \"dmd-testsuite|lit-tests|ldc2-unittest\"";
testCmd = if bootstrapVersion then
"ctest -j$NIX_BUILD_CORES --output-on-failure -E \"dmd-testsuite|lit-tests|ldc2-unittest|llvm-ir-testsuite\""
else
"ctest -j$NIX_BUILD_CORES --output-on-failure -E \"dmd-testsuite|lit-tests|ldc2-unittest\"";
buildPhase = ''
${buildCmd}
ln -s ${ldcBuild.out}/bin/ldmd2 $PWD/bin/ldmd2
${testCmd}
'';
buildPhase = ''
${buildCmd}
ln -s ${ldcBuild.out}/bin/ldmd2 $PWD/bin/ldmd2
${testCmd}
'';
installPhase = ''
echo -n $inputString > $out
'';
};
installPhase = ''
echo -n $inputString > $out
'';
}
else
"";
in

View file

@ -4,7 +4,7 @@ let
dubBuild = stdenv.mkDerivation rec {
name = "dubBuild-${version}";
version = "1.8.1";
version = "1.10.0";
enableParallelBuilding = true;
@ -12,7 +12,7 @@ let
owner = "dlang";
repo = "dub";
rev = "v${version}";
sha256 = "16r7x4jsfv5fjssvs6mwj8ymr6fjpvbkjhpr4f4368sjr5iyfad6";
sha256 = "02xxpfcjs427jqbwz0vh5vl3bh62ys65zmi9gpa3svzqffyx13n4";
};
postUnpack = ''
@ -51,40 +51,45 @@ let
# Need to test in a fixed-output derivation, otherwise the
# network tests would fail if sandbox mode is enabled.
dubUnittests = stdenv.mkDerivation rec {
name = "dubUnittests-${version}";
version = dubBuild.version;
# Disable tests on Darwin for now because they don't work
# reliably there.
dubUnittests = if !stdenv.hostPlatform.isDarwin then
stdenv.mkDerivation rec {
name = "dubUnittests-${version}";
version = dubBuild.version;
enableParallelBuilding = dubBuild.enableParallelBuilding;
preferLocalBuild = true;
inputString = dubBuild.outPath;
outputHashAlgo = "sha256";
outputHash = builtins.hashString "sha256" inputString;
enableParallelBuilding = dubBuild.enableParallelBuilding;
preferLocalBuild = true;
inputString = dubBuild.outPath;
outputHashAlgo = "sha256";
outputHash = builtins.hashString "sha256" inputString;
src = dubBuild.src;
postUnpack = dubBuild.postUnpack;
postPatch = dubBuild.postPatch;
src = dubBuild.src;
postUnpack = dubBuild.postUnpack;
postPatch = dubBuild.postPatch;
nativeBuildInputs = dubBuild.nativeBuildInputs;
buildInputs = dubBuild.buildInputs;
nativeBuildInputs = dubBuild.nativeBuildInputs;
buildInputs = dubBuild.buildInputs;
buildPhase = ''
# Can't use dub from dubBuild directly because one unittest
# (issue895-local-configuration) needs to generate a config
# file under ../etc relative to the dub location.
cp ${dubBuild}/bin/dub bin/
export DUB=$NIX_BUILD_TOP/source/bin/dub
export PATH=$PATH:$NIX_BUILD_TOP/source/bin/
export DC=${dmd.out}/bin/dmd
export HOME=$TMP
./test/run-unittest.sh
'';
buildPhase = ''
# Can't use dub from dubBuild directly because one unittest
# (issue895-local-configuration) needs to generate a config
# file under ../etc relative to the dub location.
cp ${dubBuild}/bin/dub bin/
export DUB=$NIX_BUILD_TOP/source/bin/dub
export PATH=$PATH:$NIX_BUILD_TOP/source/bin/
export DC=${dmd.out}/bin/dmd
export HOME=$TMP
./test/run-unittest.sh
'';
installPhase = ''
echo -n $inputString > $out
'';
};
installPhase = ''
echo -n $inputString > $out
'';
}
else
"";
in

View file

@ -2,21 +2,21 @@
stdenv.mkDerivation rec {
name = "dtools-${version}";
version = "2.079.1";
version = "2.081.1";
srcs = [
(fetchFromGitHub {
owner = "dlang";
repo = "dmd";
rev = "v${version}";
sha256 = "0mlk095aw94d940qkymfp85daggiz3f0xv598nlc7acgp6408kyj";
sha256 = "1xdz7p0pdzwkn57ai93mavgdkd8xb1sr2brlc6y3c12x84h43s8z";
name = "dmd";
})
(fetchFromGitHub {
owner = "dlang";
repo = "tools";
rev = "v${version}";
sha256 = "0fvpfwh3bh3fymrmis3n39x9hkfklmv81lrlqcyl8fmmk694yvad";
sha256 = "1sbcfj8r1nvy7ynh9dy55q9bvfvxwf1z3llpxckvi8p6yvf35qn2";
name = "dtools";
})
];