nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 89 lines 2.3 kB view raw
1{ 2 lib, 3 stdenv, 4 llvm_meta, 5 release_version, 6 buildLlvmPackages, 7 monorepoSrc ? null, 8 src ? null, 9 runCommand, 10 cmake, 11 ninja, 12 libxml2, 13 libllvm, 14 version, 15 devExtraCmakeFlags ? [ ], 16 getVersionFile, 17 fetchpatch, 18}: 19stdenv.mkDerivation (finalAttrs: { 20 pname = "lld"; 21 inherit version; 22 23 src = 24 if monorepoSrc != null then 25 runCommand "lld-src-${version}" { inherit (monorepoSrc) passthru; } '' 26 mkdir -p "$out" 27 cp -r ${monorepoSrc}/cmake "$out" 28 cp -r ${monorepoSrc}/lld "$out" 29 mkdir -p "$out/libunwind" 30 cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" 31 mkdir -p "$out/llvm" 32 '' 33 else 34 src; 35 36 sourceRoot = "${finalAttrs.src.name}/lld"; 37 38 patches = [ 39 (getVersionFile "lld/gnu-install-dirs.patch") 40 ] 41 ++ lib.optional (lib.versions.major release_version == "18") ( 42 # https://github.com/llvm/llvm-project/pull/97122 43 fetchpatch { 44 name = "more-openbsd-program-headers.patch"; 45 url = "https://github.com/llvm/llvm-project/commit/d7fd8b19e560fbb613159625acd8046d0df75115.patch"; 46 stripLen = 1; 47 hash = "sha256-7wTy7XDTx0+fhWQpW1KEuz7xJvpl42qMTUfd20KGOfA="; 48 } 49 ); 50 51 nativeBuildInputs = [ 52 cmake 53 ninja 54 ]; 55 buildInputs = [ 56 libllvm 57 libxml2 58 ]; 59 60 cmakeFlags = [ 61 (lib.cmakeFeature "LLD_INSTALL_PACKAGE_DIR" "${placeholder "dev"}/lib/cmake/lld") 62 (lib.cmakeFeature "LLVM_TABLEGEN_EXE" "${buildLlvmPackages.tblgen}/bin/llvm-tblgen") 63 ] 64 ++ devExtraCmakeFlags; 65 66 # Musl's default stack size is too small for lld to be able to link Firefox. 67 env = lib.optionalAttrs stdenv.hostPlatform.isMusl { 68 LDFLAGS = "-Wl,-z,stack-size=2097152"; 69 }; 70 71 outputs = [ 72 "out" 73 "lib" 74 "dev" 75 ]; 76 77 meta = llvm_meta // { 78 homepage = "https://lld.llvm.org/"; 79 description = "LLVM linker (unwrapped)"; 80 longDescription = '' 81 LLD is a linker from the LLVM project that is a drop-in replacement for 82 system linkers and runs much faster than them. It also provides features 83 that are useful for toolchain developers. 84 The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and 85 WebAssembly in descending order of completeness. Internally, LLD consists 86 of several different linkers. 87 ''; 88 }; 89})