1{ lib, stdenv, llvm_meta
2, buildLlvmTools
3, monorepoSrc, runCommand
4, cmake
5, libxml2
6, libllvm
7, version
8}:
9
10stdenv.mkDerivation rec {
11 pname = "lld";
12 inherit version;
13
14 # Blank llvm dir just so relative path works
15 src = runCommand "${pname}-src-${version}" {} ''
16 mkdir -p "$out"
17 cp -r ${monorepoSrc}/cmake "$out"
18 cp -r ${monorepoSrc}/${pname} "$out"
19 mkdir -p "$out/libunwind"
20 cp -r ${monorepoSrc}/libunwind/include "$out/libunwind"
21 mkdir -p "$out/llvm"
22 '';
23
24 sourceRoot = "${src.name}/${pname}";
25
26 patches = [
27 ./gnu-install-dirs.patch
28 ];
29
30 nativeBuildInputs = [ cmake ];
31 buildInputs = [ libllvm libxml2 ];
32
33 cmakeFlags = [
34 "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld"
35 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
36 "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
37 ];
38
39 outputs = [ "out" "lib" "dev" ];
40
41 meta = llvm_meta // {
42 homepage = "https://lld.llvm.org/";
43 description = "The LLVM linker (unwrapped)";
44 longDescription = ''
45 LLD is a linker from the LLVM project that is a drop-in replacement for
46 system linkers and runs much faster than them. It also provides features
47 that are useful for toolchain developers.
48 The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
49 WebAssembly in descending order of completeness. Internally, LLD consists
50 of several different linkers.
51 '';
52 };
53}