nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 88 lines 3.1 kB view raw
1{ lib, stdenv, llvm_meta, fetch, cmake, python3, fixDarwinDylibNames, version 2, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi 3, libcxxabi, libcxxrt 4, enableShared ? !stdenv.hostPlatform.isStatic 5}: 6 7assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi"; 8 9stdenv.mkDerivation { 10 pname = "libcxx"; 11 inherit version; 12 13 src = fetch "libcxx" "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"; 14 15 postUnpack = '' 16 unpackFile ${libcxxabi.src} 17 export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" 18 ''; 19 20 outputs = [ "out" "dev" ]; 21 22 patches = [ 23 ./gnu-install-dirs.patch 24 ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 25 ../../libcxx-0001-musl-hacks.patch 26 ]; 27 28 # Prevent errors like "error: 'foo' is unavailable: introduced in macOS yy.zz" 29 postPatch = '' 30 substituteInPlace include/__config \ 31 --replace "# define _LIBCPP_USE_AVAILABILITY_APPLE" "" 32 ''; 33 34 preConfigure = '' 35 # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package 36 cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") 37 '' + lib.optionalString stdenv.hostPlatform.isMusl '' 38 patchShebangs utils/cat_files.py 39 ''; 40 nativeBuildInputs = [ cmake ] 41 ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) python3 42 ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 43 44 buildInputs = [ cxxabi ]; 45 46 cmakeFlags = [ 47 "-DLIBCXX_LIBCPPABI_VERSION=2" 48 "-DLIBCXX_CXX_ABI=${cxxabi.pname}" 49 ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" 50 ++ lib.optional (cxxabi.pname == "libcxxabi") "-DLIBCXX_LIBCXXABI_LIB_PATH=${cxxabi}/lib" 51 ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" 52 ++ lib.optionals stdenv.hostPlatform.isWasm [ 53 "-DLIBCXX_ENABLE_THREADS=OFF" 54 "-DLIBCXX_ENABLE_FILESYSTEM=OFF" 55 "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" 56 ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; 57 58 preInstall = lib.optionalString (stdenv.isDarwin) '' 59 for file in lib/*.dylib; do 60 if [ -L "$file" ]; then continue; fi 61 62 baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1)) 63 installName="$out/lib/$baseName" 64 abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/') 65 66 for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do 67 ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file 68 done 69 done 70 ''; 71 72 passthru = { 73 isLLVM = true; 74 inherit cxxabi; 75 }; 76 77 meta = llvm_meta // { 78 homepage = "https://libcxx.llvm.org/"; 79 description = "C++ standard library"; 80 longDescription = '' 81 libc++ is an implementation of the C++ standard library, targeting C++11, 82 C++14 and above. 83 ''; 84 # "All of the code in libc++ is dual licensed under the MIT license and the 85 # UIUC License (a BSD-like license)": 86 license = with lib.licenses; [ mit ncsa ]; 87 }; 88}