on iko/ghcjs-patch-master help sign in
Adds profiling support (#162)
ea6f125Moritz Angermann
builder/comp-builder.nix+9−1
@@ -32,6 +32,11 @@
32, doHaddock ? component.doHaddock # Enable haddock and hoogle generation
32, doHaddock ? component.doHaddock # Enable haddock and hoogle generation
33, doHoogle ? true # Also build a hoogle index
33, doHoogle ? true # Also build a hoogle index
34, hyperlinkSource ? true # Link documentation to the source code
34, hyperlinkSource ? true # Link documentation to the source code
35+
36+# Profiling
37+, enableLibraryProfiling ? component.enableLibraryProfiling
38+, enableExecutableProfiling ? component.enableExecutableProfiling
39+, profilingDetail ? component.profilingDetail
35}:
40}:
36
41
37let
42let
@@ -62,14 +67,17 @@ let
62 ] ++ [ # other flags
67 ] ++ [ # other flags
63 (if dontStrip then "--disable-executable-stripping" else "--enable-executable-stripping")
68 (if dontStrip then "--disable-executable-stripping" else "--enable-executable-stripping")
64 (if dontStrip then "--disable-library-stripping" else "--enable-library-stripping")
69 (if dontStrip then "--disable-library-stripping" else "--enable-library-stripping")
70+ (if enableLibraryProfiling then "--enable-library-profiling" else "--disable-library-profiling" )
71+ (if enableExecutableProfiling then "--enable-executable-profiling" else "--disable-executable-profiling" )
65 ] ++ lib.optional doHaddock' "--docdir=${docdir "$doc"}"
72 ] ++ lib.optional doHaddock' "--docdir=${docdir "$doc"}"
73+ ++ lib.optional (enableLibraryProfiling || enableExecutableProfiling) "--profiling-detail=${profilingDetail}"
66 ++ lib.optional (deadCodeElimination && stdenv.hostPlatform.isLinux) "--enable-split-sections"
74 ++ lib.optional (deadCodeElimination && stdenv.hostPlatform.isLinux) "--enable-split-sections"
67 ++ lib.optional (static) "--enable-static"
75 ++ lib.optional (static) "--enable-static"
68 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) (
76 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) (
69 map (arg: "--hsc2hs-option=" + arg) (["--cross-compile"] ++ lib.optionals (stdenv.hostPlatform.isWindows) ["--via-asm"])
77 map (arg: "--hsc2hs-option=" + arg) (["--cross-compile"] ++ lib.optionals (stdenv.hostPlatform.isWindows) ["--via-asm"])
70 ++ lib.optional (package.buildType == "Configure") "--configure-option=--host=${stdenv.hostPlatform.config}" )
78 ++ lib.optional (package.buildType == "Configure") "--configure-option=--host=${stdenv.hostPlatform.config}" )
71 ++ component.configureFlags
79 ++ component.configureFlags
72− );
80+ );
73
81
74 executableToolDepends =
82 executableToolDepends =
75 (lib.concatMap (c: if c.isHaskell or false
83 (lib.concatMap (c: if c.isHaskell or false
modules/plan.nix+16
@@ -78,6 +78,21 @@ let
78 type = unspecified; # Can be either a string or a function
78 type = unspecified; # Can be either a string or a function
79 default = (def.shellHook or "");
79 default = (def.shellHook or "");
80 };
80 };
81+ enableLibraryProfiling = mkOption {
82+ type = bool;
83+ default = (def.enableLibraryProfiling or false);
84+ };
85+
86+ enableExecutableProfiling = mkOption {
87+ type = bool;
88+ default = (def.enableExecutableProfiling or false);
89+ };
90+
91+ profilingDetail = mkOption {
92+ type = nullOr string;
93+ default = (def.profilingDetail or "exported-functions");
94+ };
95+
81 };
96 };
82 packageOptions = def: componentOptions def // {
97 packageOptions = def: componentOptions def // {
83 preUnpack = mkOption {
98 preUnpack = mkOption {
@@ -137,6 +152,7 @@ in {
137 # combined or replaced. We seed the package Options with an empty set forcing the
152 # combined or replaced. We seed the package Options with an empty set forcing the
138 # default values.
153 # default values.
139 options = (packageOptions {}) // {
154 options = (packageOptions {}) // {
155+
140 packages = mkOption {
156 packages = mkOption {
141 type =
157 type =
142 let mod_args = {
158 let mod_args = {
test/cabal-simple-prof/.plan.nix/cabal-simple.nixnew file+32
@@ -0,0 +1,32 @@
1+{ system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }:
2+ {
3+ flags = {};
4+ package = {
5+ specVersion = "1.10";
6+ identifier = { name = "cabal-simple"; version = "0.1.0.0"; };
7+ license = "LicenseRef-PublicDomain";
8+ copyright = "";
9+ maintainer = "rodney.lorrimar@iohk.io";
10+ author = "Rodney Lorrimar";
11+ homepage = "";
12+ url = "";
13+ synopsis = "";
14+ description = "";
15+ buildType = "Simple";
16+ };
17+ components = {
18+ "library" = {
19+ depends = [ (hsPkgs.base) (hsPkgs.extra) (hsPkgs.safe) (hsPkgs.aeson) ];
20+ };
21+ exes = {
22+ "cabal-simple" = {
23+ depends = [
24+ (hsPkgs.base)
25+ (hsPkgs.cabal-simple)
26+ (hsPkgs.extra)
27+ (hsPkgs.optparse-applicative)
28+ ];
29+ };
30+ };
31+ };
32+ } // rec { src = (pkgs.lib).mkDefault ../.; }
test/cabal-simple-prof/Main.hsnew file+4
@@ -0,0 +1,4 @@
1+module Main where
2+
3+main :: IO ()
4+main = putStrLn "Hello, Haskell!"
test/cabal-simple-prof/Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
test/cabal-simple-prof/cabal-simple.cabalnew file+37
@@ -0,0 +1,37 @@
1+cabal-version: >=1.10
2+-- Initial package description 'cabal-simple.cabal' generated by 'cabal
3+-- init'. For further documentation, see
4+-- http://haskell.org/cabal/users-guide/
5+
6+name: cabal-simple
7+version: 0.1.0.0
8+-- synopsis:
9+-- description:
10+-- bug-reports:
11+license: PublicDomain
12+author: Rodney Lorrimar
13+maintainer: rodney.lorrimar@iohk.io
14+-- category:
15+build-type: Simple
16+
17+library
18+ -- exposed-modules:
19+ -- other-modules:
20+ -- other-extensions:
21+ build-depends: base
22+ , extra
23+ , safe
24+ , aeson
25+ -- hs-source-dirs:
26+ default-language: Haskell2010
27+
28+executable cabal-simple
29+ main-is: Main.hs
30+ -- other-modules:
31+ -- other-extensions:
32+ build-depends: base
33+ , cabal-simple
34+ , extra
35+ , optparse-applicative
36+ -- hs-source-dirs:
37+ default-language: Haskell2010
test/cabal-simple-prof/default.nixnew file+62
@@ -0,0 +1,62 @@
1+# Test a package set
2+{ stdenv, util, mkCabalProjectPkgSet }:
3+
4+with stdenv.lib;
5+
6+let
7+ pkgSet = mkCabalProjectPkgSet {
8+ plan-pkgs = import ./pkgs.nix;
9+ modules = [
10+ {
11+ # Package has no exposed modules which causes
12+ # haddock: No input file(s)
13+ packages.cabal-simple.doHaddock = false;
14+ packages.cabal-simple.enableExecutableProfiling = true;
15+ enableLibraryProfiling = true;
16+ # executableProfiling = false;
17+ }
18+ ];
19+ };
20+
21+ packages = pkgSet.config.hsPkgs;
22+
23+in
24+ stdenv.mkDerivation {
25+ name = "cabal-simple-prof-test";
26+
27+ buildCommand = ''
28+ exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple"
29+
30+ size=$(command stat --format '%s' "$exe")
31+ printf "size of executable $exe is $size. \n" >& 2
32+
33+ # fixme: run on target platform when cross-compiled
34+ printf "checking whether executable runs with profiling... " >& 2
35+ $exe +RTS -p -h
36+
37+ printf "checking that executable is dynamically linked to system libraries... " >& 2
38+ '' + optionalString stdenv.isLinux ''
39+ ldd $exe | grep libpthread
40+ '' + optionalString stdenv.isDarwin ''
41+ otool -L $exe |grep .dylib
42+ '' + ''
43+
44+ printf "Checking that \"all\" component has the programs... " >& 2
45+ all_exe="${packages.cabal-simple.components.all}/bin/cabal-simple"
46+ test -f "$all_exe"
47+ echo "$all_exe" >& 2
48+
49+ touch $out
50+ '';
51+
52+ meta.platforms = platforms.all;
53+
54+ passthru = {
55+ # Used for debugging with nix repl
56+ inherit pkgSet packages;
57+
58+ # Used for testing externally with nix-shell (../tests.sh).
59+ # This just adds cabal-install to the existing shells.
60+ test-shell = util.addCabalInstall packages.cabal-simple.components.all;
61+ };
62+}
test/cabal-simple-prof/pkgs.nixnew file+124
@@ -0,0 +1,124 @@
1+{
2+ pkgs = hackage:
3+ {
4+ packages = {
5+ "binary".revision = (((hackage."binary")."0.8.5.1").revisions).default;
6+ "ghc-prim".revision = (((hackage."ghc-prim")."0.5.2.0").revisions).default;
7+ "extra".revision = (((hackage."extra")."1.6.15").revisions).default;
8+ "stm".revision = (((hackage."stm")."2.4.5.1").revisions).default;
9+ "unix".revision = (((hackage."unix")."2.7.2.2").revisions).default;
10+ "rts".revision = (((hackage."rts")."1.0").revisions).default;
11+ "clock".revision = (((hackage."clock")."0.8").revisions).default;
12+ "clock".flags.llvm = false;
13+ "scientific".revision = (((hackage."scientific")."0.3.6.2").revisions).default;
14+ "scientific".flags.integer-simple = false;
15+ "scientific".flags.bytestring-builder = false;
16+ "deepseq".revision = (((hackage."deepseq")."1.4.3.0").revisions).default;
17+ "random".revision = (((hackage."random")."1.1").revisions).default;
18+ "uuid-types".revision = (((hackage."uuid-types")."1.0.3").revisions).default;
19+ "optparse-applicative".revision = (((hackage."optparse-applicative")."0.14.3.0").revisions).default;
20+ "dlist".revision = (((hackage."dlist")."0.8.0.6").revisions).default;
21+ "semigroups".revision = (((hackage."semigroups")."0.19").revisions).default;
22+ "semigroups".flags.bytestring = true;
23+ "semigroups".flags.unordered-containers = true;
24+ "semigroups".flags.text = true;
25+ "semigroups".flags.tagged = true;
26+ "semigroups".flags.containers = true;
27+ "semigroups".flags.binary = true;
28+ "semigroups".flags.hashable = true;
29+ "semigroups".flags.transformers = true;
30+ "semigroups".flags.deepseq = true;
31+ "semigroups".flags.bytestring-builder = false;
32+ "semigroups".flags.template-haskell = true;
33+ "directory".revision = (((hackage."directory")."1.3.1.5").revisions).default;
34+ "transformers-compat".revision = (((hackage."transformers-compat")."0.6.5").revisions).default;
35+ "transformers-compat".flags.five = false;
36+ "transformers-compat".flags.generic-deriving = true;
37+ "transformers-compat".flags.two = false;
38+ "transformers-compat".flags.five-three = true;
39+ "transformers-compat".flags.mtl = true;
40+ "transformers-compat".flags.four = false;
41+ "transformers-compat".flags.three = false;
42+ "template-haskell".revision = (((hackage."template-haskell")."2.13.0.0").revisions).default;
43+ "vector".revision = (((hackage."vector")."0.12.0.3").revisions).default;
44+ "vector".flags.unsafechecks = false;
45+ "vector".flags.internalchecks = false;
46+ "vector".flags.wall = false;
47+ "vector".flags.boundschecks = true;
48+ "primitive".revision = (((hackage."primitive")."0.6.4.0").revisions).default;
49+ "time-locale-compat".revision = (((hackage."time-locale-compat")."0.1.1.5").revisions).default;
50+ "time-locale-compat".flags.old-locale = false;
51+ "safe".revision = (((hackage."safe")."0.3.17").revisions).default;
52+ "base-compat".revision = (((hackage."base-compat")."0.10.5").revisions).default;
53+ "ansi-terminal".revision = (((hackage."ansi-terminal")."0.9.1").revisions).default;
54+ "ansi-terminal".flags.example = false;
55+ "tagged".revision = (((hackage."tagged")."0.8.6").revisions).default;
56+ "tagged".flags.transformers = true;
57+ "tagged".flags.deepseq = true;
58+ "containers".revision = (((hackage."containers")."0.5.11.0").revisions).default;
59+ "integer-logarithms".revision = (((hackage."integer-logarithms")."1.0.3").revisions).default;
60+ "integer-logarithms".flags.check-bounds = false;
61+ "integer-logarithms".flags.integer-gmp = true;
62+ "bytestring".revision = (((hackage."bytestring")."0.10.8.2").revisions).default;
63+ "ansi-wl-pprint".revision = (((hackage."ansi-wl-pprint")."0.6.9").revisions).default;
64+ "ansi-wl-pprint".flags.example = false;
65+ "StateVar".revision = (((hackage."StateVar")."1.1.1.1").revisions).default;
66+ "contravariant".revision = (((hackage."contravariant")."1.5.1").revisions).default;
67+ "contravariant".flags.semigroups = true;
68+ "contravariant".flags.tagged = true;
69+ "contravariant".flags.statevar = true;
70+ "text".revision = (((hackage."text")."1.2.3.1").revisions).default;
71+ "unordered-containers".revision = (((hackage."unordered-containers")."0.2.10.0").revisions).default;
72+ "unordered-containers".flags.debug = false;
73+ "base".revision = (((hackage."base")."4.11.1.0").revisions).default;
74+ "time".revision = (((hackage."time")."1.8.0.2").revisions).default;
75+ "transformers".revision = (((hackage."transformers")."0.5.6.2").revisions).default;
76+ "hashable".revision = (((hackage."hashable")."1.2.7.0").revisions).default;
77+ "hashable".flags.sse2 = true;
78+ "hashable".flags.integer-gmp = true;
79+ "hashable".flags.sse41 = false;
80+ "hashable".flags.examples = false;
81+ "attoparsec".revision = (((hackage."attoparsec")."0.13.2.2").revisions).default;
82+ "attoparsec".flags.developer = false;
83+ "colour".revision = (((hackage."colour")."2.3.5").revisions).default;
84+ "filepath".revision = (((hackage."filepath")."1.4.2").revisions).default;
85+ "process".revision = (((hackage."process")."1.6.5.0").revisions).default;
86+ "pretty".revision = (((hackage."pretty")."1.1.3.6").revisions).default;
87+ "aeson".revision = (((hackage."aeson")."1.4.3.0").revisions).default;
88+ "aeson".flags.cffi = false;
89+ "aeson".flags.fast = false;
90+ "aeson".flags.bytestring-builder = false;
91+ "aeson".flags.developer = false;
92+ "ghc-boot-th".revision = (((hackage."ghc-boot-th")."8.4.4").revisions).default;
93+ "th-abstraction".revision = (((hackage."th-abstraction")."0.3.1.0").revisions).default;
94+ "array".revision = (((hackage."array")."0.5.2.0").revisions).default;
95+ "integer-gmp".revision = (((hackage."integer-gmp")."1.0.2.0").revisions).default;
96+ };
97+ compiler = {
98+ version = "8.4.4";
99+ nix-name = "ghc844";
100+ packages = {
101+ "binary" = "0.8.5.1";
102+ "ghc-prim" = "0.5.2.0";
103+ "stm" = "2.4.5.1";
104+ "unix" = "2.7.2.2";
105+ "rts" = "1.0";
106+ "deepseq" = "1.4.3.0";
107+ "directory" = "1.3.1.5";
108+ "template-haskell" = "2.13.0.0";
109+ "containers" = "0.5.11.0";
110+ "bytestring" = "0.10.8.2";
111+ "text" = "1.2.3.1";
112+ "base" = "4.11.1.0";
113+ "time" = "1.8.0.2";
114+ "filepath" = "1.4.2";
115+ "pretty" = "1.1.3.6";
116+ "ghc-boot-th" = "8.4.4";
117+ "array" = "0.5.2.0";
118+ "integer-gmp" = "1.0.2.0";
119+ };
120+ };
121+ };
122+ extras = hackage:
123+ { packages = { cabal-simple = ./.plan.nix/cabal-simple.nix; }; };
124+ }
test/default.nix+1
@@ -10,6 +10,7 @@ let
10
10
11in pkgs.recurseIntoAttrs {
11in pkgs.recurseIntoAttrs {
12 cabal-simple = haskell.callPackage ./cabal-simple { inherit util; };
12 cabal-simple = haskell.callPackage ./cabal-simple { inherit util; };
13+ cabal-simple-prof = haskell.callPackage ./cabal-simple-prof { inherit util; };
13 cabal-sublib = haskell.callPackage ./cabal-sublib { inherit util; };
14 cabal-sublib = haskell.callPackage ./cabal-sublib { inherit util; };
14 cabal-22 = haskell.callPackage ./cabal-22 {};
15 cabal-22 = haskell.callPackage ./cabal-22 {};
15 with-packages = haskell.callPackage ./with-packages { inherit util; };
16 with-packages = haskell.callPackage ./with-packages { inherit util; };