ldc: modernize

This commit is contained in:
Jeremy Baxter
2024-06-06 15:25:21 +12:00
parent ad4a42b2ce
commit 44b69c0ad2
2 changed files with 51 additions and 43 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ in stdenv.mkDerivation {
src = fetchurl rec {
name = "ldc2-${version}-${OS}-${ARCH}.tar.xz";
url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/${name}";
sha256 = hashes."${OS}-${ARCH}" or (throw "missing bootstrap sha256 for ${OS}-${ARCH}");
hash = hashes."${OS}-${ARCH}" or (throw "missing bootstrap hash for ${OS}-${ARCH}");
};
dontConfigure = true;
+50 -42
View File
@@ -1,6 +1,22 @@
{ lib, stdenv, fetchurl, cmake, ninja, llvm_17, curl, tzdata
, libconfig, lit, gdb, unzip, darwin, bash
, callPackage, makeWrapper, runCommand, targetPackages
{ lib
, stdenv
, fetchFromGitHub
, cmake
, ninja
, llvm_17
, curl
, tzdata
, libconfig
, lit
, gdb
, unzip
, darwin
, bash
, callPackage
, makeWrapper
, runCommand
, targetPackages
, ldcBootstrap ? callPackage ./bootstrap.nix { }
}:
@@ -13,52 +29,44 @@ let
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "ldc";
version = "1.36.0";
src = fetchurl {
url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz";
sha256 = "sha256-oAx5BzEjqIfBf0Rsd4KklVajUSo9Natna31Trhu41u8=";
src = fetchFromGitHub {
owner = "ldc-developers";
repo = "ldc";
rev = "v${finalAttrs.version}";
hash = "sha256-tFc+vgC9Iq3VvlKEn3c1yHFEbgbz6/zP8S9IEDz8Qvw=";
fetchSubmodules = true;
};
# https://issues.dlang.org/show_bug.cgi?id=19553
hardeningDisable = [ "fortify" ];
postUnpack = ''
patchShebangs .
''
+ ''
rm ldc-${version}-src/tests/dmd/fail_compilation/mixin_gc.d
rm ldc-${version}-src/tests/dmd/runnable/xtest46_gc.d
rm ldc-${version}-src/tests/dmd/runnable/testptrref_gc.d
# test depends on current year
rm ldc-${version}-src/tests/dmd/compilable/ddocYear.d
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# https://github.com/NixOS/nixpkgs/issues/34817
rm -r ldc-${version}-src/tests/plugins/addFuncEntryCall
'';
postPatch = ''
# Setting SHELL=$SHELL when dmd testsuite is run doesn't work on Linux somehow
substituteInPlace tests/dmd/Makefile --replace "SHELL=/bin/bash" "SHELL=${bash}/bin/bash"
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
substituteInPlace runtime/phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" ""
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace runtime/phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)"
patchShebangs runtime tools tests
rm tests/dmd/fail_compilation/mixin_gc.d
rm tests/dmd/runnable/xtest46_gc.d
rm tests/dmd/runnable/testptrref_gc.d
# test depends on current year
rm tests/dmd/compilable/ddocYear.d
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
substituteInPlace runtime/phobos/std/socket.d --replace-fail "assert(ih.addrList[0] == 0x7F_00_00_01);" ""
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace runtime/phobos/std/socket.d --replace-fail "foreach (name; names)" "names = []; foreach (name; names)"
# https://github.com/NixOS/nixpkgs/issues/34817
rm -r tests/plugins/addFuncEntryCall
'';
nativeBuildInputs = [
cmake ldcBootstrap lit lit.python llvm_17.dev makeWrapper ninja unzip
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
darwin.apple_sdk.frameworks.Foundation
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
# https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818
gdb
];
@@ -75,7 +83,7 @@ stdenv.mkDerivation rec {
makeFlags = [ "DMD=$DMD" ];
fixNames = lib.optionalString stdenv.hostPlatform.isDarwin ''
fixNames = lib.optionalString stdenv.hostPlatform.isDarwin ''
fixDarwinDylibNames() {
local flags=()
@@ -102,7 +110,7 @@ stdenv.mkDerivation rec {
# Build default lib test runners
ninja -j$NIX_BUILD_CORES all-test-runners
${fixNames}
${finalAttrs.fixNames}
# Run dmd testsuite
export DMD_TESTSUITE_MAKE_ARGS="-j$NIX_BUILD_CORES DMD=$DMD"
@@ -115,14 +123,14 @@ stdenv.mkDerivation rec {
ctest -V -R "lit-tests"
# Run default lib unittests
ctest -j$NIX_BUILD_CORES --output-on-failure -E "ldc2-unittest|lit-tests|dmd-testsuite${additionalExceptions}"
ctest -j$NIX_BUILD_CORES --output-on-failure -E "ldc2-unittest|lit-tests|dmd-testsuite${finalAttrs.additionalExceptions}"
'';
postInstall = ''
wrapProgram $out/bin/ldc2 \
--prefix PATH ":" "${targetPackages.stdenv.cc}/bin" \
--set-default CC "${targetPackages.stdenv.cc}/bin/cc"
'';
--prefix PATH : ${targetPackages.stdenv.cc}/bin \
--set-default CC ${targetPackages.stdenv.cc}/bin/cc
'';
meta = with lib; {
description = "The LLVM-based D compiler";
@@ -133,4 +141,4 @@ stdenv.mkDerivation rec {
maintainers = with maintainers; [ lionello jtbx ];
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
};
}
})