From 6c9beaa744ede63e633b59c4e32c5953cc079ad2 Mon Sep 17 00:00:00 2001 From: Lionello Lunesu Date: Sat, 18 Apr 2020 16:56:02 +0800 Subject: [PATCH] dmd: 2.085.1 -> 2.091.1 Apply patch dlang/dmd#11053 --- pkgs/development/compilers/dmd/binary.nix | 52 ++++++++++++++++++++ pkgs/development/compilers/dmd/bootstrap.nix | 9 ++++ pkgs/development/compilers/dmd/default.nix | 34 ++++++++----- 3 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 pkgs/development/compilers/dmd/binary.nix create mode 100644 pkgs/development/compilers/dmd/bootstrap.nix diff --git a/pkgs/development/compilers/dmd/binary.nix b/pkgs/development/compilers/dmd/binary.nix new file mode 100644 index 00000000000..cd3a15889b2 --- /dev/null +++ b/pkgs/development/compilers/dmd/binary.nix @@ -0,0 +1,52 @@ +{ stdenv, fetchurl, curl, tzdata, autoPatchelfHook, fixDarwinDylibNames, glibc +, version, hashes }: +with stdenv; +let + OS = if hostPlatform.isDarwin then "osx" else hostPlatform.parsed.kernel.name; + MODEL = toString hostPlatform.parsed.cpu.bits; +in mkDerivation { + pname = "dmd-bootstrap"; + inherit version; + + src = fetchurl rec { + name = "dmd.${version}.${OS}.tar.xz"; + url = "http://downloads.dlang.org/releases/2.x/${version}/${name}"; + sha256 = hashes.${OS} or (throw "missing bootstrap sha256 for OS ${OS}"); + }; + + dontConfigure = true; + dontBuild = true; + + nativeBuildInputs = [ fixDarwinDylibNames autoPatchelfHook ]; + propagatedBuildInputs = [ curl tzdata ] ++ lib.optional hostPlatform.isLinux glibc; + + installPhase = '' + mkdir -p $out + + # try to copy model-specific binaries into bin first + mv ${OS}/bin${MODEL} $out/bin || true + + mv src license.txt ${OS}/* $out/ + + # move man into place + mkdir -p $out/share + mv man $out/share/ + + # move docs into place + mkdir -p $out/share/doc + mv html/d $out/share/doc/ + + # fix paths in dmd.conf (one level less) + substituteInPlace $out/bin/dmd.conf --replace "/../../" "/../" + ''; + + meta = with lib; { + inherit version; + description = "Digital Mars D Compiler Package"; + # As of 2.075 all sources and binaries use the boost license + license = licenses.boost; + maintainers = [ maintainers.lionello ]; + homepage = "https://dlang.org/"; + platforms = [ "x86_64-darwin" "i686-linux" "x86_64-linux" ]; + }; +} diff --git a/pkgs/development/compilers/dmd/bootstrap.nix b/pkgs/development/compilers/dmd/bootstrap.nix new file mode 100644 index 00000000000..087781ae2ca --- /dev/null +++ b/pkgs/development/compilers/dmd/bootstrap.nix @@ -0,0 +1,9 @@ +{ callPackage }: +callPackage ./binary.nix { + version = "2.090.1"; + hashes = { + # Get these from `nix-prefetch-url http://downloads.dlang.org/releases/2.x/2.090.1/dmd.2.090.1.linux.tar.xz` etc.. + osx = "0rbn7j4dr3q0y09fblpj999bi063pi4230rqd5xgd3gwxxa0cz7l"; + linux = "1vk6lsvd6y7ccvffd23yial4ig90azaxf2rxc6yvidqd1qhan807"; + }; +} diff --git a/pkgs/development/compilers/dmd/default.nix b/pkgs/development/compilers/dmd/default.nix index 9281e01ad3e..028c863d0cf 100644 --- a/pkgs/development/compilers/dmd/default.nix +++ b/pkgs/development/compilers/dmd/default.nix @@ -1,11 +1,13 @@ { stdenv, lib, fetchFromGitHub , makeWrapper, unzip, which, writeTextFile -, curl, tzdata, gdb, darwin, git -, targetPackages, ldc -, version ? "2.085.1" -, dmdSha256 ? "0ccidfcawrcwdpfjwjiln5xwr4ffp8i2hwx52p8zn3xmc5yxm660" -, druntimeSha256 ? "109f2glsqrlshk06761xlw4r5v22mivp873cq9g5gcax3g00k617" -, phobosSha256 ? "0giispqqx8j8xg6c0hm7nx77bcahiwic8rvf12sws3sv5pizv8pr" +, curl, tzdata, gdb, darwin, git, callPackage +, targetPackages, fetchpatch +, dmdBootstrap ? callPackage ./bootstrap.nix { } +, HOST_DMD ? "${dmdBootstrap}/bin/dmd" +, version ? "2.091.1" +, dmdSha256 ? "0brz0n84jdkhr4sq4k91w48p739psbhbb1jk2pi9q60psmx353yr" +, druntimeSha256 ? "0smgpmfriffh110ksski1s5j921kmxbc2zjy0dyj9ksyrxbzklbl" +, phobosSha256 ? "1n00anajgibrfs1xzvrmag28hvbvkc0w1fwlimqbznvhf28rhrxs" }: let @@ -51,7 +53,17 @@ stdenv.mkDerivation rec { }) ]; - patchFlags = [ "--directory=dmd" "-p1" ]; + patchFlags = [ "--directory=dmd" "-p1" "-F3" ]; + patches = [ + (fetchpatch { + url = "https://github.com/dlang/dmd/commit/4157298cf04f7aae9f701432afd1de7b7e05c30f.patch"; + sha256 = "0v4xgqmrx5r8vbx5a4v88s0xnm23mam9nm99yfga7s2sxr0hi5p2"; + }) + (fetchpatch { + url = "https://github.com/dlang/dmd/commit/14547ae37a97678a80a32fea4c76626bbd8595ca.patch"; + sha256 = "17f7glbmq61r9zy9y40p1zwgqc9daf2sbly3p6d6z9wsd1p57xnl"; + }) + ]; sourceRoot = "."; @@ -65,12 +77,11 @@ stdenv.mkDerivation rec { postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isLinux '' substituteInPlace phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" "" '' - + stdenv.lib.optionalString stdenv.hostPlatform.isDarwin '' substituteInPlace phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)" ''; - nativeBuildInputs = [ ldc makeWrapper unzip which gdb git ] + nativeBuildInputs = [ makeWrapper unzip which gdb git ] ++ stdenv.lib.optional stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation @@ -89,7 +100,7 @@ stdenv.mkDerivation rec { # 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 BUILD=release ENABLE_RELEASE=1 PIC=1 HOST_DMD=ldmd2 + make -j$NIX_BUILD_CORES -f posix.mak INSTALL_DIR=$out BUILD=release ENABLE_RELEASE=1 PIC=1 HOST_DMD=${HOST_DMD} cd ../druntime make -j$NIX_BUILD_CORES -f posix.mak BUILD=release ENABLE_RELEASE=1 PIC=1 INSTALL_DIR=$out DMD=${pathToDmd} cd ../phobos @@ -147,8 +158,7 @@ stdenv.mkDerivation rec { # Everything is now Boost licensed, even the backend. # https://github.com/dlang/dmd/pull/6680 license = licenses.boost; - maintainers = with maintainers; [ ThomasMader ]; + maintainers = with maintainers; [ ThomasMader lionello ]; platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ]; }; } -