summary refs log tree commit diff
path: root/pkgs/development/libraries
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-11-04 14:30:43 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-11-04 14:30:43 +0100
commit7495c61d49208a9fc90b937bca548d9005ff17c8 (patch)
tree5eec5f802d3146b8b1f788aa1275ea1c44a24d31 /pkgs/development/libraries
parented867a50eb89a90db3b1741bf4c0bf0cd4557dba (diff)
parent899d81b37ba6dc26431b82b40300505f19504e03 (diff)
downloadnixpkgs-7495c61d49208a9fc90b937bca548d9005ff17c8.tar
nixpkgs-7495c61d49208a9fc90b937bca548d9005ff17c8.tar.gz
nixpkgs-7495c61d49208a9fc90b937bca548d9005ff17c8.tar.bz2
nixpkgs-7495c61d49208a9fc90b937bca548d9005ff17c8.tar.lz
nixpkgs-7495c61d49208a9fc90b937bca548d9005ff17c8.tar.xz
nixpkgs-7495c61d49208a9fc90b937bca548d9005ff17c8.tar.zst
nixpkgs-7495c61d49208a9fc90b937bca548d9005ff17c8.zip
Merge remote-tracking branch 'origin/darwin-clang-stdenv' into staging
Conflicts:
	pkgs/applications/editors/vim/macvim.nix
Diffstat (limited to 'pkgs/development/libraries')
-rw-r--r--pkgs/development/libraries/apr-util/default.nix3
-rw-r--r--pkgs/development/libraries/aspell/clang.patch18
-rw-r--r--pkgs/development/libraries/aspell/default.nix4
-rw-r--r--pkgs/development/libraries/boost/1.55.nix6
-rw-r--r--pkgs/development/libraries/boost/boost-155-clang.patch90
-rw-r--r--pkgs/development/libraries/cyrus-sasl/default.nix9
-rw-r--r--pkgs/development/libraries/db/generic.nix4
-rw-r--r--pkgs/development/libraries/db/osx.patch20
-rw-r--r--pkgs/development/libraries/gmp/5.1.x.nix3
-rw-r--r--pkgs/development/libraries/libc++/darwin.patch30
-rw-r--r--pkgs/development/libraries/libc++/default.nix30
-rw-r--r--pkgs/development/libraries/libc++/setup-hook.sh2
-rw-r--r--pkgs/development/libraries/libc++abi/darwin.patch17
-rw-r--r--pkgs/development/libraries/libc++abi/default.nix36
-rw-r--r--pkgs/development/libraries/libc++abi/no-stdc++.patch12
-rw-r--r--pkgs/development/libraries/libdevil/default.nix9
-rw-r--r--pkgs/development/libraries/libedit/default.nix2
-rw-r--r--pkgs/development/libraries/libffi/default.nix5
-rw-r--r--pkgs/development/libraries/libgcrypt/default.nix2
-rw-r--r--pkgs/development/libraries/libunistring/clang.patch14
-rw-r--r--pkgs/development/libraries/libunistring/default.nix2
-rw-r--r--pkgs/development/libraries/mesa-darwin/default.nix2
-rw-r--r--pkgs/development/libraries/mpc/default.nix2
-rw-r--r--pkgs/development/libraries/mpfr/default.nix2
-rw-r--r--pkgs/development/libraries/ncurses/clang.patch42
-rw-r--r--pkgs/development/libraries/ncurses/default.nix4
-rw-r--r--pkgs/development/libraries/qt-4.x/4.8/default.nix2
-rw-r--r--pkgs/development/libraries/readline/6.2.nix1
-rw-r--r--pkgs/development/libraries/readline/clang.patch13
-rw-r--r--pkgs/development/libraries/serf/default.nix14
-rw-r--r--pkgs/development/libraries/v8/default.nix2
31 files changed, 358 insertions, 44 deletions
diff --git a/pkgs/development/libraries/apr-util/default.nix b/pkgs/development/libraries/apr-util/default.nix
index 6932f389b84..76477d38b6d 100644
--- a/pkgs/development/libraries/apr-util/default.nix
+++ b/pkgs/development/libraries/apr-util/default.nix
@@ -2,6 +2,7 @@
 , sslSupport ? true, openssl
 , bdbSupport ? false, db
 , ldapSupport ? true, openldap
+, libiconvOrNull
 }:
 
 assert sslSupport -> openssl != null;
@@ -28,7 +29,7 @@ stdenv.mkDerivation rec {
     ${stdenv.lib.optionalString ldapSupport "--with-ldap"}
   '';
 
-  propagatedBuildInputs = [ makeWrapper apr expat ]
+  propagatedBuildInputs = [ makeWrapper apr expat libiconvOrNull ]
     ++ optional sslSupport openssl
     ++ optional bdbSupport db
     ++ optional ldapSupport openldap;
diff --git a/pkgs/development/libraries/aspell/clang.patch b/pkgs/development/libraries/aspell/clang.patch
new file mode 100644
index 00000000000..c4cfa426588
--- /dev/null
+++ b/pkgs/development/libraries/aspell/clang.patch
@@ -0,0 +1,18 @@
+--- interfaces/cc/aspell.h	2013-10-13 20:29:33.000000000 +0200
++++ interfaces/cc/aspell.h	2013-10-13 20:30:01.000000000 +0200
+@@ -237,6 +237,7 @@
+ /******************************** errors ********************************/
+ 
+ 
++#ifndef __cplusplus
+ extern const struct AspellErrorInfo * const aerror_other;
+ extern const struct AspellErrorInfo * const aerror_operation_not_supported;
+ extern const struct AspellErrorInfo * const   aerror_cant_copy;
+@@ -322,6 +323,7 @@
+ extern const struct AspellErrorInfo * const   aerror_bad_magic;
+ extern const struct AspellErrorInfo * const aerror_expression;
+ extern const struct AspellErrorInfo * const   aerror_invalid_expression;
++#endif
+ 
+ 
+ /******************************* speller *******************************/
diff --git a/pkgs/development/libraries/aspell/default.nix b/pkgs/development/libraries/aspell/default.nix
index 4ac6dc58ba9..38d734e902c 100644
--- a/pkgs/development/libraries/aspell/default.nix
+++ b/pkgs/development/libraries/aspell/default.nix
@@ -8,6 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "1qgn5psfyhbrnap275xjfrzppf5a83fb67gpql0kfqv37al869gm";
   };
 
+  patchPhase = ''
+    patch interfaces/cc/aspell.h < ${./clang.patch}
+  '';
+
   buildInputs = [ perl ];
 
   doCheck = true;
diff --git a/pkgs/development/libraries/boost/1.55.nix b/pkgs/development/libraries/boost/1.55.nix
index 31469b3e06c..2c02ce13e8d 100644
--- a/pkgs/development/libraries/boost/1.55.nix
+++ b/pkgs/development/libraries/boost/1.55.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, icu, expat, zlib, bzip2, python, fixDarwinDylibNames
-, toolset ? null
+, toolset ? if stdenv.isDarwin then "clang" else null
 , enableRelease ? true
 , enableDebug ? false
 , enableSingleThreaded ? false
@@ -57,6 +57,8 @@ let res = stdenv.mkDerivation {
     sha256 = "0lkv5dzssbl5fmh2nkaszi8x9qbj80pr4acf9i26sj3rvlih1w7z";
   };
 
+  patches = stdenv.lib.optional (toolset == "clang") [ ./boost-155-clang.patch ];
+
   enableParallelBuilding = true;
 
   buildInputs =
@@ -66,7 +68,7 @@ let res = stdenv.mkDerivation {
   configureScript = "./bootstrap.sh";
   configureFlags = "--with-icu=${icu} --with-python=${python}/bin/python" + withToolset;
 
-  buildPhase = "${stdenv.lib.optionalString (toolset == "clang") "unset NIX_ENFORCE_PURITY; "}./b2 -j$NIX_BUILD_CORES -sEXPAT_INCLUDE=${expat}/include -sEXPAT_LIBPATH=${expat}/lib --layout=${layout} variant=${variant} threading=${threading} link=${link} ${cflags} install${withToolset}";
+  buildPhase = "${stdenv.lib.optionalString (toolset == "clang") "unset NIX_ENFORCE_PURITY; "}./b2 -j$NIX_BUILD_CORES -sEXPAT_INCLUDE=${expat}/include -sEXPAT_LIBPATH=${expat}/lib --layout=${layout} variant=${variant} threading=${threading} link=${link} ${cflags} install";
 
   # normal install does not install bjam, this is a separate step
   installPhase = ''
diff --git a/pkgs/development/libraries/boost/boost-155-clang.patch b/pkgs/development/libraries/boost/boost-155-clang.patch
new file mode 100644
index 00000000000..9c4e3a74cd2
--- /dev/null
+++ b/pkgs/development/libraries/boost/boost-155-clang.patch
@@ -0,0 +1,90 @@
+diff --git a/boost/atomic/detail/cas128strong.hpp b/boost/atomic/detail/cas128strong.hpp
+index 906c13e..dcb4d7d 100644
+--- a/boost/atomic/detail/cas128strong.hpp
++++ b/boost/atomic/detail/cas128strong.hpp
+@@ -196,15 +196,17 @@ class base_atomic<T, void, 16, Sign>
+ 
+ public:
+     BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
+-    explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : v_(0)
++    explicit base_atomic(value_type const& v) BOOST_NOEXCEPT
+     {
++        memset(&v_, 0, sizeof(v_));
+         memcpy(&v_, &v, sizeof(value_type));
+     }
+ 
+     void
+     store(value_type const& value, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
+     {
+-        storage_type value_s = 0;
++        storage_type value_s;
++        memset(&value_s, 0, sizeof(value_s));
+         memcpy(&value_s, &value, sizeof(value_type));
+         platform_fence_before_store(order);
+         platform_store128(value_s, &v_);
+@@ -247,7 +249,9 @@ class base_atomic<T, void, 16, Sign>
+         memory_order success_order,
+         memory_order failure_order) volatile BOOST_NOEXCEPT
+     {
+-        storage_type expected_s = 0, desired_s = 0;
++        storage_type expected_s, desired_s;
++        memset(&expected_s, 0, sizeof(expected_s));
++        memset(&desired_s, 0, sizeof(desired_s));
+         memcpy(&expected_s, &expected, sizeof(value_type));
+         memcpy(&desired_s, &desired, sizeof(value_type));
+
+diff --git a/boost/atomic/detail/gcc-atomic.hpp b/boost/atomic/detail/gcc-atomic.hpp
+index a130590..4af99a1 100644
+--- a/boost/atomic/detail/gcc-atomic.hpp
++++ b/boost/atomic/detail/gcc-atomic.hpp
+@@ -958,14 +958,16 @@ class base_atomic<T, void, 16, Sign>
+ 
+ public:
+     BOOST_DEFAULTED_FUNCTION(base_atomic(void), {})
+-    explicit base_atomic(value_type const& v) BOOST_NOEXCEPT : v_(0)
++    explicit base_atomic(value_type const& v) BOOST_NOEXCEPT
+     {
++        memset(&v_, 0, sizeof(v_));
+         memcpy(&v_, &v, sizeof(value_type));
+     }
+ 
+     void store(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
+     {
+-        storage_type tmp = 0;
++        storage_type tmp;
++        memset(&tmp, 0, sizeof(tmp));
+         memcpy(&tmp, &v, sizeof(value_type));
+         __atomic_store_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order));
+     }
+@@ -980,7 +982,8 @@ class base_atomic<T, void, 16, Sign>
+ 
+     value_type exchange(value_type const& v, memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
+     {
+-        storage_type tmp = 0;
++        storage_type tmp;
++        memset(&tmp, 0, sizeof(tmp));
+         memcpy(&tmp, &v, sizeof(value_type));
+         tmp = __atomic_exchange_n(&v_, tmp, atomics::detail::convert_memory_order_to_gcc(order));
+         value_type res;
+@@ -994,7 +997,9 @@ class base_atomic<T, void, 16, Sign>
+         memory_order success_order,
+         memory_order failure_order) volatile BOOST_NOEXCEPT
+     {
+-        storage_type expected_s = 0, desired_s = 0;
++        storage_type expected_s, desired_s;
++        memset(&expected_s, 0, sizeof(expected_s));
++        memset(&desired_s, 0, sizeof(desired_s));
+         memcpy(&expected_s, &expected, sizeof(value_type));
+         memcpy(&desired_s, &desired, sizeof(value_type));
+         const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, false,
+@@ -1010,7 +1015,9 @@ class base_atomic<T, void, 16, Sign>
+         memory_order success_order,
+         memory_order failure_order) volatile BOOST_NOEXCEPT
+     {
+-        storage_type expected_s = 0, desired_s = 0;
++        storage_type expected_s, desired_s;
++        memset(&expected_s, 0, sizeof(expected_s));
++        memset(&desired_s, 0, sizeof(desired_s));
+         memcpy(&expected_s, &expected, sizeof(value_type));
+         memcpy(&desired_s, &desired, sizeof(value_type));
+         const bool success = __atomic_compare_exchange_n(&v_, &expected_s, desired_s, true,
diff --git a/pkgs/development/libraries/cyrus-sasl/default.nix b/pkgs/development/libraries/cyrus-sasl/default.nix
index 712f05b8d65..391638548fb 100644
--- a/pkgs/development/libraries/cyrus-sasl/default.nix
+++ b/pkgs/development/libraries/cyrus-sasl/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, openssl, db, gettext, pam }:
+{ lib, stdenv, fetchurl, openssl, db, gettext, pam, fixDarwinDylibNames }:
 
 stdenv.mkDerivation rec {
   name = "cyrus-sasl-2.1.26";
@@ -8,7 +8,10 @@ stdenv.mkDerivation rec {
     sha256 = "1hvvbcsg21nlncbgs0cgn3iwlnb3vannzwsp6rwvnn9ba4v53g4g";
   };
 
-  buildInputs = [ openssl db gettext ] ++ stdenv.lib.optional stdenv.isLinux pam;
+  buildInputs =
+    [ openssl db gettext ]
+    ++ lib.optional stdenv.isLinux pam
+    ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
 
   patches = [ ./missing-size_t.patch ]; # https://bugzilla.redhat.com/show_bug.cgi?id=906519
   patchFlags = "-p0";
@@ -22,7 +25,7 @@ stdenv.mkDerivation rec {
                         )
   '';
 
-  installFlags = if stdenv.isDarwin then [ "framedir=$(out)/Library/Frameworks/SASL2.framework" ] else null;
+  installFlags = lib.optional stdenv.isDarwin [ "framedir=$(out)/Library/Frameworks/SASL2.framework" ];
 
   meta = {
     homepage = "http://cyrusimap.web.cmu.edu/";
diff --git a/pkgs/development/libraries/db/generic.nix b/pkgs/development/libraries/db/generic.nix
index 6217bc46124..9d3f87ad5cb 100644
--- a/pkgs/development/libraries/db/generic.nix
+++ b/pkgs/development/libraries/db/generic.nix
@@ -18,6 +18,10 @@ stdenv.mkDerivation rec {
 
   patches = extraPatches;
 
+  patchPhase = ''
+    patch src/dbinc/atomic.h < ${./osx.patch}
+  '';
+
   configureFlags = [
     (if cxxSupport then "--enable-cxx" else "--disable-cxx")
     (if compat185 then "--enable-compat185" else "--disable-compat185")
diff --git a/pkgs/development/libraries/db/osx.patch b/pkgs/development/libraries/db/osx.patch
new file mode 100644
index 00000000000..398aa1d3700
--- /dev/null
+++ b/pkgs/development/libraries/db/osx.patch
@@ -0,0 +1,20 @@
+--- src/dbinc/atomic.h	2013-03-12 14:07:22.000000000 -0400
++++ src/dbinc/atomic.h.change	2013-03-12 14:06:35.000000000 -0400
+@@ -144,7 +144,7 @@
+ #define	atomic_inc(env, p)	__atomic_inc(p)
+ #define	atomic_dec(env, p)	__atomic_dec(p)
+ #define	atomic_compare_exchange(env, p, o, n)	\
+-	__atomic_compare_exchange((p), (o), (n))
++	__atomic_compare_exchange_db((p), (o), (n))
+ static inline int __atomic_inc(db_atomic_t *p)
+ {
+ 	int	temp;
+@@ -176,7 +176,7 @@
+  * http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
+  * which configure could be changed to use.
+  */
+-static inline int __atomic_compare_exchange(
++static inline int __atomic_compare_exchange_db(
+ 	db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
+ {
+ 	atomic_value_t was;
diff --git a/pkgs/development/libraries/gmp/5.1.x.nix b/pkgs/development/libraries/gmp/5.1.x.nix
index 14a6d34d932..e9495b796dd 100644
--- a/pkgs/development/libraries/gmp/5.1.x.nix
+++ b/pkgs/development/libraries/gmp/5.1.x.nix
@@ -16,10 +16,13 @@ stdenv.mkDerivation (rec {
     # Build a "fat binary", with routines for several sub-architectures
     # (x86), except on Solaris where some tests crash with "Memory fault".
     # See <http://hydra.nixos.org/build/2760931>, for instance.
+    #
+    # no darwin because gmp uses ASM that clang doesn't like
     optional (!stdenv.isSunOS) "--enable-fat"
     ++ (if cxx then [ "--enable-cxx"  ]
                else [ "--disable-cxx" ])
     ++ optional (cxx && stdenv.isDarwin) "CPPFLAGS=-fexceptions"
+    ++ optional stdenv.isDarwin "ABI=64"
     ++ optional stdenv.is64bit "--with-pic"
     ;
 
diff --git a/pkgs/development/libraries/libc++/darwin.patch b/pkgs/development/libraries/libc++/darwin.patch
new file mode 100644
index 00000000000..bf83f169cfc
--- /dev/null
+++ b/pkgs/development/libraries/libc++/darwin.patch
@@ -0,0 +1,30 @@
+diff -ru -x '*~' libcxx-3.4.2.src-orig/lib/CMakeLists.txt libcxx-3.4.2.src/lib/CMakeLists.txt
+--- libcxx-3.4.2.src-orig/lib/CMakeLists.txt	2013-11-15 18:18:57.000000000 +0100
++++ libcxx-3.4.2.src/lib/CMakeLists.txt	2014-09-24 14:04:01.000000000 +0200
+@@ -56,7 +56,7 @@
+       "-compatibility_version 1"
+       "-current_version ${LIBCXX_VERSION}"
+       "-install_name /usr/lib/libc++.1.dylib"
+-      "-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
++      "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib"
+       "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
+       "/usr/lib/libSystem.B.dylib")
+   else()
+@@ -64,14 +64,14 @@
+       list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7)
+       if (OSX_HAS_ARMV7)
+         set(OSX_RE_EXPORT_LINE
+-          "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"
++          "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib"
+           "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp")
+       else()
+         set(OSX_RE_EXPORT_LINE
+-          "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
++          "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib")
+       endif()
+     else()
+-      set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
++      set (OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+     endif()
+ 
+     list(APPEND link_flags
diff --git a/pkgs/development/libraries/libc++/default.nix b/pkgs/development/libraries/libc++/default.nix
index 732ae08b797..99e9bfe1de2 100644
--- a/pkgs/development/libraries/libc++/default.nix
+++ b/pkgs/development/libraries/libc++/default.nix
@@ -1,9 +1,8 @@
-{ stdenv, fetchurl, cmake, libcxxabi, python }:
+{ lib, stdenv, fetchurl, cmake, libcxxabi, fixDarwinDylibNames }:
 
-let
-  version = "3.4.2";
+let version = "3.4.2"; in
 
-in stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
   name = "libc++-${version}";
 
   src = fetchurl {
@@ -11,21 +10,32 @@ in stdenv.mkDerivation rec {
     sha256 = "0z3jdvgcq995khkpis5c5vaxhbmvbqjlalbhn09k6pgb5zp46rc2";
   };
 
-  buildInputs = [ cmake libcxxabi python ];
+  patches = [ ./darwin.patch ];
 
-  cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release"
-                 "-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=${libcxxabi}/include"
-                 "-DLIBCXX_CXX_ABI=libcxxabi" ];
+  buildInputs = [ cmake libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  cmakeFlags =
+    [ "-DCMAKE_BUILD_TYPE=Release"
+      "-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=${libcxxabi}/include"
+      "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib"
+      "-DLIBCXX_LIBCPPABI_VERSION=2"
+      "-DLIBCXX_CXX_ABI=libcxxabi"
+    ];
 
   enableParallelBuilding = true;
 
-  passthru.abi = libcxxabi;
+  inherit libcxxabi;
+
+  # Remove a Makefile that causes many retained dependencies.
+  postInstall = "rm $out/include/c++/v1/Makefile";
+
+  setupHook = ./setup-hook.sh;
 
   meta = {
     homepage = http://libcxx.llvm.org/;
     description = "A new implementation of the C++ standard library, targeting C++11";
     license = "BSD";
     maintainers = [ stdenv.lib.maintainers.shlevy ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libc++/setup-hook.sh b/pkgs/development/libraries/libc++/setup-hook.sh
new file mode 100644
index 00000000000..8543d09d8f5
--- /dev/null
+++ b/pkgs/development/libraries/libc++/setup-hook.sh
@@ -0,0 +1,2 @@
+export NIX_CFLAGS_COMPILE+=" -isystem @out@/include/c++/v1 -stdlib=libc++"
+export NIX_CFLAGS_LINK+=" -stdlib=libc++ -Wl,-rpath,@libcxxabi@/lib"
diff --git a/pkgs/development/libraries/libc++abi/darwin.patch b/pkgs/development/libraries/libc++abi/darwin.patch
new file mode 100644
index 00000000000..53ea8783f7a
--- /dev/null
+++ b/pkgs/development/libraries/libc++abi/darwin.patch
@@ -0,0 +1,17 @@
+diff -ru -x '*~' libcxxabi-orig/lib/buildit libcxxabi/lib/buildit
+--- libcxxabi-orig/lib/buildit	2014-09-18 16:54:14.000000000 +0200
++++ libcxxabi/lib/buildit	2014-09-24 13:22:27.000000000 +0200
+@@ -51,12 +51,8 @@
+         -dynamiclib -nodefaultlibs  \
+         -current_version ${RC_ProjectSourceVersion} \
+         -compatibility_version 1 \
+-        -install_name /usr/lib/libc++abi.dylib \
++        -install_name $out/lib/libc++abi.dylib \
+         -lSystem"
+-	if [ -f "${SDKROOT}/usr/local/lib/libCrashReporterClient.a" ]
+-	then
+-		LDSHARED_FLAGS+=" -lCrashReporterClient"
+-	fi
+     ;;
+   *-*-mingw*)
+     # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt
diff --git a/pkgs/development/libraries/libc++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix
index a03caa9f571..ec87254c170 100644
--- a/pkgs/development/libraries/libc++abi/default.nix
+++ b/pkgs/development/libraries/libc++abi/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, libcxx, libunwind }:
+{ lib, stdenv, fetchurl, libcxx, coreutils, gnused }:
 
 let rev = "199626"; in
 
@@ -10,22 +10,32 @@ stdenv.mkDerivation {
     sha256 = "09wr6qwgmdzbmgfkdzfhph9giy0zd6fp3s017fcfy4g0prjn5s4c";
   };
 
-  NIX_CFLAGS_LINK = "-L${libunwind}/lib -lunwind";
+  patches = [ ./no-stdc++.patch ./darwin.patch ];
+
+  buildInputs = [ coreutils ];
 
   postUnpack = ''
     unpackFile ${libcxx.src}
-    export NIX_CFLAGS_COMPILE="-I${libunwind}/include -I$PWD/include -I$(readlink -f libcxx-*)/include"
-  '';
-
-  installPhase = ''
-    install -d -m 755 $out/include $out/lib
-    install -m 644 lib/libc++abi.so.1.0 $out/lib
-    install -m 644 include/cxxabi.h $out/include
-    ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
-    ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
+  '' + lib.optionalString stdenv.isDarwin ''
+    export TRIPLE=x86_64-apple-darwin
+    # Hack: NIX_CFLAGS_COMPILE doesn't work here because clang++ isn't
+    # wrapped at this point.
+    export CXX="clang++ -D_LIBCXX_DYNAMIC_FALLBACK=1"
   '';
 
-  patchPhase = "sed -e s,-lstdc++,, -i lib/buildit";
+  installPhase = if stdenv.isDarwin
+    then ''
+      install -d -m 755 $out/include $out/lib
+      install -m 644 lib/libc++abi.dylib $out/lib
+      install -m 644 include/cxxabi.h $out/include
+    ''
+    else ''
+      install -d -m 755 $out/include $out/lib
+      install -m 644 lib/libc++abi.so.1.0 $out/lib
+      install -m 644 include/cxxabi.h $out/include
+      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
+      ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
+    '';
 
   buildPhase = "(cd lib; ./buildit)";
 
@@ -34,6 +44,6 @@ stdenv.mkDerivation {
     description = "A new implementation of low level support for a standard C++ library";
     license = "BSD";
     maintainers = [ stdenv.lib.maintainers.shlevy ];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
   };
 }
diff --git a/pkgs/development/libraries/libc++abi/no-stdc++.patch b/pkgs/development/libraries/libc++abi/no-stdc++.patch
new file mode 100644
index 00000000000..ddc9778a486
--- /dev/null
+++ b/pkgs/development/libraries/libc++abi/no-stdc++.patch
@@ -0,0 +1,12 @@
+diff -ru -x '*~' libcxxabi-orig/lib/buildit libcxxabi/lib/buildit
+--- libcxxabi-orig/lib/buildit	2014-09-18 16:54:14.000000000 +0200
++++ libcxxabi/lib/buildit	2014-09-24 13:22:27.000000000 +0200
+@@ -70,7 +66,7 @@
+     SOEXT=so
+     LDSHARED_FLAGS="-o libc++abi.so.1.0 \
+         -shared -nodefaultlibs -Wl,-soname,libc++abi.so.1 \
+-        -lpthread -lrt -lc -lstdc++"
++        -lpthread -lrt -lc"
+     ;;
+ esac
+ 
diff --git a/pkgs/development/libraries/libdevil/default.nix b/pkgs/development/libraries/libdevil/default.nix
index d3053b4d2a5..6cbbddfdba8 100644
--- a/pkgs/development/libraries/libdevil/default.nix
+++ b/pkgs/development/libraries/libdevil/default.nix
@@ -16,6 +16,15 @@ stdenv.mkDerivation rec {
 
   configureFlags = [ "--enable-ILU" "--enable-ILUT" ];
 
+  preConfigure = ''
+    sed -i 's, -std=gnu99,,g' configure
+    sed -i 's,malloc.h,stdlib.h,g' src-ILU/ilur/ilur.c
+  '';
+
+  postConfigure = ''
+    sed -i '/RESTRICT_KEYWORD/d' include/IL/config.h
+  '';
+
   patches =
     [ ( fetchurl {
         url = http://patch-tracker.debian.org/patch/series/dl/devil/1.7.8-6.1/03_CVE-2009-3994.diff;
diff --git a/pkgs/development/libraries/libedit/default.nix b/pkgs/development/libraries/libedit/default.nix
index 27c803fd81e..f913ab8e493 100644
--- a/pkgs/development/libraries/libedit/default.nix
+++ b/pkgs/development/libraries/libedit/default.nix
@@ -12,7 +12,7 @@ stdenv.mkDerivation rec {
   NROFF = "${groff}/bin/nroff";
 
   postInstall = ''
-    sed -i s/-lncurses/-lncursesw/g $out/lib/pkgconfig/libedit.pc
+    sed -i ${stdenv.lib.optionalString (stdenv.isDarwin && stdenv.gcc.nativeTools) "''"} s/-lncurses/-lncursesw/g $out/lib/pkgconfig/libedit.pc
   '';
 
   configureFlags = [ "--enable-widec" ];
diff --git a/pkgs/development/libraries/libffi/default.nix b/pkgs/development/libraries/libffi/default.nix
index da5a080521c..d661bbfc7a2 100644
--- a/pkgs/development/libraries/libffi/default.nix
+++ b/pkgs/development/libraries/libffi/default.nix
@@ -16,13 +16,14 @@ stdenv.mkDerivation rec {
     "--with-gcc-arch=generic" # no detection of -march= or -mtune=
   ] ++ stdenv.lib.optional (stdenv.needsPax) "--enable-pax_emutramp";
 
-  doCheck = stdenv.isLinux; # until we solve dejagnu problems on darwin and expect on BSD
+  #doCheck = stdenv.isLinux; # until we solve dejagnu problems on darwin and expect on BSD
+  doCheck = false;
 
   dontStrip = stdenv ? cross; # Don't run the native `strip' when cross-compiling.
 
   postInstall =
     # Install headers in the right place.
-    '' ln -s${if stdenv.isFreeBSD then "" else "r"}v "$out/lib/"libffi*/include "$out/include"
+    '' ln -s${if stdenv.isBSD then "" else "r"}v "$out/lib/"libffi*/include "$out/include"
     '';
 
   meta = {
diff --git a/pkgs/development/libraries/libgcrypt/default.nix b/pkgs/development/libraries/libgcrypt/default.nix
index b47709940dd..af231632022 100644
--- a/pkgs/development/libraries/libgcrypt/default.nix
+++ b/pkgs/development/libraries/libgcrypt/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation (rec {
 
   propagatedBuildInputs = [ libgpgerror ];
 
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-asm";
+
   doCheck = stdenv.system != "i686-linux"; # "basic" test fails after stdenv+glibc-2.18
 
   # For some reason the tests don't find `libgpg-error.so'.
diff --git a/pkgs/development/libraries/libunistring/clang.patch b/pkgs/development/libraries/libunistring/clang.patch
new file mode 100644
index 00000000000..fdcbc0d528d
--- /dev/null
+++ b/pkgs/development/libraries/libunistring/clang.patch
@@ -0,0 +1,14 @@
+diff --git a/lib/stdint.in.h b/lib/stdint.in.h
+index 997e406..e0827f5 100644
+--- a/lib/stdint.in.h
++++ b/lib/stdint.in.h
+@@ -53,7 +53,8 @@
+      in <inttypes.h> would reinclude us, skipping our contents because
+      _GL_STDINT_H is defined.
+      The include_next requires a split double-inclusion guard.  */
+-# @INCLUDE_NEXT@ @NEXT_STDINT_H@
++# include <inttypes.h>
++// # @INCLUDE_NEXT@ @NEXT_STDINT_H@
+ #endif
+ 
+ #if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
diff --git a/pkgs/development/libraries/libunistring/default.nix b/pkgs/development/libraries/libunistring/default.nix
index 2a87d7a3249..9470240fc14 100644
--- a/pkgs/development/libraries/libunistring/default.nix
+++ b/pkgs/development/libraries/libunistring/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation (rec {
     sha256 = "18q620269xzpw39dwvr9zpilnl2dkw5z5kz3mxaadnpv4k3kw3b1";
   };
 
+  patches = stdenv.lib.optional stdenv.isDarwin [ ./clang.patch ];
+
   propagatedBuildInputs =
     stdenv.lib.optional ((! (stdenv ? glibc))
                          || (stdenv ? cross &&
diff --git a/pkgs/development/libraries/mesa-darwin/default.nix b/pkgs/development/libraries/mesa-darwin/default.nix
index 98936904be5..f259a397c84 100644
--- a/pkgs/development/libraries/mesa-darwin/default.nix
+++ b/pkgs/development/libraries/mesa-darwin/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, stdenvAdapters, gccApple, fetchurl, pkgconfig, intltool, flex, bison
+{ stdenv, stdenvAdapters, fetchurl, pkgconfig, intltool, flex, bison
 , python, libxml2Python, file, expat, makedepend, xorg, llvm, libffi, libvdpau
 , enableTextureFloats ? false # Texture floats are patented, see docs/patents.txt
 , enableExtraFeatures ? false # not maintained
diff --git a/pkgs/development/libraries/mpc/default.nix b/pkgs/development/libraries/mpc/default.nix
index 3d05fa2e040..dd132cfb5b7 100644
--- a/pkgs/development/libraries/mpc/default.nix
+++ b/pkgs/development/libraries/mpc/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ gmp mpfr ];
 
+  CFLAGS = "-I${gmp}/include";
+
   doCheck = true;
 
   meta = {
diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix
index 653481aeccd..d999ba0cda5 100644
--- a/pkgs/development/libraries/mpfr/default.nix
+++ b/pkgs/development/libraries/mpfr/default.nix
@@ -10,6 +10,8 @@ stdenv.mkDerivation rec {
 
   buildInputs = [ gmp ];
 
+  CFLAGS = "-I${gmp}/include";
+
   configureFlags =
     /* Work around a FreeBSD bug that otherwise leads to segfaults in the test suite:
           http://hydra.bordeaux.inria.fr/build/34862
diff --git a/pkgs/development/libraries/ncurses/clang.patch b/pkgs/development/libraries/ncurses/clang.patch
new file mode 100644
index 00000000000..ce33049bf40
--- /dev/null
+++ b/pkgs/development/libraries/ncurses/clang.patch
@@ -0,0 +1,42 @@
+diff -ruNp ncurses-5.8.orig/c++/cursesf.h ncurses-5.8/c++/cursesf.h
+--- ncurses-5.8.orig/c++/cursesf.h	2005-08-13 21:08:24.000000000 +0300
++++ ncurses-5.8/c++/cursesf.h	2011-04-03 18:29:29.000000000 +0300
+@@ -681,7 +681,7 @@ public:
+ 		   const T* p_UserData = STATIC_CAST(T*)(0),
+ 		   bool with_frame=FALSE,
+ 		   bool autoDelete_Fields=FALSE)
+-    : NCursesForm (Fields, with_frame, autoDelete_Fields) {
++    : NCursesForm (&Fields, with_frame, autoDelete_Fields) {
+       if (form)
+ 	set_user (const_cast<void *>(p_UserData));
+   };
+@@ -694,7 +694,7 @@ public:
+ 		   const T* p_UserData = STATIC_CAST(T*)(0),
+ 		   bool with_frame=FALSE,
+ 		   bool autoDelete_Fields=FALSE)
+-    : NCursesForm (Fields, nlines, ncols, begin_y, begin_x,
++    : NCursesForm (&Fields, nlines, ncols, begin_y, begin_x,
+ 		   with_frame, autoDelete_Fields) {
+       if (form)
+ 	set_user (const_cast<void *>(p_UserData));
+diff -ruNp ncurses-5.8.orig/c++/cursesm.h ncurses-5.8/c++/cursesm.h
+--- ncurses-5.8.orig/c++/cursesm.h	2005-08-13 21:10:36.000000000 +0300
++++ ncurses-5.8/c++/cursesm.h	2011-04-03 18:31:42.000000000 +0300
+@@ -639,7 +639,7 @@ public:
+ 		   const T* p_UserData = STATIC_CAST(T*)(0),
+ 		   bool with_frame=FALSE,
+ 		   bool autoDelete_Items=FALSE)
+-    : NCursesMenu (Items, with_frame, autoDelete_Items) {
++    : NCursesMenu (&Items, with_frame, autoDelete_Items) {
+       if (menu)
+ 	set_user (const_cast<void *>(p_UserData));
+   };
+@@ -651,7 +651,7 @@ public:
+ 		   int begin_x = 0,
+ 		   const T* p_UserData = STATIC_CAST(T*)(0),
+ 		   bool with_frame=FALSE)
+-    : NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) {
++    : NCursesMenu (&Items, nlines, ncols, begin_y, begin_x, with_frame) {
+       if (menu)
+ 	set_user (const_cast<void *>(p_UserData));
+   };
diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
index 631199bf87c..3aa27480a0f 100644
--- a/pkgs/development/libraries/ncurses/default.nix
+++ b/pkgs/development/libraries/ncurses/default.nix
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
     sha256 = "0fsn7xis81za62afan0vvm38bvgzg5wfmv1m86flqcj0nj7jjilh";
   };
 
-  patches = [ ./patch-ac ];
+  patches = [ ./patch-ac ./clang.patch ];
 
   configureFlags = ''
     --with-shared --without-debug --enable-pc-files --enable-symlinks
@@ -35,8 +35,6 @@ stdenv.mkDerivation rec {
     export configureFlags="$configureFlags --includedir=$out/include"
     export PKG_CONFIG_LIBDIR="$out/lib/pkgconfig"
     mkdir -p "$PKG_CONFIG_LIBDIR"
-  '' + lib.optionalString stdenv.isDarwin ''
-    substituteInPlace configure --replace -no-cpp-precomp ""
   '';
 
   selfNativeBuildInput = true;
diff --git a/pkgs/development/libraries/qt-4.x/4.8/default.nix b/pkgs/development/libraries/qt-4.x/4.8/default.nix
index 1679b4953e7..6c534f4220d 100644
--- a/pkgs/development/libraries/qt-4.x/4.8/default.nix
+++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix
@@ -78,8 +78,6 @@ stdenv.mkDerivation rec {
       -translationdir $out/share/${name}/translations
     "
   '' + optionalString stdenv.isDarwin ''
-    export CXX=clang++
-    export CC=clang
     sed -i 's/QMAKE_CC = gcc/QMAKE_CC = clang/' mkspecs/common/g++-base.conf
     sed -i 's/QMAKE_CXX = g++/QMAKE_CXX = clang++/' mkspecs/common/g++-base.conf
   '';
diff --git a/pkgs/development/libraries/readline/6.2.nix b/pkgs/development/libraries/readline/6.2.nix
index d72d6566bbc..1555f255c51 100644
--- a/pkgs/development/libraries/readline/6.2.nix
+++ b/pkgs/development/libraries/readline/6.2.nix
@@ -14,6 +14,7 @@ stdenv.mkDerivation (rec {
   patches =
     [ ./link-against-ncurses.patch
       ./no-arch_only.patch
+      ./clang.patch
     ]
     ++
     (let
diff --git a/pkgs/development/libraries/readline/clang.patch b/pkgs/development/libraries/readline/clang.patch
new file mode 100644
index 00000000000..42bb0be09c3
--- /dev/null
+++ b/pkgs/development/libraries/readline/clang.patch
@@ -0,0 +1,13 @@
+diff --git a/support/shobj-conf b/support/shobj-conf
+index 5a63e80..4b2a741 100644
+--- support/shobj-conf
++++ support/shobj-conf
+@@ -189,7 +189,7 @@ darwin*|macosx*)
+ 	darwin[789]*|darwin10*)	SHOBJ_LDFLAGS=''
+ 			SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
+ 			;;
+-	*)		SHOBJ_LDFLAGS='-dynamic'
++	*)		SHOBJ_LDFLAGS='-dynamiclib'
+ 			SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
+ 			;;
+ 	esac
diff --git a/pkgs/development/libraries/serf/default.nix b/pkgs/development/libraries/serf/default.nix
index 1e8eec6ae45..49d7cec9590 100644
--- a/pkgs/development/libraries/serf/default.nix
+++ b/pkgs/development/libraries/serf/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, apr, scons, openssl, aprutil, zlib, krb5, pkgconfig }:
+{ stdenv, fetchurl, apr, scons, openssl, aprutil, zlib, krb5, pkgconfig, gnused }:
 
 stdenv.mkDerivation rec {
   name = "serf-1.3.7";
@@ -11,16 +11,20 @@ stdenv.mkDerivation rec {
   buildInputs = [ apr scons openssl aprutil zlib krb5 pkgconfig ];
 
   configurePhase = ''
-    sed -e '/^env[.]Append(BUILDERS/ienv.Append(ENV={"PATH":os.environ["PATH"]})' -i SConstruct
-    sed -e '/^env[.]Append(BUILDERS/ienv.Append(ENV={"NIX_CFLAGS_COMPILE":os.environ["NIX_CFLAGS_COMPILE"]})' -i SConstruct
-    sed -e '/^env[.]Append(BUILDERS/ienv.Append(ENV={"NIX_LDFLAGS":os.environ["NIX_LDFLAGS"]})' -i SConstruct
+    ${gnused}/bin/sed -e '/^env[.]Append(BUILDERS/ienv.Append(ENV={"PATH":os.environ["PATH"]})' -i SConstruct
+    ${gnused}/bin/sed -e '/^env[.]Append(BUILDERS/ienv.Append(ENV={"NIX_CFLAGS_COMPILE":os.environ["NIX_CFLAGS_COMPILE"]})' -i SConstruct
+    ${gnused}/bin/sed -e '/^env[.]Append(BUILDERS/ienv.Append(ENV={"NIX_LDFLAGS":os.environ["NIX_LDFLAGS"]})' -i SConstruct
   '';
 
   buildPhase = ''
     scons PREFIX="$out" OPENSSL="${openssl}" ZLIB="${zlib}" APR="$(echo "${apr}"/bin/*-config)" \
-        APU="$(echo "${aprutil}"/bin/*-config)" GSSAPI="${krb5}" CC="${stdenv.gcc}/bin/gcc"
+        APU="$(echo "${aprutil}"/bin/*-config)" GSSAPI="${krb5}" CC="${
+          if stdenv.isDarwin then "clang" else "${stdenv.gcc}/bin/gcc"
+        }"
   '';
 
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-L/usr/lib";
+
   installPhase = ''
     scons install
   '';
diff --git a/pkgs/development/libraries/v8/default.nix b/pkgs/development/libraries/v8/default.nix
index fda32a7ddbd..3abac0feab3 100644
--- a/pkgs/development/libraries/v8/default.nix
+++ b/pkgs/development/libraries/v8/default.nix
@@ -63,7 +63,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Google's open source JavaScript engine";
-    platforms = with platforms; linux ++ darwin;
+    platforms = with platforms; linux;
     license = licenses.bsd3;
   };
 }