nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 79 lines 2.5 kB view raw
1{ lib, stdenv, llvm_meta, fetch, cmake, python3, llvm, 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" "05cx39ldlxchck454lgfly1xj0c7x65iyx4hqhiihrlg6p6qj854"; 14 15 postUnpack = '' 16 unpackFile ${libcxxabi.src} 17 mv libcxxabi-* libcxxabi 18 unpackFile ${llvm.src} 19 mv llvm-* llvm 20 ''; 21 22 outputs = [ "out" "dev" ]; 23 24 patches = [ 25 ./gnu-install-dirs.patch 26 ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 27 ../../libcxx-0001-musl-hacks.patch 28 ]; 29 30 preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' 31 patchShebangs utils/cat_files.py 32 ''; 33 34 nativeBuildInputs = [ cmake python3 ] 35 ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; 36 37 buildInputs = [ cxxabi ]; 38 39 cmakeFlags = [ 40 "-DLIBCXX_CXX_ABI=${cxxabi.pname}" 41 ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" 42 ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" 43 ++ lib.optionals stdenv.hostPlatform.isWasm [ 44 "-DLIBCXX_ENABLE_THREADS=OFF" 45 "-DLIBCXX_ENABLE_FILESYSTEM=OFF" 46 "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" 47 ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; 48 49 preInstall = lib.optionalString (stdenv.isDarwin) '' 50 for file in lib/*.dylib; do 51 if [ -L "$file" ]; then continue; fi 52 53 baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1)) 54 installName="$out/lib/$baseName" 55 abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/') 56 57 for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do 58 ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file 59 done 60 done 61 ''; 62 63 passthru = { 64 isLLVM = true; 65 inherit cxxabi; 66 }; 67 68 meta = llvm_meta // { 69 homepage = "https://libcxx.llvm.org/"; 70 description = "C++ standard library"; 71 longDescription = '' 72 libc++ is an implementation of the C++ standard library, targeting C++11, 73 C++14 and above. 74 ''; 75 # "All of the code in libc++ is dual licensed under the MIT license and the 76 # UIUC License (a BSD-like license)": 77 license = with lib.licenses; [ mit ncsa ]; 78 }; 79}