diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh index ed7ad0a50b73..e7c3400e9f7f 100644 --- a/pkgs/build-support/gcc-wrapper/builder.sh +++ b/pkgs/build-support/gcc-wrapper/builder.sh @@ -66,13 +66,23 @@ else echo "$gccCFlags" > $out/nix-support/gcc-cflags gccPath="$gcc/bin" - ldPath="$binutils/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 \ @@ -85,7 +95,7 @@ doSubstitute() { -e "s^@binutils@^$binutils^g" \ -e "s^@coreutils@^$coreutils^g" \ -e "s^@libc@^$libc^g" \ - -e "s^@ld@^$ldPath/ld^g" \ + -e "s^@ld@^$ld^g" \ < "$src" > "$dst" } @@ -174,6 +184,13 @@ ln -s $ldPath/as $out/bin/as 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. diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix index 87617621e64c..aa4f6a3944e1 100644 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ b/pkgs/build-support/gcc-wrapper/default.nix @@ -36,6 +36,7 @@ stdenv.mkDerivation { gnatWrapper = ./gnat-wrapper.sh; gnatlinkWrapper = ./gnatlink-wrapper.sh; ldWrapper = ./ld-wrapper.sh; + ldSolarisWrapper = ./ld-solaris-wrapper.sh; utils = ./utils.sh; addFlags = ./add-flags; diff --git a/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh new file mode 100644 index 000000000000..5a7b92b5ad7d --- /dev/null +++ b/pkgs/build-support/gcc-wrapper/ld-solaris-wrapper.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e +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" + +args=("$@"); + +# This loop makes sure all -L arguments are before -l arguments, or ld may complain it cannot find a library. +# GNU binutils does not have this problem: +# http://stackoverflow.com/questions/5817269/does-the-order-of-l-and-l-options-in-the-gnu-linker-matter +i=0; +while [[ $i -lt $# ]]; do + case "${args[$i]}" in + -L) cmd="$cmd ${args[$i]} ${args[($i+1)]}"; i=($i+1); ;; + -L*) cmd="$cmd ${args[$i]}" ;; + *) ;; + esac + i=($i+1); +done + +i=0; +while [[ $i -lt $# ]]; do + case "${args[$i]}" in + -L) i=($i+1); ;; + -L*) ;; + *) cmd="$cmd ${args[$i]}" ;; + esac + i=($i+1); +done + +# Trace: +set -x +exec $cmd + +exit 0 diff --git a/pkgs/development/compilers/gcc/4.7/builder.sh b/pkgs/development/compilers/gcc/4.7/builder.sh index 37400fba5bf5..dc6fdd935613 100644 --- a/pkgs/development/compilers/gcc/4.7/builder.sh +++ b/pkgs/development/compilers/gcc/4.7/builder.sh @@ -155,7 +155,7 @@ if test -n "$targetConfig"; then dontStrip=1 fi - +providedPreConfigure="$preConfigure"; preConfigure() { if test -n "$newlibSrc"; then tar xvf "$newlibSrc" -C .. @@ -188,6 +188,9 @@ preConfigure() { configureFlags="$configureFlags --with-build-sysroot=`pwd`/.." fi + # Eval the preConfigure script from nix expression. + eval $providedPreConfigure; + env; # Perform the build in a different directory. mkdir ../build cd ../build diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix index 6e8e5d86cc53..d97f8aaf5c64 100644 --- a/pkgs/development/compilers/gcc/4.7/default.nix +++ b/pkgs/development/compilers/gcc/4.7/default.nix @@ -277,19 +277,34 @@ stdenv.mkDerivation ({ ++ (optional stdenv.isDarwin gnused) ; - configureFlagsArray = stdenv.lib.optionals - (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic) - [ "--with-host-libstdcxx=-lstdc++ -lgcc_s" ]; + NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isSunOS "-lm -ldl"; + + preConfigure = '' + configureFlagsArray=( + ${stdenv.lib.optionalString (ppl != null && ppl ? dontDisableStatic && ppl.dontDisableStatic) + "'--with-host-libstdcxx=-lstdc++ -lgcc_s'"} + ${stdenv.lib.optionalString (ppl != null && stdenv.isSunOS) + "\"--with-host-libstdcxx=-Wl,-rpath,\$prefix/lib/amd64 -lstdc++\" + \"--with-boot-ldflags=-L../prev-x86_64-pc-solaris2.11/libstdc++-v3/src/.libs\""} + ); + ${stdenv.lib.optionalString (stdenv.isSunOS && stdenv.is64bit) + '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''} + ''; # 'iant' at #go-nuts@freenode, gccgo maintainer, said that # they have a bug in 4.7.1 if adding "--disable-static" - dontDisableStatic = langGo; + dontDisableStatic = langGo || staticCompiler; configureFlags = " ${if stdenv.isSunOS then " --enable-long-long --enable-libssp --enable-threads=posix --disable-nls --enable-__cxa_atexit " + # On Illumos/Solaris GNU as is preferred - " --with-gnu-as --with-gnu-ld " + " --with-gnu-as --without-gnu-ld " else ""} --enable-lto ${if enableMultilib then "" else "--disable-multilib"} diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix index 113093a80678..e88308bb2e9c 100644 --- a/pkgs/development/libraries/gettext/default.nix +++ b/pkgs/development/libraries/gettext/default.nix @@ -10,7 +10,7 @@ stdenv.mkDerivation (rec { patches = [ ./no-gets.patch ]; - LDFLAGS = if stdenv.isSunOS then "-lsec -lavl" else ""; + LDFLAGS = if stdenv.isSunOS then "-lm -lmd -lmp -luutil -lnvpair -lnsl -lidmap -lavl -lsec" else ""; configureFlags = [ "--disable-csharp" ] ++ (stdenv.lib.optionals stdenv.isCygwin diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix index 802fd93f8cfc..6fbb6253ee52 100644 --- a/pkgs/development/libraries/mpfr/default.nix +++ b/pkgs/development/libraries/mpfr/default.nix @@ -1,6 +1,6 @@ {stdenv, fetchurl, gmp}: -stdenv.mkDerivation (rec { +stdenv.mkDerivation rec { name = "mpfr-3.1.1"; src = fetchurl { @@ -35,16 +35,14 @@ stdenv.mkDerivation (rec { maintainers = [ stdenv.lib.maintainers.ludo ]; platforms = stdenv.lib.platforms.all; }; + + configureFlags = + /* Work around a FreeBSD bug that otherwise leads to segfaults in + the test suite: + http://hydra.bordeaux.inria.fr/build/34862 + http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00015.html + http://www.freebsd.org/cgi/query-pr.cgi?pr=161344 + */ + stdenv.lib.optional (stdenv.isSunOS or stdenv.isFreeBSD) "--disable-thread-safe" ++ + stdenv.lib.optional stdenv.is64bit "--with-pic"; } - -// - -(stdenv.lib.optionalAttrs (stdenv.isSunOS or stdenv.isFreeBSD) { - /* Work around a FreeBSD bug that otherwise leads to segfaults in - the test suite: - http://hydra.bordeaux.inria.fr/build/34862 - http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00015.html - http://www.freebsd.org/cgi/query-pr.cgi?pr=161344 - */ - configureFlags = [ "--disable-thread-safe" ]; - })) diff --git a/pkgs/development/libraries/ppl/upstream-based.patch b/pkgs/development/libraries/ppl/upstream-based.patch new file mode 100644 index 000000000000..551050f67bf9 --- /dev/null +++ b/pkgs/development/libraries/ppl/upstream-based.patch @@ -0,0 +1,42 @@ +https://bugs.gentoo.org/show_bug.cgi?id=447928 +--- ppl-1.0/src/p_std_bits.cc.org 2012-12-30 00:37:03.033948083 +0100 ++++ ppl-1.0/src/mp_std_bits.cc 2012-12-30 00:44:12.893019313 +0100 +@@ -25,6 +25,9 @@ + #include "ppl-config.h" + #include "mp_std_bits.defs.hh" + ++#if __GNU_MP_VERSION < 5 \ ++ || (__GNU_MP_VERSION == 5 && __GNU_MP_VERSION_MINOR < 1) ++ + const bool std::numeric_limits<mpz_class>::is_specialized; + const int std::numeric_limits<mpz_class>::digits; + const int std::numeric_limits<mpz_class>::digits10; +@@ -70,3 +73,6 @@ + const bool std::numeric_limits<mpq_class>::traps; + const bool std::numeric_limits<mpq_class>::tininess_before; + const std::float_round_style std::numeric_limits<mpq_class>::round_style; ++ ++#endif // __GNU_MP_VERSION < 5 ++ // || (__GNU_MP_VERSION == 5 && __GNU_MP_VERSION_MINOR < 1) +--- ppl-1.0/src/mp_std_bits.defs.hh.org 2012-12-30 00:37:03.037948187 +0100 ++++ ppl-1.0/src/mp_std_bits.defs.hh 2012-12-30 00:42:32.002424189 +0100 +@@ -38,6 +38,9 @@ + #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS) + void swap(mpq_class& x, mpq_class& y); + ++#if __GNU_MP_VERSION < 5 \ ++ || (__GNU_MP_VERSION == 5 && __GNU_MP_VERSION_MINOR < 1) ++ + namespace std { + + #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS +@@ -164,6 +167,9 @@ + + } // namespace std + ++#endif // __GNU_MP_VERSION < 5 ++ // || (__GNU_MP_VERSION == 5 && __GNU_MP_VERSION_MINOR < 1) ++ + #include "mp_std_bits.inlines.hh" + + #endif // !defined(PPL_mp_std_bits_defs_hh) diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix index d0f7d60f101c..b16c51f7580b 100644 --- a/pkgs/stdenv/nix/default.nix +++ b/pkgs/stdenv/nix/default.nix @@ -23,6 +23,7 @@ import ../generic rec { gcc = import ../../build-support/gcc-wrapper { nativeTools = false; + nativePrefix = stdenv.lib.optionalString stdenv.isSunOS "/usr"; nativeLibc = true; inherit stdenv; binutils = diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix index 69892cbfd738..1ed3fc928f0c 100644 --- a/pkgs/tools/misc/coreutils/default.nix +++ b/pkgs/tools/misc/coreutils/default.nix @@ -49,8 +49,8 @@ stdenv.mkDerivation (rec { enableParallelBuilding = true; - LDFLAGS = stdenv.lib.optionalString stdenv.isSunOS "-lmp -lmd -lnsl -lsocket -lresolv"; - NIX_LDFLAGS = stdenv.lib.optionalString selinuxSupport "-lsepol"; + NIX_LDFLAGS = stdenv.lib.optionalString selinuxSupport "-lsepol" + + stdenv.lib.optionalString stdenv.isSunOS "-lmp -lmd -lnsl -lsocket -lresolv -luutil -lnvpair -lidmap -lavl -lsec"; meta = { homepage = http://www.gnu.org/software/coreutils/;