forked from mirrors/nixpkgs
* addCoverageInstrumentation: factor out the code that keeps the build
tree under $out into a separate stdenv adapter named keepBuildTree. * makeModulesClosure: support building an initrd for a kernel that has been compiled with coverage instrumentation. svn path=/nixpkgs/trunk/; revision=16916
This commit is contained in:
parent
043fe38f80
commit
58e6161768
|
@ -3,11 +3,13 @@
|
||||||
# the modules identified by `rootModules', plus their dependencies.
|
# the modules identified by `rootModules', plus their dependencies.
|
||||||
# Also generate an appropriate modules.dep.
|
# Also generate an appropriate modules.dep.
|
||||||
|
|
||||||
{stdenv, kernel, rootModules, module_init_tools, allowMissing ? false}:
|
{ stdenv, kernel, nukeReferences, rootModules
|
||||||
|
, module_init_tools, allowMissing ? false }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = kernel.name + "-shrunk";
|
name = kernel.name + "-shrunk";
|
||||||
builder = ./modules-closure.sh;
|
builder = ./modules-closure.sh;
|
||||||
|
buildInputs = [nukeReferences];
|
||||||
inherit kernel rootModules module_init_tools allowMissing;
|
inherit kernel rootModules module_init_tools allowMissing;
|
||||||
allowedReferences = ["out"];
|
allowedReferences = ["out"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,11 @@ for module in $closure; do
|
||||||
mkdir -p $(dirname $target)
|
mkdir -p $(dirname $target)
|
||||||
echo $module
|
echo $module
|
||||||
cp $module $target
|
cp $module $target
|
||||||
|
# If the kernel is compiled with coverage instrumentation, it
|
||||||
|
# contains the paths of the *.gcda coverage data output files
|
||||||
|
# (which it doesn't actually use...). Get rid of them to prevent
|
||||||
|
# the whole kernel from being included in the initrd.
|
||||||
|
nuke-refs $target
|
||||||
echo $target >> $out/insmod-list
|
echo $target >> $out/insmod-list
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -121,33 +121,33 @@ rec {
|
||||||
{ mkDerivation = args: stdenv.mkDerivation (args // extraAttrs); };
|
{ mkDerivation = args: stdenv.mkDerivation (args // extraAttrs); };
|
||||||
|
|
||||||
|
|
||||||
|
/* Return a modified stdenv that perfoms the build under $out/.build
|
||||||
|
instead of in $TMPDIR. Thus, the sources are kept available.
|
||||||
|
This is useful for things like debugging or generation of
|
||||||
|
dynamic analysis reports. */
|
||||||
|
keepBuildTree = stdenv:
|
||||||
|
addAttrsToDerivation
|
||||||
|
{ prePhases = "moveBuildDir";
|
||||||
|
|
||||||
|
moveBuildDir =
|
||||||
|
''
|
||||||
|
ensureDir $out/.build
|
||||||
|
cd $out/.build
|
||||||
|
'';
|
||||||
|
} stdenv;
|
||||||
|
|
||||||
|
|
||||||
/* Return a modified stdenv that builds packages with GCC's coverage
|
/* Return a modified stdenv that builds packages with GCC's coverage
|
||||||
instrumentation. The coverage note files (*.gcno) are stored in
|
instrumentation. The coverage note files (*.gcno) are stored in
|
||||||
$out/.coverage, along with the source code of the package, to
|
$out/.build, along with the source code of the package, to enable
|
||||||
enable programs like lcov to produce pretty-printed reports.
|
programs like lcov to produce pretty-printed reports.
|
||||||
*/
|
*/
|
||||||
addCoverageInstrumentation = stdenv:
|
addCoverageInstrumentation = stdenv:
|
||||||
addAttrsToDerivation
|
addAttrsToDerivation
|
||||||
{ NIX_CFLAGS_COMPILE = "-O0 --coverage";
|
{ NIX_CFLAGS_COMPILE = "-O0 --coverage";
|
||||||
|
|
||||||
prePhases = "moveBuildDir";
|
|
||||||
postPhases = "cleanupBuildDir";
|
postPhases = "cleanupBuildDir";
|
||||||
|
|
||||||
# Object files instrumented with coverage analysis write
|
|
||||||
# runtime coverage data to <path>/<object>.gcda, where <path>
|
|
||||||
# is the location where gcc originally created the object
|
|
||||||
# file. That would be /tmp/nix-build-<something>, which will
|
|
||||||
# be long gone by the time we run the program. Furthermore,
|
|
||||||
# the <object>.gcno files created at compile time are also
|
|
||||||
# written there. And to make nice coverage reports with lcov,
|
|
||||||
# we need the source code. So we move the whole build tree to
|
|
||||||
# $out/.coverage.
|
|
||||||
moveBuildDir =
|
|
||||||
''
|
|
||||||
ensureDir $out/.coverage
|
|
||||||
cd $out/.coverage
|
|
||||||
'';
|
|
||||||
|
|
||||||
# This is an uberhack to prevent libtool from removing gcno
|
# This is an uberhack to prevent libtool from removing gcno
|
||||||
# files. This has been fixed in libtool, but there are
|
# files. This has been fixed in libtool, but there are
|
||||||
# packages out there with old ltmain.sh scripts.
|
# packages out there with old ltmain.sh scripts.
|
||||||
|
@ -165,10 +165,21 @@ rec {
|
||||||
# suite.
|
# suite.
|
||||||
cleanupBuildDir =
|
cleanupBuildDir =
|
||||||
''
|
''
|
||||||
find $out/.coverage/ -type f -a ! \
|
find $out/.build/ -type f -a ! \
|
||||||
\( -name "*.c" -o -name "*.gcno" -o -name "*.h" \) \
|
\( -name "*.c" -o -name "*.gcno" -o -name "*.h" \) \
|
||||||
| xargs rm -f --
|
| xargs rm -f --
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
stdenv;
|
|
||||||
|
# Object files instrumented with coverage analysis write
|
||||||
|
# runtime coverage data to <path>/<object>.gcda, where <path>
|
||||||
|
# is the location where gcc originally created the object
|
||||||
|
# file. That would be /tmp/nix-build-<something>, which will
|
||||||
|
# be long gone by the time we run the program. Furthermore,
|
||||||
|
# the <object>.gcno files created at compile time are also
|
||||||
|
# written there. And to make nice coverage reports with lcov,
|
||||||
|
# we need the source code. So we have to use the
|
||||||
|
# `keepBuildTree' adapter as well.
|
||||||
|
(keepBuildTree stdenv);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,7 +228,7 @@ let
|
||||||
inherit (import ../stdenv/adapters.nix {inherit (pkgs) dietlibc fetchurl runCommand;})
|
inherit (import ../stdenv/adapters.nix {inherit (pkgs) dietlibc fetchurl runCommand;})
|
||||||
overrideGCC overrideInStdenv overrideSetup
|
overrideGCC overrideInStdenv overrideSetup
|
||||||
useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation
|
useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation
|
||||||
addCoverageInstrumentation;
|
keepBuildTree addCoverageInstrumentation;
|
||||||
|
|
||||||
|
|
||||||
### BUILD SUPPORT
|
### BUILD SUPPORT
|
||||||
|
@ -324,7 +324,8 @@ let
|
||||||
|
|
||||||
makeModulesClosure = {kernel, rootModules, allowMissing ? false}:
|
makeModulesClosure = {kernel, rootModules, allowMissing ? false}:
|
||||||
import ../build-support/kernel/modules-closure.nix {
|
import ../build-support/kernel/modules-closure.nix {
|
||||||
inherit stdenv module_init_tools kernel rootModules allowMissing;
|
inherit stdenv module_init_tools kernel nukeReferences
|
||||||
|
rootModules allowMissing;
|
||||||
};
|
};
|
||||||
|
|
||||||
pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;
|
pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;
|
||||||
|
@ -5169,8 +5170,7 @@ let
|
||||||
[(getConfig ["kernel" "addConfig"] "")];
|
[(getConfig ["kernel" "addConfig"] "")];
|
||||||
};
|
};
|
||||||
|
|
||||||
kernel_2_6_28 = (
|
kernel_2_6_28 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.28.nix) {
|
||||||
import ../os-specific/linux/kernel/linux-2.6.28.nix {
|
|
||||||
inherit fetchurl stdenv perl mktemp module_init_tools;
|
inherit fetchurl stdenv perl mktemp module_init_tools;
|
||||||
kernelPatches = [
|
kernelPatches = [
|
||||||
{ name = "fbcondecor-0.9.5-2.6.28";
|
{ name = "fbcondecor-0.9.5-2.6.28";
|
||||||
|
@ -5196,7 +5196,7 @@ let
|
||||||
extraConfig =
|
extraConfig =
|
||||||
lib.optional (getConfig ["kernel" "no_irqbalance"] false) "# CONFIG_IRQBALANCE is not set" ++
|
lib.optional (getConfig ["kernel" "no_irqbalance"] false) "# CONFIG_IRQBALANCE is not set" ++
|
||||||
[(getConfig ["kernel" "addConfig"] "")];
|
[(getConfig ["kernel" "addConfig"] "")];
|
||||||
});
|
};
|
||||||
|
|
||||||
kernel_2_6_29 = (
|
kernel_2_6_29 = (
|
||||||
makeOverridable (import ../os-specific/linux/kernel/linux-2.6.29.nix) {
|
makeOverridable (import ../os-specific/linux/kernel/linux-2.6.29.nix) {
|
||||||
|
@ -5279,8 +5279,7 @@ let
|
||||||
for a specific kernel. This function can then be called for
|
for a specific kernel. This function can then be called for
|
||||||
whatever kernel you're using. */
|
whatever kernel you're using. */
|
||||||
|
|
||||||
kernelPackagesFor = kernel:
|
kernelPackagesFor = kernel: rec {
|
||||||
rec {
|
|
||||||
|
|
||||||
inherit kernel;
|
inherit kernel;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue