Skip to content

Commit

Permalink
Add build system profiling to build system
Browse files Browse the repository at this point in the history
  • Loading branch information
igfoo committed Jan 23, 2011
1 parent dd47428 commit eb3a1ae
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions ghc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ endif
# -----------------------------------------------------------------------------
# Utility definitions

include rules/prof.mk
include rules/trace.mk
include rules/make-command.mk

Expand Down
2 changes: 2 additions & 0 deletions rules/build-dependencies.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

define build-dependencies
$(call trace, build-dependencies($1,$2,$3))
$(call profStart, build-dependencies($1,$2,$3))
# $1 = dir
# $2 = distdir
# $3 = GHC stage to use (0 == bootstrapping compiler)
Expand Down Expand Up @@ -73,6 +74,7 @@ endif # $1_$2_NO_BUILD_DEPS
# Note sed magic above: mkdependC can't do -odir stuff, so we have to
# munge the dependencies it generates to refer to the correct targets.

$(call profEnd, build-dependencies($1,$2,$3))
endef

# This comment is outside the "define addCFileDeps" as that definition
Expand Down
2 changes: 2 additions & 0 deletions rules/build-package-data.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

define build-package-data
$(call trace, build-package-data($1,$2,$3))
$(call profStart, build-package-data($1,$2,$3))
# args:
# $1 = dir
# $2 = distdir
Expand Down Expand Up @@ -80,4 +81,5 @@ endif

PACKAGE_DATA_MKS += $1/$2/package-data.mk

$(call profEnd, build-package-data($1,$2,$3))
endef
2 changes: 2 additions & 0 deletions rules/build-package-way.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

define build-package-way # $1 = dir, $2 = distdir, $3 = way, $4 = stage
$(call trace, build-package-way($1,$2,$3))
$(call profStart, build-package-way($1,$2,$3))

$(call distdir-way-opts,$1,$2,$3,$4)
$(call hs-suffix-rules,$1,$2,$3)
Expand Down Expand Up @@ -130,5 +131,6 @@ endif
endif
endif

$(call profEnd, build-package-way($1,$2,$3))
endef

2 changes: 2 additions & 0 deletions rules/build-package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

define build-package
$(call trace, build-package($1,$2,$3))
$(call profStart, build-package($1,$2,$3))
# $1 = dir
# $2 = distdir
# $3 = GHC stage to use (0 == bootstrapping compiler)
Expand All @@ -52,6 +53,7 @@ clean_$1_$2_config:
ifneq "$$($1_$2_NOT_NEEDED)" "YES"
$$(eval $$(call build-package-helper,$1,$2,$3))
endif
$(call profEnd, build-package($1,$2,$3))
endef


Expand Down
2 changes: 2 additions & 0 deletions rules/build-perl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

define build-perl
$(call trace, build-perl($1,$2))
$(call profStart, build-perl($1,$2))
# $1 = dir
# $2 = distdir

Expand Down Expand Up @@ -65,4 +66,5 @@ install_$1_$2: $1/$2/$$($1_$2_PROG)
endif
endif

$(call profEnd, build-perl($1,$2))
endef
2 changes: 2 additions & 0 deletions rules/build-prog.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

define build-prog
$(call trace, build-prog($1,$2,$3))
$(call profStart, build-prog($1,$2,$3))
# $1 = dir
# $2 = distdir
# $3 = GHC stage to use (0 == bootstrapping compiler)
Expand All @@ -40,6 +41,7 @@ $(call clean-target,$1,$2,$1/$2)
ifneq "$$($1_$2_NOT_NEEDED)" "YES"
$$(eval $$(call build-prog-helper,$1,$2,$3))
endif
$(call profEnd, build-prog($1,$2,$3))
endef


Expand Down
2 changes: 2 additions & 0 deletions rules/docbook.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

define docbook
$(call trace, docbook($1,$2))
$(call profStart, docbook($1,$2))
# $1 = dir
# $2 = docname

Expand Down Expand Up @@ -80,5 +81,6 @@ $1/$2.pdf: $$($1_DOCBOOK_SOURCES)
[ -f $$@ ]
endif

$(call profEnd, docbook($1,$2))
endef

2 changes: 2 additions & 0 deletions rules/haddock.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

define haddock # args: $1 = dir, $2 = distdir
$(call trace, haddock($1,$2))
$(call profStart, haddock($1,$2))

ifneq "$$($1_$2_DO_HADDOCK)" "NO"

Expand Down Expand Up @@ -71,5 +72,6 @@ endif

endif

$(call profEnd, haddock($1,$2))
endef

2 changes: 2 additions & 0 deletions rules/include-dependencies.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

define include-dependencies
$(call trace, include-dependencies($1,$2,$3))
$(call profStart, include-dependencies($1,$2,$3))
# $1 = dir
# $2 = distdir
# $3 = GHC stage to use (0 == bootstrapping compiler)
Expand All @@ -29,5 +30,6 @@ $$(warning not building dependencies in $1)
endif
endif

$(call profEnd, include-dependencies($1,$2,$3))
endef

2 changes: 2 additions & 0 deletions rules/manual-package-config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

define manual-package-config # args: $1 = dir
$(call trace, manual-package-config($1))
$(call profStart, manual-package-config($1))

$1/package.conf.inplace : $1/package.conf.in $(GHC_PKG_INPLACE)
$$(CPP) $$(RAWCPP_FLAGS) -P \
Expand Down Expand Up @@ -42,4 +43,5 @@ distclean : clean_$1_package.conf
clean_$1_package.conf :
"$$(RM)" $$(RM_OPTS) $1/package.conf.install $1/package.conf.inplace

$(call profEnd, manual-package-config($1))
endef
2 changes: 2 additions & 0 deletions rules/package-config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

define package-config # args: $1 = dir, $2 = distdir, $3 = GHC stage
$(call trace, package-config($1,$2,$3))
$(call profStart, package-config($1,$2,$3))

$1_$2_HC = $$(GHC_STAGE$3)

Expand Down Expand Up @@ -55,4 +56,5 @@ endif
# Useful later
$1_$2_SLASH_MODS = $$(subst .,/,$$($1_$2_MODULES))

$(call profEnd, package-config($1,$2,$3))
endef
20 changes: 20 additions & 0 deletions rules/prof.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -----------------------------------------------------------------------------
#
# (c) 2010 The University of Glasgow
#
# This file is part of the GHC build system.
#
# To understand how the build system works and how to modify it, see
# http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
# http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
#
# -----------------------------------------------------------------------------

define profStart
$$(if $(PROF),$$(info $$(shell date +%s.%N): Start $1))
endef

define profEnd
$$(if $(PROF),$$(info $$(shell date +%s.%N): End $1))
endef

2 changes: 2 additions & 0 deletions rules/shell-wrapper.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

define shell-wrapper
$(call trace, shell-wrapper($1,$2))
$(call profStart, shell-wrapper($1,$2))
# $1 = dir
# $2 = distdir

Expand Down Expand Up @@ -85,4 +86,5 @@ endif

endif # $1_$2_SHELL_WRAPPER

$(call profEnd, shell-wrapper($1,$2))
endef
2 changes: 2 additions & 0 deletions rules/tags-package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

define tags-package
$(call trace, tags-package($1,$2))
$(call profStart, tags-package($1,$2))
# $1 = dir
# $2 = distdir

Expand All @@ -30,5 +31,6 @@ tags_$1:
TAGS_$1:
inplace/bin/ghctags --topdir $$(TOP)/inplace/lib -e --use-cabal-config $1/$2 -- $$($1_$2_TAGS_HC_OPTS) $$($1_$2_v_ALL_HC_OPTS) -- $$($1_$2_HS_SRCS)

$(call profEnd, tags-package($1,$2))
endef

0 comments on commit eb3a1ae

Please sign in to comment.