nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 108 lines 3.6 kB view raw
1{ lib, stdenv, llvm_meta, cmake, ninja, python3 2, monorepoSrc, runCommand, fetchpatch 3, cxx-headers, libunwind, version 4, enableShared ? !stdenv.hostPlatform.isStatic 5}: 6 7stdenv.mkDerivation rec { 8 pname = "libcxxabi"; 9 inherit version; 10 11 src = runCommand "${pname}-src-${version}" {} '' 12 mkdir -p "$out" 13 cp -r ${monorepoSrc}/cmake "$out" 14 cp -r ${monorepoSrc}/${pname} "$out" 15 mkdir -p "$out/libcxx/src" 16 cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx" 17 cp -r ${monorepoSrc}/libcxx/include "$out/libcxx" 18 cp -r ${monorepoSrc}/libcxx/src/include "$out/libcxx/src" 19 mkdir -p "$out/llvm" 20 cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" 21 cp -r ${monorepoSrc}/llvm/utils "$out/llvm" 22 cp -r ${monorepoSrc}/runtimes "$out" 23 ''; 24 25 sourceRoot = "${src.name}/runtimes"; 26 27 outputs = [ "out" "dev" ]; 28 29 postUnpack = lib.optionalString stdenv.isDarwin '' 30 export TRIPLE=x86_64-apple-darwin 31 '' + lib.optionalString stdenv.hostPlatform.isWasm '' 32 patch -p1 -d llvm -i ${./wasm.patch} 33 ''; 34 35 prePatch = '' 36 cd ../${pname} 37 chmod -R u+w . 38 ''; 39 40 patches = [ 41 ./gnu-install-dirs.patch 42 43 # https://reviews.llvm.org/D132298, Allow building libcxxabi alone 44 (fetchpatch { 45 url = "https://github.com/llvm/llvm-project/commit/e6a0800532bb409f6d1c62f3698bdd6994a877dc.patch"; 46 sha256 = "1xyjd56m4pfwq8p3xh6i8lhkk9kq15jaml7qbhxdf87z4jjkk63a"; 47 stripLen = 1; 48 }) 49 ]; 50 51 postPatch = '' 52 cd ../runtimes 53 ''; 54 55 nativeBuildInputs = [ cmake ninja python3 ]; 56 buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind; 57 58 cmakeFlags = [ 59 "-DLLVM_ENABLE_RUNTIMES=libcxxabi" 60 "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1" 61 62 # `libcxxabi`'s build does not need a toolchain with a c++ stdlib attached 63 # (we specify the headers it should use explicitly above). 64 # 65 # CMake however checks for this anyways; this flag tells it not to. See: 66 # https://github.com/llvm/llvm-project/blob/4bd3f3759259548e159aeba5c76efb9a0864e6fa/llvm/runtimes/CMakeLists.txt#L243 67 "-DCMAKE_CXX_COMPILER_WORKS=ON" 68 ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ 69 "-DLLVM_ENABLE_LIBCXX=ON" 70 "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" 71 ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 72 "-DLIBCXXABI_ENABLE_THREADS=OFF" 73 "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" 74 ] ++ lib.optionals (!enableShared) [ 75 "-DLIBCXXABI_ENABLE_SHARED=OFF" 76 ]; 77 78 preInstall = lib.optionalString stdenv.isDarwin '' 79 for file in lib/*.dylib; do 80 # this should be done in CMake, but having trouble figuring out 81 # the magic combination of necessary CMake variables 82 # if you fancy a try, take a look at 83 # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling 84 install_name_tool -id $out/$file $file 85 done 86 ''; 87 88 postInstall = '' 89 mkdir -p "$dev/include" 90 install -m 644 ../../${pname}/include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include" 91 ''; 92 93 passthru = { 94 libName = "c++abi"; 95 }; 96 97 meta = llvm_meta // { 98 homepage = "https://libcxxabi.llvm.org/"; 99 description = "Provides C++ standard library support"; 100 longDescription = '' 101 libc++abi is a new implementation of low level support for a standard C++ library. 102 ''; 103 # "All of the code in libc++abi is dual licensed under the MIT license and 104 # the UIUC License (a BSD-like license)": 105 license = with lib.licenses; [ mit ncsa ]; 106 maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ]; 107 }; 108}