about summary refs log tree commit diff
path: root/pkgs/build-support/gcc-cross-wrapper
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2009-11-22 19:51:45 +0000
committerLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2009-11-22 19:51:45 +0000
commit585ba8c27f766a15abcab22c232170f6ae1cc0a9 (patch)
tree6b2411a130c9683b6696a63da584e56137029caf /pkgs/build-support/gcc-cross-wrapper
parent9dcff09187d5e41ed9bf4d841243a4bf6082c719 (diff)
Big fixes in the cross build:
- Before this changes, cflags and ldflags for the native and the cross compiler
  got mixed. Not all the gcc-wrapper/gcc-cross-wrapper variables are
  independant now, but enough, I think.
- Fixed the generic stdenv expression, which did a big mess on buildInputs and
  buildNativeInputs. Now it distinguishes when there is a stdenvCross or not.
  Maybe we should have a single stdenv and forget about the stdenvCross
  adapter - this could end in a stdenv a bit complex, but simpler than the
  generic stdenv + adapter.
- Added basic support in pkgconfig for cross-builds: a single PKG_CONFIG_PATH
  now works for both the cross and the native compilers, but I think this
  should work well for most cases I can think of.
- I tried to fix the guile expression to cross-biuld; guile is built, but not
  its manual, so the derivation still fails. Guile requires patching to
  cross-build, as far as I understnad.
- Made the glibcCross build to be done through the usage of a
  gcc-cross-wrapper over the gcc-cross-stage-static, instead of using it
  directly.
- Trying to make physfs (a neverball dependency) cross build.
- Updated the gcc expression to support building a cross compiler without getting
  derivation variables mixed with those of the stdenvCross.

svn path=/nixpkgs/branches/stdenv-updates/; revision=18534
Diffstat (limited to 'pkgs/build-support/gcc-cross-wrapper')
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/add-flags10
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/default.nix4
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh14
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh10
-rw-r--r--pkgs/build-support/gcc-cross-wrapper/setup-hook.sh18
5 files changed, 32 insertions, 24 deletions
diff --git a/pkgs/build-support/gcc-cross-wrapper/add-flags b/pkgs/build-support/gcc-cross-wrapper/add-flags
index ac1e58ebb8126..9ff4522e800b5 100644
--- a/pkgs/build-support/gcc-cross-wrapper/add-flags
+++ b/pkgs/build-support/gcc-cross-wrapper/add-flags
@@ -1,5 +1,5 @@
-export NIX_CFLAGS_COMPILE="@cflagsCompile@ $NIX_CFLAGS_COMPILE"
-export NIX_CFLAGS_LINK="@cflagsLink@ $NIX_CFLAGS_LINK"
-export NIX_LDFLAGS="@ldflags@ $NIX_LDFLAGS"
-export NIX_LDFLAGS_BEFORE="@ldflagsBefore@ $NIX_LDFLAGS_BEFORE"
-export NIX_GLIBC_FLAGS_SET=1
+export NIX_CROSS_CFLAGS_COMPILE="@cflagsCompile@ $NIX_CROSS_CFLAGS_COMPILE"
+export NIX_CROSS_CFLAGS_LINK="@cflagsLink@ $NIX_CROSS_CFLAGS_LINK"
+export NIX_CROSS_LDFLAGS="@ldflags@ $NIX_CROSS_LDFLAGS"
+export NIX_CROSS_LDFLAGS_BEFORE="@ldflagsBefore@ $NIX_CROSS_LDFLAGS_BEFORE"
+export NIX_CROSS_GLIBC_FLAGS_SET=1
diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix
index 140432adfbca1..362e378273dd2 100644
--- a/pkgs/build-support/gcc-cross-wrapper/default.nix
+++ b/pkgs/build-support/gcc-cross-wrapper/default.nix
@@ -6,7 +6,7 @@
 # variables so that the compiler and the linker just "work".
 
 { name ? "", stdenv, nativeTools, nativeLibc, noLibc ? false, nativePrefix ? ""
-, gcc ? null, libc ? null, binutils ? null, shell ? "", cross ? ""
+, gcc ? null, libc ? null, binutils ? null, shell ? "", cross
 }:
 
 assert nativeTools -> nativePrefix != "";
@@ -32,6 +32,6 @@ stdenv.mkDerivation {
     };
 
   passthru = {
-    inherit cross;
+    target = cross;
   };
 }
diff --git a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
index e5a2f5e65bb11..491de8f7f9848 100644
--- a/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/gcc-wrapper.sh
@@ -4,7 +4,7 @@ if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
     source "$NIX_GCC_WRAPPER_START_HOOK"
 fi
 
-if test -z "$NIX_GLIBC_FLAGS_SET"; then
+if test -z "$NIX_CROSS_GLIBC_FLAGS_SET"; then
     source @out@/nix-support/add-flags
 fi
 
@@ -63,28 +63,28 @@ fi
 
 
 # Add the flags for the C compiler proper.
-extraAfter=($NIX_CFLAGS_COMPILE)
+extraAfter=($NIX_CROSS_CFLAGS_COMPILE)
 extraBefore=()
 
 if test "$dontLink" != "1"; then
 
     # Add the flags that should only be passed to the compiler when
     # linking.
-    extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK)
+    extraAfter=(${extraAfter[@]} $NIX_CROSS_CFLAGS_LINK)
 
     # Add the flags that should be passed to the linker (and prevent
-    # `ld-wrapper' from adding NIX_LDFLAGS again).
-    for i in $NIX_LDFLAGS_BEFORE; do
+    # `ld-wrapper' from adding NIX_CROSS_LDFLAGS again).
+    for i in $NIX_CROSS_LDFLAGS_BEFORE; do
         extraBefore=(${extraBefore[@]} "-Wl,$i")
     done
-    for i in $NIX_LDFLAGS; do
+    for i in $NIX_CROSS_LDFLAGS; do
 	if test "${i:0:3}" = "-L/"; then
 	    extraAfter=(${extraAfter[@]} "$i")
 	else
 	    extraAfter=(${extraAfter[@]} "-Wl,$i")
 	fi
     done
-    export NIX_LDFLAGS_SET=1
+    export NIX_CROSS_LDFLAGS_SET=1
 
     if test "$NIX_STRIP_DEBUG" = "1"; then
         # Add executable-stripping flags.
diff --git a/pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh
index f3ff33f5c2516..226fad8335999 100644
--- a/pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/ld-wrapper.sh
@@ -4,7 +4,7 @@ if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
     source "$NIX_LD_WRAPPER_START_HOOK"
 fi
 
-if test -z "$NIX_GLIBC_FLAGS_SET"; then
+if test -z "$NIX_CROSS_GLIBC_FLAGS_SET"; then
     source @out@/nix-support/add-flags
 fi
 
@@ -14,7 +14,7 @@ source @out@/nix-support/utils
 # 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
+        -a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_CROSS_LDFLAGS_SET" \); then
     rest=()
     n=0
     while test $n -lt ${#params[*]}; do
@@ -44,9 +44,9 @@ fi
 extra=()
 extraBefore=()
 
-if test -z "$NIX_LDFLAGS_SET"; then
-    extra=(${extra[@]} $NIX_LDFLAGS)
-    extraBefore=(${extraBefore[@]} $NIX_LDFLAGS_BEFORE)
+if test -z "$NIX_CROSS_LDFLAGS_SET"; then
+    extra=(${extra[@]} $NIX_CROSS_LDFLAGS)
+    extraBefore=(${extraBefore[@]} $NIX_CROSS_LDFLAGS_BEFORE)
 fi
 
 
diff --git a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
index 99618cb21124c..d854f5ff0d7c2 100644
--- a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
+++ b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh
@@ -1,14 +1,14 @@
-addCVars () {
+crossAddCVars () {
     if test -d $1/include; then
-        export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$1/include"
+        export NIX_CROSS_CFLAGS_COMPILE="$NIX_CROSS_CFLAGS_COMPILE -I$1/include"
     fi
 
     if test -d $1/lib; then
-        export NIX_LDFLAGS="$NIX_LDFLAGS -L$1/lib"
+        export NIX_CROSS_LDFLAGS="$NIX_CROSS_LDFLAGS -L$1/lib"
     fi
 }
 
-crossEnvHooks=(${crossEnvHooks[@]} addCVars)
+crossEnvHooks=(${crossEnvHooks[@]} crossAddCVars)
 
 # Note: these come *after* $out in the PATH (see setup.sh).
 
@@ -22,10 +22,18 @@ fi
 
 if test -n "@libc@"; then
     PATH=$PATH:@libc@/bin
-    addCVars @libc@
+    crossAddCVars @libc@
 fi
 
 configureFlags="$configureFlags --build=$system --host=$crossConfig"
 # Disabling the tests when cross compiling, as usually the tests are meant for
 # native compilations.
 doCheck=""
+
+# Add the output as an rpath.
+if test "$NIX_NO_SELF_RPATH" != "1"; then
+    export NIX_CROSS_LDFLAGS="-rpath $out/lib -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
+    if test -n "$NIX_LIB64_IN_SELF_RPATH"; then
+        export NIX_CROSS_LDFLAGS="-rpath $out/lib64 -rpath-link $out/lib $NIX_CROSS_LDFLAGS"
+    fi
+fi