From 3e8344d334d42824ac3061a919ac15b19a1bf21d Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Sun, 17 Aug 2014 13:17:13 -0700 Subject: [PATCH 01/47] suitable clang stdenv --- pkgs/applications/editors/vim/default.nix | 6 +- pkgs/applications/editors/vim/macvim.nix | 5 +- .../version-management/subversion/default.nix | 13 +-- pkgs/build-support/cabal/default.nix | 5 + pkgs/build-support/clang-wrapper/builder.sh | 40 +++++--- pkgs/build-support/clang-wrapper/default.nix | 2 + .../compilers/gcc/4.2-apple64/default.nix | 1 + .../compilers/ghc/7.4.2-binary.nix | 3 +- .../compilers/ghc/7.8.3-binary.nix | 93 +++++++++++++++++++ pkgs/development/compilers/ghc/7.8.3.nix | 2 - pkgs/development/compilers/llvm/3.3/clang.nix | 4 + .../interpreters/guile/clang.patch | 14 +++ .../interpreters/guile/default.nix | 6 +- pkgs/development/interpreters/lua-5/5.1.nix | 2 +- .../interpreters/perl/5.16/default.nix | 1 - .../development/interpreters/ruby/ruby-19.nix | 2 + pkgs/development/libraries/aspell/clang.patch | 18 ++++ pkgs/development/libraries/aspell/default.nix | 4 + pkgs/development/libraries/db/generic.nix | 4 + pkgs/development/libraries/db/osx.patch | 20 ++++ pkgs/development/libraries/gmp/5.1.x.nix | 3 + .../development/libraries/libedit/default.nix | 2 +- pkgs/development/libraries/libffi/default.nix | 2 +- .../libraries/libgcrypt/default.nix | 2 + .../libraries/libunistring/clang.patch | 14 +++ .../libraries/libunistring/default.nix | 2 + .../libraries/mesa-darwin/default.nix | 2 +- .../development/libraries/ncurses/clang.patch | 42 +++++++++ .../development/libraries/ncurses/default.nix | 4 +- .../libraries/readline/clang.patch | 13 +++ .../libraries/readline/readline6.nix | 5 + pkgs/development/libraries/serf/default.nix | 6 +- pkgs/development/libraries/zlib/default.nix | 4 +- pkgs/development/tools/misc/distcc/masq.nix | 4 + pkgs/servers/http/nginx/default.nix | 2 +- pkgs/servers/x11/xorg/overrides.nix | 1 + pkgs/stdenv/darwin/default.nix | 47 ++++++++++ pkgs/stdenv/default.nix | 8 +- pkgs/stdenv/generic/default.nix | 3 +- pkgs/tools/archivers/sharutils/default.nix | 6 +- pkgs/tools/misc/getopt/default.nix | 2 + pkgs/tools/security/gnupg/clang.patch | 13 +++ pkgs/tools/security/gnupg/default.nix | 1 + pkgs/tools/system/tree/default.nix | 1 + pkgs/tools/typesetting/tex/tetex/clang.patch | 13 +++ pkgs/tools/typesetting/tex/tetex/default.nix | 2 +- pkgs/top-level/all-packages.nix | 33 ++----- pkgs/top-level/haskell-defaults.nix | 4 +- 48 files changed, 415 insertions(+), 71 deletions(-) create mode 100644 pkgs/development/compilers/ghc/7.8.3-binary.nix create mode 100644 pkgs/development/interpreters/guile/clang.patch create mode 100644 pkgs/development/libraries/aspell/clang.patch create mode 100644 pkgs/development/libraries/db/osx.patch create mode 100644 pkgs/development/libraries/libunistring/clang.patch create mode 100644 pkgs/development/libraries/ncurses/clang.patch create mode 100644 pkgs/development/libraries/readline/clang.patch create mode 100644 pkgs/stdenv/darwin/default.nix create mode 100644 pkgs/tools/security/gnupg/clang.patch create mode 100644 pkgs/tools/typesetting/tex/tetex/clang.patch diff --git a/pkgs/applications/editors/vim/default.nix b/pkgs/applications/editors/vim/default.nix index 95f654eb8cac..8f27f5409975 100644 --- a/pkgs/applications/editors/vim/default.nix +++ b/pkgs/applications/editors/vim/default.nix @@ -3,12 +3,12 @@ stdenv.mkDerivation rec { name = "vim-${version}"; - version = "7.4.335"; + version = "7.4.410"; src = fetchhg { url = "https://vim.googlecode.com/hg/"; - rev = "v7-4-335"; - sha256 = "0qnpzfcbi6fhz82pj68l4vrnigca1akq2ksrxz6krwlfhns6jhhj"; + rev = "v7-4-410"; + sha256 = "145llhj6gq2bh9b7p8xkxc388krrximq80b87f3cn4w4d4k9fhqp"; }; enableParallelBuilding = true; diff --git a/pkgs/applications/editors/vim/macvim.nix b/pkgs/applications/editors/vim/macvim.nix index feafa7b99777..ad40344f19f4 100644 --- a/pkgs/applications/editors/vim/macvim.nix +++ b/pkgs/applications/editors/vim/macvim.nix @@ -1,9 +1,8 @@ -{ stdenv, stdenvAdapters, gccApple, fetchFromGitHub, ncurses, gettext, +{ stdenv, stdenvAdapters, fetchFromGitHub, ncurses, gettext, pkgconfig, cscope, python, ruby, tcl, perl, luajit }: -let inherit (stdenvAdapters.overrideGCC stdenv gccApple) mkDerivation; -in mkDerivation rec { +stdenv.mkDerivation rec { name = "macvim-${version}"; version = "7.4.355"; diff --git a/pkgs/applications/version-management/subversion/default.nix b/pkgs/applications/version-management/subversion/default.nix index 283ea7591538..30283ad387c8 100644 --- a/pkgs/applications/version-management/subversion/default.nix +++ b/pkgs/applications/version-management/subversion/default.nix @@ -15,7 +15,7 @@ assert httpServer -> httpd != null; assert pythonBindings -> swig != null && python != null; assert javahlBindings -> jdk != null && perl != null; -stdenv.mkDerivation rec { +stdenv.mkDerivation (rec { version = "1.8.10"; @@ -73,14 +73,15 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - # Hack to build on Mac OS X. The system header files use C99-style - # comments, but Subversion passes -std=c90. - NIX_CFLAGS_COMPILE = "-std=c99"; - meta = { description = "A version control system intended to be a compelling replacement for CVS in the open source community"; homepage = http://subversion.apache.org/; maintainers = with stdenv.lib.maintainers; [ eelco lovek323 ]; hydraPlatforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; }; -} +} // stdenv.lib.optionalAttrs stdenv.isDarwin { + CXX = "clang++"; + CC = "clang"; + CPP = "clang -E"; + CXXCPP = "clang++ -E"; +}) diff --git a/pkgs/build-support/cabal/default.nix b/pkgs/build-support/cabal/default.nix index d73b4a1f364c..bf91de0bd505 100644 --- a/pkgs/build-support/cabal/default.nix +++ b/pkgs/build-support/cabal/default.nix @@ -214,6 +214,10 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version; configureFlags+=" --ghc-option=-j$NIX_BUILD_CORES" ''} + ${optionalString self.stdenv.isDarwin '' + configureFlags+=" --with-gcc=clang" + ''} + echo "configure flags: $extraConfigureFlags $configureFlags" ./Setup configure --verbose --prefix="$out" --libdir='$prefix/lib/$compiler' \ --libsubdir='$pkgid' $extraConfigureFlags $configureFlags 2>&1 \ @@ -236,6 +240,7 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version; export GHC_PACKAGE_PATH=$(${ghc.GHCPackages}) test -n "$noHaddock" || ./Setup haddock --html --hoogle \ + --ghc-options=-optP-P \ ${optionalString self.hyperlinkSource "--hyperlink-source"} eval "$postBuild" diff --git a/pkgs/build-support/clang-wrapper/builder.sh b/pkgs/build-support/clang-wrapper/builder.sh index 0cdb2b96135e..2dec6c59933b 100644 --- a/pkgs/build-support/clang-wrapper/builder.sh +++ b/pkgs/build-support/clang-wrapper/builder.sh @@ -28,20 +28,32 @@ if test -z "$nativeLibc"; then fi if test -n "$nativeTools"; then - clangPath="$nativePrefix/bin" + if [ -n "$isDarwin" ]; then + clangPath="$clang/bin" + else + clangPath="$nativePrefix/bin" + fi ldPath="$nativePrefix/bin" else - basePath=`echo $gcc/lib/*/*/*` - # Need libgcc until the llvm compiler-rt library is complete - clangLDFlags="$clangLDFlags -L$basePath" - if test -e "$gcc/lib64"; then - clangLDFlags="$clangLDFlags -L$gcc/lib64" - else - clangLDFlags="$clangLDFlags -L$gcc/lib" + clangLDFlags="" + if test -d "$gcc/lib"; then + basePath=`echo $gcc/lib/*/*/*` + # Need libgcc until the llvm compiler-rt library is complete + clangLDFlags="$clangLDFlags -L$basePath" + if test -e "$gcc/lib64"; then + clangLDFlags="$clangLDFlags -L$gcc/lib64" + else + clangLDFlags="$clangLDFlags -L$gcc/lib" + fi fi - clangLDFlags="$clangLDFlags -L$clang/lib" - echo "$clangLDFlags" > $out/nix-support/clang-ldflags + if test -d "$clang/lib"; then + clangLDFlags="$clangLDFlags -L$clang/lib" + fi + + if [ -n "$clangLDFlags" ]; then + echo "$clangLDFlags" > $out/nix-support/clang-ldflags + fi # Need files like crtbegin.o from gcc # It's unclear if these will ever be provided by an LLVM project @@ -49,9 +61,9 @@ else clangCFlags="$clangCFlags -isystem$clang/lib/clang/$clangVersion/include" echo "$clangCFlags" > $out/nix-support/clang-cflags - - clangPath="$clang/bin" + ldPath="$binutils/bin" + clangPath="$clang/bin" fi @@ -125,6 +137,10 @@ test -n "$libc" && echo $libc > $out/nix-support/orig-libc doSubstitute "$addFlags" "$out/nix-support/add-flags.sh" doSubstitute "$setupHook" "$out/nix-support/setup-hook" +cat >> "$out/nix-support/setup-hook" << EOF +export CC=clang +export CXX=clang++ +EOF cp -p $utils $out/nix-support/utils.sh diff --git a/pkgs/build-support/clang-wrapper/default.nix b/pkgs/build-support/clang-wrapper/default.nix index 7a5d87127d90..e61c07ca9d23 100644 --- a/pkgs/build-support/clang-wrapper/default.nix +++ b/pkgs/build-support/clang-wrapper/default.nix @@ -26,6 +26,8 @@ stdenv.mkDerivation { (if name != "" then name else clangName + "-wrapper") + (if clang != null && clangVersion != "" then "-" + clangVersion else ""); + isDarwin = stdenv.isDarwin; + builder = ./builder.sh; setupHook = ./setup-hook.sh; clangWrapper = ./clang-wrapper.sh; diff --git a/pkgs/development/compilers/gcc/4.2-apple64/default.nix b/pkgs/development/compilers/gcc/4.2-apple64/default.nix index b2444ebb9bff..42d9f29e2b5b 100644 --- a/pkgs/development/compilers/gcc/4.2-apple64/default.nix +++ b/pkgs/development/compilers/gcc/4.2-apple64/default.nix @@ -4,6 +4,7 @@ , gmp ? null, mpfr ? null, bison ? null, flex ? null }: +assert false; assert stdenv.isDarwin; assert langF77 -> gmp != null; diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix index 7000081e5dbe..f6dc974227cc 100644 --- a/pkgs/development/compilers/ghc/7.4.2-binary.nix +++ b/pkgs/development/compilers/ghc/7.4.2-binary.nix @@ -62,7 +62,8 @@ stdenv.mkDerivation rec { '' else ""); configurePhase = '' - ./configure --prefix=$out --with-gmp-libraries=${gmp}/lib --with-gmp-includes=${gmp}/include + ./configure --prefix=$out --with-gmp-libraries=${gmp}/lib --with-gmp-includes=${gmp}/include \ + --with-clang ''; # Stripping combined with patchelf breaks the executables (they die diff --git a/pkgs/development/compilers/ghc/7.8.3-binary.nix b/pkgs/development/compilers/ghc/7.8.3-binary.nix new file mode 100644 index 000000000000..f2c65c6ad053 --- /dev/null +++ b/pkgs/development/compilers/ghc/7.8.3-binary.nix @@ -0,0 +1,93 @@ +{stdenv, fetchurl, perl, ncurses, gmp}: + +stdenv.mkDerivation rec { + version = "7.8.3"; + + name = "ghc-${version}-binary"; + + src = + if stdenv.system == "i686-linux" then + fetchurl { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2"; + sha256 = "0gny7knhss0w0d9r6jm1gghrcb8kqjvj94bb7hxf9syrk4fxlcxi"; + } + else if stdenv.system == "x86_64-linux" then + fetchurl { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2"; + sha256 = "043jabd0lh6n1zlqhysngbpvlsdznsa2mmsj08jyqgahw9sjb5ns"; + } + else if stdenv.system == "i686-darwin" then + fetchurl { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2"; + sha256 = "1vrbs3pzki37hzym1f1nh07lrqh066z3ypvm81fwlikfsvk4djc0"; + } + else if stdenv.system == "x86_64-darwin" then + fetchurl { + url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2"; + sha256 = "1ja0cq5xyjcvjpvjmm4nzhkpmwfs2kjlldbc48lxcs9rmqi7rnay"; + } + else throw "cannot bootstrap GHC on this platform"; + + buildInputs = [perl]; + + postUnpack = + # Strip is harmful, see also below. It's important that this happens + # first. The GHC Cabal build system makes use of strip by default and + # has hardcoded paths to /usr/bin/strip in many places. We replace + # those below, making them point to our dummy script. + '' + mkdir "$TMP/bin" + for i in strip; do + echo '#! ${stdenv.shell}' > "$TMP/bin/$i" + chmod +x "$TMP/bin/$i" + done + PATH="$TMP/bin:$PATH" + '' + + # We have to patch the GMP paths for the integer-gmp package. + '' + find . -name integer-gmp.buildinfo \ + -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp}/lib@" {} \; + '' + + # On Linux, use patchelf to modify the executables so that they can + # find editline/gmp. + (if stdenv.isLinux then '' + find . -type f -perm +100 \ + -exec patchelf --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \ + --set-rpath "${ncurses}/lib:${gmp}/lib" {} \; + sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 + sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 + for prog in ld ar gcc strip ranlib; do + find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \; + done + '' else ""); + + configurePhase = '' + ./configure --prefix=$out --with-gmp-libraries=${gmp}/lib \ + --with-gmp-includes=${gmp}/include + ''; + + # Stripping combined with patchelf breaks the executables (they die + # with a segfault or the kernel even refuses the execve). (NIXPKGS-85) + dontStrip = true; + + # No building is necessary, but calling make without flags ironically + # calls install-strip ... + buildPhase = "true"; + + postInstall = + '' + # Sanity check, can ghc create executables? + cd $TMP + mkdir test-ghc; cd test-ghc + cat > main.hs << EOF + module Main where + main = putStrLn "yes" + EOF + $out/bin/ghc --make main.hs + echo compilation ok + [ $(./main) == "yes" ] + ''; + + meta.license = stdenv.lib.licenses.bsd3; + meta.platforms = ["x86_64-linux" "i686-linux" "i686-darwin" "x86_64-darwin"]; +} diff --git a/pkgs/development/compilers/ghc/7.8.3.nix b/pkgs/development/compilers/ghc/7.8.3.nix index dbcba36fa8ff..0971cbb1f933 100644 --- a/pkgs/development/compilers/ghc/7.8.3.nix +++ b/pkgs/development/compilers/ghc/7.8.3.nix @@ -26,8 +26,6 @@ stdenv.mkDerivation rec { export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" ''; - configureFlags = "--with-gcc=${stdenv.gcc}/bin/gcc"; - # required, because otherwise all symbols from HSffi.o are stripped, and # that in turn causes GHCi to abort stripDebugFlags = [ "-S" "--keep-file-symbols" ]; diff --git a/pkgs/development/compilers/llvm/3.3/clang.nix b/pkgs/development/compilers/llvm/3.3/clang.nix index 262e0bff2483..72287560b245 100644 --- a/pkgs/development/compilers/llvm/3.3/clang.nix +++ b/pkgs/development/compilers/llvm/3.3/clang.nix @@ -1,5 +1,9 @@ { stdenv, fetchurl, perl, groff, llvm, cmake, libxml2, python }: +# be sure not to rebuild clang on darwin; some packages request it specifically +# we need to fix those +assert stdenv.isDarwin -> stdenv.gcc.nativeTools; + let version = "3.3"; gccReal = if (stdenv.gcc.gcc or null) == null then stdenv.gcc else stdenv.gcc.gcc; diff --git a/pkgs/development/interpreters/guile/clang.patch b/pkgs/development/interpreters/guile/clang.patch new file mode 100644 index 000000000000..4d0f342b211f --- /dev/null +++ b/pkgs/development/interpreters/guile/clang.patch @@ -0,0 +1,14 @@ +diff --git a/lib/stdint.in.h b/lib/stdint.in.h +index 889bca7..15d39b0 100644 +--- a/lib/stdint.in.h ++++ b/lib/stdint.in.h +@@ -74,7 +74,8 @@ + in would reinclude us, skipping our contents because + _@GUARD_PREFIX@_STDINT_H is defined. + The include_next requires a split double-inclusion guard. */ +-# @INCLUDE_NEXT@ @NEXT_STDINT_H@ ++# include ++// # @INCLUDE_NEXT@ @NEXT_STDINT_H@ + #endif + + #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H diff --git a/pkgs/development/interpreters/guile/default.nix b/pkgs/development/interpreters/guile/default.nix index 2ddad5cde677..ad5d2f1cc587 100644 --- a/pkgs/development/interpreters/guile/default.nix +++ b/pkgs/development/interpreters/guile/default.nix @@ -7,11 +7,11 @@ else stdenv.mkDerivation) (rec { - name = "guile-2.0.9"; + name = "guile-2.0.11"; src = fetchurl { url = "mirror://gnu/guile/${name}.tar.xz"; - sha256 = "0nw9y8vjyz4r61v06p9msks5lm58pd91irmzg4k487vmv743h2pp"; + sha256 = "1qh3j7308qvsjgwf7h94yqgckpbgz2k3yqdkzsyhqcafvfka9l5f"; }; nativeBuildInputs = [ makeWrapper gawk pkgconfig ]; @@ -29,7 +29,7 @@ enableParallelBuilding = true; - patches = [ ./disable-gc-sensitive-tests.patch ./eai_system.patch ] ++ + patches = [ ./disable-gc-sensitive-tests.patch ./eai_system.patch ./clang.patch ] ++ (stdenv.lib.optional (coverageAnalysis != null) ./gcov-file-name.patch); # Explicitly link against libgcc_s, to work around the infamous diff --git a/pkgs/development/interpreters/lua-5/5.1.nix b/pkgs/development/interpreters/lua-5/5.1.nix index 444ecbc787af..b2ccc7fd6428 100644 --- a/pkgs/development/interpreters/lua-5/5.1.nix +++ b/pkgs/development/interpreters/lua-5/5.1.nix @@ -29,7 +29,7 @@ stdenv.mkDerivation rec { configurePhase = if stdenv.isDarwin then '' - makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2" LDFLAGS="" ) + makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2" LDFLAGS="" CC=clang ) installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.5.1.5.dylib" INSTALL_DATA='cp -d' ) '' else '' makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC" LDFLAGS="-fPIC" ) diff --git a/pkgs/development/interpreters/perl/5.16/default.nix b/pkgs/development/interpreters/perl/5.16/default.nix index c1a5374c92ea..344f91b29805 100644 --- a/pkgs/development/interpreters/perl/5.16/default.nix +++ b/pkgs/development/interpreters/perl/5.16/default.nix @@ -32,7 +32,6 @@ stdenv.mkDerivation rec { # Miniperl needs -lm. perl needs -lrt. configureFlags = [ "-de" - "-Dcc=gcc" "-Uinstallusrbinperl" "-Dinstallstyle=lib/perl5" "-Duseshrplib" diff --git a/pkgs/development/interpreters/ruby/ruby-19.nix b/pkgs/development/interpreters/ruby/ruby-19.nix index d18718184ba6..963d462dc009 100644 --- a/pkgs/development/interpreters/ruby/ruby-19.nix +++ b/pkgs/development/interpreters/ruby/ruby-19.nix @@ -49,6 +49,8 @@ stdenv.mkDerivation rec { installFlags = stdenv.lib.optionalString docSupport "install-doc"; + CFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-mmacosx-version-min=10.7"; + postInstall = '' # Bundler tries to create this directory mkdir -pv $out/${passthru.gemPath} diff --git a/pkgs/development/libraries/aspell/clang.patch b/pkgs/development/libraries/aspell/clang.patch new file mode 100644 index 000000000000..c4cfa426588c --- /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 734bcc0797cc..a8d660e89a7f 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/db/generic.nix b/pkgs/development/libraries/db/generic.nix index 6217bc461249..9d3f87ad5cb6 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 000000000000..398aa1d37002 --- /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 14a6d34d932b..5bee2fe43368 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 , 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 CC=clang" ++ optional stdenv.is64bit "--with-pic" ; diff --git a/pkgs/development/libraries/libedit/default.nix b/pkgs/development/libraries/libedit/default.nix index 1382af16484c..659f22b9b3b3 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 ''; # taken from gentoo http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-libs/libedit/files/ diff --git a/pkgs/development/libraries/libffi/default.nix b/pkgs/development/libraries/libffi/default.nix index da5a080521c6..20b697144a0c 100644 --- a/pkgs/development/libraries/libffi/default.nix +++ b/pkgs/development/libraries/libffi/default.nix @@ -22,7 +22,7 @@ stdenv.mkDerivation rec { 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 ed267e23c87b..8cc5b924cce9 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 000000000000..fdcbc0d528d0 --- /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 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 ++// # @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 2a87d7a32490..9470240fc146 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 98936904be59..f259a397c847 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/ncurses/clang.patch b/pkgs/development/libraries/ncurses/clang.patch new file mode 100644 index 000000000000..ce33049bf405 --- /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(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(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(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(p_UserData)); + }; diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix index 631199bf87c3..3aa27480a0f5 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/readline/clang.patch b/pkgs/development/libraries/readline/clang.patch new file mode 100644 index 000000000000..42bb0be09c39 --- /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/readline/readline6.nix b/pkgs/development/libraries/readline/readline6.nix index d72d6566bbc9..bffa838d2b35 100644 --- a/pkgs/development/libraries/readline/readline6.nix +++ b/pkgs/development/libraries/readline/readline6.nix @@ -10,10 +10,15 @@ stdenv.mkDerivation (rec { propagatedBuildInputs = [ncurses]; + preConfigure = '' + export CC=clang + ''; + patchFlags = "-p0"; patches = [ ./link-against-ncurses.patch ./no-arch_only.patch + ./clang.patch ] ++ (let diff --git a/pkgs/development/libraries/serf/default.nix b/pkgs/development/libraries/serf/default.nix index 1e8eec6ae452..033e53e521d5 100644 --- a/pkgs/development/libraries/serf/default.nix +++ b/pkgs/development/libraries/serf/default.nix @@ -18,9 +18,13 @@ stdenv.mkDerivation rec { 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/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index 0938e2a17a79..1b46c9594488 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -15,7 +15,9 @@ stdenv.mkDerivation rec { configureFlags = if static then "" else "--shared"; - preConfigure = '' + preConfigure = stdenv.lib.optionalString stdenv.isDarwin '' + export CC=clang + '' + '' if test -n "$crossConfig"; then export CC=$crossConfig-gcc configureFlags=${if static then "" else "--shared"} diff --git a/pkgs/development/tools/misc/distcc/masq.nix b/pkgs/development/tools/misc/distcc/masq.nix index 753c35b5d3a2..28b31cbb48d5 100644 --- a/pkgs/development/tools/misc/distcc/masq.nix +++ b/pkgs/development/tools/misc/distcc/masq.nix @@ -3,6 +3,10 @@ stdenv.mkDerivation { name = "distcc-masq-${gccRaw.name}"; + meta = { + platforms = stdenv.lib.platforms.linux; + }; + phases = [ "installPhase" ]; installPhase = '' mkdir -p $out/bin diff --git a/pkgs/servers/http/nginx/default.nix b/pkgs/servers/http/nginx/default.nix index 700317bc7994..204a33cd4a51 100644 --- a/pkgs/servers/http/nginx/default.nix +++ b/pkgs/servers/http/nginx/default.nix @@ -105,7 +105,7 @@ stdenv.mkDerivation rec { ++ optional (elem stdenv.system (with platforms; linux ++ freebsd)) "--with-file-aio"; - additionalFlags = optionalString stdenv.isDarwin "-Wno-error=deprecated-declarations"; + additionalFlags = optionalString stdenv.isDarwin "-Wno-error=deprecated-declarations -Wno-error=conditional-uninitialized"; preConfigure = '' export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${libxml2}/include/libxml2 $additionalFlags" diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix index 93afa06a7f24..66f74f305494 100644 --- a/pkgs/servers/x11/xorg/overrides.nix +++ b/pkgs/servers/x11/xorg/overrides.nix @@ -75,6 +75,7 @@ in # Remove useless DocBook XML files. rm -rf $out/share/doc ''; + CPP = stdenv.lib.optionalString stdenv.isDarwin "clang -E -"; }; libXfont = attrs: attrs // { diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix new file mode 100644 index 000000000000..5c2044386c6e --- /dev/null +++ b/pkgs/stdenv/darwin/default.nix @@ -0,0 +1,47 @@ +{ stdenv, pkgs, config }: + +import ../generic rec { + inherit config; + + preHook = + '' + export NIX_ENFORCE_PURITY= + export NIX_IGNORE_LD_THROUGH_GCC=1 + export NIX_DONT_SET_RPATH=1 + export NIX_NO_SELF_RPATH=1 + dontFixLibtool=1 + stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" + xargsFlags=" " + export MACOSX_DEPLOYMENT_TARGET=10.6 + export SDKROOT=$(/usr/bin/xcrun --show-sdk-path 2> /dev/null || true) + export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT/usr/include -F$SDKROOT/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations" + export NIX_LDFLAGS_AFTER+=" -L$SDKROOT/usr/lib" + ''; + + initialPath = (import ../common-path.nix) {pkgs = pkgs;}; + + system = stdenv.system; + + gcc = import ../../build-support/clang-wrapper { + nativeTools = false; + nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; + nativeLibc = true; + inherit stdenv; + binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; + clang = pkgs.clang_34; + coreutils = pkgs.coreutils; + shell = pkgs.bash + "/bin/sh"; + }; + + shell = pkgs.bash + "/bin/sh"; + + fetchurlBoot = stdenv.fetchurlBoot; + + overrides = pkgs_: { + inherit gcc; + inherit (gcc) binutils; + inherit (pkgs) + gzip bzip2 xz bash coreutils diffutils findutils gawk + gnumake gnused gnutar gnugrep gnupatch perl; + }; +} diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 47d1fb6d9f75..8e8be748795c 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -33,6 +33,12 @@ rec { pkgs = stdenvNativePkgs; }; + stdenvDarwin = import ./darwin { + inherit config; + stdenv = stdenvNative; + pkgs = stdenvNativePkgs; + }; + # Linux standard environment. stdenvLinux = (import ./linux { inherit system allPackages platform config;}).stdenvLinux; @@ -47,7 +53,7 @@ rec { if system == "armv7l-linux" then stdenvLinux else if system == "mips64el-linux" then stdenvLinux else if system == "powerpc-linux" then /* stdenvLinux */ stdenvNative else - if system == "x86_64-darwin" then stdenvNix else + if system == "x86_64-darwin" then stdenvDarwin else if system == "x86_64-solaris" then stdenvNix else stdenvNative; } diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 29e4455f7cb3..b126e7bf36b3 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -163,7 +163,8 @@ let isBSD = system == "i686-freebsd" || system == "x86_64-freebsd" || system == "i686-openbsd" - || system == "x86_64-openbsd"; + || system == "x86_64-openbsd" + || system == "x86_64-darwin"; isi686 = system == "i686-linux" || system == "i686-gnu" || system == "i686-freebsd" diff --git a/pkgs/tools/archivers/sharutils/default.nix b/pkgs/tools/archivers/sharutils/default.nix index f19564e4ad91..281a148a5ca4 100644 --- a/pkgs/tools/archivers/sharutils/default.nix +++ b/pkgs/tools/archivers/sharutils/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, gettext }: +{ stdenv, fetchurl, gettext, coreutils }: stdenv.mkDerivation rec { name = "sharutils-4.11.1"; @@ -12,11 +12,11 @@ stdenv.mkDerivation rec { '' # Fix for building on Glibc 2.16. Won't be needed once the # gnulib in sharutils is updated. - sed -i '/gets is a security hole/d' lib/stdio.in.h + sed -i ${stdenv.lib.optionalString (stdenv.isBSD && stdenv.gcc.nativeTools) "''"} '/gets is a security hole/d' lib/stdio.in.h ''; # GNU Gettext is needed on non-GNU platforms. - buildInputs = [ gettext ]; + buildInputs = [ gettext coreutils ]; doCheck = true; diff --git a/pkgs/tools/misc/getopt/default.nix b/pkgs/tools/misc/getopt/default.nix index 41bc2ffc99df..84d15a187471 100644 --- a/pkgs/tools/misc/getopt/default.nix +++ b/pkgs/tools/misc/getopt/default.nix @@ -7,4 +7,6 @@ stdenv.mkDerivation { url = http://tarballs.nixos.org/getopt-1.1.4.tar.gz; md5 = "02188ca68da27c4175d6e9f3da732101"; }; + + buildFlags = stdenv.lib.optional stdenv.isDarwin [ "CC=clang" ]; } diff --git a/pkgs/tools/security/gnupg/clang.patch b/pkgs/tools/security/gnupg/clang.patch new file mode 100644 index 000000000000..842785e5c932 --- /dev/null +++ b/pkgs/tools/security/gnupg/clang.patch @@ -0,0 +1,13 @@ +diff --git a/gl/stdint_.h b/gl/stdint_.h +index bc27595..303e81a 100644 +--- a/gl/stdint_.h ++++ b/gl/stdint_.h +@@ -62,7 +62,7 @@ + int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. + also defines intptr_t and uintptr_t. */ + # define _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H +-# include ++// # include + # undef _GL_JUST_INCLUDE_ABSOLUTE_INTTYPES_H + #elif @HAVE_SYS_INTTYPES_H@ + /* Solaris 7 has the types except the *_fast*_t types, and diff --git a/pkgs/tools/security/gnupg/default.nix b/pkgs/tools/security/gnupg/default.nix index 64e2be90d30d..e00985b16ed5 100644 --- a/pkgs/tools/security/gnupg/default.nix +++ b/pkgs/tools/security/gnupg/default.nix @@ -31,6 +31,7 @@ stdenv.mkDerivation rec { patchPhase = '' find tests -type f | xargs sed -e 's@/bin/pwd@${coreutils}&@g' -i find . -name pcsc-wrapper.c | xargs sed -i 's/typedef unsinged int pcsc_dword_t/typedef unsigned int pcsc_dword_t/' + patch gl/stdint_.h < ${./clang.patch} ''; checkPhase="GNUPGHOME=`pwd` ./agent/gpg-agent --daemon make check"; diff --git a/pkgs/tools/system/tree/default.nix b/pkgs/tools/system/tree/default.nix index e108589aaefe..51de5998069f 100644 --- a/pkgs/tools/system/tree/default.nix +++ b/pkgs/tools/system/tree/default.nix @@ -37,6 +37,7 @@ stdenv.mkDerivation { prefix=$out MANDIR=$out/share/man/man1 ${systemFlags} + CC=clang ) ''; diff --git a/pkgs/tools/typesetting/tex/tetex/clang.patch b/pkgs/tools/typesetting/tex/tetex/clang.patch new file mode 100644 index 000000000000..50d83f624437 --- /dev/null +++ b/pkgs/tools/typesetting/tex/tetex/clang.patch @@ -0,0 +1,13 @@ +diff --git a/texk/ps2pkm/type1.c b/texk/ps2pkm/type1.c +index 027bf1f..4dcbad0 100644 +--- a/texk/ps2pkm/type1.c ++++ b/texk/ps2pkm/type1.c +@@ -800,7 +800,7 @@ static void PSFakePush(Num) + static DOUBLE PSFakePop () + { + if (PSFakeTop >= 0) return(PSFakeStack[PSFakeTop--]); +- else Error0("PSFakePop : Stack empty\n"); ++ else { CC; IfTrace0(TRUE, "PSFakePop : Stack empty\n"); errflag = TRUE; return 0; } + /*NOTREACHED*/ + } + diff --git a/pkgs/tools/typesetting/tex/tetex/default.nix b/pkgs/tools/typesetting/tex/tetex/default.nix index 5cd3228aced3..173571eda23c 100644 --- a/pkgs/tools/typesetting/tex/tetex/default.nix +++ b/pkgs/tools/typesetting/tex/tetex/default.nix @@ -20,7 +20,7 @@ stdenv.mkDerivation { sed -i 57d texk/kpathsea/c-std.h ''; - patches = [ ./environment.patch ./getline.patch ]; + patches = [ ./environment.patch ./getline.patch ./clang.patch ]; setupHook = ./setup-hook.sh; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 49fc5f5658f3..d4995b0e1d75 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -231,8 +231,6 @@ let else defaultStdenv; - stdenvApple = stdenvAdapters.overrideGCC allStdenvs.stdenvNative gccApple; - forceNativeDrv = drv : if crossSystem == null then drv else (drv // { crossDrv = drv.nativeDrv; }); @@ -2686,8 +2684,7 @@ let }; clangUnwrapped = llvm: pkg: callPackage pkg { - stdenv = if stdenv.isDarwin then stdenvApple else stdenv; - inherit llvm; + inherit stdenv llvm; }; clangSelf = clangWrapSelf llvmPackagesSelf.clang; @@ -2704,7 +2701,7 @@ let }; #Use this instead of stdenv to build with clang - clangStdenv = lowPrio (stdenvAdapters.overrideGCC stdenv clang); + clangStdenv = if stdenv.isDarwin then stdenv else lowPrio (stdenvAdapters.overrideGCC stdenv clang); libcxxStdenv = stdenvAdapters.overrideGCC stdenv (clangWrapSelf llvmPackages.clang); clean = callPackage ../development/compilers/clean { }; @@ -2912,16 +2909,6 @@ let else null; })); - gccApple = - assert stdenv.isDarwin; - wrapGCC (makeOverridable (import ../development/compilers/gcc/4.2-apple64) { - inherit fetchurl noSysDirs; - profiledCompiler = true; - # Since it fails to build with GCC 4.6, build it with the "native" - # Apple-GCC. - stdenv = allStdenvs.stdenvNative; - }); - gfortran = gfortran48; gfortran48 = wrapGCC (gcc48.gcc.override { @@ -3216,9 +3203,7 @@ let llvm_34 = llvmPackages_34.llvm; llvm_33 = llvm_v ../development/compilers/llvm/3.3/llvm.nix; - llvm_v = path: callPackage path { - stdenv = if stdenv.isDarwin then stdenvApple else stdenv; - }; + llvm_v = path: callPackage path { }; llvmPackages = if !stdenv.isDarwin then llvmPackages_34 else llvmPackages_34 // { # until someone solves build problems with _34 @@ -3956,7 +3941,7 @@ let bam = callPackage ../development/tools/build-managers/bam {}; binutils = if stdenv.isDarwin - then stdenv.gcc.binutils + then import ../build-support/native-darwin-cctools-wrapper {inherit stdenv;} else callPackage ../development/tools/misc/binutils { inherit noSysDirs; }; @@ -4097,10 +4082,12 @@ let wrapGCC (distcc.links extraConfig)) {}; distccStdenv = lowPrio (overrideGCC stdenv distccWrapper); - distccMasquerade = callPackage ../development/tools/misc/distcc/masq.nix { - gccRaw = gcc.gcc; - binutils = binutils; - }; + distccMasquerade = if stdenv.isDarwin + then null + else callPackage ../development/tools/misc/distcc/masq.nix { + gccRaw = gcc.gcc; + binutils = binutils; + }; docutils = builderDefsPackage (import ../development/tools/documentation/docutils) { inherit python pil makeWrapper; diff --git a/pkgs/top-level/haskell-defaults.nix b/pkgs/top-level/haskell-defaults.nix index 9a064212a40e..93d8431b8d08 100644 --- a/pkgs/top-level/haskell-defaults.nix +++ b/pkgs/top-level/haskell-defaults.nix @@ -204,6 +204,8 @@ gmp = pkgs.gmp4; }); + ghc783Binary = lowPrio (callPackage ../development/compilers/ghc/7.8.3-binary.nix {}); + ghc6101BinaryDarwin = if stdenv.isDarwin then ghc704Binary else ghc6101Binary; ghc6121BinaryDarwin = if stdenv.isDarwin then ghc704Binary else ghc6121Binary; @@ -224,7 +226,7 @@ packages_ghc783 = packages { ghcPath = ../development/compilers/ghc/7.8.3.nix; - ghcBinary = ghc742Binary; + ghcBinary = ghc783Binary; prefFun = ghc783Prefs; }; From 7da056233f8436d361528d0eb20bec8286445a51 Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Wed, 20 Aug 2014 19:30:50 -0700 Subject: [PATCH 02/47] wip libc++ --- .../version-management/subversion/default.nix | 2 -- pkgs/development/compilers/llvm/3.4/llvm.nix | 2 +- .../libraries/libc++abi/default.nix | 9 ++++---- .../libraries/libunwind/native.nix | 22 +++++++++++++++++++ pkgs/development/libraries/mpc/default.nix | 2 ++ pkgs/development/libraries/mpfr/default.nix | 2 ++ pkgs/development/libraries/serf/default.nix | 8 +++---- pkgs/stdenv/darwin/default.nix | 5 +++++ pkgs/tools/package-management/nix/default.nix | 4 +++- .../tools/package-management/nix/unstable.nix | 5 +++-- pkgs/tools/text/sgml/opensp/default.nix | 5 +++++ pkgs/top-level/all-packages.nix | 2 ++ 12 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 pkgs/development/libraries/libunwind/native.nix diff --git a/pkgs/applications/version-management/subversion/default.nix b/pkgs/applications/version-management/subversion/default.nix index 30283ad387c8..af9827ef4b85 100644 --- a/pkgs/applications/version-management/subversion/default.nix +++ b/pkgs/applications/version-management/subversion/default.nix @@ -46,8 +46,6 @@ stdenv.mkDerivation (rec { preBuild = '' makeFlagsArray=(APACHE_LIBEXECDIR=$out/modules) - '' + stdenv.lib.optionalString stdenv.isDarwin '' - substituteInPlace configure --replace "-no-cpp-precomp" "" ''; postInstall = '' diff --git a/pkgs/development/compilers/llvm/3.4/llvm.nix b/pkgs/development/compilers/llvm/3.4/llvm.nix index fbc881fc8e02..dfd7b5570eae 100644 --- a/pkgs/development/compilers/llvm/3.4/llvm.nix +++ b/pkgs/development/compilers/llvm/3.4/llvm.nix @@ -65,6 +65,6 @@ in stdenv.mkDerivation rec { license = stdenv.lib.licenses.bsd3; maintainers = with stdenv.lib.maintainers; [ shlevy lovek323 raskin viric ]; platforms = stdenv.lib.platforms.all; - broken = stdenv.isDarwin; + # broken = stdenv.isDarwin; }; } diff --git a/pkgs/development/libraries/libc++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix index 8218cbb966f0..aae3027fd629 100644 --- a/pkgs/development/libraries/libc++abi/default.nix +++ b/pkgs/development/libraries/libc++abi/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchsvn, libcxx, libunwind }: +{ stdenv, fetchsvn, libcxx, libunwind, gnused }: let rev = "199626"; in stdenv.mkDerivation { @@ -15,17 +15,16 @@ in stdenv.mkDerivation { postUnpack = '' unpackFile ${libcxx.src} export NIX_CFLAGS_COMPILE="-I${libunwind}/include -I$PWD/include -I$(readlink -f libcxx-*)/include" + export TRIPLE=x86_64-apple-darwin ''; installPhase = '' install -d -m 755 $out/include $out/lib - install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 lib/libc++abi.dylib $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 ''; - patchPhase = "sed -e s,-lstdc++,, -i lib/buildit"; + patchPhase = "${gnused}/bin/sed -e s,-lstdc++,, -i lib/buildit"; buildPhase = "(cd lib; ./buildit)"; diff --git a/pkgs/development/libraries/libunwind/native.nix b/pkgs/development/libraries/libunwind/native.nix new file mode 100644 index 000000000000..dd2ebb6a6422 --- /dev/null +++ b/pkgs/development/libraries/libunwind/native.nix @@ -0,0 +1,22 @@ +{ stdenv }: + +stdenv.mkDerivation { + name = "libunwind-native"; + + unpackPhase = ":"; + dontBuild = true; + + installPhase = '' + mkdir -p $out/lib + cat ${/usr/lib/system/libunwind.dylib} > $out/lib/libunwind.dylib + /usr/bin/install_name_tool \ + -change /usr/lib/system/libunwind.dylib ${/usr/lib/system/libunwind.dylib} \ + -change /usr/lib/system/libsystem_malloc.dylib ${/usr/lib/system/libsystem_malloc.dylib} \ + -change /usr/lib/system/libsystem_pthread.dylib ${/usr/lib/system/libsystem_pthread.dylib} \ + -change /usr/lib/system/libsystem_platform.dylib ${/usr/lib/system/libsystem_platform.dylib} \ + -change /usr/lib/system/libsystem_c.dylib ${/usr/lib/system/libsystem_c.dylib} \ + -change /usr/lib/system/libdyld.dylib ${/usr/lib/system/libdyld.dylib} \ + -change /usr/lib/system/libkeymgr.dylib ${/usr/lib/system/libkeymgr.dylib} \ + $out/lib/libunwind.dylib + ''; +} diff --git a/pkgs/development/libraries/mpc/default.nix b/pkgs/development/libraries/mpc/default.nix index 3d05fa2e0405..dd132cfb5b7b 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 653481aeccd6..d999ba0cda5c 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/serf/default.nix b/pkgs/development/libraries/serf/default.nix index 033e53e521d5..49d7cec95901 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,9 +11,9 @@ 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 = '' diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 5c2044386c6e..d9668d0972cf 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -27,6 +27,11 @@ import ../generic rec { nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; nativeLibc = true; inherit stdenv; + libcxx = pkgs.libcxx.override { + libcxxabi = pkgs.libcxxabi.override { + libunwind = pkgs.libunwindNative; + }; + }; binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; clang = pkgs.clang_34; coreutils = pkgs.coreutils; diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix index 6631214f39ab..e64bc3293939 100644 --- a/pkgs/tools/package-management/nix/default.nix +++ b/pkgs/tools/package-management/nix/default.nix @@ -22,6 +22,8 @@ stdenv.mkDerivation rec { postUnpack = '' export CPATH="${bzip2}/include" export LIBRARY_PATH="${bzip2}/lib" + export CXX=/usr/bin/clang++ + export CXXFLAGS="-O3 -Wno-error=reserved-user-defined-literal" ''; configureFlags = @@ -32,7 +34,7 @@ stdenv.mkDerivation rec { --with-www-curl=${perlPackages.WWWCurl}/${perl.libPrefix} --disable-init-state --enable-gc - CFLAGS=-O3 CXXFLAGS=-O3 + CFLAGS=-O3 ''; makeFlags = "profiledir=$(out)/etc/profile.d"; diff --git a/pkgs/tools/package-management/nix/unstable.nix b/pkgs/tools/package-management/nix/unstable.nix index 5c20c7eb72aa..514924325e4a 100644 --- a/pkgs/tools/package-management/nix/unstable.nix +++ b/pkgs/tools/package-management/nix/unstable.nix @@ -1,5 +1,5 @@ { stdenv, fetchurl, perl, curl, bzip2, sqlite, openssl ? null -, pkgconfig, boehmgc, perlPackages +, pkgconfig, boehmgc, perlPackages, bash , storeDir ? "/nix/store" , stateDir ? "/nix/var" }: @@ -24,6 +24,7 @@ stdenv.mkDerivation rec { postUnpack = '' export CPATH="${bzip2}/include" export LIBRARY_PATH="${bzip2}/lib" + export CXXFLAGS="-O3 -Wno-error=reserved-user-defined-literal" ''; configureFlags = @@ -34,7 +35,7 @@ stdenv.mkDerivation rec { --with-www-curl=${perlPackages.WWWCurl}/${perl.libPrefix} --disable-init-state --enable-gc - CFLAGS=-O3 CXXFLAGS=-O3 + CFLAGS=-O3 ''; makeFlags = "profiledir=$(out)/etc/profile.d"; diff --git a/pkgs/tools/text/sgml/opensp/default.nix b/pkgs/tools/text/sgml/opensp/default.nix index 59b9b7bc13d1..71901b20ff1d 100644 --- a/pkgs/tools/text/sgml/opensp/default.nix +++ b/pkgs/tools/text/sgml/opensp/default.nix @@ -13,6 +13,11 @@ stdenv.mkDerivation { docsrc/*.xml ''; + configureFlags = [ + "--with-libintl-prefix=/usr" + "--with-libiconv-prefix=/usr" + ]; + setupHook = ./setup-hook.sh; buildInputs = [ xmlto docbook_xml_dtd_412 libxslt docbook_xsl ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d4995b0e1d75..8e130d8c1b85 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5699,6 +5699,8 @@ let libunwind = callPackage ../development/libraries/libunwind { }; + libunwindNative = callPackage ../development/libraries/libunwind/native.nix {}; + libuvVersions = callPackage ../development/libraries/libuv { }; libv4l = lowPrio (v4l_utils.override { From 2e26f7bef14678667c87dcb1f9e76dcf1e47ec3d Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Thu, 21 Aug 2014 16:15:31 -0700 Subject: [PATCH 03/47] livcxx build --- pkgs/development/libraries/libc++/default.nix | 2 +- pkgs/development/libraries/libc++abi/default.nix | 2 +- pkgs/development/libraries/readline/readline6.nix | 4 ---- pkgs/stdenv/darwin/default.nix | 6 +++--- pkgs/stdenv/default.nix | 8 ++++++++ pkgs/top-level/all-packages.nix | 6 +++++- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pkgs/development/libraries/libc++/default.nix b/pkgs/development/libraries/libc++/default.nix index 32035709d8f9..1ec1a61716d8 100644 --- a/pkgs/development/libraries/libc++/default.nix +++ b/pkgs/development/libraries/libc++/default.nix @@ -26,6 +26,6 @@ in stdenv.mkDerivation rec { 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++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix index aae3027fd629..141802d1616b 100644 --- a/pkgs/development/libraries/libc++abi/default.nix +++ b/pkgs/development/libraries/libc++abi/default.nix @@ -33,6 +33,6 @@ in 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/readline/readline6.nix b/pkgs/development/libraries/readline/readline6.nix index bffa838d2b35..1555f255c51b 100644 --- a/pkgs/development/libraries/readline/readline6.nix +++ b/pkgs/development/libraries/readline/readline6.nix @@ -10,10 +10,6 @@ stdenv.mkDerivation (rec { propagatedBuildInputs = [ncurses]; - preConfigure = '' - export CC=clang - ''; - patchFlags = "-p0"; patches = [ ./link-against-ncurses.patch diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index d9668d0972cf..28c863b63b0b 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -1,4 +1,4 @@ -{ stdenv, pkgs, config }: +{ stdenv, pkgs, config, haveLibCxx }: import ../generic rec { inherit config; @@ -27,11 +27,11 @@ import ../generic rec { nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; nativeLibc = true; inherit stdenv; - libcxx = pkgs.libcxx.override { + libcxx = if haveLibCxx then pkgs.libcxx.override { libcxxabi = pkgs.libcxxabi.override { libunwind = pkgs.libunwindNative; }; - }; + } else null; binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; clang = pkgs.clang_34; coreutils = pkgs.coreutils; diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 8e8be748795c..665cefbfc43b 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -37,6 +37,14 @@ rec { inherit config; stdenv = stdenvNative; pkgs = stdenvNativePkgs; + haveLibCxx = true; + }; + + stdenvDarwinNaked = import ./darwin { + inherit config; + stdenv = stdenvNative; + pkgs = stdenvNativePkgs; + haveLibCxx = false; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8e130d8c1b85..49b1cd9b1801 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1800,7 +1800,11 @@ let openssh_with_kerberos = pkgs.appendToName "with-kerberos" (openssh.override { withKerberos = true; }); - opensp = callPackage ../tools/text/sgml/opensp { }; + opensp = callPackage ../tools/text/sgml/opensp { + stdenv = if stdenv.isDarwin + then allStdenvs.stdenvDarwinNaked + else stdenv; + }; spCompat = callPackage ../tools/text/sgml/opensp/compat.nix { }; From 374648deaab5e8cacaa21b7d514375f6d8c42695 Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Thu, 21 Aug 2014 16:40:14 -0700 Subject: [PATCH 04/47] X11 build purity --- pkgs/servers/x11/xorg/overrides.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix index 66f74f305494..7073adb85dde 100644 --- a/pkgs/servers/x11/xorg/overrides.nix +++ b/pkgs/servers/x11/xorg/overrides.nix @@ -69,7 +69,9 @@ in }; libX11 = attrs: attrs // { - preConfigure = setMalloc0ReturnsNullCrossCompiling; + preConfigure = setMalloc0ReturnsNullCrossCompiling + '' + sed 's,^as_dummy.*,as_dummy="\$PATH",' -i configure + ''; postInstall = '' # Remove useless DocBook XML files. From c5cb8aab31a9b0bd3f48595e0e70f9ec91c2f068 Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Thu, 21 Aug 2014 16:42:52 -0700 Subject: [PATCH 05/47] build ghc with older binary where possible --- pkgs/top-level/haskell-defaults.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/haskell-defaults.nix b/pkgs/top-level/haskell-defaults.nix index 93d8431b8d08..0d1ddc6cbfb8 100644 --- a/pkgs/top-level/haskell-defaults.nix +++ b/pkgs/top-level/haskell-defaults.nix @@ -226,7 +226,7 @@ packages_ghc783 = packages { ghcPath = ../development/compilers/ghc/7.8.3.nix; - ghcBinary = ghc783Binary; + ghcBinary = if stdenv.isDarwin then ghc783Binary else ghc742Binary; prefFun = ghc783Prefs; }; From f3f6acc9f8e963c460e1bb971c2606160cac7294 Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Thu, 21 Aug 2014 16:47:29 -0700 Subject: [PATCH 06/47] mark nixUnstable as broken on darwin --- pkgs/tools/package-management/nix/unstable.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/package-management/nix/unstable.nix b/pkgs/tools/package-management/nix/unstable.nix index 514924325e4a..d5aebe45dd64 100644 --- a/pkgs/tools/package-management/nix/unstable.nix +++ b/pkgs/tools/package-management/nix/unstable.nix @@ -24,7 +24,6 @@ stdenv.mkDerivation rec { postUnpack = '' export CPATH="${bzip2}/include" export LIBRARY_PATH="${bzip2}/lib" - export CXXFLAGS="-O3 -Wno-error=reserved-user-defined-literal" ''; configureFlags = @@ -69,6 +68,9 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; meta = { + # due to builder args bug; see + # https://github.com/NixOS/nix/commit/b224ac15201c57b40ea855f5a98b1bd166c1c7f6 + broken = stdenv.isDarwin; description = "The Nix Deployment System"; homepage = http://nixos.org/; license = stdenv.lib.licenses.lgpl2Plus; From 6920b0066c1724784599aaad5cae4fd53157e814 Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Thu, 21 Aug 2014 16:49:36 -0700 Subject: [PATCH 07/47] stick darwin-specifics in a conditional --- .../libraries/libc++abi/default.nix | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pkgs/development/libraries/libc++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix index 141802d1616b..a2e333313b8b 100644 --- a/pkgs/development/libraries/libc++abi/default.nix +++ b/pkgs/development/libraries/libc++abi/default.nix @@ -15,14 +15,23 @@ in stdenv.mkDerivation { postUnpack = '' unpackFile ${libcxx.src} export NIX_CFLAGS_COMPILE="-I${libunwind}/include -I$PWD/include -I$(readlink -f libcxx-*)/include" + '' + stdenv.lib.optionalString '' export TRIPLE=x86_64-apple-darwin ''; - installPhase = '' - 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 - ''; + 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 + ''; patchPhase = "${gnused}/bin/sed -e s,-lstdc++,, -i lib/buildit"; From 799f4444778dc804f950e9559c46144bd7f7f0be Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Thu, 21 Aug 2014 16:50:34 -0700 Subject: [PATCH 08/47] libunwindNative for darwin only --- pkgs/development/libraries/libunwind/native.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/libraries/libunwind/native.nix b/pkgs/development/libraries/libunwind/native.nix index dd2ebb6a6422..10e552a28103 100644 --- a/pkgs/development/libraries/libunwind/native.nix +++ b/pkgs/development/libraries/libunwind/native.nix @@ -6,6 +6,7 @@ stdenv.mkDerivation { unpackPhase = ":"; dontBuild = true; + # TODO: figure out if these are different in Mavericks + older installPhase = '' mkdir -p $out/lib cat ${/usr/lib/system/libunwind.dylib} > $out/lib/libunwind.dylib @@ -19,4 +20,6 @@ stdenv.mkDerivation { -change /usr/lib/system/libkeymgr.dylib ${/usr/lib/system/libkeymgr.dylib} \ $out/lib/libunwind.dylib ''; + + meta.platforms = stdenv.lib.platforms.darwin; } From e961c0621542d65abb0280b0daea25d4258c6aaf Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Thu, 21 Aug 2014 16:57:30 -0700 Subject: [PATCH 09/47] missing an argument --- pkgs/development/libraries/libc++abi/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libc++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix index a2e333313b8b..cedd4bc6dba4 100644 --- a/pkgs/development/libraries/libc++abi/default.nix +++ b/pkgs/development/libraries/libc++abi/default.nix @@ -15,7 +15,7 @@ in stdenv.mkDerivation { postUnpack = '' unpackFile ${libcxx.src} export NIX_CFLAGS_COMPILE="-I${libunwind}/include -I$PWD/include -I$(readlink -f libcxx-*)/include" - '' + stdenv.lib.optionalString '' + '' + stdenv.lib.optionalString stdenv.isDarwin '' export TRIPLE=x86_64-apple-darwin ''; From ed42a8c1387a4a642ea4656fd4c4b0eaba532810 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Thu, 21 Aug 2014 19:32:31 -0700 Subject: [PATCH 10/47] libcxxabi needs coreutils for `cp -d` --- pkgs/development/libraries/libc++abi/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libc++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix index cedd4bc6dba4..4020856575b5 100644 --- a/pkgs/development/libraries/libc++abi/default.nix +++ b/pkgs/development/libraries/libc++abi/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchsvn, libcxx, libunwind, gnused }: +{ stdenv, coreutils, fetchsvn, libcxx, libunwind, gnused }: let rev = "199626"; in stdenv.mkDerivation { @@ -12,6 +12,8 @@ in stdenv.mkDerivation { NIX_CFLAGS_LINK="-L${libunwind}/lib -lunwind"; + buildInputs = [ coreutils ]; + postUnpack = '' unpackFile ${libcxx.src} export NIX_CFLAGS_COMPILE="-I${libunwind}/include -I$PWD/include -I$(readlink -f libcxx-*)/include" From e22889064f82be3a7f841b87e7af63dd489e79e4 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Fri, 22 Aug 2014 09:06:19 -0700 Subject: [PATCH 11/47] fix boost build with clang --- pkgs/development/libraries/boost/1.55.nix | 6 +- .../libraries/boost/boost-155-clang.patch | 90 +++++++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/libraries/boost/boost-155-clang.patch diff --git a/pkgs/development/libraries/boost/1.55.nix b/pkgs/development/libraries/boost/1.55.nix index 1e9d2134d120..cdbf98f44831 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 @@ stdenv.mkDerivation { sha256 = "0lkv5dzssbl5fmh2nkaszi8x9qbj80pr4acf9i26sj3rvlih1w7z"; }; + patches = stdenv.lib.optional (toolset == "clang") [ ./boost-155-clang.patch ]; + enableParallelBuilding = true; buildInputs = @@ -66,7 +68,7 @@ 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 000000000000..9c4e3a74cd25 --- /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 + + 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 + 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 + + 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 + + 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 + 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 + 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, From 0577499d74dda2bb77ba3649681c10cadbfed5f2 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Fri, 22 Aug 2014 14:16:38 -0700 Subject: [PATCH 12/47] fix some packages on darwin --- pkgs/development/compilers/llvm/3.4/llvm.nix | 1 - pkgs/development/compilers/ocaml/4.01.0.nix | 2 ++ .../ocaml/fix-clang-build-on-osx.diff | 20 +++++++++++++++++++ .../tools/misc/sloccount/default.nix | 1 + pkgs/shells/fish/default.nix | 2 +- pkgs/tools/compression/bzip2/default.nix | 2 ++ pkgs/tools/networking/isync/default.nix | 2 +- pkgs/tools/typesetting/tex/tex4ht/default.nix | 2 +- .../tools/typesetting/tex/texlive/default.nix | 1 - 9 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff diff --git a/pkgs/development/compilers/llvm/3.4/llvm.nix b/pkgs/development/compilers/llvm/3.4/llvm.nix index dfd7b5570eae..f7f794f4f87b 100644 --- a/pkgs/development/compilers/llvm/3.4/llvm.nix +++ b/pkgs/development/compilers/llvm/3.4/llvm.nix @@ -65,6 +65,5 @@ in stdenv.mkDerivation rec { license = stdenv.lib.licenses.bsd3; maintainers = with stdenv.lib.maintainers; [ shlevy lovek323 raskin viric ]; platforms = stdenv.lib.platforms.all; - # broken = stdenv.isDarwin; }; } diff --git a/pkgs/development/compilers/ocaml/4.01.0.nix b/pkgs/development/compilers/ocaml/4.01.0.nix index 2876bce9caff..5e3cb61c3398 100644 --- a/pkgs/development/compilers/ocaml/4.01.0.nix +++ b/pkgs/development/compilers/ocaml/4.01.0.nix @@ -26,6 +26,8 @@ stdenv.mkDerivation rec { sha256 = "b1ca708994180236917ae79e17606da5bd334ca6acd6873a550027e1c0ec874a"; }; + patches = [ ./fix-clang-build-on-osx.diff ]; + prefixKey = "-prefix "; configureFlags = ["-no-tk"] ++ optionals useX11 [ "-x11lib" x11lib "-x11include" x11inc ]; diff --git a/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff b/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff new file mode 100644 index 000000000000..d7d9c863858f --- /dev/null +++ b/pkgs/development/compilers/ocaml/fix-clang-build-on-osx.diff @@ -0,0 +1,20 @@ +diff --git a/configure b/configure +index d45e88f..25d872b 100755 +--- a/configure ++++ b/configure +@@ -322,7 +322,14 @@ case "$bytecc,$target" in + bytecccompopts="-fno-defer-pop $gcc_warnings -DSHRINKED_GNUC" + mathlib="";; + *,*-*-darwin*) +- bytecccompopts="-fno-defer-pop $gcc_warnings" ++ # On recent version of OSX, gcc is a symlink to clang ++ if $bytecc --version | grep -q clang; then ++ # -fno-defer-pop is not supported by clang, and make recent ++ # versions of clang to fail ++ bytecccompopts="$gcc_warnings" ++ else ++ bytecccompopts="-fno-defer-pop $gcc_warnings" ++ fi + mathlib="" + mkexe="$mkexe -Wl,-no_compact_unwind" + # Tell gcc that we can use 32-bit code addresses for threaded code diff --git a/pkgs/development/tools/misc/sloccount/default.nix b/pkgs/development/tools/misc/sloccount/default.nix index 1aa9a2c058d6..fffb80747482 100644 --- a/pkgs/development/tools/misc/sloccount/default.nix +++ b/pkgs/development/tools/misc/sloccount/default.nix @@ -31,6 +31,7 @@ stdenv.mkDerivation rec { configurePhase = '' sed -i "makefile" -"es|PREFIX[[:blank:]]*=.*$|PREFIX = $out|g" + sed -i "makefile" -"es|gcc|$CC|g" ''; doCheck = true; diff --git a/pkgs/shells/fish/default.nix b/pkgs/shells/fish/default.nix index adfe44b3bac1..03ecc290d14c 100644 --- a/pkgs/shells/fish/default.nix +++ b/pkgs/shells/fish/default.nix @@ -31,7 +31,7 @@ stdenv.mkDerivation rec { description = "Smart and user-friendly command line shell"; homepage = "http://fishshell.com/"; license = licenses.gpl2; - platforms = platforms.linux; + platforms = platforms.unix; maintainers = with maintainers; [ ocharles ]; }; } diff --git a/pkgs/tools/compression/bzip2/default.nix b/pkgs/tools/compression/bzip2/default.nix index 55fca6ca3cb9..256f574c2e0c 100644 --- a/pkgs/tools/compression/bzip2/default.nix +++ b/pkgs/tools/compression/bzip2/default.nix @@ -26,6 +26,8 @@ stdenv.mkDerivation { sharedLibrary = !stdenv.isDarwin && !(stdenv ? isDietLibC) && !(stdenv ? isStatic) && stdenv.system != "i686-cygwin" && !linkStatic; + patchPhase = stdenv.lib.optionalString stdenv.isDarwin "substituteInPlace Makefile --replace 'CC=gcc' 'CC=clang'"; + preConfigure = "substituteInPlace Makefile --replace '$(PREFIX)/man' '$(PREFIX)/share/man'"; makeFlags = if linkStatic then "LDFLAGS=-static" else ""; diff --git a/pkgs/tools/networking/isync/default.nix b/pkgs/tools/networking/isync/default.nix index 2d3ffb2cb0a8..021f470af241 100644 --- a/pkgs/tools/networking/isync/default.nix +++ b/pkgs/tools/networking/isync/default.nix @@ -16,6 +16,6 @@ stdenv.mkDerivation rec { license = [ "GPLv2+" ]; maintainers = with stdenv.lib.maintainers; [ the-kenny viric ]; - platforms = stdenv.lib.platforms.linux; + platforms = stdenv.lib.platforms.unix; }; } diff --git a/pkgs/tools/typesetting/tex/tex4ht/default.nix b/pkgs/tools/typesetting/tex/tex4ht/default.nix index 69d02a275b34..93d33439084a 100644 --- a/pkgs/tools/typesetting/tex/tex4ht/default.nix +++ b/pkgs/tools/typesetting/tex/tex4ht/default.nix @@ -14,7 +14,7 @@ stdenv.mkDerivation rec { cd src for f in tex4ht t4ht htcmd ; do # -DENVFILE="$out/share/texmf-nix/tex4ht/base/unix/tex4ht.env" - gcc -o $f $f.c -I${tetex}/include -L${tetex}/lib -DHAVE_DIRENT_H -DHAVE_DIRENT_H -DKPATHSEA -lkpathsea + $CC -o $f $f.c -I${tetex}/include -L${tetex}/lib -DHAVE_DIRENT_H -DHAVE_DIRENT_H -DKPATHSEA -lkpathsea done cd - ''; diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix index beb6a7f3a68c..384768666dec 100644 --- a/pkgs/tools/typesetting/tex/texlive/default.nix +++ b/pkgs/tools/typesetting/tex/texlive/default.nix @@ -22,7 +22,6 @@ rec { setupHook = ./setup-hook.sh; doMainBuild = fullDepEntry ( stdenv.lib.optionalString stdenv.isDarwin '' - export MACOSX_DEPLOYMENT_TARGET=10.9 export DYLD_LIBRARY_PATH="${poppler}/lib" '' + '' mkdir -p $out From 6f949b2e872c8ef3d8c53c083506187c56afc85e Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Fri, 22 Aug 2014 23:51:25 -0700 Subject: [PATCH 13/47] get rid of nasty CC stuff --- pkgs/development/interpreters/lua-5/5.1.nix | 2 +- pkgs/development/libraries/gmp/5.1.x.nix | 2 +- .../development/libraries/qt-4.x/4.8/default.nix | 2 -- pkgs/development/libraries/zlib/default.nix | 4 +--- pkgs/tools/misc/getopt/default.nix | 5 +++-- pkgs/tools/package-management/nix/default.nix | 16 +++++----------- pkgs/tools/system/tree/default.nix | 2 +- 7 files changed, 12 insertions(+), 21 deletions(-) diff --git a/pkgs/development/interpreters/lua-5/5.1.nix b/pkgs/development/interpreters/lua-5/5.1.nix index b2ccc7fd6428..adeaa9fae7bb 100644 --- a/pkgs/development/interpreters/lua-5/5.1.nix +++ b/pkgs/development/interpreters/lua-5/5.1.nix @@ -29,7 +29,7 @@ stdenv.mkDerivation rec { configurePhase = if stdenv.isDarwin then '' - makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2" LDFLAGS="" CC=clang ) + makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2" LDFLAGS="" CC="$CC" ) installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.5.1.5.dylib" INSTALL_DATA='cp -d' ) '' else '' makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC" LDFLAGS="-fPIC" ) diff --git a/pkgs/development/libraries/gmp/5.1.x.nix b/pkgs/development/libraries/gmp/5.1.x.nix index 5bee2fe43368..e9495b796dd2 100644 --- a/pkgs/development/libraries/gmp/5.1.x.nix +++ b/pkgs/development/libraries/gmp/5.1.x.nix @@ -22,7 +22,7 @@ stdenv.mkDerivation (rec { ++ (if cxx then [ "--enable-cxx" ] else [ "--disable-cxx" ]) ++ optional (cxx && stdenv.isDarwin) "CPPFLAGS=-fexceptions" - ++ optional stdenv.isDarwin "ABI=64 CC=clang" + ++ optional stdenv.isDarwin "ABI=64" ++ optional stdenv.is64bit "--with-pic" ; 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 1679b4953e77..6c534f4220d8 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/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index 1b46c9594488..0938e2a17a79 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -15,9 +15,7 @@ stdenv.mkDerivation rec { configureFlags = if static then "" else "--shared"; - preConfigure = stdenv.lib.optionalString stdenv.isDarwin '' - export CC=clang - '' + '' + preConfigure = '' if test -n "$crossConfig"; then export CC=$crossConfig-gcc configureFlags=${if static then "" else "--shared"} diff --git a/pkgs/tools/misc/getopt/default.nix b/pkgs/tools/misc/getopt/default.nix index 84d15a187471..14bdb7889c91 100644 --- a/pkgs/tools/misc/getopt/default.nix +++ b/pkgs/tools/misc/getopt/default.nix @@ -7,6 +7,7 @@ stdenv.mkDerivation { url = http://tarballs.nixos.org/getopt-1.1.4.tar.gz; md5 = "02188ca68da27c4175d6e9f3da732101"; }; - - buildFlags = stdenv.lib.optional stdenv.isDarwin [ "CC=clang" ]; + preBuild = '' + export buildFlags=CC="$CC" # for darwin + ''; } diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix index e64bc3293939..e659a1f1b03f 100644 --- a/pkgs/tools/package-management/nix/default.nix +++ b/pkgs/tools/package-management/nix/default.nix @@ -22,8 +22,6 @@ stdenv.mkDerivation rec { postUnpack = '' export CPATH="${bzip2}/include" export LIBRARY_PATH="${bzip2}/lib" - export CXX=/usr/bin/clang++ - export CXXFLAGS="-O3 -Wno-error=reserved-user-defined-literal" ''; configureFlags = @@ -34,7 +32,7 @@ stdenv.mkDerivation rec { --with-www-curl=${perlPackages.WWWCurl}/${perl.libPrefix} --disable-init-state --enable-gc - CFLAGS=-O3 + CFLAGS=-O3 CXXFLAGS=-O3 ''; makeFlags = "profiledir=$(out)/etc/profile.d"; @@ -68,14 +66,10 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; meta = { - description = "Powerful package manager that makes package management reliable and reproducible"; - longDescription = '' - Nix is a powerful package manager for Linux and other Unix systems that - makes package management reliable and reproducible. It provides atomic - upgrades and rollbacks, side-by-side installation of multiple versions of - a package, multi-user package management and easy setup of build - environments. - ''; + # due to builder args bug; see + # https://github.com/NixOS/nix/commit/b224ac15201c57b40ea855f5a98b1bd166c1c7f6 + broken = stdenv.isDarwin; + description = "The Nix Deployment System"; homepage = http://nixos.org/; license = stdenv.lib.licenses.lgpl2Plus; maintainers = [ stdenv.lib.maintainers.eelco ]; diff --git a/pkgs/tools/system/tree/default.nix b/pkgs/tools/system/tree/default.nix index 51de5998069f..eca8882643d1 100644 --- a/pkgs/tools/system/tree/default.nix +++ b/pkgs/tools/system/tree/default.nix @@ -37,7 +37,7 @@ stdenv.mkDerivation { prefix=$out MANDIR=$out/share/man/man1 ${systemFlags} - CC=clang + CC="$CC" ) ''; From fa9b1f9cda5e44795d02df54defc6e8b9a0b2132 Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Sat, 23 Aug 2014 18:26:55 -0700 Subject: [PATCH 14/47] build nix head successfully --- pkgs/development/compilers/llvm/3.3/clang.nix | 4 ---- pkgs/development/compilers/llvm/3.4/clang.nix | 4 ++++ pkgs/stdenv/darwin/default.nix | 6 ++++-- pkgs/stdenv/default.nix | 8 +++++++- pkgs/tools/package-management/nix/unstable.nix | 4 +--- pkgs/top-level/all-packages.nix | 7 ++----- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/pkgs/development/compilers/llvm/3.3/clang.nix b/pkgs/development/compilers/llvm/3.3/clang.nix index 72287560b245..262e0bff2483 100644 --- a/pkgs/development/compilers/llvm/3.3/clang.nix +++ b/pkgs/development/compilers/llvm/3.3/clang.nix @@ -1,9 +1,5 @@ { stdenv, fetchurl, perl, groff, llvm, cmake, libxml2, python }: -# be sure not to rebuild clang on darwin; some packages request it specifically -# we need to fix those -assert stdenv.isDarwin -> stdenv.gcc.nativeTools; - let version = "3.3"; gccReal = if (stdenv.gcc.gcc or null) == null then stdenv.gcc else stdenv.gcc.gcc; diff --git a/pkgs/development/compilers/llvm/3.4/clang.nix b/pkgs/development/compilers/llvm/3.4/clang.nix index 6ec3f7bf44a3..fc33a7809a6c 100644 --- a/pkgs/development/compilers/llvm/3.4/clang.nix +++ b/pkgs/development/compilers/llvm/3.4/clang.nix @@ -1,5 +1,9 @@ { stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src }: +# be sure not to rebuild clang on darwin; some packages request it specifically +# we need to fix those +assert stdenv.isDarwin -> stdenv.gcc.nativeTools; + stdenv.mkDerivation { name = "clang-${version}"; diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 28c863b63b0b..f42cd7139d91 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -1,4 +1,6 @@ -{ stdenv, pkgs, config, haveLibCxx }: +{ stdenv, pkgs, config +, haveLibCxx ? true +, useClang33 ? false }: import ../generic rec { inherit config; @@ -33,7 +35,7 @@ import ../generic rec { }; } else null; binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; - clang = pkgs.clang_34; + clang = if useClang33 then pkgs.clang_33 else pkgs.clang; coreutils = pkgs.coreutils; shell = pkgs.bash + "/bin/sh"; }; diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 665cefbfc43b..674f5585c0b9 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -37,7 +37,6 @@ rec { inherit config; stdenv = stdenvNative; pkgs = stdenvNativePkgs; - haveLibCxx = true; }; stdenvDarwinNaked = import ./darwin { @@ -47,6 +46,13 @@ rec { haveLibCxx = false; }; + stdenvDarwin33 = import ./darwin { + inherit config; + stdenv = stdenvNative; + pkgs = stdenvNativePkgs; + useClang33 = true; + }; + # Linux standard environment. stdenvLinux = (import ./linux { inherit system allPackages platform config;}).stdenvLinux; diff --git a/pkgs/tools/package-management/nix/unstable.nix b/pkgs/tools/package-management/nix/unstable.nix index d5aebe45dd64..514924325e4a 100644 --- a/pkgs/tools/package-management/nix/unstable.nix +++ b/pkgs/tools/package-management/nix/unstable.nix @@ -24,6 +24,7 @@ stdenv.mkDerivation rec { postUnpack = '' export CPATH="${bzip2}/include" export LIBRARY_PATH="${bzip2}/lib" + export CXXFLAGS="-O3 -Wno-error=reserved-user-defined-literal" ''; configureFlags = @@ -68,9 +69,6 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; meta = { - # due to builder args bug; see - # https://github.com/NixOS/nix/commit/b224ac15201c57b40ea855f5a98b1bd166c1c7f6 - broken = stdenv.isDarwin; description = "The Nix Deployment System"; homepage = http://nixos.org/; license = stdenv.lib.licenses.lgpl2Plus; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 49b1cd9b1801..22d35e03d594 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3209,11 +3209,7 @@ let llvm_v = path: callPackage path { }; - llvmPackages = if !stdenv.isDarwin then llvmPackages_34 else llvmPackages_34 // { - # until someone solves build problems with _34 - llvm = llvm_33; - clang = clang_33; - }; + llvmPackages = llvmPackages_34; llvmPackages_34 = recurseIntoAttrs (import ../development/compilers/llvm/3.4 { inherit stdenv newScope fetchurl; @@ -11455,6 +11451,7 @@ let }; nixUnstable = callPackage ../tools/package-management/nix/unstable.nix { + stdenv = if stdenv.isDarwin then allStdenvs.stdenvDarwin33 else stdenv; storeDir = config.nix.storeDir or "/nix/store"; stateDir = config.nix.stateDir or "/nix/var"; }; From afa1db198bc88abea65d61ef6761866ed490ba6b Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Sat, 23 Aug 2014 23:15:23 -0700 Subject: [PATCH 15/47] fix even more clang builds --- pkgs/development/libraries/libdevil/default.nix | 9 +++++++++ pkgs/servers/x11/xorg/overrides.nix | 5 ++++- pkgs/stdenv/adapters.nix | 5 +++++ pkgs/top-level/all-packages.nix | 8 ++++---- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pkgs/development/libraries/libdevil/default.nix b/pkgs/development/libraries/libdevil/default.nix index d3053b4d2a5f..6cbbddfdba83 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/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix index 7073adb85dde..4811659ac413 100644 --- a/pkgs/servers/x11/xorg/overrides.nix +++ b/pkgs/servers/x11/xorg/overrides.nix @@ -102,8 +102,11 @@ in # Note: most of these are in Requires.private, so maybe builder.sh # should propagate them automatically. libXt = attrs: attrs // { - preConfigure = setMalloc0ReturnsNullCrossCompiling; + preConfigure = setMalloc0ReturnsNullCrossCompiling + '' + sed 's,^as_dummy.*,as_dummy="\$PATH",' -i configure + ''; propagatedBuildInputs = [ xorg.libSM ]; + CPP = stdenv.lib.optionalString stdenv.isDarwin "clang -E -"; }; # See https://bugs.freedesktop.org/show_bug.cgi?id=47792 diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 09c92b552d48..c57f1d00f0a5 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -299,4 +299,9 @@ rec { ''; # */ in overrideGCC stdenv (stdenv.gcc.override { binutils = binutils'; }); + dropCxx = drv: drv.override { + stdenv = if pkgs.stdenv.isDarwin + then pkgs.allStdenvs.stdenvDarwinNaked + else pkgs.stdenv; + }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 22d35e03d594..623d464d30ee 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4574,7 +4574,7 @@ let coredumper = callPackage ../development/libraries/coredumper { }; - ctl = callPackage ../development/libraries/ctl { }; + ctl = dropCxx (callPackage ../development/libraries/ctl { }); cpp-netlib = callPackage ../development/libraries/cpp-netlib { }; @@ -5079,7 +5079,7 @@ let ilixi = callPackage ../development/libraries/ilixi { }; - ilmbase = callPackage ../development/libraries/ilmbase { }; + ilmbase = dropCxx (callPackage ../development/libraries/ilmbase { }); imlib = callPackage ../development/libraries/imlib { libpng = libpng12; @@ -5253,7 +5253,7 @@ let libdc1394avt = callPackage ../development/libraries/libdc1394avt { }; - libdevil = callPackage ../development/libraries/libdevil { }; + libdevil = dropCxx (callPackage ../development/libraries/libdevil { }); libdiscid = callPackage ../development/libraries/libdiscid { }; @@ -5994,7 +5994,7 @@ let # this ctl version is needed by openexr_viewers openexr_ctl = callPackage ../development/libraries/openexr_ctl { }; - openexr = callPackage ../development/libraries/openexr { }; + openexr = dropCxx (callPackage ../development/libraries/openexr { }); openldap = callPackage ../development/libraries/openldap { stdenv = if stdenv.isDarwin From 25b395bc8d8b1590723dc42edd97561611f8db68 Mon Sep 17 00:00:00 2001 From: Joel Taylor Date: Wed, 3 Sep 2014 18:46:47 -0700 Subject: [PATCH 16/47] stop copying everything into the store --- pkgs/development/libraries/libunwind/native.nix | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pkgs/development/libraries/libunwind/native.nix b/pkgs/development/libraries/libunwind/native.nix index 10e552a28103..3220d20495ee 100644 --- a/pkgs/development/libraries/libunwind/native.nix +++ b/pkgs/development/libraries/libunwind/native.nix @@ -6,19 +6,9 @@ stdenv.mkDerivation { unpackPhase = ":"; dontBuild = true; - # TODO: figure out if these are different in Mavericks + older installPhase = '' mkdir -p $out/lib cat ${/usr/lib/system/libunwind.dylib} > $out/lib/libunwind.dylib - /usr/bin/install_name_tool \ - -change /usr/lib/system/libunwind.dylib ${/usr/lib/system/libunwind.dylib} \ - -change /usr/lib/system/libsystem_malloc.dylib ${/usr/lib/system/libsystem_malloc.dylib} \ - -change /usr/lib/system/libsystem_pthread.dylib ${/usr/lib/system/libsystem_pthread.dylib} \ - -change /usr/lib/system/libsystem_platform.dylib ${/usr/lib/system/libsystem_platform.dylib} \ - -change /usr/lib/system/libsystem_c.dylib ${/usr/lib/system/libsystem_c.dylib} \ - -change /usr/lib/system/libdyld.dylib ${/usr/lib/system/libdyld.dylib} \ - -change /usr/lib/system/libkeymgr.dylib ${/usr/lib/system/libkeymgr.dylib} \ - $out/lib/libunwind.dylib ''; meta.platforms = stdenv.lib.platforms.darwin; From d00f88603db787ca4021244435cf8f3b740ec909 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 23 Sep 2014 13:12:26 +0200 Subject: [PATCH 17/47] libc++abi: Drop unused Python dependency --- pkgs/development/libraries/libc++/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/libc++/default.nix b/pkgs/development/libraries/libc++/default.nix index 36ac1d98ed0d..6dc49f4684e0 100644 --- a/pkgs/development/libraries/libc++/default.nix +++ b/pkgs/development/libraries/libc++/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, cmake, libcxxabi, python }: +{ stdenv, fetchurl, cmake, libcxxabi }: let version = "3.4.2"; @@ -11,7 +11,7 @@ in stdenv.mkDerivation rec { sha256 = "0z3jdvgcq995khkpis5c5vaxhbmvbqjlalbhn09k6pgb5zp46rc2"; }; - buildInputs = [ cmake libcxxabi python ]; + buildInputs = [ cmake libcxxabi ]; cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" "-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=${libcxxabi}/include" From cb9f69c05272e638cf6ff14eab1216a06b61897d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 23 Sep 2014 13:13:53 +0200 Subject: [PATCH 18/47] llvm: Don't depend on Python on Darwin There already is a Python in /usr/bin, so we don't need to build another one. --- pkgs/development/compilers/llvm/3.4/llvm.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/llvm/3.4/llvm.nix b/pkgs/development/compilers/llvm/3.4/llvm.nix index f7f794f4f87b..d9dd1a976b35 100644 --- a/pkgs/development/compilers/llvm/3.4/llvm.nix +++ b/pkgs/development/compilers/llvm/3.4/llvm.nix @@ -27,7 +27,10 @@ in stdenv.mkDerivation rec { mv compiler-rt-* $sourceRoot/projects/compiler-rt ''; - buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind; + buildInputs = + [ perl groff cmake libxml2 libffi ] + ++ stdenv.lib.optional (!stdenv.isDarwin) python + ++ stdenv.lib.optional stdenv.isLinux valgrind; propagatedBuildInputs = [ ncurses zlib ]; From 66dedaa6eec453b4cecb084e9bc1996aee7ec82c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 23 Sep 2014 19:43:38 +0200 Subject: [PATCH 19/47] gcc-wrapper: Remove NIX_GCC_NEEDS_GREP This is not needed on any currently supported platform. --- pkgs/build-support/clang-wrapper/clang-wrapper.sh | 11 +---------- pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh | 11 +---------- pkgs/build-support/gcc-wrapper/gcc-wrapper.sh | 12 +----------- pkgs/build-support/gcc-wrapper/gnat-wrapper.sh | 12 +----------- pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh | 12 +----------- pkgs/stdenv/native/default.nix | 9 --------- 6 files changed, 5 insertions(+), 62 deletions(-) diff --git a/pkgs/build-support/clang-wrapper/clang-wrapper.sh b/pkgs/build-support/clang-wrapper/clang-wrapper.sh index 57715274f1e2..3c6a9c8e4529 100644 --- a/pkgs/build-support/clang-wrapper/clang-wrapper.sh +++ b/pkgs/build-support/clang-wrapper/clang-wrapper.sh @@ -138,13 +138,4 @@ if test -n "$NIX_CLANG_WRAPPER_EXEC_HOOK"; then source "$NIX_CLANG_WRAPPER_EXEC_HOOK" fi -# Call the real `clang'. Filter out warnings from stderr about unused -# `-B' flags, since they confuse some programs. Deep bash magic to -# apply grep to stderr (by swapping stdin/stderr twice). -if test -z "$NIX_CLANG_NEEDS_GREP"; then - @clangProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} -else - (@clangProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \ - | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3- - exit $? -fi +exec @clangProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh index f954cae05d86..ec1f6004edd9 100644 --- a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh +++ b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh @@ -114,13 +114,4 @@ fi # We want gcc to call the wrapper linker, not that of binutils. export PATH="@ldPath@:$PATH" -# Call the real `gcc'. Filter out warnings from stderr about unused -# `-B' flags, since they confuse some programs. Deep bash magic to -# apply grep to stderr (by swapping stdin/stderr twice). -if test -z "$NIX_GCC_NEEDS_GREP"; then - @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} -else - (@gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \ - | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3- - exit $? -fi +exec @gccProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh index 11ee85929321..d01ce54fd969 100644 --- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh @@ -143,14 +143,4 @@ if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then source "$NIX_GCC_WRAPPER_EXEC_HOOK" fi - -# Call the real `gcc'. Filter out warnings from stderr about unused -# `-B' flags, since they confuse some programs. Deep bash magic to -# apply grep to stderr (by swapping stdin/stderr twice). -if test -z "$NIX_GCC_NEEDS_GREP"; then - @gccProg@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" -else - (@gccProg@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" 3>&2 2>&1 1>&3- \ - | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3- - exit $? -fi +exec @gccProg@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" diff --git a/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh b/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh index f6fa4b18400a..4404194ff1bf 100644 --- a/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh @@ -100,14 +100,4 @@ if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then source "$NIX_GNAT_WRAPPER_EXEC_HOOK" fi - -# Call the real `gcc'. Filter out warnings from stderr about unused -# `-B' flags, since they confuse some programs. Deep bash magic to -# apply grep to stderr (by swapping stdin/stderr twice). -if test -z "$NIX_GNAT_NEEDS_GREP"; then - @gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} -else - (@gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} 3>&2 2>&1 1>&3- \ - | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3- - exit $? -fi +exec @gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh b/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh index 25907108b4db..d8e4b5254bfc 100644 --- a/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh @@ -30,14 +30,4 @@ if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then source "$NIX_GNAT_WRAPPER_EXEC_HOOK" fi - -# Call the real `gcc'. Filter out warnings from stderr about unused -# `-B' flags, since they confuse some programs. Deep bash magic to -# apply grep to stderr (by swapping stdin/stderr twice). -if test -z "$NIX_GNAT_NEEDS_GREP"; then - @gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]} -else - (@gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]} 3>&2 2>&1 1>&3- \ - | (grep -v 'file path prefix' || true); exit ${PIPESTATUS[0]}) 3>&2 2>&1 1>&3- - exit $? -fi +exec @gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]} diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index 715bc02758bc..b0ed7c93f788 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -35,9 +35,6 @@ rec { alias sed=gsed export MAKE=gmake shopt -s expand_aliases - - # Filter out stupid GCC warnings (in gcc-wrapper). - export NIX_GCC_NEEDS_GREP=1 ''; prehookOpenBSD = '' @@ -52,9 +49,6 @@ rec { export MAKE=gmake shopt -s expand_aliases - - # Filter out stupid GCC warnings (in gcc-wrapper). - export NIX_GCC_NEEDS_GREP=1 ''; prehookNetBSD = '' @@ -65,9 +59,6 @@ rec { alias tar=gtar export MAKE=gmake shopt -s expand_aliases - - # Filter out stupid GCC warnings (in gcc-wrapper). - export NIX_GCC_NEEDS_GREP=1 ''; prehookCygwin = '' From 1117201a97eb6b1be3594c0282fbb3d1c8fd413e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 12:05:09 +0200 Subject: [PATCH 20/47] libc++abi: Don't set dylib install name to /usr/lib This caused users of libc++abi to use the system libc++abi. --- .../libraries/libc++abi/darwin.patch | 17 +++++++++++++++++ .../development/libraries/libc++abi/default.nix | 8 ++++---- .../libraries/libc++abi/no-stdc++.patch | 12 ++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/libraries/libc++abi/darwin.patch create mode 100644 pkgs/development/libraries/libc++abi/no-stdc++.patch diff --git a/pkgs/development/libraries/libc++abi/darwin.patch b/pkgs/development/libraries/libc++abi/darwin.patch new file mode 100644 index 000000000000..53ea8783f7a8 --- /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 f14ac7780feb..eb3d3e5e4a8b 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, coreutils, gnused }: +{ lib, stdenv, fetchurl, libcxx, libunwind, coreutils, gnused }: let rev = "199626"; in @@ -10,6 +10,8 @@ stdenv.mkDerivation { sha256 = "09wr6qwgmdzbmgfkdzfhph9giy0zd6fp3s017fcfy4g0prjn5s4c"; }; + patches = [ ./no-stdc++.patch ./darwin.patch ]; + NIX_CFLAGS_LINK = "-L${libunwind}/lib -lunwind"; buildInputs = [ coreutils ]; @@ -17,7 +19,7 @@ stdenv.mkDerivation { postUnpack = '' unpackFile ${libcxx.src} export NIX_CFLAGS_COMPILE="-I${libunwind}/include -I$PWD/include -I$(readlink -f libcxx-*)/include" - '' + stdenv.lib.optionalString stdenv.isDarwin '' + '' + lib.optionalString stdenv.isDarwin '' export TRIPLE=x86_64-apple-darwin ''; @@ -35,8 +37,6 @@ stdenv.mkDerivation { ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 ''; - patchPhase = "${gnused}/bin/sed -e s,-lstdc++,, -i lib/buildit"; - buildPhase = "(cd lib; ./buildit)"; meta = { 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 000000000000..ddc9778a486e --- /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 + From 43424d9028d381e597712b005da2395d32d8c165 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 13:15:46 +0200 Subject: [PATCH 21/47] libc++: Don't install include/c++/v1/Makefile It causes many retained dependencies (e.g. on cmake). Let's hope nobody depends on it... --- pkgs/development/libraries/libc++/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/libc++/default.nix b/pkgs/development/libraries/libc++/default.nix index 6dc49f4684e0..9f6f1ecdeb57 100644 --- a/pkgs/development/libraries/libc++/default.nix +++ b/pkgs/development/libraries/libc++/default.nix @@ -1,9 +1,8 @@ { stdenv, fetchurl, cmake, libcxxabi }: -let - version = "3.4.2"; +let version = "3.4.2"; in -in stdenv.mkDerivation rec { +stdenv.mkDerivation rec { name = "libc++-${version}"; src = fetchurl { @@ -21,6 +20,9 @@ in stdenv.mkDerivation rec { passthru.abi = libcxxabi; + # Remove a Makefile that causes many retained dependencies. + postInstall = "rm $out/include/c++/v1/Makefile"; + meta = { homepage = http://libcxx.llvm.org/; description = "A new implementation of the C++ standard library, targeting C++11"; From be330c47ebf3b8ffc08ad4211e56f0885174fc11 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 14:43:05 +0200 Subject: [PATCH 22/47] libc++: Fix /usr/lib references The install name and libc++abi reexport were pointing to /usr/lib, preventing our libc++ from being used at runtime. --- .../development/libraries/libc++/darwin.patch | 30 +++++++++++++++++++ pkgs/development/libraries/libc++/default.nix | 15 ++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 pkgs/development/libraries/libc++/darwin.patch diff --git a/pkgs/development/libraries/libc++/darwin.patch b/pkgs/development/libraries/libc++/darwin.patch new file mode 100644 index 000000000000..bf83f169cfc3 --- /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 9f6f1ecdeb57..e956b1877c61 100644 --- a/pkgs/development/libraries/libc++/default.nix +++ b/pkgs/development/libraries/libc++/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, cmake, libcxxabi }: +{ lib, stdenv, fetchurl, cmake, libcxxabi, fixDarwinDylibNames }: let version = "3.4.2"; in @@ -10,11 +10,16 @@ stdenv.mkDerivation rec { sha256 = "0z3jdvgcq995khkpis5c5vaxhbmvbqjlalbhn09k6pgb5zp46rc2"; }; - buildInputs = [ cmake libcxxabi ]; + 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_CXX_ABI=libcxxabi" + ]; enableParallelBuilding = true; From ae18038c6d33d26548df6c05881570b0a790be49 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 16:12:49 +0200 Subject: [PATCH 23/47] fixDarwinDylibNames: Use new hook mechanism --- pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh b/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh index 5962bf039069..2b64fbf8f093 100644 --- a/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh +++ b/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh @@ -10,6 +10,8 @@ # their absolute path (using "install_name_tool -id"). It also # rewrites references in other dylibs to absolute paths. +postFixupHooks+=('fixDarwinDylibNamesIn $prefix') + fixDarwinDylibNames() { local flags=() local old_id @@ -29,7 +31,3 @@ fixDarwinDylibNamesIn() { local dir="$1" fixDarwinDylibNames $(find "$dir" -name "*.dylib") } - -postFixup() { - fixDarwinDylibNamesIn "$prefix" -} From 07f603f89ee2a3258f75964e3d7f004f8dcca972 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 16:39:36 +0200 Subject: [PATCH 24/47] libc++: Use the right libc++abi re-export list Also, remove the explicit -lc++abi flag from clang-wrapper. It's not needed because libc++ re-exports the necessary symbols from libc++abi. --- pkgs/build-support/clang-wrapper/clang-wrapper.sh | 2 +- pkgs/development/libraries/libc++/default.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/clang-wrapper/clang-wrapper.sh b/pkgs/build-support/clang-wrapper/clang-wrapper.sh index 3c6a9c8e4529..bad257fd9b06 100644 --- a/pkgs/build-support/clang-wrapper/clang-wrapper.sh +++ b/pkgs/build-support/clang-wrapper/clang-wrapper.sh @@ -81,7 +81,7 @@ fi if test -n "@libcxx@"; then NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem@libcxx@/include/c++/v1 -stdlib=libc++" - NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -L@libcxx@/lib -stdlib=libc++ -L@libcxxabi@/lib -lc++abi" + NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -L@libcxx@/lib -stdlib=libc++ -L@libcxxabi@/lib" fi # Add the flags for the C compiler proper. diff --git a/pkgs/development/libraries/libc++/default.nix b/pkgs/development/libraries/libc++/default.nix index e956b1877c61..71705d47d125 100644 --- a/pkgs/development/libraries/libc++/default.nix +++ b/pkgs/development/libraries/libc++/default.nix @@ -18,6 +18,7 @@ stdenv.mkDerivation rec { [ "-DCMAKE_BUILD_TYPE=Release" "-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=${libcxxabi}/include" "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" "-DLIBCXX_CXX_ABI=libcxxabi" ]; From 84a586fa9e6b35fb3d995d6b14c26239cacb1115 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 16:54:43 +0200 Subject: [PATCH 25/47] stdenvDarwin: Do not wrap clang twice --- pkgs/stdenv/darwin/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index f42cd7139d91..6ab83aae188b 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -26,7 +26,6 @@ import ../generic rec { gcc = import ../../build-support/clang-wrapper { nativeTools = false; - nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; nativeLibc = true; inherit stdenv; libcxx = if haveLibCxx then pkgs.libcxx.override { @@ -35,7 +34,7 @@ import ../generic rec { }; } else null; binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; - clang = if useClang33 then pkgs.clang_33 else pkgs.clang; + clang = if useClang33 then pkgs.clang_33.clang else pkgs.clang.clang; coreutils = pkgs.coreutils; shell = pkgs.bash + "/bin/sh"; }; From 1e6dfdf29c776ddd936314442816752fef1fda91 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 17:55:05 +0200 Subject: [PATCH 26/47] clang-wrapper: Remove explicit dependency on libc++ Now libc++ is just another build input propagated from clang-wrapper. --- pkgs/build-support/clang-wrapper/builder.sh | 8 ++------ pkgs/build-support/clang-wrapper/clang-wrapper.sh | 5 ----- pkgs/build-support/clang-wrapper/default.nix | 6 ++---- pkgs/development/libraries/libc++/default.nix | 2 ++ pkgs/development/libraries/libc++/setup-hook.sh | 2 ++ pkgs/stdenv/darwin/default.nix | 11 ++++++----- 6 files changed, 14 insertions(+), 20 deletions(-) create mode 100644 pkgs/development/libraries/libc++/setup-hook.sh diff --git a/pkgs/build-support/clang-wrapper/builder.sh b/pkgs/build-support/clang-wrapper/builder.sh index 2dec6c59933b..6a8ea6370dfe 100644 --- a/pkgs/build-support/clang-wrapper/builder.sh +++ b/pkgs/build-support/clang-wrapper/builder.sh @@ -70,17 +70,11 @@ fi doSubstitute() { local src=$1 local dst=$2 - local uselibcxx= - local uselibcxxabi= - if test -n "$libcxx" && echo $dst | fgrep ++; then uselibcxx=$libcxx; fi - if test -n "$libcxxabi" && echo $dst | fgrep ++; then uselibcxxabi=$libcxxabi; fi # Can't use substitute() here, because replace may not have been # built yet (in the bootstrap). sed \ -e "s^@out@^$out^g" \ -e "s^@shell@^$shell^g" \ - -e "s^@libcxx@^$uselibcxx^g" \ - -e "s^@libcxxabi@^$uselibcxxabi^g" \ -e "s^@clang@^$clang^g" \ -e "s^@clangProg@^$clangProg^g" \ -e "s^@binutils@^$binutils^g" \ @@ -151,3 +145,5 @@ cp -p $utils $out/nix-support/utils.sh if test -z "$nativeTools"; then echo $clang $binutils $libc > $out/nix-support/propagated-user-env-packages fi + +echo $extraPackages > $out/nix-support/propagated-native-build-inputs diff --git a/pkgs/build-support/clang-wrapper/clang-wrapper.sh b/pkgs/build-support/clang-wrapper/clang-wrapper.sh index bad257fd9b06..c375fc951c0f 100644 --- a/pkgs/build-support/clang-wrapper/clang-wrapper.sh +++ b/pkgs/build-support/clang-wrapper/clang-wrapper.sh @@ -79,11 +79,6 @@ if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE --sysroot=/var/empty" fi -if test -n "@libcxx@"; then - NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem@libcxx@/include/c++/v1 -stdlib=libc++" - NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -L@libcxx@/lib -stdlib=libc++ -L@libcxxabi@/lib" -fi - # Add the flags for the C compiler proper. extraAfter=($NIX_CFLAGS_COMPILE) extraBefore=() diff --git a/pkgs/build-support/clang-wrapper/default.nix b/pkgs/build-support/clang-wrapper/default.nix index e61c07ca9d23..c49bc4c08934 100644 --- a/pkgs/build-support/clang-wrapper/default.nix +++ b/pkgs/build-support/clang-wrapper/default.nix @@ -7,7 +7,7 @@ { name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" , clang ? null, libc ? null, binutils ? null, coreutils ? null, shell ? "" -, zlib ? null, libcxx ? null +, zlib ? null, extraPackages ? [] }: assert nativeTools -> nativePrefix != ""; @@ -35,9 +35,7 @@ stdenv.mkDerivation { utils = ../gcc-wrapper/utils.sh; addFlags = ./add-flags; - inherit nativeTools nativeLibc nativePrefix clang clangVersion libcxx; - - libcxxabi = libcxx.abi or null; + inherit nativeTools nativeLibc nativePrefix clang clangVersion extraPackages; gcc = clang.gcc; libc = if nativeLibc then null else libc; diff --git a/pkgs/development/libraries/libc++/default.nix b/pkgs/development/libraries/libc++/default.nix index 71705d47d125..ae4b9d825e80 100644 --- a/pkgs/development/libraries/libc++/default.nix +++ b/pkgs/development/libraries/libc++/default.nix @@ -29,6 +29,8 @@ stdenv.mkDerivation rec { # 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"; diff --git a/pkgs/development/libraries/libc++/setup-hook.sh b/pkgs/development/libraries/libc++/setup-hook.sh new file mode 100644 index 000000000000..e2b1b10e8a3f --- /dev/null +++ b/pkgs/development/libraries/libc++/setup-hook.sh @@ -0,0 +1,2 @@ +NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem @out@/include/c++/v1 -stdlib=libc++" +NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -stdlib=libc++" diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 6ab83aae188b..08d9e713494a 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -28,11 +28,12 @@ import ../generic rec { nativeTools = false; nativeLibc = true; inherit stdenv; - libcxx = if haveLibCxx then pkgs.libcxx.override { - libcxxabi = pkgs.libcxxabi.override { - libunwind = pkgs.libunwindNative; - }; - } else null; + extraPackages = + stdenv.lib.optional haveLibCxx (pkgs.libcxx.override { + libcxxabi = pkgs.libcxxabi.override { + libunwind = pkgs.libunwindNative; + }; + }); binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; clang = if useClang33 then pkgs.clang_33.clang else pkgs.clang.clang; coreutils = pkgs.coreutils; From a7aa211780626a647901651ebda201c0f994617e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 18:28:26 +0200 Subject: [PATCH 27/47] cyrus-sasl: Fix dylib installed named --- pkgs/development/libraries/cyrus-sasl/default.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/cyrus-sasl/default.nix b/pkgs/development/libraries/cyrus-sasl/default.nix index 712f05b8d651..391638548fb7 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/"; From a007647bfb9c5d7c217be374831ee574e410fbbd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 18:46:08 +0200 Subject: [PATCH 28/47] apr-util: Purify iconv dependency on Darwin --- pkgs/development/libraries/apr-util/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/apr-util/default.nix b/pkgs/development/libraries/apr-util/default.nix index 229529f08cec..1dc4b1d77bae 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; From 542a4d0287054aedcd444057596d88bbb61c8aab Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 18:51:29 +0200 Subject: [PATCH 29/47] subversion: Fix broken configure flags This caused an impure dependency on libsasl on Darwin. --- pkgs/applications/version-management/subversion/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/version-management/subversion/default.nix b/pkgs/applications/version-management/subversion/default.nix index af9827ef4b85..7bf491a0b16f 100644 --- a/pkgs/applications/version-management/subversion/default.nix +++ b/pkgs/applications/version-management/subversion/default.nix @@ -38,8 +38,8 @@ stdenv.mkDerivation (rec { ${if pythonBindings || perlBindings then "--with-swig=${swig}" else "--without-swig"} ${if javahlBindings then "--enable-javahl --with-jdk=${jdk}" else ""} ${if stdenv.isDarwin then "--enable-keychain" else "--disable-keychain"} - ${if saslSupport then "--enable-sasl --with-sasl=${sasl}" else "--disable-sasl"} - ${if httpSupport then "--enable-serf --with-serf=${serf}" else "--disable-serf"} + ${if saslSupport then "--with-sasl=${sasl}" else "--without-sasl"} + ${if httpSupport then "--with-serf=${serf}" else "--without-serf"} --with-zlib=${zlib} --with-sqlite=${sqlite} ''; From 6db6dea4c9ae24953ff0df16c706e322b20ea594 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 18:55:07 +0200 Subject: [PATCH 30/47] subversion: Remove apparently unnecessary environment variables At least it seems to build fine (and use clang) without them. --- .../version-management/subversion/default.nix | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/version-management/subversion/default.nix b/pkgs/applications/version-management/subversion/default.nix index 7bf491a0b16f..ff19b0af16f4 100644 --- a/pkgs/applications/version-management/subversion/default.nix +++ b/pkgs/applications/version-management/subversion/default.nix @@ -15,7 +15,7 @@ assert httpServer -> httpd != null; assert pythonBindings -> swig != null && python != null; assert javahlBindings -> jdk != null && perl != null; -stdenv.mkDerivation (rec { +stdenv.mkDerivation rec { version = "1.8.10"; @@ -77,9 +77,4 @@ stdenv.mkDerivation (rec { maintainers = with stdenv.lib.maintainers; [ eelco lovek323 ]; hydraPlatforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; }; -} // stdenv.lib.optionalAttrs stdenv.isDarwin { - CXX = "clang++"; - CC = "clang"; - CPP = "clang -E"; - CXXCPP = "clang++ -E"; -}) +} From ee7a54df0c8ef74bb6387488a8735f7730b75ceb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 24 Sep 2014 19:00:35 +0200 Subject: [PATCH 31/47] nix: Revert meta attribute removal --- pkgs/tools/package-management/nix/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix index e659a1f1b03f..55f5b0aedc9c 100644 --- a/pkgs/tools/package-management/nix/default.nix +++ b/pkgs/tools/package-management/nix/default.nix @@ -69,7 +69,14 @@ stdenv.mkDerivation rec { # due to builder args bug; see # https://github.com/NixOS/nix/commit/b224ac15201c57b40ea855f5a98b1bd166c1c7f6 broken = stdenv.isDarwin; - description = "The Nix Deployment System"; + description = "Powerful package manager that makes package management reliable and reproducible"; + longDescription = '' + Nix is a powerful package manager for Linux and other Unix systems that + makes package management reliable and reproducible. It provides atomic + upgrades and rollbacks, side-by-side installation of multiple versions of + a package, multi-user package management and easy setup of build + environments. + ''; homepage = http://nixos.org/; license = stdenv.lib.licenses.lgpl2Plus; maintainers = [ stdenv.lib.maintainers.eelco ]; From 250c7682e1c971b4c265ed181ad6857549947157 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 29 Sep 2014 19:58:09 +0200 Subject: [PATCH 32/47] Remove broken libunwindNative package Copying /usr/lib/system/libunwind.dylib at evaluation time doesn't work (e.g. on Hydra). And copying binary system libraries is a bad idea anyway for license reasons. --- pkgs/development/libraries/libc++abi/default.nix | 7 ++++--- pkgs/development/libraries/libunwind/native.nix | 15 --------------- pkgs/stdenv/darwin/default.nix | 7 +------ pkgs/top-level/all-packages.nix | 2 -- 4 files changed, 5 insertions(+), 26 deletions(-) delete mode 100644 pkgs/development/libraries/libunwind/native.nix diff --git a/pkgs/development/libraries/libc++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix index eb3d3e5e4a8b..a12b6e423bc7 100644 --- a/pkgs/development/libraries/libc++abi/default.nix +++ b/pkgs/development/libraries/libc++abi/default.nix @@ -12,15 +12,16 @@ stdenv.mkDerivation { patches = [ ./no-stdc++.patch ./darwin.patch ]; - NIX_CFLAGS_LINK = "-L${libunwind}/lib -lunwind"; - buildInputs = [ coreutils ]; postUnpack = '' unpackFile ${libcxx.src} - export NIX_CFLAGS_COMPILE="-I${libunwind}/include -I$PWD/include -I$(readlink -f libcxx-*)/include" + export NIX_CFLAGS_COMPILE="-I$PWD/include -I$(readlink -f libcxx-*)/include" '' + lib.optionalString stdenv.isDarwin '' export TRIPLE=x86_64-apple-darwin + '' + lib.optionalString (!stdenv.isDarwin) '' + export NIX_CFLAGS_COMPILE+=" -I${libunwind}/include" + export NIX_CFLAGS_LINK+=" -L${libunwind}/lib -lunwind" ''; installPhase = if stdenv.isDarwin diff --git a/pkgs/development/libraries/libunwind/native.nix b/pkgs/development/libraries/libunwind/native.nix deleted file mode 100644 index 3220d20495ee..000000000000 --- a/pkgs/development/libraries/libunwind/native.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ stdenv }: - -stdenv.mkDerivation { - name = "libunwind-native"; - - unpackPhase = ":"; - dontBuild = true; - - installPhase = '' - mkdir -p $out/lib - cat ${/usr/lib/system/libunwind.dylib} > $out/lib/libunwind.dylib - ''; - - meta.platforms = stdenv.lib.platforms.darwin; -} diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 08d9e713494a..787180cbe3a4 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -28,12 +28,7 @@ import ../generic rec { nativeTools = false; nativeLibc = true; inherit stdenv; - extraPackages = - stdenv.lib.optional haveLibCxx (pkgs.libcxx.override { - libcxxabi = pkgs.libcxxabi.override { - libunwind = pkgs.libunwindNative; - }; - }); + extraPackages = stdenv.lib.optional haveLibCxx pkgs.libcxx; binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; clang = if useClang33 then pkgs.clang_33.clang else pkgs.clang.clang; coreutils = pkgs.coreutils; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 236b14fed96e..a546bb0e1d8f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5759,8 +5759,6 @@ let libunwind = callPackage ../development/libraries/libunwind { }; - libunwindNative = callPackage ../development/libraries/libunwind/native.nix {}; - libuvVersions = callPackage ../development/libraries/libuv { }; libv4l = lowPrio (v4l_utils.override { From 6843fc41c9e6d95ebb99e04df4b508ac459349c0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 30 Sep 2014 00:51:00 +0200 Subject: [PATCH 33/47] Fix evaluation --- pkgs/development/libraries/v8/default.nix | 2 +- pkgs/development/tools/misc/ccache/default.nix | 2 ++ pkgs/games/spring/default.nix | 4 ++-- pkgs/tools/text/sgml/opensp/default.nix | 5 ++--- pkgs/top-level/all-packages.nix | 5 ++++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkgs/development/libraries/v8/default.nix b/pkgs/development/libraries/v8/default.nix index fda32a7ddbd3..3abac0feab38 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; }; } diff --git a/pkgs/development/tools/misc/ccache/default.nix b/pkgs/development/tools/misc/ccache/default.nix index 3dd634274f3e..7207767a896d 100644 --- a/pkgs/development/tools/misc/ccache/default.nix +++ b/pkgs/development/tools/misc/ccache/default.nix @@ -1,5 +1,7 @@ {stdenv, fetchurl, runCommand, gcc, zlib}: +assert stdenv.isLinux; + let ccache = stdenv.mkDerivation { diff --git a/pkgs/games/spring/default.nix b/pkgs/games/spring/default.nix index 69387f0cfd3a..bc00dfd8765a 100644 --- a/pkgs/games/spring/default.nix +++ b/pkgs/games/spring/default.nix @@ -32,7 +32,7 @@ stdenv.mkDerivation rec { postInstall = '' wrapProgram "$out/bin/spring" \ - --prefix LD_LIBRARY_PATH : "${stdenv.gcc.gcc}/lib64:${stdenv.gcc.gcc}/lib::${systemd}/lib" + --prefix LD_LIBRARY_PATH : "${stdenv.gcc.gcc}/lib::${systemd}/lib" ''; meta = with stdenv.lib; { @@ -40,6 +40,6 @@ stdenv.mkDerivation rec { description = "A powerful real-time strategy (RTS) game engine"; license = licenses.gpl2; maintainers = [ maintainers.phreedom maintainers.qknight maintainers.iElectric ]; - platforms = platforms.mesaPlatforms; + platforms = platforms.linux; }; } diff --git a/pkgs/tools/text/sgml/opensp/default.nix b/pkgs/tools/text/sgml/opensp/default.nix index 78c964dac1ea..4b807718baae 100644 --- a/pkgs/tools/text/sgml/opensp/default.nix +++ b/pkgs/tools/text/sgml/opensp/default.nix @@ -1,4 +1,4 @@ -{stdenv, fetchurl, xmlto, docbook_xml_dtd_412, libxslt, docbook_xsl}: +{ lib, stdenv, fetchurl, xmlto, docbook_xml_dtd_412, libxslt, docbook_xsl }: stdenv.mkDerivation { name = "opensp-1.5.2"; @@ -13,7 +13,7 @@ stdenv.mkDerivation { docsrc/*.xml ''; - configureFlags = optional stdenv.isDarwin [ + configureFlags = lib.optional stdenv.isDarwin [ "--with-libintl-prefix=/usr" "--with-libiconv-prefix=/usr" ]; @@ -26,7 +26,6 @@ stdenv.mkDerivation { sed -i -e 's/name="idm.*"//g' $out/share/doc/OpenSP/releasenotes.html ''; - buildInputs = [ xmlto docbook_xml_dtd_412 libxslt docbook_xsl ]; meta = { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a546bb0e1d8f..5bc61e004c77 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2732,7 +2732,8 @@ let libc = glibc; binutils = binutils; shell = bash; - inherit libcxx coreutils zlib; + inherit coreutils zlib; + extraPackages = [ libcxx ]; nativeTools = false; nativeLibc = false; }; @@ -2772,6 +2773,8 @@ let gcc = gcc48; gcc_multi = gcc48_multi; + gccApple = throw "gccApple is no longer supported"; + gcc33 = wrapGCC (import ../development/compilers/gcc/3.3 { inherit fetchurl stdenv noSysDirs; }); From 3e0a3487287743dfe8020533bf7690e124a1748a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Oct 2014 13:49:26 +0200 Subject: [PATCH 34/47] gcc-wrapper: Get rid of builder.sh + cleanup --- pkgs/build-support/gcc-wrapper/builder.sh | 214 ----------------- pkgs/build-support/gcc-wrapper/default.nix | 219 ++++++++++++++---- pkgs/build-support/gcc-wrapper/gcc-wrapper.sh | 8 +- .../build-support/gcc-wrapper/gnat-wrapper.sh | 8 +- .../gcc-wrapper/gnatlink-wrapper.sh | 8 +- .../gcc-wrapper/ld-solaris-wrapper.sh | 2 +- pkgs/build-support/gcc-wrapper/ld-wrapper.sh | 6 +- pkgs/top-level/all-packages.nix | 9 +- 8 files changed, 194 insertions(+), 280 deletions(-) delete mode 100644 pkgs/build-support/gcc-wrapper/builder.sh diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh deleted file mode 100644 index c79680712ee7..000000000000 --- a/pkgs/build-support/gcc-wrapper/builder.sh +++ /dev/null @@ -1,214 +0,0 @@ -source $stdenv/setup - - -mkdir -p $out/bin -mkdir -p $out/nix-support - - -if test -z "$nativeLibc"; then - dynamicLinker="$libc/lib/$dynamicLinker" - echo $dynamicLinker > $out/nix-support/dynamic-linker - - if test -e $libc/lib/32/ld-linux.so.2; then - echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 - fi - - # The "-B$libc/lib/" flag is a quick hack to force gcc to link - # against the crt1.o from our own glibc, rather than the one in - # /usr/lib. (This is only an issue when using an `impure' - # compiler/linker, i.e., one that searches /usr/lib and so on.) - # - # Unfortunately, setting -B appears to override the default search - # path. Thus, the gcc-specific "../includes-fixed" directory is - # now longer searched and glibc's header fails to - # compile, because it uses "#include_next " to find the - # limits.h file in ../includes-fixed. To remedy the problem, - # another -idirafter is necessary to add that directory again. - echo "-B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags - - echo "-L$libc/lib" > $out/nix-support/libc-ldflags - - # The dynamic linker is passed in `ldflagsBefore' to allow - # explicit overrides of the dynamic linker by callers to gcc/ld - # (the *last* value counts, so ours should come first). - echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before -fi - -if test -n "$nativeTools"; then - gccPath="$nativePrefix/bin" - ldPath="$nativePrefix/bin" -else - if test -e "$gcc/lib64"; then - gccLDFlags="$gccLDFlags -L$gcc/lib64" - fi - gccLDFlags="$gccLDFlags -L$gcc/lib" - if [ -n "$langVhdl" ]; then - gccLDFlags="$gccLDFlags -L$zlib/lib" - fi - echo "$gccLDFlags" > $out/nix-support/gcc-ldflags - - # GCC shows $gcc/lib in `gcc -print-search-dirs', but not - # $gcc/lib64 (even though it does actually search there...).. - # This confuses libtool. So add it to the compiler tool search - # path explicitly. - if test -e "$gcc/lib64"; then - gccCFlags="$gccCFlags -B$gcc/lib64" - fi - - # Find the gcc libraries path (may work only without multilib) - if [ -n "$langAda" ]; then - basePath=`echo $gcc/lib/*/*/*` - gccCFlags="$gccCFlags -B$basePath -I$basePath/adainclude" - - gnatCFlags="-aI$basePath/adainclude -aO$basePath/adalib" - echo "$gnatCFlags" > $out/nix-support/gnat-cflags - fi - echo "$gccCFlags" > $out/nix-support/gcc-cflags - - gccPath="$gcc/bin" - # On Illumos/Solaris we might prefer native ld - if test -n "$nativePrefix"; then - ldPath="$nativePrefix/bin" - else - ldPath="$binutils/bin" - fi; -fi - - -doSubstitute() { - local src=$1 - local dst=$2 - local ld="$ldPath/ld" - if $ld -V 2>&1 |grep Solaris; then - # Use Solaris specific linker wrapper - ld="$out/bin/ld-solaris" - fi - # Can't use substitute() here, because replace may not have been - # built yet (in the bootstrap). - sed \ - -e "s^@out@^$out^g" \ - -e "s^@shell@^$shell^g" \ - -e "s^@gcc@^$gcc^g" \ - -e "s^@gccProg@^$gccProg^g" \ - -e "s^@gnatProg@^$gnatProg^g" \ - -e "s^@gnatlinkProg@^$gnatlinkProg^g" \ - -e "s^@binutils@^$binutils^g" \ - -e "s^@coreutils@^$coreutils^g" \ - -e "s^@libc@^$libc^g" \ - -e "s^@ld@^$ld^g" \ - < "$src" > "$dst" -} - - -# Make wrapper scripts around gcc, g++, and gfortran. Also make symlinks -# cc, c++, and f77. -mkGccWrapper() { - local dst=$1 - local src=$2 - - if ! test -f "$src"; then - echo "$src does not exist (skipping)" - return 1 - fi - - gccProg="$src" - doSubstitute "$gccWrapper" "$dst" - chmod +x "$dst" -} - -mkGnatWrapper() { - local dst=$1 - local src=$2 - - if ! test -f "$src"; then - echo "$src does not exist (skipping)" - return 1 - fi - - gnatProg="$src" - doSubstitute "$gnatWrapper" "$dst" - chmod +x "$dst" -} - -mkGnatLinkWrapper() { - local dst=$1 - local src=$2 - - if ! test -f "$src"; then - echo "$src does not exist (skipping)" - return 1 - fi - - gnatlinkProg="$src" - doSubstitute "$gnatlinkWrapper" "$dst" - chmod +x "$dst" -} - -if mkGccWrapper $out/bin/gcc $gccPath/gcc -then - ln -sv gcc $out/bin/cc -fi - -if mkGccWrapper $out/bin/g++ $gccPath/g++ -then - ln -sv g++ $out/bin/c++ -fi - -mkGccWrapper $out/bin/cpp $gccPath/cpp || true - -if mkGccWrapper $out/bin/gfortran $gccPath/gfortran -then - ln -sv gfortran $out/bin/g77 - ln -sv gfortran $out/bin/f77 -fi - -mkGccWrapper $out/bin/gcj $gccPath/gcj || true - -mkGccWrapper $out/bin/gccgo $gccPath/gccgo || true - -mkGccWrapper $out/bin/gnatgcc $gccPath/gnatgcc || true -mkGnatWrapper $out/bin/gnatmake $gccPath/gnatmake || true -mkGnatWrapper $out/bin/gnatbind $gccPath/gnatbind || true -mkGnatLinkWrapper $out/bin/gnatlink $gccPath/gnatlink || true - -if [ -f $gccPath/ghdl ]; then - ln -sf $gccPath/ghdl $out/bin/ghdl -fi - - -# Create a symlink to as (the assembler). This is useful when a -# gcc-wrapper is installed in a user environment, as it ensures that -# the right assembler is called. -ln -s $ldPath/as $out/bin/as - - -# Make a wrapper around the linker. -doSubstitute "$ldWrapper" "$out/bin/ld" -chmod +x "$out/bin/ld" - -# Copy solaris ld wrapper if needed -if $ldPath/ld -V 2>&1 |grep Solaris; then - # Use Solaris specific linker wrapper - sed -e "s^@ld@^$ldPath/ld^g" < "$ldSolarisWrapper" > "$out/bin/ld-solaris" - chmod +x "$out/bin/ld-solaris" -fi - - -# Emit a setup hook. Also store the path to the original GCC and -# Glibc. -test -n "$gcc" && echo $gcc > $out/nix-support/orig-gcc -test -n "$libc" && echo $libc > $out/nix-support/orig-libc - -doSubstitute "$addFlags" "$out/nix-support/add-flags.sh" - -doSubstitute "$setupHook" "$out/nix-support/setup-hook" - -cp -p $utils $out/nix-support/utils.sh - - -# Propagate the wrapped gcc so that if you install the wrapper, you get -# tools like gcov, the manpages, etc. as well (including for binutils -# and Glibc). -if test -z "$nativeTools"; then - echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages -fi diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix index 8e8b0b909454..5b80c92acbfc 100644 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ b/pkgs/build-support/gcc-wrapper/default.nix @@ -1,28 +1,29 @@ -# The Nix `gcc' stdenv.mkDerivation is not directly usable, since it doesn't -# know where the C library and standard header files are. Therefore -# the compiler produced by that package cannot be installed directly -# in a user environment and used from the command line. This -# stdenv.mkDerivation provides a wrapper that sets up the right environment -# variables so that the compiler and the linker just "work". +# The Nixpkgs GCC is not directly usable, since it doesn't know where +# the C library and standard header files are. Therefore the compiler +# produced by that package cannot be installed directly in a user +# environment and used from the command line. So we use a wrapper +# script that sets up the right environment variables so that the +# compiler and the linker just "work". { name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" -, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? "" +, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell , zlib ? null }: +with stdenv.lib; + assert nativeTools -> nativePrefix != ""; assert !nativeTools -> gcc != null && binutils != null && coreutils != null; assert !nativeLibc -> libc != null; -# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper -assert (gcc != null && gcc ? langVhdl && gcc.langVhdl) -> zlib != null; +# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper. +assert gcc.langVhdl or false -> zlib != null; let gccVersion = (builtins.parseDrvName gcc.name).version; gccName = (builtins.parseDrvName gcc.name).name; - langGo = if nativeTools then false else gcc ? langGo && gcc.langGo; in stdenv.mkDerivation { @@ -30,31 +31,175 @@ stdenv.mkDerivation { (if name != "" then name else gccName + "-wrapper") + (if gcc != null && gccVersion != "" then "-" + gccVersion else ""); - builder = ./builder.sh; - setupHook = ./setup-hook.sh; - gccWrapper = ./gcc-wrapper.sh; - gnatWrapper = ./gnat-wrapper.sh; - gnatlinkWrapper = ./gnatlink-wrapper.sh; - ldWrapper = ./ld-wrapper.sh; - ldSolarisWrapper = ./ld-solaris-wrapper.sh; - utils = ./utils.sh; - addFlags = ./add-flags; + preferLocalBuild = true; - inherit nativeTools nativeLibc nativePrefix gcc; + inherit gcc shell; libc = if nativeLibc then null else libc; binutils = if nativeTools then null else binutils; - # The wrapper scripts use 'cat', so we may need coreutils + # The wrapper scripts use 'cat', so we may need coreutils. coreutils = if nativeTools then null else coreutils; - langC = if nativeTools then true else gcc.langC; - langCC = if nativeTools then true else gcc.langCC; - langFortran = if nativeTools then false else gcc ? langFortran; - langAda = if nativeTools then false else gcc ? langAda && gcc.langAda; - langVhdl = if nativeTools then false else gcc ? langVhdl && gcc.langVhdl; - zlib = if gcc != null && gcc ? langVhdl then zlib else null; - shell = if shell == "" then stdenv.shell else - if builtins.isAttrs shell then (shell + shell.shellPath) - else shell; + passthru = { inherit nativeTools nativeLibc nativePrefix; }; + + buildCommand = + '' + mkdir -p $out/bin $out/nix-support + + wrap() { + local dst="$1" + local wrapper="$2" + export prog="$3" + substituteAll "$wrapper" "$out/bin/$dst" + chmod +x "$out/bin/$dst" + } + '' + + + optionalString (!nativeLibc) '' + dynamicLinker="$libc/lib/$dynamicLinker" + echo $dynamicLinker > $out/nix-support/dynamic-linker + + if [ -e $libc/lib/32/ld-linux.so.2 ]; then + echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 + fi + + # The "-B$libc/lib/" flag is a quick hack to force gcc to link + # against the crt1.o from our own glibc, rather than the one in + # /usr/lib. (This is only an issue when using an `impure' + # compiler/linker, i.e., one that searches /usr/lib and so on.) + # + # Unfortunately, setting -B appears to override the default search + # path. Thus, the gcc-specific "../includes-fixed" directory is + # now longer searched and glibc's header fails to + # compile, because it uses "#include_next " to find the + # limits.h file in ../includes-fixed. To remedy the problem, + # another -idirafter is necessary to add that directory again. + echo "-B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags + + echo "-L$libc/lib" > $out/nix-support/libc-ldflags + + # The dynamic linker is passed in `ldflagsBefore' to allow + # explicit overrides of the dynamic linker by callers to gcc/ld + # (the *last* value counts, so ours should come first). + echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before + + echo $libc > $out/nix-support/orig-libc + '' + + + (if nativeTools then '' + gccPath="${nativePrefix}/bin" + ldPath="${nativePrefix}/bin" + '' else '' + echo $gcc > $out/nix-support/orig-gcc + + # GCC shows $gcc/lib in `gcc -print-search-dirs', but not + # $gcc/lib64 (even though it does actually search there...).. + # This confuses libtool. So add it to the compiler tool search + # path explicitly. + if [ -e "$gcc/lib64" -a ! -L "$gcc/lib64" ]; then + gccLDFlags+=" -L$gcc/lib64" + gccCFlags+=" -B$gcc/lib64" + fi + gccLDFlags+=" -L$gcc/lib" + + ${optionalString gcc.langVhdl or false '' + gccLDFlags+=" -L${zlib}/lib" + ''} + + # Find the gcc libraries path (may work only without multilib). + ${optionalString gcc.langAda or false '' + basePath=`echo $gcc/lib/*/*/*` + gccCFlags+=" -B$basePath -I$basePath/adainclude" + gnatCFlags="-aI$basePath/adainclude -aO$basePath/adalib" + echo "$gnatCFlags" > $out/nix-support/gnat-cflags + ''} + + echo "$gccLDFlags" > $out/nix-support/gcc-ldflags + echo "$gccCFlags" > $out/nix-support/gcc-cflags + + gccPath="$gcc/bin" + ldPath="$binutils/bin" + ld="$ldPath/ld" + + # Propagate the wrapped gcc so that if you install the wrapper, + # you get tools like gcov, the manpages, etc. as well (including + # for binutils and Glibc). + echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages + '' + + + optionalString (stdenv.isSunOS && nativePrefix != "") '' + # Solaris needs an additional ld wrapper. + ldPath="${nativePrefix}/bin" + ld="$out/bin/ld-solaris" + wrap ld-solaris ${./ld-solaris-wrapper.sh} + '') + + + '' + # Create a symlink to as (the assembler). This is useful when a + # gcc-wrapper is installed in a user environment, as it ensures that + # the right assembler is called. + if [ -e $ldPath/as ]; then + ln -s $ldPath/as $out/bin/as + fi + + wrap ld ${./ld-wrapper.sh} $ld + + if [ -e $gccPath/gcc ]; then + wrap gcc ${./gcc-wrapper.sh} $gccPath/gcc + ln -s gcc $out/bin/cc + fi + + if [ -e $gccPath/g++ ]; then + wrap g++ ${./gcc-wrapper.sh} $gccPath/g++ + ln -s g++ $out/bin/c++ + fi + + if [ -e $gccPath/cpp ]; then + wrap cpp ${./gcc-wrapper.sh} $gccPath/cpp + fi + '' + + + optionalString gcc.langFortran or false '' + wrap gfortran ${./gcc-wrapper.sh} $gccPath/gfortran + ln -sv gfortran $out/bin/g77 + ln -sv gfortran $out/bin/f77 + '' + + + optionalString gcc.langJava or false '' + wrap gcj ${./gcc-wrapper.sh} $gccPath/gcj + '' + + + optionalString gcc.langGo or false '' + wrap gccgo ${./gcc-wrapper.sh} $gccPath/gccgo + '' + + + optionalString gcc.langAda or false '' + wrap gnatgcc ${./gcc-wrapper.sh} $gccPath/gnatgcc + wrap gnatmake ${./gnat-wrapper.sh} $gccPath/gnatmake + wrap gnatbind ${./gnat-wrapper.sh} $gccPath/gnatbind + wrap gnatlink ${./gnatlink-wrapper.sh} $gccPath/gnatlink + '' + + + optionalString gcc.langVhdl or false '' + ln -s $gccPath/ghdl $out/bin/ghdl + '' + + + '' + substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook + substituteAll ${./add-flags} $out/nix-support/add-flags.sh + cp -p ${./utils.sh} $out/nix-support/utils.sh + ''; + + # The dynamic linker has different names on different Linux platforms. + dynamicLinker = + if !nativeLibc then + (if stdenv.system == "i686-linux" then "ld-linux.so.2" else + if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else + # ARM with a wildcard, which can be "" or "-armhf". + if stdenv.isArm then "ld-linux*.so.3" else + if stdenv.system == "powerpc-linux" then "ld.so.1" else + if stdenv.system == "mips64el-linux" then "ld.so.1" else + abort "Don't know the name of the dynamic linker for this platform.") + else ""; crossAttrs = { shell = shell.crossDrv + shell.crossDrv.shellPath; @@ -73,8 +218,6 @@ stdenv.mkDerivation { abort "don't know the name of the dynamic linker for this platform"); }; - preferLocalBuild = true; - meta = let gcc_ = if gcc != null then gcc else {}; in (if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) // @@ -82,16 +225,4 @@ stdenv.mkDerivation { stdenv.lib.attrByPath ["meta" "description"] "System C compiler" gcc_ + " (wrapper script)"; }; - - # The dynamic linker has different names on different Linux platforms. - dynamicLinker = - if !nativeLibc then - (if stdenv.system == "i686-linux" then "ld-linux.so.2" else - if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else - # ARM with a wildcard, which can be "" or "-armhf". - if stdenv.isArm then "ld-linux*.so.3" else - if stdenv.system == "powerpc-linux" then "ld.so.1" else - if stdenv.system == "mips64el-linux" then "ld.so.1" else - abort "don't know the name of the dynamic linker for this platform") - else ""; } diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh index d01ce54fd969..f515fafdac0a 100644 --- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh @@ -125,15 +125,15 @@ fi # Optionally print debug info. if test "$NIX_DEBUG" = "1"; then - echo "original flags to @gccProg@:" >&2 + echo "original flags to @prog@:" >&2 for i in "${params[@]}"; do echo " $i" >&2 done - echo "extraBefore flags to @gccProg@:" >&2 + echo "extraBefore flags to @prog@:" >&2 for i in ${extraBefore[@]}; do echo " $i" >&2 done - echo "extraAfter flags to @gccProg@:" >&2 + echo "extraAfter flags to @prog@:" >&2 for i in ${extraAfter[@]}; do echo " $i" >&2 done @@ -143,4 +143,4 @@ if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then source "$NIX_GCC_WRAPPER_EXEC_HOOK" fi -exec @gccProg@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" +exec @prog@ ${extraBefore[@]} "${params[@]}" "${extraAfter[@]}" diff --git a/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh b/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh index 4404194ff1bf..3c2f1d034744 100644 --- a/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh @@ -82,15 +82,15 @@ fi # Optionally print debug info. if test "$NIX_DEBUG" = "1"; then - echo "original flags to @gnatProg@:" >&2 + echo "original flags to @prog@:" >&2 for i in "${params[@]}"; do echo " $i" >&2 done - echo "extraBefore flags to @gnatProg@:" >&2 + echo "extraBefore flags to @prog@:" >&2 for i in ${extraBefore[@]}; do echo " $i" >&2 done - echo "extraAfter flags to @gnatProg@:" >&2 + echo "extraAfter flags to @prog@:" >&2 for i in ${extraAfter[@]}; do echo " $i" >&2 done @@ -100,4 +100,4 @@ if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then source "$NIX_GNAT_WRAPPER_EXEC_HOOK" fi -exec @gnatProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} +exec @prog@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh b/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh index d8e4b5254bfc..cd7768c85a39 100644 --- a/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh @@ -12,15 +12,15 @@ extraBefore=() # Optionally print debug info. if test "$NIX_DEBUG" = "1"; then - echo "original flags to @gnatlinkProg@:" >&2 + echo "original flags to @prog@:" >&2 for i in "$@"; do echo " $i" >&2 done - echo "extraBefore flags to @gnatlinkProg@:" >&2 + echo "extraBefore flags to @prog@:" >&2 for i in ${extraBefore[@]}; do echo " $i" >&2 done - echo "extraAfter flags to @gnatlinkProg@:" >&2 + echo "extraAfter flags to @prog@:" >&2 for i in ${extraAfter[@]}; do echo " $i" >&2 done @@ -30,4 +30,4 @@ if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then source "$NIX_GNAT_WRAPPER_EXEC_HOOK" fi -exec @gnatlinkProg@ ${extraBefore[@]} "$@" ${extraAfter[@]} +exec @prog@ ${extraBefore[@]} "$@" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh index 5a7b92b5ad7d..9216ea3198dd 100644 --- a/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh @@ -6,7 +6,7 @@ set -u # I've also tried adding -z direct and -z lazyload, but it gave too many problems with C++ exceptions :'( # Also made sure libgcc would not be lazy-loaded, as suggested here: https://www.illumos.org/issues/2534#note-3 # but still no success. -cmd="@ld@ -z ignore" +cmd="@prog@ -z ignore" args=("$@"); diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh index 822c4a03a218..df00dcdb222a 100644 --- a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh @@ -149,11 +149,11 @@ fi # Optionally print debug info. if test "$NIX_DEBUG" = "1"; then - echo "original flags to @ld@:" >&2 + echo "original flags to @prog@:" >&2 for i in "${params[@]}"; do echo " $i" >&2 done - echo "extra flags to @ld@:" >&2 + echo "extra flags to @prog@:" >&2 for i in ${extra[@]}; do echo " $i" >&2 done @@ -163,4 +163,4 @@ if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then source "$NIX_LD_WRAPPER_EXEC_HOOK" fi -exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]} +exec @prog@ ${extraBefore[@]} "${params[@]}" ${extra[@]} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 66fc0d8df6f7..43985bd6a6b2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2784,7 +2784,6 @@ let stdenv = clangStdenv; libc = glibc; binutils = binutils; - shell = bash; inherit coreutils zlib; extraPackages = [ libcxx ]; nativeTools = false; @@ -3661,12 +3660,11 @@ let win32hello = callPackage ../development/compilers/visual-c++/test { }; wrapGCCWith = gccWrapper: glibc: baseGCC: gccWrapper { - nativeTools = stdenv ? gcc && stdenv.gcc.nativeTools; - nativeLibc = stdenv ? gcc && stdenv.gcc.nativeLibc; - nativePrefix = if stdenv ? gcc then stdenv.gcc.nativePrefix else ""; + nativeTools = stdenv.gcc.nativeTools or false; + nativeLibc = stdenv.gcc.nativeLibc or false; + nativePrefix = stdenv.gcc.nativePrefix or ""; gcc = baseGCC; libc = glibc; - shell = bash; inherit stdenv binutils coreutils zlib; }; @@ -3676,7 +3674,6 @@ let nativePrefix = stdenv.gcc.nativePrefix or ""; clang = baseClang; libc = glibc; - shell = bash; binutils = stdenv.gcc.binutils; inherit stdenv coreutils zlib; }; From ffbdcbfe29ea1076e87a321f47df39cd1ddc4d6b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Oct 2014 14:01:38 +0200 Subject: [PATCH 35/47] gcc-wrapper: Wrap ld.gold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures that gcc's ‘-fuse-ld=gold’ flag works. --- pkgs/build-support/gcc-wrapper/default.nix | 8 ++++++++ pkgs/stdenv/adapters.nix | 20 +++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix index 5b80c92acbfc..1af35f58a3fe 100644 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ b/pkgs/build-support/gcc-wrapper/default.nix @@ -143,6 +143,14 @@ stdenv.mkDerivation { wrap ld ${./ld-wrapper.sh} $ld + if [ -e $binutils/bin/ld.gold ]; then + wrap ld.gold ${./ld-wrapper.sh} $binutils/bin/ld.gold + fi + + if [ -e $binutils/bin/ld.bfd ]; then + wrap ld.bfd ${./ld-wrapper.sh} $binutils/bin/ld.bfd + fi + if [ -e $gccPath/gcc ]; then wrap gcc ${./gcc-wrapper.sh} $gccPath/gcc ln -s gcc $out/bin/cc diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index a90a00e6d4f3..9e82359865bf 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -285,19 +285,13 @@ rec { }; - /* Modify a stdenv so that it uses the Gold linker. FIXME: should - use -fuse-ld=gold instead, but then the ld-wrapper won't be - invoked. */ - useGoldLinker = stdenv: - let - binutils = stdenv.gcc.binutils; - binutils' = pkgs.runCommand "${binutils.name}-gold" { } - '' - mkdir -p $out/bin - ln -s ${binutils}/bin/* $out/bin/ - ln -sfn ${binutils}/bin/ld.gold $out/bin/ld - ''; # */ - in overrideGCC stdenv (stdenv.gcc.override { binutils = binutils'; }); + /* Modify a stdenv so that it uses the Gold linker. */ + useGoldLinker = stdenv: stdenv // + { mkDerivation = args: stdenv.mkDerivation (args // { + dontStrip = true; + NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_COMPILE or "") + " -fuse-ld=gold"; + }); + }; dropCxx = drv: drv.override { stdenv = if pkgs.stdenv.isDarwin From 02122ccfd0f4c4156c38662622831e7b6b98dbc8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Oct 2014 14:25:23 +0200 Subject: [PATCH 36/47] gcc-wrapper: Style fix --- pkgs/build-support/gcc-wrapper/add-flags | 12 ++-- pkgs/build-support/gcc-wrapper/gcc-wrapper.sh | 62 +++++++++---------- .../build-support/gcc-wrapper/gnat-wrapper.sh | 32 +++++----- .../gcc-wrapper/gnatlink-wrapper.sh | 4 +- pkgs/build-support/gcc-wrapper/ld-wrapper.sh | 56 ++++++++--------- pkgs/build-support/gcc-wrapper/setup-hook.sh | 14 ++--- pkgs/build-support/gcc-wrapper/utils.sh | 8 +-- 7 files changed, 94 insertions(+), 94 deletions(-) diff --git a/pkgs/build-support/gcc-wrapper/add-flags b/pkgs/build-support/gcc-wrapper/add-flags index 26e536f6d575..ede1a8683039 100644 --- a/pkgs/build-support/gcc-wrapper/add-flags +++ b/pkgs/build-support/gcc-wrapper/add-flags @@ -1,27 +1,27 @@ # `-B@out@/bin' forces gcc to use ld-wrapper.sh when calling ld. export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE" -if test -e @out@/nix-support/libc-cflags; then +if [ -e @out@/nix-support/libc-cflags ]; then export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE" fi -if test -e @out@/nix-support/gcc-cflags; then +if [ -e @out@/nix-support/gcc-cflags ]; then export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/gcc-cflags) $NIX_CFLAGS_COMPILE" fi -if test -e @out@/nix-support/gnat-cflags; then +if [ -e @out@/nix-support/gnat-cflags ]; then export NIX_GNATFLAGS_COMPILE="$(cat @out@/nix-support/gnat-cflags) $NIX_GNATFLAGS_COMPILE" fi -if test -e @out@/nix-support/libc-ldflags; then +if [ -e @out@/nix-support/libc-ldflags ]; then export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)" fi -if test -e @out@/nix-support/gcc-ldflags; then +if [ -e @out@/nix-support/gcc-ldflags ]; then export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/gcc-ldflags)" fi -if test -e @out@/nix-support/libc-ldflags-before; then +if [ -e @out@/nix-support/libc-ldflags-before ]; then export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE" fi diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh index f515fafdac0a..d0c82c82dc1c 100644 --- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh @@ -1,10 +1,10 @@ #! @shell@ -e -if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then +if [ -n "$NIX_GCC_WRAPPER_START_HOOK" ]; then source "$NIX_GCC_WRAPPER_START_HOOK" fi -if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then +if [ -z "$NIX_GCC_WRAPPER_FLAGS_SET" ]; then source @out@/nix-support/add-flags.sh fi @@ -18,26 +18,26 @@ getVersion=0 nonFlagArgs=0 for i in "$@"; do - if test "$i" = "-c"; then + if [ "$i" = -c ]; then dontLink=1 - elif test "$i" = "-S"; then + elif [ "$i" = -S ]; then dontLink=1 - elif test "$i" = "-E"; then + elif [ "$i" = -E ]; then dontLink=1 - elif test "$i" = "-E"; then + elif [ "$i" = -E ]; then dontLink=1 - elif test "$i" = "-M"; then + elif [ "$i" = -M ]; then dontLink=1 - elif test "$i" = "-MM"; then + elif [ "$i" = -MM ]; then dontLink=1 - elif test "$i" = "-x"; then + elif [ "$i" = -x ]; then # At least for the cases c-header or c++-header we should set dontLink. # I expect no one use -x other than making precompiled headers. dontLink=1 - elif test "${i:0:1}" != "-"; then + elif [ "${i:0:1}" != - ]; then nonFlagArgs=1 - elif test "$i" = "-m32"; then - if test -e @out@/nix-support/dynamic-linker-m32; then + elif [ "$i" = -m32 ]; then + if [ -e @out@/nix-support/dynamic-linker-m32 ]; then NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" fi fi @@ -48,28 +48,28 @@ done # "-c" flag). So if no non-flag arguments are given, don't pass any # linker flags. This catches cases like "gcc" (should just print # "gcc: no input files") and "gcc -v" (should print the version). -if test "$nonFlagArgs" = "0"; then +if [ "$nonFlagArgs" = 0 ]; then dontLink=1 fi # Optionally filter out paths not refering to the store. params=("$@") -if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then +if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then rest=() n=0 - while test $n -lt ${#params[*]}; do + while [ $n -lt ${#params[*]} ]; do p=${params[n]} p2=${params[$((n+1))]} - if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then + if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then skip $p - elif test "$p" = "-L" && badPath "$p2"; then + elif [ "$p" = -L ] && badPath "$p2"; then n=$((n + 1)); skip $p2 - elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then + elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then skip $p - elif test "$p" = "-I" && badPath "$p2"; then + elif [ "$p" = -I ] && badPath "$p2"; then n=$((n + 1)); skip $p2 - elif test "$p" = "-isystem" && badPath "$p2"; then + elif [ "$p" = -isystem ] && badPath "$p2"; then n=$((n + 1)); skip $p2 else rest=("${rest[@]}" "$p") @@ -86,14 +86,14 @@ extraBefore=() # When enforcing purity, pretend gcc can't find the current date and # time -if test "$NIX_ENFORCE_PURITY" = "1"; then +if [ "$NIX_ENFORCE_PURITY" = 1 ]; then extraAfter+=('-D__DATE__="Jan 01 1970"' '-D__TIME__="00:00:01"' -Wno-builtin-macro-redefined) fi -if test "$dontLink" != "1"; then +if [ "$dontLink" != 1 ]; then # Add the flags that should only be passed to the compiler when # linking. @@ -105,11 +105,11 @@ if test "$dontLink" != "1"; then extraBefore=(${extraBefore[@]} "-Wl,$i") done for i in $NIX_LDFLAGS; do - if test "${i:0:3}" = "-L/"; then - extraAfter+=("$i") - else - extraAfter+=("-Wl,$i") - fi + if [ "${i:0:3}" = -L/ ]; then + extraAfter+=("$i") + else + extraAfter+=("-Wl,$i") + fi done export NIX_LDFLAGS_SET=1 fi @@ -118,13 +118,13 @@ fi # add anything. This is to prevent `gcc -v' (which normally prints # out the version number and returns exit code 0) from printing out # `No input files specified' and returning exit code 1. -if test "$*" = "-v"; then +if [ "$*" = -v ]; then extraAfter=() extraBefore=() -fi +fi # Optionally print debug info. -if test "$NIX_DEBUG" = "1"; then +if [ -n "$NIX_DEBUG" ]; then echo "original flags to @prog@:" >&2 for i in "${params[@]}"; do echo " $i" >&2 @@ -139,7 +139,7 @@ if test "$NIX_DEBUG" = "1"; then done fi -if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then +if [ -n "$NIX_GCC_WRAPPER_EXEC_HOOK" ]; then source "$NIX_GCC_WRAPPER_EXEC_HOOK" fi diff --git a/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh b/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh index 3c2f1d034744..3514ccd67325 100644 --- a/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gnat-wrapper.sh @@ -1,10 +1,10 @@ #! @shell@ -e -if test -n "$NIX_GNAT_WRAPPER_START_HOOK"; then +if [ -n "$NIX_GNAT_WRAPPER_START_HOOK" ]; then source "$NIX_GNAT_WRAPPER_START_HOOK" fi -if test -z "$NIX_GNAT_WRAPPER_FLAGS_SET"; then +if [ -z "$NIX_GNAT_WRAPPER_FLAGS_SET" ]; then source @out@/nix-support/add-flags.sh fi @@ -18,14 +18,14 @@ getVersion=0 nonFlagArgs=0 for i in "$@"; do - if test "$i" = "-c"; then + if [ "$i" = -c ]; then dontLink=1 - elif test "$i" = "-M"; then + elif [ "$i" = -M ]; then dontLink=1 - elif test "${i:0:1}" != "-"; then + elif [ "${i:0:1}" != - ]; then nonFlagArgs=1 - elif test "$i" = "-m32"; then - if test -e @out@/nix-support/dynamic-linker-m32; then + elif [ "$i" = -m32 ]; then + if [ -e @out@/nix-support/dynamic-linker-m32 ]; then NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" fi fi @@ -36,26 +36,26 @@ done # "-c" flag). So if no non-flag arguments are given, don't pass any # linker flags. This catches cases like "gcc" (should just print # "gcc: no input files") and "gcc -v" (should print the version). -if test "$nonFlagArgs" = "0"; then +if [ "$nonFlagArgs" = 0 ]; then dontLink=1 fi # Optionally filter out paths not refering to the store. params=("$@") -if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then +if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" ]; then rest=() n=0 - while test $n -lt ${#params[*]}; do + while [ $n -lt ${#params[*]} ]; do p=${params[n]} p2=${params[$((n+1))]} - if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then + if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then skip $p - elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then + elif [ "${p:0:3}" = -I/ ] && badPath "${p:2}"; then skip $p - elif test "${p:0:4}" = "-aI/" && badPath "${p:3}"; then + elif [ "${p:0:4}" = -aI/ ] && badPath "${p:3}"; then skip $p - elif test "${p:0:4}" = "-aO/" && badPath "${p:3}"; then + elif [ "${p:0:4}" = -aO/ ] && badPath "${p:3}"; then skip $p else rest=("${rest[@]}" "$p") @@ -81,7 +81,7 @@ fi #done # Optionally print debug info. -if test "$NIX_DEBUG" = "1"; then +if [ -n "$NIX_DEBUG" ]; then echo "original flags to @prog@:" >&2 for i in "${params[@]}"; do echo " $i" >&2 @@ -96,7 +96,7 @@ if test "$NIX_DEBUG" = "1"; then done fi -if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then +if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then source "$NIX_GNAT_WRAPPER_EXEC_HOOK" fi diff --git a/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh b/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh index cd7768c85a39..c9958dbbb413 100644 --- a/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gnatlink-wrapper.sh @@ -11,7 +11,7 @@ extraBefore=() #done # Optionally print debug info. -if test "$NIX_DEBUG" = "1"; then +if [ -n "$NIX_DEBUG" ]; then echo "original flags to @prog@:" >&2 for i in "$@"; do echo " $i" >&2 @@ -26,7 +26,7 @@ if test "$NIX_DEBUG" = "1"; then done fi -if test -n "$NIX_GNAT_WRAPPER_EXEC_HOOK"; then +if [ -n "$NIX_GNAT_WRAPPER_EXEC_HOOK" ]; then source "$NIX_GNAT_WRAPPER_EXEC_HOOK" fi diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh index df00dcdb222a..894dbf9a352c 100644 --- a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh @@ -1,10 +1,10 @@ #! @shell@ -e -if test -n "$NIX_LD_WRAPPER_START_HOOK"; then +if [ -n "$NIX_LD_WRAPPER_START_HOOK" ]; then source "$NIX_LD_WRAPPER_START_HOOK" fi -if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then +if [ -z "$NIX_GCC_WRAPPER_FLAGS_SET" ]; then source @out@/nix-support/add-flags.sh fi @@ -13,26 +13,26 @@ source @out@/nix-support/utils.sh # Optionally filter out paths not refering to the store. params=("$@") -if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \ - -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then +if [ "$NIX_ENFORCE_PURITY" = 1 -a -n "$NIX_STORE" \ + -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \) ]; then rest=() n=0 - while test $n -lt ${#params[*]}; do + while [ $n -lt ${#params[*]} ]; do p=${params[n]} p2=${params[$((n+1))]} - if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then + if [ "${p:0:3}" = -L/ ] && badPath "${p:2}"; then skip $p - elif test "$p" = "-L" && badPath "$p2"; then + elif [ "$p" = -L ] && badPath "$p2"; then n=$((n + 1)); skip $p2 - elif test "$p" = "-rpath" && badPath "$p2"; then + elif [ "$p" = -rpath ] && badPath "$p2"; then n=$((n + 1)); skip $p2 - elif test "$p" = "-dynamic-linker" && badPath "$p2"; then + elif [ "$p" = -dynamic-linker ] && badPath "$p2"; then n=$((n + 1)); skip $p2 - elif test "${p:0:1}" = "/" && badPath "$p"; then + elif [ "${p:0:1}" = / ] && badPath "$p"; then # We cannot skip this; barf. echo "impure path \`$p' used in link" >&2 exit 1 - elif test "${p:0:9}" = "--sysroot"; then + elif [ "${p:0:9}" = --sysroot ]; then # Our ld is not built with sysroot support (Can we fix that?) : else @@ -47,7 +47,7 @@ fi extra=() extraBefore=() -if test -z "$NIX_LDFLAGS_SET"; then +if [ -z "$NIX_LDFLAGS_SET" ]; then extra+=($NIX_LDFLAGS) extraBefore+=($NIX_LDFLAGS_BEFORE) fi @@ -56,12 +56,12 @@ extra+=($NIX_LDFLAGS_AFTER) # Add all used dynamic libraries to the rpath. -if test "$NIX_DONT_SET_RPATH" != "1"; then +if [ "$NIX_DONT_SET_RPATH" != 1 ]; then libPath="" addToLibPath() { local path="$1" - if test "${path:0:1}" != "/"; then return 0; fi + if [ "${path:0:1}" != / ]; then return 0; fi case "$path" in *..*|*./*|*/.*|*//*) local path2 @@ -75,12 +75,12 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then esac libPath="$libPath $path " } - + addToRPath() { # If the path is not in the store, don't add it to the rpath. # This typically happens for libraries in /tmp that are later # copied to $out/lib. If not, we're screwed. - if test "${1:0:${#NIX_STORE}}" != "$NIX_STORE"; then return 0; fi + if [ "${1:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then return 0; fi case $rpath in *\ $1\ *) return 0 ;; esac @@ -97,21 +97,21 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then # First, find all -L... switches. allParams=("${params[@]}" ${extra[@]}) n=0 - while test $n -lt ${#allParams[*]}; do + while [ $n -lt ${#allParams[*]} ]; do p=${allParams[n]} p2=${allParams[$((n+1))]} - if test "${p:0:3}" = "-L/"; then + if [ "${p:0:3}" = -L/ ]; then addToLibPath ${p:2} - elif test "$p" = "-L"; then + elif [ "$p" = -L ]; then addToLibPath ${p2} n=$((n + 1)) - elif test "$p" = "-l"; then + elif [ "$p" = -l ]; then addToLibs ${p2} n=$((n + 1)) - elif test "${p:0:2}" = "-l"; then + elif [ "${p:0:2}" = -l ]; then addToLibs ${p:2} - elif test "$p" = "-dynamic-linker"; then - # Ignore the dynamic linker argument, or it + elif [ "$p" = -dynamic-linker ]; then + # Ignore the dynamic linker argument, or it # will get into the next 'elif'. We don't want # the dynamic linker path rpath to go always first. n=$((n + 1)) @@ -129,16 +129,16 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then # so, add the directory to the rpath. # It's important to add the rpath in the order of -L..., so # the link time chosen objects will be those of runtime linking. - + for i in $libPath; do for j in $libs; do - if test -f "$i/lib$j.so"; then + if [ -f "$i/lib$j.so" ]; then addToRPath $i break fi done done - + # Finally, add `-rpath' switches. for i in $rpath; do @@ -148,7 +148,7 @@ fi # Optionally print debug info. -if test "$NIX_DEBUG" = "1"; then +if [ -n "$NIX_DEBUG" ]; then echo "original flags to @prog@:" >&2 for i in "${params[@]}"; do echo " $i" >&2 @@ -159,7 +159,7 @@ if test "$NIX_DEBUG" = "1"; then done fi -if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then +if [ -n "$NIX_LD_WRAPPER_EXEC_HOOK" ]; then source "$NIX_LD_WRAPPER_EXEC_HOOK" fi diff --git a/pkgs/build-support/gcc-wrapper/setup-hook.sh b/pkgs/build-support/gcc-wrapper/setup-hook.sh index a3ada9e984fd..93b20fa1e99a 100644 --- a/pkgs/build-support/gcc-wrapper/setup-hook.sh +++ b/pkgs/build-support/gcc-wrapper/setup-hook.sh @@ -1,15 +1,15 @@ export NIX_GCC=@out@ addCVars () { - if test -d $1/include; then + if [ -d $1/include ]; then export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" fi - if test -d $1/lib64; then + if [ -d $1/lib64 -a ! -L $1/lib64 ]; then export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64" fi - if test -d $1/lib; then + if [ -d $1/lib ]; then export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib" fi } @@ -18,18 +18,18 @@ envHooks+=(addCVars) # Note: these come *after* $out in the PATH (see setup.sh). -if test -n "@gcc@"; then +if [ -n "@gcc@" ]; then addToSearchPath PATH @gcc@/bin fi -if test -n "@binutils@"; then +if [ -n "@binutils@" ]; then addToSearchPath PATH @binutils@/bin fi -if test -n "@libc@"; then +if [ -n "@libc@" ]; then addToSearchPath PATH @libc@/bin fi -if test -n "@coreutils@"; then +if [ -n "@coreutils@" ]; then addToSearchPath PATH @coreutils@/bin fi diff --git a/pkgs/build-support/gcc-wrapper/utils.sh b/pkgs/build-support/gcc-wrapper/utils.sh index 753b3772e956..3ab512d85c4e 100644 --- a/pkgs/build-support/gcc-wrapper/utils.sh +++ b/pkgs/build-support/gcc-wrapper/utils.sh @@ -1,5 +1,5 @@ skip () { - if test "$NIX_DEBUG" = "1"; then + if [ -n "$NIX_DEBUG" ]; then echo "skipping impure path $1" >&2 fi } @@ -9,11 +9,11 @@ skip () { # `/nix/store/.../lib/foo.so' isn't. badPath() { local p=$1 - + # Relative paths are okay (since they're presumably relative to # the temporary build directory). - if test "${p:0:1}" != "/"; then return 1; fi - + if [ "${p:0:1}" != / ]; then return 1; fi + # Otherwise, the path should refer to the store or some temporary # directory (including the build directory). test \ From 0d67d13527f0b984ae4a1d0f362a947b16a86bf8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Oct 2014 15:23:16 +0200 Subject: [PATCH 37/47] gcc-wrapper: Style fix --- pkgs/build-support/gcc-wrapper/add-flags | 4 ++-- pkgs/build-support/gcc-wrapper/setup-hook.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/gcc-wrapper/add-flags b/pkgs/build-support/gcc-wrapper/add-flags index ede1a8683039..d75f378e2c97 100644 --- a/pkgs/build-support/gcc-wrapper/add-flags +++ b/pkgs/build-support/gcc-wrapper/add-flags @@ -14,11 +14,11 @@ if [ -e @out@/nix-support/gnat-cflags ]; then fi if [ -e @out@/nix-support/libc-ldflags ]; then - export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)" + export NIX_LDFLAGS+=" $(cat @out@/nix-support/libc-ldflags)" fi if [ -e @out@/nix-support/gcc-ldflags ]; then - export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/gcc-ldflags)" + export NIX_LDFLAGS+=" $(cat @out@/nix-support/gcc-ldflags)" fi if [ -e @out@/nix-support/libc-ldflags-before ]; then diff --git a/pkgs/build-support/gcc-wrapper/setup-hook.sh b/pkgs/build-support/gcc-wrapper/setup-hook.sh index 93b20fa1e99a..a6b7edbcb694 100644 --- a/pkgs/build-support/gcc-wrapper/setup-hook.sh +++ b/pkgs/build-support/gcc-wrapper/setup-hook.sh @@ -2,15 +2,15 @@ export NIX_GCC=@out@ addCVars () { if [ -d $1/include ]; then - export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" + export NIX_CFLAGS_COMPILE+=" -isystem $1/include" fi if [ -d $1/lib64 -a ! -L $1/lib64 ]; then - export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64" + export NIX_LDFLAGS+=" -L$1/lib64" fi if [ -d $1/lib ]; then - export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib" + export NIX_LDFLAGS+=" -L$1/lib" fi } From 79d0d7b4376b3fbc9ccdda7d95ed0b39b37ffc63 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Oct 2014 15:48:34 +0200 Subject: [PATCH 38/47] Unify gcc-wrapper and clang-wrapper --- pkgs/build-support/clang-wrapper/add-flags | 24 --- pkgs/build-support/clang-wrapper/builder.sh | 149 ------------------ .../clang-wrapper/clang-wrapper.sh | 136 ---------------- pkgs/build-support/clang-wrapper/default.nix | 89 ----------- .../build-support/clang-wrapper/setup-hook.sh | 38 ----- pkgs/build-support/gcc-wrapper/default.nix | 22 ++- pkgs/stdenv/darwin/default.nix | 4 +- pkgs/tools/networking/strongswan/default.nix | 2 +- pkgs/top-level/all-packages.nix | 22 +-- 9 files changed, 29 insertions(+), 457 deletions(-) delete mode 100644 pkgs/build-support/clang-wrapper/add-flags delete mode 100644 pkgs/build-support/clang-wrapper/builder.sh delete mode 100644 pkgs/build-support/clang-wrapper/clang-wrapper.sh delete mode 100644 pkgs/build-support/clang-wrapper/default.nix delete mode 100644 pkgs/build-support/clang-wrapper/setup-hook.sh diff --git a/pkgs/build-support/clang-wrapper/add-flags b/pkgs/build-support/clang-wrapper/add-flags deleted file mode 100644 index 7a9711290aa1..000000000000 --- a/pkgs/build-support/clang-wrapper/add-flags +++ /dev/null @@ -1,24 +0,0 @@ -# `-B@out@/bin' forces clang to use ld-wrapper.sh when calling ld. -export NIX_CFLAGS_COMPILE="-B@out@/bin/ $NIX_CFLAGS_COMPILE" - -if test -e @out@/nix-support/libc-cflags; then - export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/libc-cflags) $NIX_CFLAGS_COMPILE" -fi - -if test -e @out@/nix-support/clang-cflags; then - export NIX_CFLAGS_COMPILE="$(cat @out@/nix-support/clang-cflags) $NIX_CFLAGS_COMPILE" -fi - -if test -e @out@/nix-support/libc-ldflags; then - export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/libc-ldflags)" -fi - -if test -e @out@/nix-support/clang-ldflags; then - export NIX_LDFLAGS="$NIX_LDFLAGS $(cat @out@/nix-support/clang-ldflags)" -fi - -if test -e @out@/nix-support/libc-ldflags-before; then - export NIX_LDFLAGS_BEFORE="$(cat @out@/nix-support/libc-ldflags-before) $NIX_LDFLAGS_BEFORE" -fi - -export NIX_GCC_WRAPPER_FLAGS_SET=1 diff --git a/pkgs/build-support/clang-wrapper/builder.sh b/pkgs/build-support/clang-wrapper/builder.sh deleted file mode 100644 index 6a8ea6370dfe..000000000000 --- a/pkgs/build-support/clang-wrapper/builder.sh +++ /dev/null @@ -1,149 +0,0 @@ -source $stdenv/setup - - -mkdir -p $out/bin -mkdir -p $out/nix-support - - -if test -z "$nativeLibc"; then - dynamicLinker="$libc/lib/$dynamicLinker" - echo $dynamicLinker > $out/nix-support/dynamic-linker - - if test -e $libc/lib/32/ld-linux.so.2; then - echo $libc/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32 - fi - - # The "-B$libc/lib/" flag is a quick hack to force clang to link - # against the crt1.o from our own glibc, rather than the one in - # /usr/lib. (This is only an issue when using an `impure' - # compiler/linker, i.e., one that searches /usr/lib and so on.) - echo "-B$libc/lib/ -idirafter $libc/include" > $out/nix-support/libc-cflags - - echo "-L$libc/lib" > $out/nix-support/libc-ldflags - - # The dynamic linker is passed in `ldflagsBefore' to allow - # explicit overrides of the dynamic linker by callers to clang/ld - # (the *last* value counts, so ours should come first). - echo "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before -fi - -if test -n "$nativeTools"; then - if [ -n "$isDarwin" ]; then - clangPath="$clang/bin" - else - clangPath="$nativePrefix/bin" - fi - ldPath="$nativePrefix/bin" -else - clangLDFlags="" - if test -d "$gcc/lib"; then - basePath=`echo $gcc/lib/*/*/*` - # Need libgcc until the llvm compiler-rt library is complete - clangLDFlags="$clangLDFlags -L$basePath" - if test -e "$gcc/lib64"; then - clangLDFlags="$clangLDFlags -L$gcc/lib64" - else - clangLDFlags="$clangLDFlags -L$gcc/lib" - fi - fi - - if test -d "$clang/lib"; then - clangLDFlags="$clangLDFlags -L$clang/lib" - fi - - if [ -n "$clangLDFlags" ]; then - echo "$clangLDFlags" > $out/nix-support/clang-ldflags - fi - - # Need files like crtbegin.o from gcc - # It's unclear if these will ever be provided by an LLVM project - clangCFlags="$clangCFlags -B$basePath" - - clangCFlags="$clangCFlags -isystem$clang/lib/clang/$clangVersion/include" - echo "$clangCFlags" > $out/nix-support/clang-cflags - - ldPath="$binutils/bin" - clangPath="$clang/bin" -fi - - -doSubstitute() { - local src=$1 - local dst=$2 - # Can't use substitute() here, because replace may not have been - # built yet (in the bootstrap). - sed \ - -e "s^@out@^$out^g" \ - -e "s^@shell@^$shell^g" \ - -e "s^@clang@^$clang^g" \ - -e "s^@clangProg@^$clangProg^g" \ - -e "s^@binutils@^$binutils^g" \ - -e "s^@coreutils@^$coreutils^g" \ - -e "s^@libc@^$libc^g" \ - -e "s^@ld@^$ldPath/ld^g" \ - < "$src" > "$dst" -} - - -# Make wrapper scripts around clang and clang++. Also make symlinks -# cc and c++ -mkClangWrapper() { - local dst=$1 - local src=$2 - - if ! test -f "$src"; then - echo "$src does not exist (skipping)" - return 1 - fi - - clangProg="$src" - doSubstitute "$clangWrapper" "$dst" - chmod +x "$dst" -} - -if mkClangWrapper $out/bin/clang $clangPath/clang -then - ln -sv clang $out/bin/cc -fi - -if mkClangWrapper $out/bin/clang++ $clangPath/clang++ -then - ln -sv clang++ $out/bin/c++ -fi - - -# Create a symlink to as (the assembler). This is useful when a -# clang-wrapper is installed in a user environment, as it ensures that -# the right assembler is called. -ln -s $ldPath/as $out/bin/as - - -# Make a wrapper around the linker. -doSubstitute "$ldWrapper" "$out/bin/ld" -chmod +x "$out/bin/ld" - - -# Emit a setup hook. Also store the path to the original Clang and -# libc. -test -n "$clang" && echo $clang > $out/nix-support/orig-clang -test -n "$libc" && echo $libc > $out/nix-support/orig-libc - -doSubstitute "$addFlags" "$out/nix-support/add-flags.sh" - -doSubstitute "$setupHook" "$out/nix-support/setup-hook" -cat >> "$out/nix-support/setup-hook" << EOF -export CC=clang -export CXX=clang++ -EOF - -cp -p $utils $out/nix-support/utils.sh - - -# Propagate the wrapped clang so that if you install the wrapper, you get -# llvm tools, the manpages, etc. as well (including for binutils -# and Glibc). -if test -z "$nativeTools"; then - echo $clang $binutils $libc > $out/nix-support/propagated-user-env-packages -fi - -echo $extraPackages > $out/nix-support/propagated-native-build-inputs diff --git a/pkgs/build-support/clang-wrapper/clang-wrapper.sh b/pkgs/build-support/clang-wrapper/clang-wrapper.sh deleted file mode 100644 index c375fc951c0f..000000000000 --- a/pkgs/build-support/clang-wrapper/clang-wrapper.sh +++ /dev/null @@ -1,136 +0,0 @@ -#! @shell@ -e - -if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then - source "$NIX_GCC_WRAPPER_START_HOOK" -fi - -if test -z "$NIX_GCC_WRAPPER_FLAGS_SET"; then - source @out@/nix-support/add-flags.sh -fi - -source @out@/nix-support/utils.sh - - -# Figure out if linker flags should be passed. Clang prints annoying -# warnings when they are not needed. (does it really? Copied from gcc-wrapper) -dontLink=0 -getVersion=0 -nonFlagArgs=0 - -for i in "$@"; do - if test "$i" = "-c"; then - dontLink=1 - elif test "$i" = "-S"; then - dontLink=1 - elif test "$i" = "-E"; then - dontLink=1 - elif test "$i" = "-E"; then - dontLink=1 - elif test "$i" = "-M"; then - dontLink=1 - elif test "$i" = "-MM"; then - dontLink=1 - elif test "$i" = "-x"; then - # At least for the cases c-header or c++-header we should set dontLink. - # I expect no one use -x other than making precompiled headers. - dontLink=1 - elif test "${i:0:1}" != "-"; then - nonFlagArgs=1 - elif test "$i" = "-m32"; then - if test -e @out@/nix-support/dynamic-linker-m32; then - NIX_LDFLAGS="$NIX_LDFLAGS -dynamic-linker $(cat @out@/nix-support/dynamic-linker-m32)" - fi - fi -done - -# If we pass a flag like -Wl, then clang will call the linker unless it -# can figure out that it has to do something else (e.g., because of a -# "-c" flag). So if no non-flag arguments are given, don't pass any -# linker flags. This catches cases like "clang" (should just print -# "clang: no input files") and "clang -v" (should print the version). -if test "$nonFlagArgs" = "0"; then - dontLink=1 -fi - -# Optionally filter out paths not refering to the store. -params=("$@") -if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then - rest=() - n=0 - while test $n -lt ${#params[*]}; do - p=${params[n]} - p2=${params[$((n+1))]} - if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then - skip $p - elif test "$p" = "-L" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif test "${p:0:3}" = "-I/" && badPath "${p:2}"; then - skip $p - elif test "$p" = "-I" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - elif test "$p" = "-isystem" && badPath "$p2"; then - n=$((n + 1)); skip $p2 - else - rest=("${rest[@]}" "$p") - fi - n=$((n + 1)) - done - params=("${rest[@]}") - NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE --sysroot=/var/empty" -fi - -# Add the flags for the C compiler proper. -extraAfter=($NIX_CFLAGS_COMPILE) -extraBefore=() - -if test "$dontLink" != "1"; then - - # Add the flags that should only be passed to the compiler when - # linking. - extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK) - - # Add the flags that should be passed to the linker (and prevent - # `ld-wrapper' from adding NIX_LDFLAGS again). - for i in $NIX_LDFLAGS_BEFORE; do - extraBefore=(${extraBefore[@]} "-Wl,$i") - done - for i in $NIX_LDFLAGS; do - if test "${i:0:3}" = "-L/"; then - extraAfter=(${extraAfter[@]} "$i") - else - extraAfter=(${extraAfter[@]} "-Wl,$i") - fi - done - export NIX_LDFLAGS_SET=1 -fi - -# As a very special hack, if the arguments are just `-v', then don't -# add anything. This is to prevent `clang -v' (which normally prints -# out the version number and returns exit code 0) from printing out -# `No input files specified' and returning exit code 1. -if test "$*" = "-v"; then - extraAfter=() - extraBefore=() -fi - -# Optionally print debug info. -if test "$NIX_DEBUG" = "1"; then - echo "original flags to @clangProg@:" >&2 - for i in "${params[@]}"; do - echo " $i" >&2 - done - echo "extraBefore flags to @clangProg@:" >&2 - for i in ${extraBefore[@]}; do - echo " $i" >&2 - done - echo "extraAfter flags to @clangProg@:" >&2 - for i in ${extraAfter[@]}; do - echo " $i" >&2 - done -fi - -if test -n "$NIX_CLANG_WRAPPER_EXEC_HOOK"; then - source "$NIX_CLANG_WRAPPER_EXEC_HOOK" -fi - -exec @clangProg@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/clang-wrapper/default.nix b/pkgs/build-support/clang-wrapper/default.nix deleted file mode 100644 index c49bc4c08934..000000000000 --- a/pkgs/build-support/clang-wrapper/default.nix +++ /dev/null @@ -1,89 +0,0 @@ -# The Nix `clang' stdenv.mkDerivation is not directly usable, since it doesn't -# know where the C library and standard header files are. Therefore -# the compiler produced by that package cannot be installed directly -# in a user environment and used from the command line. This -# stdenv.mkDerivation provides a wrapper that sets up the right environment -# variables so that the compiler and the linker just "work". - -{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" -, clang ? null, libc ? null, binutils ? null, coreutils ? null, shell ? "" -, zlib ? null, extraPackages ? [] -}: - -assert nativeTools -> nativePrefix != ""; -assert !nativeTools -> clang != null && binutils != null && coreutils != null; -assert !nativeLibc -> libc != null; - -let - - clangVersion = (builtins.parseDrvName clang.name).version; - clangName = (builtins.parseDrvName clang.name).name; - -in - -stdenv.mkDerivation { - name = - (if name != "" then name else clangName + "-wrapper") + - (if clang != null && clangVersion != "" then "-" + clangVersion else ""); - - isDarwin = stdenv.isDarwin; - - builder = ./builder.sh; - setupHook = ./setup-hook.sh; - clangWrapper = ./clang-wrapper.sh; - ldWrapper = ../gcc-wrapper/ld-wrapper.sh; - utils = ../gcc-wrapper/utils.sh; - addFlags = ./add-flags; - - inherit nativeTools nativeLibc nativePrefix clang clangVersion extraPackages; - - gcc = clang.gcc; - libc = if nativeLibc then null else libc; - binutils = if nativeTools then null else binutils; - # The wrapper scripts use 'cat', so we may need coreutils - coreutils = if nativeTools then null else coreutils; - - langC = true; - langCC = true; - shell = if shell == "" then stdenv.shell else - if builtins.isAttrs shell then (shell + shell.shellPath) - else shell; - - crossAttrs = { - shell = shell.crossDrv + shell.crossDrv.shellPath; - libc = libc.crossDrv; - coreutils = coreutils.crossDrv; - binutils = binutils.crossDrv; - clang = clang.crossDrv; - # - # This is not the best way to do this. I think the reference should be - # the style in the gcc-cross-wrapper, but to keep a stable stdenv now I - # do this sufficient if/else. - dynamicLinker = - (if stdenv.cross.arch == "arm" then "ld-linux.so.3" else - if stdenv.cross.arch == "mips" then "ld.so.1" else - if stdenv.lib.hasSuffix "pc-gnu" stdenv.cross.config then "ld.so.1" else - abort "don't know the name of the dynamic linker for this platform"); - }; - - meta = - let clang_ = if clang != null then clang else {}; in - (if clang_ ? meta then removeAttrs clang.meta ["priority"] else {}) // - { description = - stdenv.lib.attrByPath ["meta" "description"] "System C compiler" clang_ - + " (wrapper script)"; - }; - - # The dynamic linker has different names on different Linux platforms. - dynamicLinker = - if !nativeLibc then - (if stdenv.system == "i686-linux" then "ld-linux.so.2" else - if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else - if stdenv.isArm then "ld-linux.so.3" else - if stdenv.system == "powerpc-linux" then "ld.so.1" else - if stdenv.system == "mips64el-linux" then "ld.so.1" else - abort "don't know the name of the dynamic linker for this platform") - else ""; - - preferLocalBuild = true; -} diff --git a/pkgs/build-support/clang-wrapper/setup-hook.sh b/pkgs/build-support/clang-wrapper/setup-hook.sh deleted file mode 100644 index 0bd531050c47..000000000000 --- a/pkgs/build-support/clang-wrapper/setup-hook.sh +++ /dev/null @@ -1,38 +0,0 @@ -export NIX_GCC=@out@ - -addCVars () { - if test -d $1/include; then - export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" - fi - - if test -d $1/lib64; then - export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib64" - fi - - if test -d $1/lib; then - export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib" - fi -} - -envHooks+=(addCVars) - -# Note: these come *after* $out in the PATH (see setup.sh). - -if test -n "@clang@"; then - addToSearchPath PATH @clang@/bin -fi - -if test -n "@binutils@"; then - addToSearchPath PATH @binutils@/bin -fi - -if test -n "@libc@"; then - addToSearchPath PATH @libc@/bin -fi - -if test -n "@coreutils@"; then - addToSearchPath PATH @coreutils@/bin -fi - -: ${CXX:=clang++} -export CXX diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix index 1af35f58a3fe..e2f57cfe43c9 100644 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ b/pkgs/build-support/gcc-wrapper/default.nix @@ -7,7 +7,7 @@ { name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? "" , gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? stdenv.shell -, zlib ? null +, zlib ? null, extraPackages ? [] }: with stdenv.lib; @@ -124,6 +124,8 @@ stdenv.mkDerivation { # you get tools like gcov, the manpages, etc. as well (including # for binutils and Glibc). echo $gcc $binutils $libc > $out/nix-support/propagated-user-env-packages + + echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs '' + optionalString (stdenv.isSunOS && nativePrefix != "") '' @@ -161,6 +163,16 @@ stdenv.mkDerivation { ln -s g++ $out/bin/c++ fi + if [ -e $gccPath/clang ]; then + wrap clang ${./gcc-wrapper.sh} $gccPath/clang + ln -s clang $out/bin/cc + fi + + if [ -e $gccPath/clang++ ]; then + wrap clang++ ${./gcc-wrapper.sh} $gccPath/clang++ + ln -s clang++ $out/bin/c++ + fi + if [ -e $gccPath/cpp ]; then wrap cpp ${./gcc-wrapper.sh} $gccPath/cpp fi @@ -195,6 +207,14 @@ stdenv.mkDerivation { substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook substituteAll ${./add-flags} $out/nix-support/add-flags.sh cp -p ${./utils.sh} $out/nix-support/utils.sh + + if [ -e $out/bin/clang ]; then + echo 'export CC; : ''${CC:=clang}' >> $out/nix-support/setup-hook + fi + + if [ -e $out/bin/clang++ ]; then + echo 'export CXX; : ''${CXX:=clang++}' >> $out/nix-support/setup-hook + fi ''; # The dynamic linker has different names on different Linux platforms. diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 787180cbe3a4..03bae7de196c 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -24,13 +24,13 @@ import ../generic rec { system = stdenv.system; - gcc = import ../../build-support/clang-wrapper { + gcc = import ../../build-support/gcc-wrapper { nativeTools = false; nativeLibc = true; inherit stdenv; extraPackages = stdenv.lib.optional haveLibCxx pkgs.libcxx; binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;}; - clang = if useClang33 then pkgs.clang_33.clang else pkgs.clang.clang; + gcc = if useClang33 then pkgs.clang_33.gcc else pkgs.clang.gcc; coreutils = pkgs.coreutils; shell = pkgs.bash + "/bin/sh"; }; diff --git a/pkgs/tools/networking/strongswan/default.nix b/pkgs/tools/networking/strongswan/default.nix index 9358b9aaa2fb..866e8eae4779 100644 --- a/pkgs/tools/networking/strongswan/default.nix +++ b/pkgs/tools/networking/strongswan/default.nix @@ -19,6 +19,6 @@ stdenv.mkDerivation rec { description = "OpenSource IPsec-based VPN Solution"; homepage = https://www.strongswan.org; license = stdenv.lib.licenses.gpl2Plus; - inherit (stdenv.gcc.clang.meta) platforms; + inherit (stdenv.gcc.gcc.meta) platforms; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 43985bd6a6b2..cf5099b3673a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2763,10 +2763,10 @@ let ccl = builderDefsPackage ../development/compilers/ccl {}; - clang = wrapClang llvmPackages.clang; + clang = wrapGCC llvmPackages.clang; - clang_34 = wrapClang llvmPackages_34.clang; - clang_33 = wrapClang (clangUnwrapped llvm_33 ../development/compilers/llvm/3.3/clang.nix); + clang_34 = wrapGCC llvmPackages_34.clang; + clang_33 = wrapGCC (clangUnwrapped llvm_33 ../development/compilers/llvm/3.3/clang.nix); clangAnalyzer = callPackage ../development/tools/analysis/clang-analyzer { clang = clang_34; @@ -2779,8 +2779,8 @@ let clangSelf = clangWrapSelf llvmPackagesSelf.clang; - clangWrapSelf = build: (import ../build-support/clang-wrapper) { - clang = build; + clangWrapSelf = build: (import ../build-support/gcc-wrapper) { + gcc = build; stdenv = clangStdenv; libc = glibc; binutils = binutils; @@ -3668,18 +3668,6 @@ let inherit stdenv binutils coreutils zlib; }; - wrapClangWith = clangWrapper: glibc: baseClang: clangWrapper { - nativeTools = stdenv.gcc.nativeTools or false; - nativeLibc = stdenv.gcc.nativeLibc or false; - nativePrefix = stdenv.gcc.nativePrefix or ""; - clang = baseClang; - libc = glibc; - binutils = stdenv.gcc.binutils; - inherit stdenv coreutils zlib; - }; - - wrapClang = wrapClangWith (makeOverridable (import ../build-support/clang-wrapper)) glibc; - wrapGCC = wrapGCCWith (makeOverridable (import ../build-support/gcc-wrapper)) glibc; wrapGCCCross = From a4619673b50bb424371b3fbfa52b202db767313d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 11 Oct 2014 22:04:03 +0200 Subject: [PATCH 39/47] clang/llvm: Fewer build-time dependencies Such as valgrind, dejagnu, tcl/tk, ... --- pkgs/development/compilers/llvm/3.4/llvm.nix | 4 ++-- pkgs/development/libraries/libffi/default.nix | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/llvm/3.4/llvm.nix b/pkgs/development/compilers/llvm/3.4/llvm.nix index d9dd1a976b35..d3beb2e7461c 100644 --- a/pkgs/development/compilers/llvm/3.4/llvm.nix +++ b/pkgs/development/compilers/llvm/3.4/llvm.nix @@ -29,8 +29,8 @@ in stdenv.mkDerivation rec { buildInputs = [ perl groff cmake libxml2 libffi ] - ++ stdenv.lib.optional (!stdenv.isDarwin) python - ++ stdenv.lib.optional stdenv.isLinux valgrind; + ++ stdenv.lib.optional (!stdenv.isDarwin) python /* + ++ stdenv.lib.optional stdenv.isLinux valgrind */; propagatedBuildInputs = [ ncurses zlib ]; diff --git a/pkgs/development/libraries/libffi/default.nix b/pkgs/development/libraries/libffi/default.nix index 20b697144a0c..d661bbfc7a25 100644 --- a/pkgs/development/libraries/libffi/default.nix +++ b/pkgs/development/libraries/libffi/default.nix @@ -16,7 +16,8 @@ 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. From 3ac28c3645c65121c17145f338cac11f43c5fc9a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 11 Oct 2014 22:21:57 +0200 Subject: [PATCH 40/47] libc++: Fix on Linux On Linux (unlike Darwin), libc++ cannot automatically propagate libc++abi. So we need to add libc++abi to the RPATH. --- pkgs/development/libraries/libc++/default.nix | 2 +- pkgs/development/libraries/libc++/setup-hook.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/libc++/default.nix b/pkgs/development/libraries/libc++/default.nix index ae4b9d825e80..99e9bfe1de2e 100644 --- a/pkgs/development/libraries/libc++/default.nix +++ b/pkgs/development/libraries/libc++/default.nix @@ -24,7 +24,7 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - passthru.abi = libcxxabi; + inherit libcxxabi; # Remove a Makefile that causes many retained dependencies. postInstall = "rm $out/include/c++/v1/Makefile"; diff --git a/pkgs/development/libraries/libc++/setup-hook.sh b/pkgs/development/libraries/libc++/setup-hook.sh index e2b1b10e8a3f..8543d09d8f52 100644 --- a/pkgs/development/libraries/libc++/setup-hook.sh +++ b/pkgs/development/libraries/libc++/setup-hook.sh @@ -1,2 +1,2 @@ -NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem @out@/include/c++/v1 -stdlib=libc++" -NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -stdlib=libc++" +export NIX_CFLAGS_COMPILE+=" -isystem @out@/include/c++/v1 -stdlib=libc++" +export NIX_CFLAGS_LINK+=" -stdlib=libc++ -Wl,-rpath,@libcxxabi@/lib" From 34f6e629b59d104c7023f1bf41e679bb4e625609 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 11 Oct 2014 22:30:41 +0200 Subject: [PATCH 41/47] libc++abi: Drop dependency on libunwind This appears no longer needed (libc++abi has its own libunwind). It also prevents every libc++ user from depending on liblzma. --- pkgs/development/libraries/libc++abi/default.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkgs/development/libraries/libc++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix index a12b6e423bc7..d5b8b0fcdcea 100644 --- a/pkgs/development/libraries/libc++abi/default.nix +++ b/pkgs/development/libraries/libc++abi/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, libcxx, libunwind, coreutils, gnused }: +{ lib, stdenv, fetchurl, libcxx, coreutils, gnused }: let rev = "199626"; in @@ -19,9 +19,6 @@ stdenv.mkDerivation { export NIX_CFLAGS_COMPILE="-I$PWD/include -I$(readlink -f libcxx-*)/include" '' + lib.optionalString stdenv.isDarwin '' export TRIPLE=x86_64-apple-darwin - '' + lib.optionalString (!stdenv.isDarwin) '' - export NIX_CFLAGS_COMPILE+=" -I${libunwind}/include" - export NIX_CFLAGS_LINK+=" -L${libunwind}/lib -lunwind" ''; installPhase = if stdenv.isDarwin From 2c65f3fa664cd7562104b677ef1fe94194ac2810 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 11 Oct 2014 23:10:27 +0200 Subject: [PATCH 42/47] Fix stdenv-native --- pkgs/build-support/gcc-wrapper/default.nix | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix index e2f57cfe43c9..b2f7d07560d3 100644 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ b/pkgs/build-support/gcc-wrapper/default.nix @@ -118,7 +118,6 @@ stdenv.mkDerivation { gccPath="$gcc/bin" ldPath="$binutils/bin" - ld="$ldPath/ld" # Propagate the wrapped gcc so that if you install the wrapper, # you get tools like gcov, the manpages, etc. as well (including @@ -143,7 +142,7 @@ stdenv.mkDerivation { ln -s $ldPath/as $out/bin/as fi - wrap ld ${./ld-wrapper.sh} $ld + wrap ld ${./ld-wrapper.sh} ''${ld:-$ldPath/ld} if [ -e $binutils/bin/ld.gold ]; then wrap ld.gold ${./ld-wrapper.sh} $binutils/bin/ld.gold @@ -156,19 +155,15 @@ stdenv.mkDerivation { if [ -e $gccPath/gcc ]; then wrap gcc ${./gcc-wrapper.sh} $gccPath/gcc ln -s gcc $out/bin/cc + elif [ -e $gccPath/clang ]; then + wrap clang ${./gcc-wrapper.sh} $gccPath/clang + ln -s clang $out/bin/cc fi if [ -e $gccPath/g++ ]; then wrap g++ ${./gcc-wrapper.sh} $gccPath/g++ ln -s g++ $out/bin/c++ - fi - - if [ -e $gccPath/clang ]; then - wrap clang ${./gcc-wrapper.sh} $gccPath/clang - ln -s clang $out/bin/cc - fi - - if [ -e $gccPath/clang++ ]; then + elif [ -e $gccPath/clang++ ]; then wrap clang++ ${./gcc-wrapper.sh} $gccPath/clang++ ln -s clang++ $out/bin/c++ fi From 7aacca25df57e83ce1e211747802763d3075ba6a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 14 Oct 2014 16:36:44 +0200 Subject: [PATCH 43/47] stdenv-darwin: Pass through libcxx/libcxxabi --- pkgs/stdenv/darwin/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 03bae7de196c..26114d2726e1 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -44,6 +44,6 @@ import ../generic rec { inherit (gcc) binutils; inherit (pkgs) gzip bzip2 xz bash coreutils diffutils findutils gawk - gnumake gnused gnutar gnugrep gnupatch perl; + gnumake gnused gnutar gnugrep gnupatch perl libcxx libcxxabi; }; } From d7abe3badad3df08e99ee63f11c8b9be62c57101 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 14 Oct 2014 16:53:48 +0200 Subject: [PATCH 44/47] libc++abi: Enable _LIBCXX_DYNAMIC_FALLBACK Without this, the C++ dynamic_cast<> operator does not work reliably in conjunction with dynamic linking. See http://www.russellmcc.com/posts/2013-08-03-rtti.html (That article suggests that Apple builds libc++abi without _LIBCXX_DYNAMIC_FALLBACK, but "strings /usr/lib/libc++abi.dylib" shows that it *is* enabled.) --- pkgs/development/libraries/libc++abi/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libc++abi/default.nix b/pkgs/development/libraries/libc++abi/default.nix index d5b8b0fcdcea..ec87254c170c 100644 --- a/pkgs/development/libraries/libc++abi/default.nix +++ b/pkgs/development/libraries/libc++abi/default.nix @@ -16,9 +16,11 @@ stdenv.mkDerivation { postUnpack = '' unpackFile ${libcxx.src} - export NIX_CFLAGS_COMPILE="-I$PWD/include -I$(readlink -f libcxx-*)/include" '' + 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" ''; installPhase = if stdenv.isDarwin From 9a979af1d3bf92e7ebe85332852b2c95bdf0aa04 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 15 Oct 2014 01:15:31 +0200 Subject: [PATCH 45/47] stdenv-darwin: Revert to clang 3.3 In 3.3, a C++ class defined in a header will get a typeinfo symbol like this (e.g. in Nix's src/libutil/util.o): (__DATA,__datacoal_nt) weak external typeinfo for nix::BaseError But in 3.4, this has changed to: (__DATA,__datacoal_nt) weak external automatically hidden typeinfo for nix::BaseError This causes the linker to change the symbol to: (__DATA,__data) non-external (was signed char private external) typeinfo for nix::BaseError i.e. losing its weak linkage. But without weak linkage, dynamic_cast and other RTTI-based mechanisms (such as catching an exception of a certain type) don't work across shared libraries / executables. The clang compiler in the SDK doesn't have this behaviour, but it's not clear exactly which version it is (it just says "based on LLVM 3.4svn"). --- pkgs/stdenv/darwin/default.nix | 2 +- pkgs/top-level/all-packages.nix | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 26114d2726e1..cbc9a38b77de 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -1,6 +1,6 @@ { stdenv, pkgs, config , haveLibCxx ? true -, useClang33 ? false }: +, useClang33 ? true }: import ../generic rec { inherit config; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cf5099b3673a..229c59f3b6ee 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11856,7 +11856,6 @@ let }; nixUnstable = callPackage ../tools/package-management/nix/unstable.nix { - stdenv = if stdenv.isDarwin then allStdenvs.stdenvDarwin33 else stdenv; storeDir = config.nix.storeDir or "/nix/store"; stateDir = config.nix.stateDir or "/nix/var"; }; From 97e9d2b3512eca5ec89eafe391efac98b101831b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 4 Nov 2014 13:26:51 +0100 Subject: [PATCH 46/47] Remove dead code --- pkgs/stdenv/nix/default.nix | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix index c7dd659195be..476e0eae3970 100644 --- a/pkgs/stdenv/nix/default.nix +++ b/pkgs/stdenv/nix/default.nix @@ -7,17 +7,6 @@ import ../generic rec { '' export NIX_ENFORCE_PURITY=1 export NIX_IGNORE_LD_THROUGH_GCC=1 - '' + lib.optionalString stdenv.isDarwin '' - export NIX_ENFORCE_PURITY= - export NIX_DONT_SET_RPATH=1 - export NIX_NO_SELF_RPATH=1 - dontFixLibtool=1 - stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" - xargsFlags=" " - export MACOSX_DEPLOYMENT_TARGET=10.6 - export SDKROOT=$(/usr/bin/xcrun --show-sdk-path 2> /dev/null || true) - export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT/usr/include -F$SDKROOT/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations" - export NIX_LDFLAGS_AFTER+=" -L$SDKROOT/usr/lib" ''; initialPath = (import ../common-path.nix) {pkgs = pkgs;}; @@ -29,11 +18,7 @@ import ../generic rec { nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; nativeLibc = true; inherit stdenv; - binutils = - if stdenv.isDarwin then - import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;} - else - pkgs.binutils; + binutils = pkgs.binutils; gcc = pkgs.gcc.gcc; coreutils = pkgs.coreutils; shell = pkgs.bash + "/bin/sh"; From 899d81b37ba6dc26431b82b40300505f19504e03 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 4 Nov 2014 13:27:42 +0100 Subject: [PATCH 47/47] Set MACOSX_DEPLOYMENT_TARGET to 10.9 This makes stuff build with Xcode 6.1 on Mac OS X 10.9 (where we got errors like "ld: file not found: /usr/lib/system/libsystem_coreservices.dylib for architecture x86_64" due to the use of the 10.10 SDK). --- pkgs/stdenv/darwin/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index cbc9a38b77de..9131f0742d00 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -14,8 +14,8 @@ import ../generic rec { dontFixLibtool=1 stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" xargsFlags=" " - export MACOSX_DEPLOYMENT_TARGET=10.6 - export SDKROOT=$(/usr/bin/xcrun --show-sdk-path 2> /dev/null || true) + export MACOSX_DEPLOYMENT_TARGET=10.9 + export SDKROOT=$(/usr/bin/xcrun --sdk macosx10.9 --show-sdk-path 2> /dev/null || true) export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT/usr/include -F$SDKROOT/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations" export NIX_LDFLAGS_AFTER+=" -L$SDKROOT/usr/lib" '';