GCC 4.7.2 + updated libraries compiles on Illumos/SmartOS!

- Add solaris native ld support to GCC build wrapper
- Add solaris ld wrapper that fixes -L argument order
This commit is contained in:
Danny Wilson 2013-02-23 13:59:59 +00:00 committed by Danny Wilson
parent bcaea92a12
commit 15e865ac09
10 changed files with 141 additions and 24 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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"}

View File

@ -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

View File

@ -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" ];
}))

View File

@ -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)

View File

@ -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 =

View File

@ -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/;