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