lol
at 24.11-pre 77 lines 2.7 kB view raw
1{ lib 2, stdenv 3, llvm_meta 4, release_version 5, patches ? [] 6, buildLlvmTools 7, monorepoSrc ? null 8, src ? null 9, libunwind ? null 10, runCommand 11, cmake 12, ninja 13, libxml2 14, libllvm 15, version 16}: 17let 18 pname = "lld"; 19 src' = 20 if monorepoSrc != null then 21 runCommand "lld-src-${version}" {} '' 22 mkdir -p "$out" 23 cp -r ${monorepoSrc}/cmake "$out" 24 cp -r ${monorepoSrc}/${pname} "$out" 25 mkdir -p "$out/libunwind" 26 cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" 27 mkdir -p "$out/llvm" 28 '' else src; 29 30 postPatch = lib.optionalString (lib.versions.major release_version == "12") '' 31 substituteInPlace MachO/CMakeLists.txt --replace \ 32 '(''${LLVM_MAIN_SRC_DIR}/' '(' 33 mkdir -p libunwind/include 34 tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/" 35 '' + lib.optionalString (lib.versions.major release_version == "13" && stdenv.isDarwin) '' 36 substituteInPlace MachO/CMakeLists.txt --replace \ 37 '(''${LLVM_MAIN_SRC_DIR}/' '(../' 38 ''; 39in 40stdenv.mkDerivation (rec { 41 inherit pname version patches; 42 43 src = src'; 44 45 sourceRoot = 46 if lib.versionOlder release_version "13" then null 47 else "${src.name}/${pname}"; 48 49 nativeBuildInputs = [ cmake ] ++ lib.optional (lib.versionAtLeast release_version "15") ninja; 50 buildInputs = [ libllvm libxml2 ]; 51 52 cmakeFlags = lib.optionals (lib.versionOlder release_version "14") [ 53 "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}" 54 ] ++ lib.optionals (lib.versionAtLeast release_version "15") [ 55 "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld" 56 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 57 "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" 58 ]; 59 60 # Musl's default stack size is too small for lld to be able to link Firefox. 61 LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; 62 63 outputs = [ "out" "lib" "dev" ]; 64 65 meta = llvm_meta // { 66 homepage = "https://lld.llvm.org/"; 67 description = "The LLVM linker (unwrapped)"; 68 longDescription = '' 69 LLD is a linker from the LLVM project that is a drop-in replacement for 70 system linkers and runs much faster than them. It also provides features 71 that are useful for toolchain developers. 72 The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and 73 WebAssembly in descending order of completeness. Internally, LLD consists 74 of several different linkers. 75 ''; 76 }; 77} // (if (postPatch == "" && lib.versions.major release_version != "13") then {} else { inherit postPatch; }))