@@ -1,4 +1,4 @@
1−{ lib, stdenv, fetch, cmake, llvm, libcxxabi, fixDarwinDylibNames, version }:
1+{ lib, stdenv, fetch, cmake, python, llvm, libcxxabi, fixDarwinDylibNames, version }:
22
33stdenv.mkDerivation rec {
44 name = "libc++-${version}";
@@ -10,6 +10,12 @@ stdenv.mkDerivation rec {
1010 export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include"
1111 '';
1212
13+ # on next rebuild, this can be replaced with optionals; for now set to null to avoid
14+ # patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
15+ patches = if stdenv.hostPlatform.isMusl then [
16+ ../../libcxx-0001-musl-hacks.patch
17+ ] else null;
18+
1319 prePatch = ''
1420 substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++"
1521 '';
@@ -17,9 +23,10 @@ stdenv.mkDerivation rec {
1723 preConfigure = ''
1824 # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package
1925 cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR")
26+ '' + lib.optionalString stdenv.hostPlatform.isMusl ''
27+ patchShebangs utils/cat_files.py
2028 '';
21−
22− nativeBuildInputs = [ cmake ];
29+ nativeBuildInputs = [ cmake ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl python;
2330
2431 buildInputs = [ libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
2532
@@ -27,7 +34,7 @@ stdenv.mkDerivation rec {
2734 "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
2835 "-DLIBCXX_LIBCPPABI_VERSION=2"
2936 "-DLIBCXX_CXX_ABI=libcxxabi"
30− ];
37+ ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "-DLIBCXX_HAS_MUSL_LIBC=1";
3138
3239 enableParallelBuilding = true;
3340