dmd: 2.079.1 -> 2.081.1
Needed to switch to ldc as bootstrap compiler to fix the compilation
This commit is contained in:
parent
f4f488de21
commit
643d9a08ef
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user