mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-05 04:23:47 +00:00
6ba1b5b0b3
What changed: * Fixed crtbeginS.o and crtendS.o missing (they may or may not be called crt{begin_end},{,_shared}. * Fixed implicit function declaration causing build errors for various builds by supplying -Wno-implicit-function-declaration. * Fixed __cxxabi_config.h missing, by adding -I${cxxabi}/include/c++/v1 in the wrapper. * Fixed libcxx failing to build due to missing libunwind symbols by including libunwind as a buildInput, and setting -DLIBCXX_ADDITIONAL_LIBRARIES=unwind for stdenv.hostPlatform.useLLVM == true. * libcxxabi wants to find libunwind at libunwind_shared.so, so symlink it there in libunwind. * llvmPackages_16.libcxxabi: Pass -nostdlib via CMAKE_*_LINKER_FLAGS Without this flag, the link of libcxxabi.so tries to pull in libgcc and friends, from the clang compiler driver. * Drop unneeded musl hack patch from libcxx. * Pass -Wno-error=implicit-function-declaration only to compiler-rt See LLVM forum discussion: https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213 In summary, LLVM 16 made implicit function declaration an error. This happens a lot in configure scripts which can break things. * llvmPackages_16: !isDarwin: Supply -DLIBCXX_ABI_USE_LLVM_UNWINDER=On Otherwise it fails with various undefined references to _Unwind_* functions: (full list: _Unwind_DeleteException _Unwind_GetIP _Unwind_GetLanguageSpecificData _Unwind_GetRegionStart _Unwind_RaiseException _Unwind_Resume _Unwind_SetGR _Unwind_SetIP). * 16.libcxxabi: Only pass -nostdlib for useLLVM and Darwin builds What was tested: * x86_64-linux, aarch64-linux, the stdenv builds. * Additionally I was able to get nix to build, with an overlay to fix a couple of minor issues in downstream packages (overlay supplied in PR #246577. * aarch64-darwin fails spuriously in a single LLVM test strip-preserve-atime.test checking atime timestamps. * The same for pkgsLLVM with llvmPackages = llvmPackages_15. Signed-off-by: Peter Waller <p@pwaller.net>
68 lines
1.9 KiB
Nix
68 lines
1.9 KiB
Nix
{ lib, stdenv, llvm_meta, version
|
|
, monorepoSrc, runCommand
|
|
, cmake
|
|
, ninja
|
|
, python3
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "libunwind";
|
|
inherit version;
|
|
|
|
# I am not so comfortable giving libc++ and friends the whole monorepo as
|
|
# requested, so I filter it to what is needed.
|
|
src = runCommand "${pname}-src-${version}" {} ''
|
|
mkdir -p "$out"
|
|
cp -r ${monorepoSrc}/cmake "$out"
|
|
cp -r ${monorepoSrc}/${pname} "$out"
|
|
mkdir -p "$out/libcxx"
|
|
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
|
|
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
|
|
mkdir -p "$out/llvm"
|
|
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
|
|
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
|
|
cp -r ${monorepoSrc}/runtimes "$out"
|
|
'';
|
|
|
|
sourceRoot = "${src.name}/runtimes";
|
|
|
|
prePatch = ''
|
|
cd ../${pname}
|
|
chmod -R u+w .
|
|
'';
|
|
|
|
patches = [
|
|
./gnu-install-dirs.patch
|
|
];
|
|
|
|
postPatch = ''
|
|
cd ../runtimes
|
|
'';
|
|
|
|
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
|
|
# libcxxabi wants to link to libunwind_shared.so (?).
|
|
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
|
|
'';
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
nativeBuildInputs = [ cmake ninja python3 ];
|
|
|
|
cmakeFlags = [
|
|
"-DLLVM_ENABLE_RUNTIMES=libunwind"
|
|
] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
|
|
|
|
meta = llvm_meta // {
|
|
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
|
|
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
|
|
description = "LLVM's unwinder library";
|
|
longDescription = ''
|
|
The unwind library provides a family of _Unwind_* functions implementing
|
|
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
|
|
I). It is a dependency of the C++ ABI library, and sometimes is a
|
|
dependency of other runtimes.
|
|
'';
|
|
};
|
|
}
|