nixpkgs/pkgs/development/compilers/llvm/17/lld/default.nix
Will Cohen a4daad0caa llvmPackages_17.lld: backport table-base patch
Starting with emscripten-3.1.46, this flag to LLVM is needed.

This is a backport of
93adcb770b.patch,
with additional review at https://reviews.llvm.org/D158892 and
emscripten-core/emscripten#20097.
2023-12-11 11:48:50 -05:00

59 lines
1.6 KiB
Nix

{ lib, stdenv, llvm_meta
, buildLlvmTools
, monorepoSrc, runCommand
, cmake
, ninja
, libxml2
, libllvm
, version
}:
stdenv.mkDerivation rec {
pname = "lld";
inherit version;
# Blank llvm dir just so relative path works
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libunwind"
cp -r ${monorepoSrc}/libunwind/include "$out/libunwind"
mkdir -p "$out/llvm"
'';
sourceRoot = "${src.name}/${pname}";
patches = [
./gnu-install-dirs.patch
./add-table-base.patch
];
nativeBuildInputs = [ cmake ninja ];
buildInputs = [ libllvm libxml2 ];
cmakeFlags = [
"-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen"
];
# Musl's default stack size is too small for lld to be able to link Firefox.
LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152";
outputs = [ "out" "lib" "dev" ];
meta = llvm_meta // {
homepage = "https://lld.llvm.org/";
description = "The LLVM linker (unwrapped)";
longDescription = ''
LLD is a linker from the LLVM project that is a drop-in replacement for
system linkers and runs much faster than them. It also provides features
that are useful for toolchain developers.
The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and
WebAssembly in descending order of completeness. Internally, LLD consists
of several different linkers.
'';
};
}