1{ lib, stdenv, fetch, cmake, libcxxabi, fixDarwinDylibNames, version }:
2
3stdenv.mkDerivation rec {
4 name = "libc++-${version}";
5
6 src = fetch "libcxx" "0qbl3afl2p2h87p977lsqr5kykl6cgjpkzczs0g6a3pn53j1bri5";
7
8 postUnpack = ''
9 unpackFile ${libcxxabi.src}
10 '';
11
12 preConfigure = ''
13 # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
14 cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$NIX_BUILD_TOP/libcxxabi-${version}.src/include")
15 '';
16
17 patches = [
18 # glibc 2.26 fix
19 ./xlocale-glibc-2.26.patch
20 ]
21 ++ lib.optional stdenv.isDarwin ./darwin.patch
22 ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [
23 ../../libcxx-0001-musl-hacks.patch
24 ../../libcxx-max_align_t.patch
25 ];
26
27 nativeBuildInputs = [ cmake ];
28 buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
29
30 cmakeFlags = [
31 "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
32 "-DLIBCXX_LIBCPPABI_VERSION=2"
33 "-DLIBCXX_CXX_ABI=libcxxabi"
34 ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
35
36 enableParallelBuilding = true;
37
38 linkCxxAbi = stdenv.isLinux;
39
40 setupHooks = [
41 ../../../../../build-support/setup-hooks/role.bash
42 ./setup-hook.sh
43 ];
44
45 meta = {
46 homepage = http://libcxx.llvm.org/;
47 description = "A new implementation of the C++ standard library, targeting C++11";
48 license = with stdenv.lib.licenses; [ ncsa mit ];
49 platforms = stdenv.lib.platforms.unix;
50 };
51}