* 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
This commit is contained in:
79
pkgs/test/rpath/builder.sh
Normal file
79
pkgs/test/rpath/builder.sh
Normal file
@@ -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
|
||||
18
pkgs/test/rpath/default.nix
Normal file
18
pkgs/test/rpath/default.nix
Normal file
@@ -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;
|
||||
}
|
||||
7
pkgs/test/rpath/src/hello1.c
Normal file
7
pkgs/test/rpath/src/hello1.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello World!\n");
|
||||
return 0;
|
||||
}
|
||||
7
pkgs/test/rpath/src/hello2.cc
Normal file
7
pkgs/test/rpath/src/hello2.cc
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
std::cout << "Hello World!\n";
|
||||
return 0;
|
||||
}
|
||||
9
pkgs/test/rpath/src/hello3.c
Normal file
9
pkgs/test/rpath/src/hello3.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
char * text();
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf(text());
|
||||
return 0;
|
||||
}
|
||||
4
pkgs/test/rpath/src/text.c
Normal file
4
pkgs/test/rpath/src/text.c
Normal file
@@ -0,0 +1,4 @@
|
||||
char * text()
|
||||
{
|
||||
return "Hello World!\n";
|
||||
}
|
||||
Reference in New Issue
Block a user