anchor.diff:        "phobos/std/datetime/timezone.d";
   
       postPatch = ''
  -        substituteInPlace runtime/${datetimePath} \
  -            --replace "import core.time;" "import core.time;import std.path;"
  -
  -        substituteInPlace runtime/${datetimePath} \
  -            --replace "tzName == \"leapseconds\"" "baseName(tzName) == \"leapseconds\""
  -
  +        # https://issues.dlang.org/show_bug.cgi?id=15391
           substituteInPlace runtime/phobos/std/net/curl.d \
               --replace libcurl.so ${curl.out}/lib/libcurl.so
  -
  -        # Ugly hack to fix the hardcoded path to zoneinfo in the source file.
  -        # https://issues.dlang.org/show_bug.cgi?id=15391
  -        substituteInPlace runtime/${datetimePath} \
  -            --replace /usr/share/zoneinfo/ ${tzdata}/share/zoneinfo/
   
           substituteInPlace tests/d2/dmd-testsuite/Makefile \
               --replace "SHELL=/bin/bash" "SHELL=${bash}/bin/bash"
       ''
   
  -    + stdenv.lib.optionalString stdenv.hostPlatform.isLinux ''
  -        # See https://github.com/NixOS/nixpkgs/issues/29443
  -        substituteInPlace runtime/phobos/std/path.d \
  -            --replace "\"/root" "\"${ROOT_HOME_DIR}"
  -
  -        # Can be remove with front end version >= 2.078.0
  -        substituteInPlace runtime/druntime/src/core/memory.d \
  -            --replace "assert(z is null);" "//assert(z is null);"
  -    ''
  -
       + stdenv.lib.optionalString (bootstrapVersion && stdenv.hostPlatform.isDarwin) ''
  -        # https://github.com/ldc-developers/ldc/pull/2306
  -        # Can be removed on bootstrap version > 0.17.5
  -        substituteInPlace gen/programs.cpp \
  -            --replace "gcc" "clang"
  -
           # Was not able to compile on darwin due to "__inline_isnanl"
           # being undefined.
           substituteInPlace dmd2/root/port.c --replace __inline_isnanl __inline_isnan
  -    ''
  -
  -    + stdenv.lib.optionalString (!bootstrapVersion) ''
  -        # TODO Can be removed with the next ldc version > 1.7.0
  -        # https://github.com/ldc-developers/ldc/issues/2493
  -        substituteInPlace tests/d2/dmd-testsuite/Makefile \
  -            --replace "# disable tests based on arch" "DISABLED_TESTS += test_cdvecfill"
  -    ''
  -
  -    + stdenv.lib.optionalString (bootstrapVersion) ''
  -        substituteInPlace runtime/${datetimePath} \
  -            --replace "import std.traits;" "import std.traits;import std.path;"
  -
  -        substituteInPlace runtime/${datetimePath} \
  -            --replace "tzName == \"+VERSION\"" "baseName(tzName) == \"leapseconds\" || tzName == \"+VERSION\""
       '';
   
       nativeBuildInputs = [ cmake makeWrapper llvm bootstrapLdc python lit gdb unzip ]
  
positive.code: 
      buildInputs = [ curl tzdata ];
  
      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"
                        )
      '';
  
  
      postConfigure = ''
        export DMD=$PWD/bin/ldmd2
  
negative.code: 
      postUnpack = ''
          patchShebangs .
      ''
  
      + stdenv.lib.optionalString (!bootstrapVersion && stdenv.hostPlatform.isDarwin) ''
          # http://forum.dlang.org/thread/xtbbqthxutdoyhnxjhxl@forum.dlang.org
          rm -r ldc-${version}-src/tests/dynamiccompile
  
          # https://github.com/NixOS/nixpkgs/issues/34817
          rm -r ldc-${version}-src/tests/plugins/addFuncEntryCall
  
          # https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818
          rm -r ldc-${version}-src/tests/debuginfo/classtypes_gdb.d
          rm -r ldc-${version}-src/tests/debuginfo/nested_gdb.d
  
          rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/test16096.sh
          rm ldc-${version}-src/tests/d2/dmd-testsuite/compilable/ldc_output_filenames.sh
          rm ldc-${version}-src/tests/d2/dmd-testsuite/compilable/crlf.sh
          rm ldc-${version}-src/tests/d2/dmd-testsuite/compilable/issue15574.sh
          rm ldc-${version}-src/tests/d2/dmd-testsuite/compilable/test6461.sh
      ''
  
      + stdenv.lib.optionalString (!bootstrapVersion) ''
          echo ${tzdata}/share/zoneinfo/ > ldc-${version}-src/TZDatabaseDirFile
  
          # Remove cppa test for now because it doesn't work.
          rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/cppa.d
          rm ldc-${version}-src/tests/d2/dmd-testsuite/runnable/extra-files/cppb.cpp
      '';
  
      datetimePath = if bootstrapVersion then
        "phobos/std/datetime.d"
  