nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 87 lines 3.1 kB view raw
1{ lib, stdenv, llvm_meta, cmake, python3, 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" "1l4idd8npbkm168d26kqn529yv3npsd8f2dm8a7iwyknj7iyivw8"; 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 ./gnu-install-dirs.patch 30 ]; 31 32 nativeBuildInputs = [ cmake python3 ]; 33 buildInputs = lib.optional withLibunwind libunwind; 34 35 cmakeFlags = lib.optionals standalone [ 36 "-DLLVM_ENABLE_LIBCXX=ON" 37 "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" 38 ] ++ lib.optionals stdenv.hostPlatform.isWasm [ 39 "-DLIBCXXABI_ENABLE_THREADS=OFF" 40 "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" 41 ] ++ lib.optionals (!enableShared) [ 42 "-DLIBCXXABI_ENABLE_SHARED=OFF" 43 ]; 44 45 preInstall = lib.optionalString stdenv.isDarwin '' 46 for file in lib/*.dylib; do 47 if [ -L "$file" ]; then continue; fi 48 49 # Fix up the install name. Preserve the basename, just replace the path. 50 installName="$out/lib/$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1))" 51 52 # this should be done in CMake, but having trouble figuring out 53 # the magic combination of necessary CMake variables 54 # if you fancy a try, take a look at 55 # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling 56 ${stdenv.cc.targetPrefix}install_name_tool -id $installName $file 57 58 # cc-wrapper passes '-lc++abi' to all c++ link steps, but that causes 59 # libcxxabi to sometimes link against a different version of itself. 60 # Here we simply make that second reference point to ourselves. 61 for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do 62 ${stdenv.cc.targetPrefix}install_name_tool -change $other $installName $file 63 done 64 done 65 ''; 66 67 postInstall = '' 68 mkdir -p "$dev/include" 69 install -m 644 ../include/${if stdenv.isDarwin then "*" else "cxxabi.h"} "$dev/include" 70 ''; 71 72 passthru = { 73 libName = "c++abi"; 74 }; 75 76 meta = llvm_meta // { 77 homepage = "https://libcxxabi.llvm.org/"; 78 description = "Provides C++ standard library support"; 79 longDescription = '' 80 libc++abi is a new implementation of low level support for a standard C++ library. 81 ''; 82 # "All of the code in libc++abi is dual licensed under the MIT license and 83 # the UIUC License (a BSD-like license)": 84 license = with lib.licenses; [ mit ncsa ]; 85 maintainers = llvm_meta.maintainers ++ [ lib.maintainers.vlstill ]; 86 }; 87}