nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 89 lines 3.1 kB view raw
1{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version 2, enableShared ? !stdenv.hostPlatform.isStatic 3, standalone ? stdenv.hostPlatform.useLLVM or false 4, withLibunwind ? !stdenv.isDarwin && !stdenv.hostPlatform.isWasm 5}: 6 7stdenv.mkDerivation { 8 pname = "libcxxabi"; 9 inherit version; 10 11 src = fetch "libcxxabi" "1azcf31mxw59hb1x17xncnm3dyw90ylh8rqx462lvypqh3nr6c8l"; 12 13 outputs = [ "out" "dev" ]; 14 15 postUnpack = '' 16 unpackFile ${libcxx.src} 17 mv libcxx-* libcxx 18 unpackFile ${llvm.src} 19 mv llvm-* llvm 20 '' + lib.optionalString stdenv.isDarwin '' 21 export TRIPLE=x86_64-apple-darwin 22 '' + lib.optionalString stdenv.hostPlatform.isMusl '' 23 patch -p1 -d libcxx -i ${../../libcxx-0001-musl-hacks.patch} 24 '' + lib.optionalString stdenv.hostPlatform.isWasm '' 25 patch -p1 -d llvm -i ${./wasm.patch} 26 ''; 27 28 patches = [ 29 ./no-threads.patch 30 ./gnu-install-dirs.patch 31 ]; 32 33 nativeBuildInputs = [ cmake ]; 34 buildInputs = lib.optional withLibunwind libunwind; 35 36 cmakeFlags = lib.optionals standalone [ 37 "-DLLVM_ENABLE_LIBCXX=ON" 38 ] ++ lib.optionals (standalone && withLibunwind) [ 39 "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" 40 ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 41 "-DLIBCXXABI_ENABLE_THREADS=OFF" 42 "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" 43 ] ++ lib.optionals (!enableShared) [ 44 "-DLIBCXXABI_ENABLE_SHARED=OFF" 45 ]; 46 47 preInstall = lib.optionalString stdenv.isDarwin '' 48 for file in lib/*.dylib; do 49 if [ -L "$file" ]; then continue; fi 50 51 # Fix up the install name. Preserve the basename, just replace the path. 52 installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))" 53 54 # this should be done in CMake, but having trouble figuring out 55 # the magic combination of necessary CMake variables 56 # if you fancy a try, take a look at 57 # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling 58 ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file 59 60 # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes 61 # libcxxabi to sometimes link against a different version of itself. 62 # Here we simply make that second reference point to ourselves. 63 for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do 64 ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file 65 done 66 done 67 ''; 68 69 postInstall = '' 70 mkdir -p "$dev/include" 71 install -m 644 ../include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include" 72 ''; 73 74 passthru = { 75 libName = "c++abi"; 76 }; 77 78 meta = llvm_meta // { 79 homepage = "https://libcxxabi.llvm.org/"; 80 description = "Provides C++ standard library support"; 81 longDescription = '' 82 libc++abi is a new implementation of low level support for a standard C++ library. 83 ''; 84 # "All of the code in libc++abi is dual licensed under the MIT license and 85 # the UIUC License (a BSD-like license)": 86 license = with lib.licenses; [ mit ncsa ]; 87 maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ]; 88 }; 89}