nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 104 lines 3.8 kB view raw
1{ lib, stdenv, llvm_meta, fetch, fetchpatch, 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" "1rgqsqpgi0vkga5d7hy0iyfsqgzfz7q1xy7afdfa1snp1qjks8xv"; 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 (fetchpatch { 26 # Backported from LLVM 12, avoids clashes with commonly used "block.h" header. 27 url = "https://github.com/llvm/llvm-project/commit/19bc9ea480b60b607a3e303f20c7a3a2ea553369.patch"; 28 sha256 = "sha256-aWa66ogmPkG0xHzSfcpD0qZyZQcNKwLV44js4eiun78="; 29 stripLen = 1; 30 }) 31 ./gnu-install-dirs.patch 32 ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 33 ../../libcxx-0001-musl-hacks.patch 34 ]; 35 36 # Prevent errors like "error: 'foo' is unavailable: introduced in macOS yy.zz" 37 postPatch = '' 38 substituteInPlace include/__config \ 39 --replace "# define _LIBCPP_USE_AVAILABILITY_APPLE" "" 40 ''; 41 42 preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' 43 patchShebangs utils/cat_files.py 44 ''; 45 46 nativeBuildInputs = [ cmake python3 ] 47 ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; 48 49 buildInputs = [ cxxabi ]; 50 51 cmakeFlags = [ 52 "-DLIBCXX_CXX_ABI=${cxxabi.pname}" 53 ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" 54 ++ lib.optional (stdenv.hostPlatform.useLLVM or false) "-DLIBCXX_USE_COMPILER_RT=ON" 55 ++ lib.optionals stdenv.hostPlatform.isWasm [ 56 "-DLIBCXX_ENABLE_THREADS=OFF" 57 "-DLIBCXX_ENABLE_FILESYSTEM=OFF" 58 "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" 59 ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" 60 61 # TODO: this is a bit of a hack to cross compile to Apple Silicon. libcxx 62 # starting with 11 enables CMAKE_BUILD_WITH_INSTALL_NAME_DIR which requires 63 # platform setup for rpaths. In cmake, this is enabled when macos is newer 64 # than 10.5. However CMAKE_SYSTEM_VERSION is set to empty (TODO: why?) 65 # which prevents the conditional configuration, and configure fails. The 66 # value here corresponds to `uname -r`. If stdenv.hostPlatform.release is 67 # not null, then this property will be set via mkDerivation (TODO: how can 68 # we set this?). 69 ++ lib.optional ( 70 stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 && 71 stdenv.hostPlatform != stdenv.buildPlatform 72 ) "-DCMAKE_SYSTEM_VERSION=20.1.0"; 73 74 preInstall = lib.optionalString (stdenv.isDarwin) '' 75 for file in lib/*.dylib; do 76 if [ -L "$file" ]; then continue; fi 77 78 baseName=$(basename $(${stdenv.cc.targetPrefix}otool -D $file | tail -n 1)) 79 installName="$out/lib/$baseName" 80 abiName=$(echo "$baseName" | sed -e 's/libc++/libc++abi/') 81 82 for other in $(${stdenv.cc.targetPrefix}otool -L $file | awk '$1 ~ "/libc\\+\\+abi" { print $1 }'); do 83 ${stdenv.cc.targetPrefix}install_name_tool -change $other ${cxxabi}/lib/$abiName $file 84 done 85 done 86 ''; 87 88 passthru = { 89 isLLVM = true; 90 inherit cxxabi; 91 }; 92 93 meta = llvm_meta // { 94 homepage = "https://libcxx.llvm.org/"; 95 description = "C++ standard library"; 96 longDescription = '' 97 libc++ is an implementation of the C++ standard library, targeting C++11, 98 C++14 and above. 99 ''; 100 # "All of the code in libc++ is dual licensed under the MIT license and the 101 # UIUC License (a BSD-like license)": 102 license = with lib.licenses; [ mit ncsa ]; 103 }; 104}