From d5097ad3d313dfcad73fe303618dd6d66dc8792e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Mon, 9 Aug 2010 21:37:31 +0000 Subject: [PATCH] Breaking dependencies on the cross-built gcc through the gcc-cross-wrapper. svn path=/nixpkgs/branches/stdenv-updates/; revision=23073 --- pkgs/build-support/gcc-cross-wrapper/builder.sh | 16 ++++++++++------ pkgs/build-support/gcc-cross-wrapper/default.nix | 11 +++++++---- .../gcc-cross-wrapper/gcc-wrapper.sh | 16 ++++++++++------ .../gcc-cross-wrapper/setup-hook.sh | 6 +++++- pkgs/development/libraries/openssl/default.nix | 6 ++++++ 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/pkgs/build-support/gcc-cross-wrapper/builder.sh b/pkgs/build-support/gcc-cross-wrapper/builder.sh index ef46cc110f2e..85d5f19fbc91 100644 --- a/pkgs/build-support/gcc-cross-wrapper/builder.sh +++ b/pkgs/build-support/gcc-cross-wrapper/builder.sh @@ -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" diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix index ea5e5d0dd564..8bf820e3d341 100644 --- a/pkgs/build-support/gcc-cross-wrapper/default.nix +++ b/pkgs/build-support/gcc-cross-wrapper/default.nix @@ -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 diff --git a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh index 491de8f7f984..98baafb4878d 100644 --- a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh +++ b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh @@ -75,14 +75,18 @@ 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 - extraBefore=(${extraBefore[@]} "-Wl,$i") + 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 - extraAfter=(${extraAfter[@]} "$i") - else - extraAfter=(${extraAfter[@]} "-Wl,$i") - fi + if test "${i:0:3}" = "-L/"; then + extraAfter=(${extraAfter[@]} "$i") + else + extraAfter=(${extraAfter[@]} "-Wl,$i") + fi done export NIX_CROSS_LDFLAGS_SET=1 diff --git a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh index 0c98062a2db1..96498c0e2469 100644 --- a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh +++ b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh @@ -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 diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix index e483af7206e5..d19ca77a1895 100644 --- a/pkgs/development/libraries/openssl/default.nix +++ b/pkgs/development/libraries/openssl/default.nix @@ -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"; };