3
0
Fork 0
forked from mirrors/nixpkgs

Removing any rest of the trunk's stdenv2, that has a fix in ld-wrapper to make

it properly put the rpath for directly passed .so files, and additionally it
works much faster than the old ld-wrapper.


svn path=/nixpkgs/branches/stdenv-updates/; revision=21978
This commit is contained in:
Lluís Batlle i Rossell 2010-05-25 20:51:01 +00:00
parent 249f35e20c
commit bd9c968158
4 changed files with 24 additions and 263 deletions

View file

@ -1,72 +0,0 @@
# 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".
{ name ? "", stdenv, nativeTools, nativeLibc, nativePrefix ? ""
, gcc ? null, libc ? null, binutils ? null, coreutils ? null, shell ? ""
, zlib ? null
}:
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;
let
gccVersion = (builtins.parseDrvName gcc.name).version;
gccName = (builtins.parseDrvName gcc.name).name;
in
stdenv.mkDerivation {
name =
(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-wrapper2.sh;
utils = ./utils.sh;
addFlags = ./add-flags;
inherit nativeTools nativeLibc nativePrefix 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 = 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 shell;
meta =
let gcc_ = if gcc != null then gcc else {}; in
(if gcc_ ? meta then removeAttrs gcc.meta ["priority"] else {}) //
{ description =
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
if stdenv.system == "armv5tel-linux" then "ld-linux.so.3" else
if stdenv.system == "powerpc-linux" then "ld.so.1" else
abort "don't know the name of the dynamic linker for this platform")
else "";
}

View file

@ -82,6 +82,13 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
rpath="$rpath $1 "
}
libs=""
addToLibs() {
libs="$libs $1"
}
rpath=""
# First, find all -L... switches.
allParams=("${params[@]}" ${extra[@]})
n=0
@ -93,6 +100,11 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
elif test "$p" = "-L"; then
addToLibPath ${p2}
n=$((n + 1))
elif test "$p" = "-l"; then
addToLibs ${p2}
n=$((n + 1))
elif test "${p:0:2}" = "-l"; then
addToLibs ${p:2}
elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
# This is a direct reference to a shared library, so add
# its directory to the rpath.
@ -105,24 +117,14 @@ if test "$NIX_DONT_SET_RPATH" != "1"; then
# Second, for each directory in the library search path (-L...),
# see if it contains a dynamic library used by a -l... flag. If
# so, add the directory to the rpath.
rpath=""
for i in $libPath; do
n=0
while test $n -lt ${#allParams[*]}; do
p=${allParams[n]}
p2=${allParams[$((n+1))]}
if test "${p:0:2}" = "-l" -a -f "$i/lib${p:2}.so"; then
addToRPath $i
break
elif test "$p" = "-l" -a -f "$i/lib${p2}"; then
# I haven't seen `-l foo', but you never know...
addToRPath $i
for i in $libs; do
for j in $libPath; do
if test -f "$j/lib$i.so"; then
addToRPath $j
break
fi
n=$((n + 1))
done
done

View file

@ -1,154 +0,0 @@
#! @shell@ -e
if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
source "$NIX_LD_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
# 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
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" = "-rpath" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "${p:0:1}" = "/" && badPath "$p"; then
# We cannot skip this; barf.
echo "impure path \`$p' used in link" >&2
exit 1
else
rest=("${rest[@]}" "$p")
fi
n=$((n + 1))
done
params=("${rest[@]}")
fi
extra=()
extraBefore=()
if test -z "$NIX_LDFLAGS_SET"; then
extra=(${extra[@]} $NIX_LDFLAGS)
extraBefore=(${extraBefore[@]} $NIX_LDFLAGS_BEFORE)
fi
# Add all used dynamic libraries to the rpath.
if test "$NIX_DONT_SET_RPATH" != "1"; then
libPath=""
addToLibPath() {
local path="$1"
if test "${path:0:1}" != "/"; then return 0; fi
case "$path" in
*..*|*./*|*/.*|*//*)
local path2
if path2=$(readlink -f "$path"); then
path="$path2"
fi
;;
esac
case $libPath in
*\ $path\ *) return 0 ;;
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
case $rpath in
*\ $1\ *) return 0 ;;
esac
rpath="$rpath $1 "
}
libs=""
addToLibs() {
libs="$libs $1"
}
rpath=""
# First, find all -L... switches.
allParams=("${params[@]}" ${extra[@]})
n=0
while test $n -lt ${#allParams[*]}; do
p=${allParams[n]}
p2=${allParams[$((n+1))]}
if test "${p:0:3}" = "-L/"; then
addToLibPath ${p:2}
elif test "$p" = "-L"; then
addToLibPath ${p2}
n=$((n + 1))
elif test "$p" = "-l"; then
addToLibs ${p2}
n=$((n + 1))
elif test "${p:0:2}" = "-l"; then
addToLibs ${p:2}
elif [[ "$p" =~ ^[^-].*\.so($|\.) ]]; then
# This is a direct reference to a shared library, so add
# its directory to the rpath.
path="$(dirname "$p")";
addToRPath "${path}"
fi
n=$((n + 1))
done
# Second, for each directory in the library search path (-L...),
# see if it contains a dynamic library used by a -l... flag. If
# so, add the directory to the rpath.
for i in $libs; do
for j in $libPath; do
if test -f "$j/lib$i.so"; then
addToRPath $j
break
fi
done
done
# Finally, add `-rpath' switches.
for i in $rpath; do
extra=(${extra[@]} -rpath $i)
done
fi
# Optionally print debug info.
if test "$NIX_DEBUG" = "1"; then
echo "original flags to @ld@:" >&2
for i in "${params[@]}"; do
echo " $i" >&2
done
echo "extra flags to @ld@:" >&2
for i in ${extra[@]}; do
echo " $i" >&2
done
fi
if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then
source "$NIX_LD_WRAPPER_EXEC_HOOK"
fi
exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]}

View file

@ -2623,14 +2623,6 @@ let
wrapGCC = wrapGCCWith (import ../build-support/gcc-wrapper) glibc;
# To be removed on stdenv-updates
# By now this has at least the fix of setting the proper rpath when a file "libbla.so"
# is passed directly to the linker.
# This is of interest to programs built by cmake, because this is a common practice
# in cmake builds.
wrapGCC2 = wrapGCCWith (import ../build-support/gcc-wrapper/default2.nix) glibc;
stdenv2 = if (gcc.nativeTools) then stdenv else (overrideGCC stdenv (wrapGCC2 gcc.gcc));
wrapGCCCross =
{gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}:
@ -4954,11 +4946,10 @@ let
};
opencv = import ../development/libraries/opencv {
inherit fetchurl cmake libjpeg libpng libtiff jasper ffmpeg
inherit stdenv fetchurl cmake libjpeg libpng libtiff jasper ffmpeg
pkgconfig xineLib;
inherit (gtkLibs) gtk glib;
inherit (gst_all) gstreamer;
stdenv = stdenv2;
};
# this ctl version is needed by openexr_viewers
@ -7179,11 +7170,10 @@ let
};
avidemux = import ../applications/video/avidemux {
inherit fetchurl cmake pkgconfig libxml2 qt4 gettext SDL libxslt x264
inherit stdenv fetchurl cmake pkgconfig libxml2 qt4 gettext SDL libxslt x264
alsaLib lame faac faad2 libvorbis;
inherit (gtkLibs) gtk;
inherit (xlibs) libXv pixman libpthreadstubs libXau libXdmcp;
stdenv = stdenv2;
};
awesome = import ../applications/window-managers/awesome {
@ -7239,19 +7229,17 @@ let
};
blender = import ../applications/misc/blender/2.49.nix {
inherit fetchurl cmake mesa gettext libjpeg libpng zlib openal SDL openexr
inherit stdenv fetchurl cmake mesa gettext libjpeg libpng zlib openal SDL openexr
libsamplerate libtiff ilmbase freetype;
inherit (xlibs) libXi;
python = python26Base;
stdenv = stdenv2;
};
blender_2_50 = lowPrio (import ../applications/misc/blender {
inherit fetchurl cmake mesa gettext libjpeg libpng zlib openal SDL openexr
inherit stdenv fetchurl cmake mesa gettext libjpeg libpng zlib openal SDL openexr
libsamplerate libtiff ilmbase;
inherit (xlibs) libXi;
python = python31Base;
stdenv = stdenv2;
});
bmp = import ../applications/audio/bmp {
@ -8257,7 +8245,7 @@ let
};
openoffice = import ../applications/office/openoffice {
inherit fetchurl pam python tcsh libxslt perl zlib libjpeg
inherit stdenv fetchurl pam python tcsh libxslt perl zlib libjpeg
expat pkgconfig freetype fontconfig libwpd libxml2 db4 sablotron
curl libsndfile flex zip unzip libmspack getopt file cairo
which icu jdk ant cups openssl bison boost gperf cppunit;
@ -8266,11 +8254,10 @@ let
inherit (perlPackages) ArchiveZip CompressZlib;
inherit (gnome) GConf ORBit2;
neon = neon026;
stdenv = stdenv2;
};
go_oo = import ../applications/office/openoffice/go-oo.nix {
inherit fetchurl pam python tcsh libxslt perl zlib libjpeg
inherit stdenv fetchurl pam python tcsh libxslt perl zlib libjpeg
expat pkgconfig freetype fontconfig libwpd libxml2 db4 sablotron
curl libsndfile flex zip unzip libmspack getopt file cairo
which icu jdk ant cups openssl bison boost gperf cppunit;
@ -8279,7 +8266,6 @@ let
inherit (perlPackages) ArchiveZip CompressZlib;
inherit (gnome) GConf ORBit2;
neon = neon026;
stdenv = stdenv2;
inherit autoconf openldap postgresql;
};
@ -8308,8 +8294,7 @@ let
};
paraview = import ../applications/graphics/paraview {
inherit fetchurl cmake qt4;
stdenv = stdenv2;
inherit stdenv fetchurl cmake qt4;
};
partitionManager = import ../tools/misc/partition-manager {
@ -9263,7 +9248,7 @@ let
kde44 = makeOverridable (import ../desktops/kde-4.4) (pkgs // {
openexr = openexr_1_6_1;
stdenv = stdenv2;
inherit stdenv;
});
xfce = xfce4;