···2828fi
29293030if test -n "$nativeTools"; then
3131- clangPath="$nativePrefix/bin"
3131+ if [ -n "$isDarwin" ]; then
3232+ clangPath="$clang/bin"
3333+ else
3434+ clangPath="$nativePrefix/bin"
3535+ fi
3236 ldPath="$nativePrefix/bin"
3337else
3434- basePath=`echo $gcc/lib/*/*/*`
3535- # Need libgcc until the llvm compiler-rt library is complete
3636- clangLDFlags="$clangLDFlags -L$basePath"
3737- if test -e "$gcc/lib64"; then
3838- clangLDFlags="$clangLDFlags -L$gcc/lib64"
3939- else
4040- clangLDFlags="$clangLDFlags -L$gcc/lib"
3838+ clangLDFlags=""
3939+ if test -d "$gcc/lib"; then
4040+ basePath=`echo $gcc/lib/*/*/*`
4141+ # Need libgcc until the llvm compiler-rt library is complete
4242+ clangLDFlags="$clangLDFlags -L$basePath"
4343+ if test -e "$gcc/lib64"; then
4444+ clangLDFlags="$clangLDFlags -L$gcc/lib64"
4545+ else
4646+ clangLDFlags="$clangLDFlags -L$gcc/lib"
4747+ fi
4148 fi
42494343- clangLDFlags="$clangLDFlags -L$clang/lib"
4444- echo "$clangLDFlags" > $out/nix-support/clang-ldflags
5050+ if test -d "$clang/lib"; then
5151+ clangLDFlags="$clangLDFlags -L$clang/lib"
5252+ fi
5353+5454+ if [ -n "$clangLDFlags" ]; then
5555+ echo "$clangLDFlags" > $out/nix-support/clang-ldflags
5656+ fi
45574658 # Need files like crtbegin.o from gcc
4759 # It's unclear if these will ever be provided by an LLVM project
···49615062 clangCFlags="$clangCFlags -isystem$clang/lib/clang/$clangVersion/include"
5163 echo "$clangCFlags" > $out/nix-support/clang-cflags
5252-5353- clangPath="$clang/bin"
6464+5465 ldPath="$binutils/bin"
6666+ clangPath="$clang/bin"
5567fi
56685769···125137doSubstitute "$addFlags" "$out/nix-support/add-flags.sh"
126138127139doSubstitute "$setupHook" "$out/nix-support/setup-hook"
140140+cat >> "$out/nix-support/setup-hook" << EOF
141141+export CC=clang
142142+export CXX=clang++
143143+EOF
128144129145cp -p $utils $out/nix-support/utils.sh
130146
···11+{stdenv, fetchurl, perl, ncurses, gmp}:
22+33+stdenv.mkDerivation rec {
44+ version = "7.8.3";
55+66+ name = "ghc-${version}-binary";
77+88+ src =
99+ if stdenv.system == "i686-linux" then
1010+ fetchurl {
1111+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2";
1212+ sha256 = "0gny7knhss0w0d9r6jm1gghrcb8kqjvj94bb7hxf9syrk4fxlcxi";
1313+ }
1414+ else if stdenv.system == "x86_64-linux" then
1515+ fetchurl {
1616+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2";
1717+ sha256 = "043jabd0lh6n1zlqhysngbpvlsdznsa2mmsj08jyqgahw9sjb5ns";
1818+ }
1919+ else if stdenv.system == "i686-darwin" then
2020+ fetchurl {
2121+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2";
2222+ sha256 = "1vrbs3pzki37hzym1f1nh07lrqh066z3ypvm81fwlikfsvk4djc0";
2323+ }
2424+ else if stdenv.system == "x86_64-darwin" then
2525+ fetchurl {
2626+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
2727+ sha256 = "1ja0cq5xyjcvjpvjmm4nzhkpmwfs2kjlldbc48lxcs9rmqi7rnay";
2828+ }
2929+ else throw "cannot bootstrap GHC on this platform";
3030+3131+ buildInputs = [perl];
3232+3333+ postUnpack =
3434+ # Strip is harmful, see also below. It's important that this happens
3535+ # first. The GHC Cabal build system makes use of strip by default and
3636+ # has hardcoded paths to /usr/bin/strip in many places. We replace
3737+ # those below, making them point to our dummy script.
3838+ ''
3939+ mkdir "$TMP/bin"
4040+ for i in strip; do
4141+ echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
4242+ chmod +x "$TMP/bin/$i"
4343+ done
4444+ PATH="$TMP/bin:$PATH"
4545+ '' +
4646+ # We have to patch the GMP paths for the integer-gmp package.
4747+ ''
4848+ find . -name integer-gmp.buildinfo \
4949+ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp}/lib@" {} \;
5050+ '' +
5151+ # On Linux, use patchelf to modify the executables so that they can
5252+ # find editline/gmp.
5353+ (if stdenv.isLinux then ''
5454+ find . -type f -perm +100 \
5555+ -exec patchelf --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
5656+ --set-rpath "${ncurses}/lib:${gmp}/lib" {} \;
5757+ sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
5858+ sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
5959+ for prog in ld ar gcc strip ranlib; do
6060+ find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \;
6161+ done
6262+ '' else "");
6363+6464+ configurePhase = ''
6565+ ./configure --prefix=$out --with-gmp-libraries=${gmp}/lib \
6666+ --with-gmp-includes=${gmp}/include
6767+ '';
6868+6969+ # Stripping combined with patchelf breaks the executables (they die
7070+ # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
7171+ dontStrip = true;
7272+7373+ # No building is necessary, but calling make without flags ironically
7474+ # calls install-strip ...
7575+ buildPhase = "true";
7676+7777+ postInstall =
7878+ ''
7979+ # Sanity check, can ghc create executables?
8080+ cd $TMP
8181+ mkdir test-ghc; cd test-ghc
8282+ cat > main.hs << EOF
8383+ module Main where
8484+ main = putStrLn "yes"
8585+ EOF
8686+ $out/bin/ghc --make main.hs
8787+ echo compilation ok
8888+ [ $(./main) == "yes" ]
8989+ '';
9090+9191+ meta.license = stdenv.lib.licenses.bsd3;
9292+ meta.platforms = ["x86_64-linux" "i686-linux" "i686-darwin" "x86_64-darwin"];
9393+}
-2
pkgs/development/compilers/ghc/7.8.3.nix
···2626 export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
2727 '';
28282929- configureFlags = "--with-gcc=${stdenv.gcc}/bin/gcc";
3030-3129 # required, because otherwise all symbols from HSffi.o are stripped, and
3230 # that in turn causes GHCi to abort
3331 stripDebugFlags = [ "-S" "--keep-file-symbols" ];
+4
pkgs/development/compilers/llvm/3.3/clang.nix
···11{ stdenv, fetchurl, perl, groff, llvm, cmake, libxml2, python }:
2233+# be sure not to rebuild clang on darwin; some packages request it specifically
44+# we need to fix those
55+assert stdenv.isDarwin -> stdenv.gcc.nativeTools;
66+37let
48 version = "3.3";
59 gccReal = if (stdenv.gcc.gcc or null) == null then stdenv.gcc else stdenv.gcc.gcc;
+14
pkgs/development/interpreters/guile/clang.patch
···11+diff --git a/lib/stdint.in.h b/lib/stdint.in.h
22+index 889bca7..15d39b0 100644
33+--- a/lib/stdint.in.h
44++++ b/lib/stdint.in.h
55+@@ -74,7 +74,8 @@
66+ in <inttypes.h> would reinclude us, skipping our contents because
77+ _@GUARD_PREFIX@_STDINT_H is defined.
88+ The include_next requires a split double-inclusion guard. */
99+-# @INCLUDE_NEXT@ @NEXT_STDINT_H@
1010++# include <inttypes.h>
1111++// # @INCLUDE_NEXT@ @NEXT_STDINT_H@
1212+ #endif
1313+1414+ #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
+3-3
pkgs/development/interpreters/guile/default.nix
···77 else stdenv.mkDerivation)
8899(rec {
1010- name = "guile-2.0.9";
1010+ name = "guile-2.0.11";
11111212 src = fetchurl {
1313 url = "mirror://gnu/guile/${name}.tar.xz";
1414- sha256 = "0nw9y8vjyz4r61v06p9msks5lm58pd91irmzg4k487vmv743h2pp";
1414+ sha256 = "1qh3j7308qvsjgwf7h94yqgckpbgz2k3yqdkzsyhqcafvfka9l5f";
1515 };
16161717 nativeBuildInputs = [ makeWrapper gawk pkgconfig ];
···29293030 enableParallelBuilding = true;
31313232- patches = [ ./disable-gc-sensitive-tests.patch ./eai_system.patch ] ++
3232+ patches = [ ./disable-gc-sensitive-tests.patch ./eai_system.patch ./clang.patch ] ++
3333 (stdenv.lib.optional (coverageAnalysis != null) ./gcov-file-name.patch);
34343535 # Explicitly link against libgcc_s, to work around the infamous
···11+--- src/dbinc/atomic.h 2013-03-12 14:07:22.000000000 -0400
22++++ src/dbinc/atomic.h.change 2013-03-12 14:06:35.000000000 -0400
33+@@ -144,7 +144,7 @@
44+ #define atomic_inc(env, p) __atomic_inc(p)
55+ #define atomic_dec(env, p) __atomic_dec(p)
66+ #define atomic_compare_exchange(env, p, o, n) \
77+- __atomic_compare_exchange((p), (o), (n))
88++ __atomic_compare_exchange_db((p), (o), (n))
99+ static inline int __atomic_inc(db_atomic_t *p)
1010+ {
1111+ int temp;
1212+@@ -176,7 +176,7 @@
1313+ * http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
1414+ * which configure could be changed to use.
1515+ */
1616+-static inline int __atomic_compare_exchange(
1717++static inline int __atomic_compare_exchange_db(
1818+ db_atomic_t *p, atomic_value_t oldval, atomic_value_t newval)
1919+ {
2020+ atomic_value_t was;
+3
pkgs/development/libraries/gmp/5.1.x.nix
···1616 # Build a "fat binary", with routines for several sub-architectures
1717 # (x86), except on Solaris where some tests crash with "Memory fault".
1818 # See <http://hydra.nixos.org/build/2760931>, for instance.
1919+ #
2020+ # no darwin because gmp uses ASM that clang doesn't like
1921 optional (!stdenv.isSunOS) "--enable-fat"
2022 ++ (if cxx then [ "--enable-cxx" ]
2123 else [ "--disable-cxx" ])
2224 ++ optional (cxx && stdenv.isDarwin) "CPPFLAGS=-fexceptions"
2525+ ++ optional stdenv.isDarwin "ABI=64 CC=clang"
2326 ++ optional stdenv.is64bit "--with-pic"
2427 ;
2528
+1-1
pkgs/development/libraries/libedit/default.nix
···1212 NROFF = "${groff}/bin/nroff";
13131414 postInstall = ''
1515- sed -i s/-lncurses/-lncursesw/g $out/lib/pkgconfig/libedit.pc
1515+ sed -i ${stdenv.lib.optionalString (stdenv.isDarwin && stdenv.gcc.nativeTools) "''"} s/-lncurses/-lncursesw/g $out/lib/pkgconfig/libedit.pc
1616 '';
17171818 # taken from gentoo http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-libs/libedit/files/
+1-1
pkgs/development/libraries/libffi/default.nix
···22222323 postInstall =
2424 # Install headers in the right place.
2525- '' ln -s${if stdenv.isFreeBSD then "" else "r"}v "$out/lib/"libffi*/include "$out/include"
2525+ '' ln -s${if stdenv.isBSD then "" else "r"}v "$out/lib/"libffi*/include "$out/include"
2626 '';
27272828 meta = {
+2
pkgs/development/libraries/libgcrypt/default.nix
···10101111 propagatedBuildInputs = [ libgpgerror ];
12121313+ configureFlags = stdenv.lib.optional stdenv.isDarwin "--disable-asm";
1414+1315 doCheck = stdenv.system != "i686-linux"; # "basic" test fails after stdenv+glibc-2.18
14161517 # For some reason the tests don't find `libgpg-error.so'.
···3333 pkgs = stdenvNativePkgs;
3434 };
35353636+ stdenvDarwin = import ./darwin {
3737+ inherit config;
3838+ stdenv = stdenvNative;
3939+ pkgs = stdenvNativePkgs;
4040+ };
4141+36423743 # Linux standard environment.
3844 stdenvLinux = (import ./linux { inherit system allPackages platform config;}).stdenvLinux;
···4753 if system == "armv7l-linux" then stdenvLinux else
4854 if system == "mips64el-linux" then stdenvLinux else
4955 if system == "powerpc-linux" then /* stdenvLinux */ stdenvNative else
5050- if system == "x86_64-darwin" then stdenvNix else
5656+ if system == "x86_64-darwin" then stdenvDarwin else
5157 if system == "x86_64-solaris" then stdenvNix else
5258 stdenvNative;
5359}
+2-1
pkgs/stdenv/generic/default.nix
···163163 isBSD = system == "i686-freebsd"
164164 || system == "x86_64-freebsd"
165165 || system == "i686-openbsd"
166166- || system == "x86_64-openbsd";
166166+ || system == "x86_64-openbsd"
167167+ || system == "x86_64-darwin";
167168 isi686 = system == "i686-linux"
168169 || system == "i686-gnu"
169170 || system == "i686-freebsd"
+3-3
pkgs/tools/archivers/sharutils/default.nix
···11-{ stdenv, fetchurl, gettext }:
11+{ stdenv, fetchurl, gettext, coreutils }:
2233stdenv.mkDerivation rec {
44 name = "sharutils-4.11.1";
···1212 ''
1313 # Fix for building on Glibc 2.16. Won't be needed once the
1414 # gnulib in sharutils is updated.
1515- sed -i '/gets is a security hole/d' lib/stdio.in.h
1515+ sed -i ${stdenv.lib.optionalString (stdenv.isBSD && stdenv.gcc.nativeTools) "''"} '/gets is a security hole/d' lib/stdio.in.h
1616 '';
17171818 # GNU Gettext is needed on non-GNU platforms.
1919- buildInputs = [ gettext ];
1919+ buildInputs = [ gettext coreutils ];
20202121 doCheck = true;
2222