lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 23.11-beta 136 lines 4.2 kB view raw
1{ version, sha256 }: 2{ lib, stdenv, fetchurl, cmake, ninja, llvm_16, curl, tzdata 3, libconfig, lit, gdb, unzip, darwin, bash 4, callPackage, makeWrapper, runCommand, targetPackages 5, ldcBootstrap ? callPackage ./bootstrap.nix { } 6}: 7 8let 9 pathConfig = runCommand "ldc-lib-paths" {} '' 10 mkdir $out 11 echo ${tzdata}/share/zoneinfo/ > $out/TZDatabaseDirFile 12 echo ${curl.out}/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary} > $out/LibcurlPathFile 13 ''; 14 15in 16 17stdenv.mkDerivation rec { 18 pname = "ldc"; 19 inherit version; 20 21 src = fetchurl { 22 url = "https://github.com/ldc-developers/ldc/releases/download/v${version}/ldc-${version}-src.tar.gz"; 23 inherit sha256; 24 }; 25 26 # https://issues.dlang.org/show_bug.cgi?id=19553 27 hardeningDisable = [ "fortify" ]; 28 29 postUnpack = '' 30 patchShebangs . 31 '' 32 + '' 33 rm ldc-${version}-src/tests/dmd/fail_compilation/mixin_gc.d 34 rm ldc-${version}-src/tests/dmd/runnable/xtest46_gc.d 35 rm ldc-${version}-src/tests/dmd/runnable/testptrref_gc.d 36 37 # test depends on current year 38 rm ldc-${version}-src/tests/dmd/compilable/ddocYear.d 39 '' 40 + lib.optionalString stdenv.hostPlatform.isDarwin '' 41 # https://github.com/NixOS/nixpkgs/issues/34817 42 rm -r ldc-${version}-src/tests/plugins/addFuncEntryCall 43 ''; 44 45 postPatch = '' 46 # Setting SHELL=$SHELL when dmd testsuite is run doesn't work on Linux somehow 47 substituteInPlace tests/dmd/Makefile --replace "SHELL=/bin/bash" "SHELL=${bash}/bin/bash" 48 '' 49 + lib.optionalString stdenv.hostPlatform.isLinux '' 50 substituteInPlace runtime/phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" "" 51 '' 52 + lib.optionalString stdenv.hostPlatform.isDarwin '' 53 substituteInPlace runtime/phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)" 54 ''; 55 56 nativeBuildInputs = [ 57 cmake ldcBootstrap lit lit.python llvm_16.dev makeWrapper ninja unzip 58 ] 59 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 60 darwin.apple_sdk.frameworks.Foundation 61 ] 62 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ 63 # https://github.com/NixOS/nixpkgs/pull/36378#issuecomment-385034818 64 gdb 65 ]; 66 67 buildInputs = [ curl tzdata ]; 68 69 cmakeFlags = [ 70 "-DD_FLAGS=-d-version=TZDatabaseDir;-d-version=LibcurlPath;-J${pathConfig}" 71 ]; 72 73 postConfigure = '' 74 export DMD=$PWD/bin/ldmd2 75 ''; 76 77 makeFlags = [ "DMD=$DMD" ]; 78 79 fixNames = lib.optionalString stdenv.hostPlatform.isDarwin '' 80 fixDarwinDylibNames() { 81 local flags=() 82 83 for fn in "$@"; do 84 flags+=(-change "$(basename "$fn")" "$fn") 85 done 86 87 for fn in "$@"; do 88 if [ -L "$fn" ]; then continue; fi 89 echo "$fn: fixing dylib" 90 install_name_tool -id "$fn" "''${flags[@]}" "$fn" 91 done 92 } 93 94 fixDarwinDylibNames $(find "$(pwd)/lib" -name "*.dylib") 95 export DYLD_LIBRARY_PATH=$(pwd)/lib 96 ''; 97 98 # https://github.com/ldc-developers/ldc/issues/2497#issuecomment-459633746 99 additionalExceptions = lib.optionalString stdenv.hostPlatform.isDarwin 100 "|druntime-test-shared"; 101 102 checkPhase = '' 103 # Build default lib test runners 104 ninja -j$NIX_BUILD_CORES all-test-runners 105 106 ${fixNames} 107 108 # Run dmd testsuite 109 export DMD_TESTSUITE_MAKE_ARGS="-j$NIX_BUILD_CORES DMD=$DMD" 110 ctest -V -R "dmd-testsuite" 111 112 # Build and run LDC D unittests. 113 ctest --output-on-failure -R "ldc2-unittest" 114 115 # Run LIT testsuite. 116 ctest -V -R "lit-tests" 117 118 # Run default lib unittests 119 ctest -j$NIX_BUILD_CORES --output-on-failure -E "ldc2-unittest|lit-tests|dmd-testsuite${additionalExceptions}" 120 ''; 121 122 postInstall = '' 123 wrapProgram $out/bin/ldc2 \ 124 --prefix PATH ":" "${targetPackages.stdenv.cc}/bin" \ 125 --set-default CC "${targetPackages.stdenv.cc}/bin/cc" 126 ''; 127 128 meta = with lib; { 129 description = "The LLVM-based D compiler"; 130 homepage = "https://github.com/ldc-developers/ldc"; 131 # from https://github.com/ldc-developers/ldc/blob/master/LICENSE 132 license = with licenses; [ bsd3 boost mit ncsa gpl2Plus ]; 133 maintainers = with maintainers; [ ThomasMader lionello jtbx ]; 134 platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; 135 }; 136}