Breaking dependencies on the cross-built gcc through the gcc-cross-wrapper.
svn path=/nixpkgs/branches/stdenv-updates/; revision=23073
This commit is contained in:
parent
ff5d0fa448
commit
d5097ad3d3
@ -8,13 +8,20 @@ mkdir $out/nix-support
|
||||
cflagsCompile="-B$out/bin/"
|
||||
|
||||
if test -z "$nativeLibc"; then
|
||||
cflagsCompile="$cflagsCompile -B$libc/lib/ -isystem $libc/include"
|
||||
cflagsCompile="$cflagsCompile -B$gccLibs/lib -B$libc/lib/ -isystem $libc/include"
|
||||
ldflags="$ldflags -L$libc/lib"
|
||||
# Get the proper dynamic linker for glibc and uclibc.
|
||||
dlinker=`eval 'echo $libc/lib/ld*.so.?'`
|
||||
if [ -n "$dlinker" ]; then
|
||||
if [ -n "$dynamicLinker" ]; then
|
||||
ldflagsBefore="-dynamic-linker $dlinker"
|
||||
fi
|
||||
# This trick is to avoid dependencies on the cross-toolchain gcc
|
||||
# for libgcc, libstdc++, ...
|
||||
# -L is for libtool's .la files, and -rpath for the usual fixupPhase
|
||||
# shrinking rpaths.
|
||||
if [ -n "$gccLibs" ]; then
|
||||
ldflagsBefore="$ldflagsBefore -rpath $gccLibs/lib"
|
||||
fi
|
||||
|
||||
# The same as above, but put into files, useful for the gcc builder.
|
||||
dynamicLinker="$libc/lib/$dynamicLinker"
|
||||
@ -31,16 +38,13 @@ if test -z "$nativeLibc"; then
|
||||
# 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 "$ldflagsBefore" > $out/nix-support/libc-ldflags-before
|
||||
fi
|
||||
|
||||
if test -n "$nativeTools"; then
|
||||
gccPath="$nativePrefix/bin"
|
||||
ldPath="$nativePrefix/bin"
|
||||
else
|
||||
if test -n "$gccLibs"; then
|
||||
ldflags="$ldflags -L$gccLibs/lib -L$gccLibs/lib64"
|
||||
fi
|
||||
ldflags="$ldflags -L$gcc/lib -L$gcc/lib64"
|
||||
gccPath="$gcc/bin"
|
||||
ldPath="$binutils/$crossConfig/bin"
|
||||
|
@ -19,11 +19,14 @@ let
|
||||
name = chosenName + "-libs";
|
||||
phases = [ "installPhase" ];
|
||||
installPhase = ''
|
||||
echo $out
|
||||
ensureDir $out
|
||||
cp -Rd ${gcc}/lib $out/lib
|
||||
if [ -d ${gcc}/lib64 ]; then
|
||||
cp -Rd ${gcc}/lib64 $out/lib64
|
||||
fi
|
||||
cp -Rd ${gcc}/${cross.config}/lib $out/lib
|
||||
chmod -R +w $out/lib
|
||||
for a in $out/lib/*.la; do
|
||||
sed -i -e s,${gcc}/${cross.config}/lib,$out/lib,g $a
|
||||
done
|
||||
rm -f $out/lib/*.py
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
@ -75,7 +75,11 @@ if test "$dontLink" != "1"; then
|
||||
# Add the flags that should be passed to the linker (and prevent
|
||||
# `ld-wrapper' from adding NIX_CROSS_LDFLAGS again).
|
||||
for i in $NIX_CROSS_LDFLAGS_BEFORE; do
|
||||
if test "${i:0:3}" = "-L/"; then
|
||||
extraBefore=(${extraBefore[@]} "$i")
|
||||
else
|
||||
extraBefore=(${extraBefore[@]} "-Wl,$i")
|
||||
fi
|
||||
done
|
||||
for i in $NIX_CROSS_LDFLAGS; do
|
||||
if test "${i:0:3}" = "-L/"; then
|
||||
|
@ -1,6 +1,8 @@
|
||||
NIX_CROSS_CFLAGS_COMPILE=""
|
||||
NIX_CROSS_LDFLAGS=""
|
||||
|
||||
set -x
|
||||
|
||||
crossAddCVars () {
|
||||
if test -d $1/include; then
|
||||
export NIX_CROSS_CFLAGS_COMPILE="$NIX_CROSS_CFLAGS_COMPILE -I$1/include"
|
||||
@ -26,7 +28,7 @@ crossStripDirs() {
|
||||
dirs=${dirsNew}
|
||||
|
||||
if test -n "${dirs}"; then
|
||||
header "stripping (with flags $stripFlags) in $dirs"
|
||||
header "cross stripping (with flags $stripFlags) in $dirs"
|
||||
# libc_nonshared.a should never be stripped, or builds will break.
|
||||
find $dirs -type f -print0 | xargs -0 ${xargsFlags:--r} $crossConfig-strip $stripFlags || true
|
||||
stopNest
|
||||
@ -80,3 +82,5 @@ if test "$NIX_NO_SELF_RPATH" != "1"; then
|
||||
export NIX_CROSS_LDFLAGS="-rpath $out/lib64 -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
|
||||
fi
|
||||
fi
|
||||
|
||||
set +x
|
||||
|
@ -30,6 +30,12 @@ stdenv.mkDerivation rec {
|
||||
# It's configure does not like --build or --host
|
||||
export configureFlags="--libdir=lib --cross-compile-prefix=${stdenv.cross.config}- shared ${opensslCrossSystem}"
|
||||
'';
|
||||
|
||||
# Openssl installs readonly files, which otherwise we can't strip.
|
||||
# This could at some stdenv hash change be put out of crossAttrs, too
|
||||
postInstall = ''
|
||||
chmod -R +w $out
|
||||
'';
|
||||
configureScript = "./Configure";
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user