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.
|
||||
# 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 {
|
||||
name = kernel.name + "-shrunk";
|
||||
builder = ./modules-closure.sh;
|
||||
buildInputs = [nukeReferences];
|
||||
inherit kernel rootModules module_init_tools allowMissing;
|
||||
allowedReferences = ["out"];
|
||||
}
|
||||
|
|
|
@ -29,6 +29,11 @@ for module in $closure; do
|
|||
mkdir -p $(dirname $target)
|
||||
echo $module
|
||||
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
|
||||
done
|
||||
|
||||
|
|
|
@ -121,33 +121,33 @@ rec {
|
|||
{ 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
|
||||
instrumentation. The coverage note files (*.gcno) are stored in
|
||||
$out/.coverage, along with the source code of the package, to
|
||||
enable programs like lcov to produce pretty-printed reports.
|
||||
$out/.build, along with the source code of the package, to enable
|
||||
programs like lcov to produce pretty-printed reports.
|
||||
*/
|
||||
addCoverageInstrumentation = stdenv:
|
||||
addAttrsToDerivation
|
||||
{ NIX_CFLAGS_COMPILE = "-O0 --coverage";
|
||||
|
||||
prePhases = "moveBuildDir";
|
||||
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
|
||||
# files. This has been fixed in libtool, but there are
|
||||
# packages out there with old ltmain.sh scripts.
|
||||
|
@ -165,10 +165,21 @@ rec {
|
|||
# suite.
|
||||
cleanupBuildDir =
|
||||
''
|
||||
find $out/.coverage/ -type f -a ! \
|
||||
\( -name "*.c" -o -name "*.gcno" -o -name "*.h" \) \
|
||||
| xargs rm -f --
|
||||
find $out/.build/ -type f -a ! \
|
||||
\( -name "*.c" -o -name "*.gcno" -o -name "*.h" \) \
|
||||
| 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;})
|
||||
overrideGCC overrideInStdenv overrideSetup
|
||||
useDietLibC useKlibc makeStaticBinaries addAttrsToDerivation
|
||||
addCoverageInstrumentation;
|
||||
keepBuildTree addCoverageInstrumentation;
|
||||
|
||||
|
||||
### BUILD SUPPORT
|
||||
|
@ -324,7 +324,8 @@ let
|
|||
|
||||
makeModulesClosure = {kernel, rootModules, allowMissing ? false}:
|
||||
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;
|
||||
|
@ -5169,8 +5170,7 @@ let
|
|||
[(getConfig ["kernel" "addConfig"] "")];
|
||||
};
|
||||
|
||||
kernel_2_6_28 = (
|
||||
import ../os-specific/linux/kernel/linux-2.6.28.nix {
|
||||
kernel_2_6_28 = makeOverridable (import ../os-specific/linux/kernel/linux-2.6.28.nix) {
|
||||
inherit fetchurl stdenv perl mktemp module_init_tools;
|
||||
kernelPatches = [
|
||||
{ name = "fbcondecor-0.9.5-2.6.28";
|
||||
|
@ -5196,7 +5196,7 @@ let
|
|||
extraConfig =
|
||||
lib.optional (getConfig ["kernel" "no_irqbalance"] false) "# CONFIG_IRQBALANCE is not set" ++
|
||||
[(getConfig ["kernel" "addConfig"] "")];
|
||||
});
|
||||
};
|
||||
|
||||
kernel_2_6_29 = (
|
||||
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
|
||||
whatever kernel you're using. */
|
||||
|
||||
kernelPackagesFor = kernel:
|
||||
rec {
|
||||
kernelPackagesFor = kernel: rec {
|
||||
|
||||
inherit kernel;
|
||||
|
||||
|
|
Loading…
Reference in a new issue