summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2004-04-04 22:02:41 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2004-04-04 22:02:41 +0000
commitbeaff0a8929b14bca736cb96a1bbf4c2e1c604d6 (patch)
treec93f32f82be57ea066cc2ebb5c919fe1b9f4b7ad /pkgs/test
parent0d4967fc35631ebfe9869739d01e713d60bd21ff (diff)
downloadnixlib-beaff0a8929b14bca736cb96a1bbf4c2e1c604d6.tar
nixlib-beaff0a8929b14bca736cb96a1bbf4c2e1c604d6.tar.gz
nixlib-beaff0a8929b14bca736cb96a1bbf4c2e1c604d6.tar.bz2
nixlib-beaff0a8929b14bca736cb96a1bbf4c2e1c604d6.tar.lz
nixlib-beaff0a8929b14bca736cb96a1bbf4c2e1c604d6.tar.xz
nixlib-beaff0a8929b14bca736cb96a1bbf4c2e1c604d6.tar.zst
nixlib-beaff0a8929b14bca736cb96a1bbf4c2e1c604d6.zip
* Ensure that when building gcc, libstdc++ is linked against the
  libgcc of the gcc being built, not the gcc building it.
* Only include a directory in the rpath of an executable/library if it
  is actually used.  Before, the `/lib' directory of every build input
  was added to the rpath, causing many unnecessary retained
  dependencies.  For instance, Perl has a `/lib' directory, but most
  applications whose build process uses Perl don't actually link
  against Perl.  (Also added a test for this.)
* After building glibc, remove glibcbug, to prevent a retained
  dependency on gcc.
* Add a newline after `building X' in GNU Make.

svn path=/nixpkgs/trunk/; revision=911
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/rpath/builder.sh79
-rw-r--r--pkgs/test/rpath/default.nix18
-rw-r--r--pkgs/test/rpath/src/hello1.c7
-rw-r--r--pkgs/test/rpath/src/hello2.cc7
-rw-r--r--pkgs/test/rpath/src/hello3.c9
-rw-r--r--pkgs/test/rpath/src/text.c4
6 files changed, 124 insertions, 0 deletions
diff --git a/pkgs/test/rpath/builder.sh b/pkgs/test/rpath/builder.sh
new file mode 100644
index 000000000000..0a75e1cd33a7
--- /dev/null
+++ b/pkgs/test/rpath/builder.sh
@@ -0,0 +1,79 @@
+export NIX_DEBUG=1
+
+. $stdenv/setup
+
+mkdir $out
+mkdir $out/bin
+
+
+# 1: link statically against glibc.
+res=$out/bin/hello1
+gcc -static $src/hello1.c -o $res
+
+case $(ldd $res) in
+  *"not a dynamic executable"*)
+        ;;
+  *)
+        echo "$res not statically linked!"
+        exit 1
+esac
+
+
+# 2: link dynamically against glibc.
+res=$out/bin/hello2
+gcc $src/hello1.c -o $res
+
+case $(ldd $res) in
+  */store/*glibc*/lib/libc.so*/store/*glibc*/lib/ld-linux.so*)
+        ;;
+  *)
+        echo "$res not dynamically linked / bad rpath!"
+        exit 1
+        ;;
+esac
+
+
+# 3: link C++ dynamically against glibc / libstdc++.
+res=$out/bin/hello3
+g++ $src/hello2.cc -o $res
+
+case $(ldd $res) in
+  */store/*gcc*/lib/*libstdc++*/store/*glibc*/lib/libm*/store/*gcc*/lib/libgcc_s*/store/*glibc*/lib/libc.so*/store/*glibc*/lib/ld-linux.so*)
+        ;;
+  *)
+        echo "$res not dynamically linked / bad rpath!"
+        exit 1
+        ;;
+esac
+
+
+# 4: build dynamic library locally, link against it, copy it.
+res=$out/bin/hello4
+mkdir bla
+gcc -shared $src/text.c -o bla/libtext.so 
+gcc $src/hello3.c -o $res -L$(pwd)/bla -ltext
+mkdir $out/lib
+
+case $(ldd $res) in
+  */tmp*)
+        echo "$res depends on file in /tmp!"
+        exit 1
+        ;;
+esac
+
+cp bla/libtext.so $out/lib
+
+case $(ldd $res) in
+  */store/*glibc*/lib/libc.so*/store/*glibc*/lib/ld-linux.so*)
+        ;;
+  *)
+        echo "$res not dynamically linked / bad rpath!"
+        exit 1
+        ;;
+esac
+
+
+# Run the programs we just made.
+for i in $out/bin/*; do
+    $i
+done
diff --git a/pkgs/test/rpath/default.nix b/pkgs/test/rpath/default.nix
new file mode 100644
index 000000000000..f0903420c96a
--- /dev/null
+++ b/pkgs/test/rpath/default.nix
@@ -0,0 +1,18 @@
+let {
+  system = "i686-linux";
+
+  stdenvs = (import ../../system/stdenvs.nix) {
+    inherit system;
+    allPackages = import ../../system/all-packages-generic.nix;
+  };
+
+  stdenv = stdenvs.stdenvLinuxBoot2;
+
+  test = stdenv.mkDerivation {
+    name = "rpath-test";
+    builder = ./builder.sh;
+    src = ./src;
+  };
+
+  body = test;
+}
diff --git a/pkgs/test/rpath/src/hello1.c b/pkgs/test/rpath/src/hello1.c
new file mode 100644
index 000000000000..c44d7c4a936d
--- /dev/null
+++ b/pkgs/test/rpath/src/hello1.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char * * argv)
+{
+    printf("Hello World!\n");
+    return 0;
+}
diff --git a/pkgs/test/rpath/src/hello2.cc b/pkgs/test/rpath/src/hello2.cc
new file mode 100644
index 000000000000..0dc34766f5f1
--- /dev/null
+++ b/pkgs/test/rpath/src/hello2.cc
@@ -0,0 +1,7 @@
+#include <iostream>
+
+int main(int argc, char * * argv)
+{
+    std::cout << "Hello World!\n";
+    return 0;
+}
diff --git a/pkgs/test/rpath/src/hello3.c b/pkgs/test/rpath/src/hello3.c
new file mode 100644
index 000000000000..2b2308360da4
--- /dev/null
+++ b/pkgs/test/rpath/src/hello3.c
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+char * text();
+
+int main(int argc, char * * argv)
+{
+    printf(text());
+    return 0;
+}
diff --git a/pkgs/test/rpath/src/text.c b/pkgs/test/rpath/src/text.c
new file mode 100644
index 000000000000..3d85ca23f795
--- /dev/null
+++ b/pkgs/test/rpath/src/text.c
@@ -0,0 +1,4 @@
+char * text()
+{
+    return "Hello World!\n";
+}