nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 92 lines 3.1 kB view raw
1{ lib, stdenv, llvm_meta, src, cmake, python3, fixDarwinDylibNames, version 2, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else libcxxabi 3, libcxxabi, libcxxrt 4, enableShared ? !stdenv.hostPlatform.isStatic 5 6# If headersOnly is true, the resulting package would only include the headers. 7# Use this to break the circular dependency between libcxx and libcxxabi. 8# 9# Some context: 10# https://reviews.llvm.org/rG1687f2bbe2e2aaa092f942d4a97d41fad43eedfb 11, headersOnly ? false 12}: 13 14assert stdenv.isDarwin -> cxxabi.pname == "libcxxabi"; 15 16stdenv.mkDerivation rec { 17 pname = if headersOnly then "cxx-headers" else "libcxx"; 18 inherit version; 19 20 inherit src; 21 sourceRoot = "source/libcxx"; 22 23 outputs = [ "out" ] ++ lib.optional (!headersOnly) "dev"; 24 25 patches = [ 26 ./gnu-install-dirs.patch 27 ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 28 ../../libcxx-0001-musl-hacks.patch 29 ]; 30 31 preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' 32 patchShebangs utils/cat_files.py 33 ''; 34 35 nativeBuildInputs = [ cmake python3 ] 36 ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; 37 38 buildInputs = lib.optionals (!headersOnly) [ cxxabi ]; 39 40 cmakeFlags = [ "-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 buildFlags = lib.optional headersOnly "generate-cxx-headers"; 50 installTargets = lib.optional headersOnly "install-cxx-headers"; 51 52 preInstall = lib.optionalString (stdenv.isDarwin && !headersOnly) '' 53 for file in lib/*.dylib; do 54 if [ -L "$file" ]; then continue; fi 55 56 baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1)) 57 installName="$out/lib/$baseName" 58 abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/') 59 60 for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do 61 ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file 62 done 63 done 64 ''; 65 66 # At this point, cxxabi headers would be installed in the dev output, which 67 # prevents moveToOutput from doing its job later in the build process. 68 postInstall = lib.optionalString (!headersOnly) '' 69 mv "$dev/include/c++/v1/"* "$out/include/c++/v1/" 70 pushd "$dev" 71 rmdir -p include/c++/v1 72 popd 73 ''; 74 75 passthru = { 76 isLLVM = true; 77 inherit cxxabi; 78 }; 79 80 meta = llvm_meta // { 81 homepage = "https://libcxx.llvm.org/"; 82 description = "C++ standard library"; 83 longDescription = '' 84 libc++ is an implementation of the C++ standard library, targeting C++11, 85 C++14 and above. 86 ''; 87 88 # "All of the code in libc++ is dual licensed under the MIT license and the 89 # UIUC License (a BSD-like license)": 90 license = with lib.licenses; [ mit ncsa ]; 91 }; 92}