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