[commit: ghc] master: Add separate rules for all .hi files, rather than using %.hi style (a49e9cf)

Ian Lynagh igloo at earth.li
Sat Feb 23 16:18:31 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/a49e9cf3ff5af48c011c7ade9338b49b667b2201

>---------------------------------------------------------------

commit a49e9cf3ff5af48c011c7ade9338b49b667b2201
Author: Ian Lynagh <ian at well-typed.com>
Date:   Fri Feb 22 22:18:50 2013 +0000

    Add separate rules for all .hi files, rather than using %.hi style
    
    If a file is created by a %.hi rule, and the actual filename isn't
    mentioned in the makefiles, then make will treat it as an 'intermediate
    file' and delete it when it is finished.
    
    We'd been lucky so far that .hi files weren't actually being built due
    to our rules (but rather, as side-effects of the .o rules). However,
    when using -dynamic-too to build, we had a rule
        $1/$2/build/%.$$(dyn_osuf): $1/$2/build/%.$$(v_hisuf)
    which meant that building a .dyn_o could cause the rule for the
    corresponding .hi to be used, and the .hi may then be deleted later on.
    This was exacerbated by a bug in GNU make 3.81 which caused make to
    enter an infinite loop if running in parallel mode:
        http://lists.gnu.org/archive/html/bug-make/2013-02/msg00020.html
    
    Adding
        .SECONDARY:
    would stop make from deleting the intermediate files. However, this
    caused make to take a pathologically long time (it appeared to be
    live-locked for 2 hours before I killed it) with our build system.
    
    This patch instead creates lines like
        $(eval $(call hi-rule,libraries/base/dist-install/build/Unsafe/Coerce.dyn_hi libraries/base/dist-install/build/Unsafe/Coerce.hi  : %hi: %o  libraries/base/Unsafe/Coerce.hs))
    in the .depend files, which results in a rule like
        libraries/base/dist-install/build/Unsafe/Coerce.dyn_hi libraries/base/dist-install/build/Unsafe/Coerce.hi  : %hi: %o  libraries/base/Unsafe/Coerce.hs ;
    which, as the files are now all named in the makefiles, means they are
    no longer intermediate files so do not get deleted.

>---------------------------------------------------------------

 rules/build-dependencies.mk  |    3 ++-
 rules/hi-rule.mk             |   14 ++------------
 rules/hs-suffix-way-rules.mk |    5 -----
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/rules/build-dependencies.mk b/rules/build-dependencies.mk
index 4a4f563..346ee10 100644
--- a/rules/build-dependencies.mk
+++ b/rules/build-dependencies.mk
@@ -48,7 +48,8 @@ endif
 #    Some packages are from the bootstrapping compiler, so are not
 #    within the build tree. On Windows this causes a problem as they look
 #    like bad rules, due to the two colons, so we filter them out.
-	grep -v ' : [a-zA-Z]:/' $$@.tmp > $$@
+	grep -v ' : [a-zA-Z]:/' $$@.tmp > $$@.tmp2
+	sed '/hs$$$$/ { p; s/o /hi /g; s/:/ : %hi: %o /; s/^/$$$$(eval $$$$(call hi-rule,/; s/$$$$/))/ }; /hs-boot$$$$/ { p; s/o-boot /hi-boot /g; s/:/ : %hi-boot: %o-boot /; s/^/$$$$(eval $$$$(call hi-rule,/; s/$$$$/))/ }' $$@.tmp2 > $$@
 
 # Some of the C files (directly or indirectly) include the generated
 # includes files.
diff --git a/rules/hi-rule.mk b/rules/hi-rule.mk
index e478c17..a343389 100644
--- a/rules/hi-rule.mk
+++ b/rules/hi-rule.mk
@@ -71,25 +71,15 @@
 #
 # a/%.hi : a/%.o b/%.hs ;
 
-define hi-rule # $1 = source directory, $2 = object directory, $3 = way
-
-$(call hi-rule-helper,$2/%.$$($3_hisuf) : $2/%.$$($3_osuf) $1/%.hs)
-$(call hi-rule-helper,$2/%.$$($3_hisuf) : $2/%.$$($3_osuf) $1/%.lhs)
-
-$(call hi-rule-helper,$2/%.$$($3_way_)hi-boot : $2/%.$$($3_way_)o-boot $1/%.hs)
-$(call hi-rule-helper,$2/%.$$($3_way_)hi-boot : $2/%.$$($3_way_)o-boot $1/%.lhs)
-
-endef
-
 ifeq "$(ExtraMakefileSanityChecks)" "NO"
 
-define hi-rule-helper # $1 = rule header
+define hi-rule # $1 = rule header
 $1 ;
 endef
 
 else
 
-define hi-rule-helper # $1 = rule header
+define hi-rule # $1 = rule header
 $1
 	@if [ ! -f $$@ ] ; then \
 	    echo "Panic! $$< exists, but $$@ does not."; \
diff --git a/rules/hs-suffix-way-rules.mk b/rules/hs-suffix-way-rules.mk
index bfab912..884ed70 100644
--- a/rules/hs-suffix-way-rules.mk
+++ b/rules/hs-suffix-way-rules.mk
@@ -32,10 +32,5 @@ endif
 $$(foreach dir,$$($1_$2_HS_SRC_DIRS),\
   $$(eval $$(call hs-suffix-way-rules-srcdir,$1,$2,$3,$$(dir))))
 
-$(call hi-rule,$1/$2/build,$1/$2/build,$3)
-$(call hi-rule,$1/$2/build/autogen,$1/$2/build,$3)
-$$(foreach dir,$$($1_$2_HS_SRC_DIRS),\
-  $$(eval $$(call hi-rule,$1/$$(dir),$1/$2/build,$3)))
-
 endef # hs-suffix-way-rules
 





More information about the ghc-commits mailing list