nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, llvm_meta
2, buildLlvmTools
3, fetch
4, libunwind
5, cmake
6, libxml2
7, libllvm
8, version
9}:
10
11stdenv.mkDerivation rec {
12 pname = "lld";
13 inherit version;
14
15 src = fetch pname "0qg3fgc7wj34hdkqn21y03zcmsdd01szhhm1hfki63iifrm3y2v9";
16
17 patches = [
18 ./gnu-install-dirs.patch
19 ];
20
21 postPatch = ''
22 substituteInPlace MachO/CMakeLists.txt --replace \
23 '(''${LLVM_MAIN_SRC_DIR}/' '('
24 mkdir -p libunwind/include
25 tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/"
26 '';
27
28 nativeBuildInputs = [ cmake ];
29 buildInputs = [ libllvm libxml2 ];
30
31 cmakeFlags = [
32 "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}"
33 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
34 "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
35 ];
36
37 # Musl's default stack size is too small for lld to be able to link Firefox.
38 LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152";
39
40 outputs = [ "out" "lib" "dev" ];
41
42 meta = llvm_meta // {
43 homepage = "https://lld.llvm.org/";
44 description = "The LLVM linker (unwrapped)";
45 longDescription = ''
46 LLD is a linker from the LLVM project that is a drop-in replacement for
47 system linkers and runs much faster than them. It also provides features
48 that are useful for toolchain developers.
49 The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
50 WebAssembly in descending order of completeness. Internally, LLD consists
51 of several different linkers.
52 '';
53 };
54}