Use touchy rather than touch when building on Windows
authorIan Lynagh <igloo@earth.li>
Fri, 2 Dec 2011 16:55:28 +0000 (16:55 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 2 Dec 2011 16:55:28 +0000 (16:55 +0000)
With Windows 7 in a vitrual box VM on OS X, some very odd things happen
with dates and time stamps when SSHing into cygwin. e.g. here the
"Change" time is in the past:

$ date; touch foo; stat foo
Fri Dec  2 16:58:07 GMTST 2011
  File: `foo'
  Size: 0               Blocks: 0          IO Block: 65536  regular
empty file
Device: 540aba0bh/1409989131d   Inode: 562949953592977  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     ian)   Gid: (  513/    None)
Access: 2011-12-02 16:58:07.414457900 +0000
Modify: 2011-12-02 16:58:07.414457900 +0000
Change: 2011-12-02 16:58:03.495141800 +0000
 Birth: 2011-12-02 16:57:57.731469900 +0000

And if we copy such a file, then the copy is older (as determined by the
"Modify" time) than the original:

$ date; touch foo; stat foo; cp foo bar; stat bar
Fri Dec  2 16:59:10 GMTST 2011
  File: `foo'
  Size: 0               Blocks: 0          IO Block: 65536  regular
empty file
Device: 540aba0bh/1409989131d   Inode: 1407374883725128  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     ian)   Gid: (  513/    None)
Access: 2011-12-02 16:59:10.118457900 +0000
Modify: 2011-12-02 16:59:10.118457900 +0000
Change: 2011-12-02 16:59:06.189477700 +0000
 Birth: 2011-12-02 16:57:57.731469900 +0000
  File: `bar'
  Size: 0               Blocks: 0          IO Block: 65536  regular
empty file
Device: 540aba0bh/1409989131d   Inode: 281474976882512  Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     ian)   Gid: (  513/    None)
Access: 2011-12-02 16:59:06.394555800 +0000
Modify: 2011-12-02 16:59:06.394555800 +0000
Change: 2011-12-02 16:59:06.395532400 +0000
 Birth: 2011-12-02 16:58:40.921899600 +0000

This means that make thinks that things are out of date when it
shouldn't, so reinvokes itself repeatedly until the MAKE_RESTARTS
infinite-recursion test triggers.

The touchy program, like most other programs, creates files with both
Modify and Change in the past, which is still a little odd, but is
consistent, so doesn't break make.

ghc.mk
libffi/ghc.mk
mk/config.mk.in
rts/ghc.mk
rules/build-dependencies.mk
rules/build-prog.mk
utils/ghc-cabal/ghc.mk
utils/touchy/ghc.mk

diff --git a/ghc.mk b/ghc.mk
index b62151d..a5afe14 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -553,6 +553,11 @@ BUILD_DIRS += \
    $(GHC_MKDIRHIER_DIR)
 endif
 
+ifeq "$(Windows)" "YES"
+BUILD_DIRS += \
+   $(GHC_TOUCHY_DIR)
+endif
+
 BUILD_DIRS += \
    docs/users_guide \
    docs/ext-core \
@@ -609,10 +614,6 @@ BUILD_DIRS += \
    utils/hpc \
    utils/runghc \
    ghc
-ifeq "$(Windows)" "YES"
-BUILD_DIRS += \
-   $(GHC_TOUCHY_DIR)
-endif
 
 ifneq "$(BINDIST)" "YES"
 BUILD_DIRS += \
index 8162c81..85a2822 100644 (file)
@@ -39,7 +39,7 @@ LIBFFI_PATH_MANGLE = PATH=$$(cygpath "$(TOP)")/libffi:$$PATH; export PATH;
 endif
 
 ifneq "$(BINDIST)" "YES"
-$(libffi_STAMP_CONFIGURE):
+$(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
        $(call removeFiles,$(libffi_STAMP_STATIC_CONFIGURE))
        $(call removeFiles,$(libffi_STAMP_STATIC_BUILD))
        $(call removeFiles,$(libffi_STAMP_STATIC_INSTALL))
@@ -88,15 +88,15 @@ $(libffi_STAMP_CONFIGURE):
        mv libffi/build/Makefile libffi/build/Makefile.orig
        sed "s#wc -w#wc -w | sed 's/ //g'#" < libffi/build/Makefile.orig > libffi/build/Makefile
 
-       touch $@
+       "$(TOUCH_CMD)" $@
 
-$(libffi_STAMP_BUILD): $(libffi_STAMP_CONFIGURE)
+$(libffi_STAMP_BUILD): $(libffi_STAMP_CONFIGURE) $(TOUCH_DEP)
        $(MAKE) -C libffi/build MAKEFLAGS=
-       touch $@
+       "$(TOUCH_CMD)" $@
 
-$(libffi_STAMP_INSTALL): $(libffi_STAMP_BUILD)
+$(libffi_STAMP_INSTALL): $(libffi_STAMP_BUILD) $(TOUCH_DEP)
        $(MAKE) -C libffi/build MAKEFLAGS= install
-       touch $@
+       "$(TOUCH_CMD)" $@
 
 $(libffi_STATIC_LIB): $(libffi_STAMP_INSTALL)
        @test -f $@ || { echo "$< exists, but $@ does not."; echo "Suggest removing $<."; exit 1; }
index f45404a..04ee71c 100644 (file)
@@ -740,6 +740,14 @@ TAR_CMD        = @TarCmd@
 BZIP2_CMD      = bzip2
 GZIP_CMD       = gzip
 
+ifeq "$(Windows)" "YES"
+TOUCH_CMD      = $(utils/touchy_dist_INPLACE)
+TOUCH_DEP      = $(TOUCH_CMD)
+else
+TOUCH_CMD      = touch
+TOUCH_DEP      =
+endif
+
 HSCOLOUR_CMD   = @HSCOLOUR@
 
 TIME_CMD       = @TimeCmd@
index 40ff02f..a18bec9 100644 (file)
@@ -107,9 +107,9 @@ endif
 ifneq "$(BINDIST)" "YES"
 rts_ffi_objs_stamp = rts/dist/ffi/stamp
 rts_ffi_objs       = rts/dist/ffi/*.o
-$(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) | $$(dir $$@)/.
+$(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) $(TOUCH_DEP) | $$(dir $$@)/.
        cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB)
-       touch $@
+       "$(TOUCH_CMD)" $@
 
 # This is a little hacky. We don't know the SO version, so we only
 # depend on libffi.so, but copy libffi.so*
index c9c62cd..6ab2edc 100644 (file)
@@ -31,9 +31,9 @@ ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES"
 # indirectly) include the generated includes files.
 $$($1_$2_depfile_haskell) : $$(includes_H_CONFIG) $$(includes_H_PLATFORM)
 
-$$($1_$2_depfile_haskell) : $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS) $$($1_$2_HC_MK_DEPEND_DEP) | $$$$(dir $$$$@)/.
+$$($1_$2_depfile_haskell) : $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS) $$($1_$2_HC_MK_DEPEND_DEP) $$(TOUCH_DEP) | $$$$(dir $$$$@)/.
        $$(call removeFiles,$$@.tmp)
-       touch $$@.tmp
+       "$$(TOUCH_CMD)" $$@.tmp
 ifneq "$$($1_$2_HS_SRCS)" ""
        "$$($1_$2_HC_MK_DEPEND)" -M $$($1_$2_MKDEPENDHS_FLAGS) \
            $$(filter-out -split-objs, $$($1_$2_v_ALL_HC_OPTS)) \
@@ -54,9 +54,9 @@ endif
 # includes files.
 $$($1_$2_depfile_c_asm) : $$(includes_H_CONFIG) $$(includes_H_PLATFORM)
 
-$$($1_$2_depfile_c_asm) : $$($1_$2_C_FILES_DEPS) $$($1_$2_S_FILES) | $$$$(dir $$$$@)/.
+$$($1_$2_depfile_c_asm) : $$($1_$2_C_FILES_DEPS) $$($1_$2_S_FILES) $$(TOUCH_DEP) | $$$$(dir $$$$@)/.
        $$(call removeFiles,$$@.tmp)
-       touch $$@.tmp
+       "$$(TOUCH_CMD)" $$@.tmp
 ifneq "$$(strip $$($1_$2_C_FILES_DEPS)$$($1_$2_S_FILES))" ""
 # We ought to actually do this for each way in $$($1_$2_WAYS), but then
 # it takes a long time to make the C deps for the RTS (30 seconds rather
index 1f43169..aa66516 100644 (file)
@@ -94,9 +94,9 @@ $(call all-target,$1_$2,$1/$2/build/tmp/$$($1_$2_PROG))
 # INPLACE_BIN might be empty if we're distcleaning
 ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
 ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
-$$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG) | $$$$(dir $$$$@)/.
+$$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG) $$(TOUCH_DEP) | $$$$(dir $$$$@)/.
        "$$(CP)" -p $$< $$@
-       touch $$@
+       "$$(TOUCH_CMD)" $$@
 endif
 endif
 
index 9af611c..20d0570 100644 (file)
@@ -25,7 +25,7 @@ $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/C
 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Cabal/Distribution/*/*.hs)
 $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Cabal/Distribution/*.hs)
 
-$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/Main.hs | $$(dir $$@)/. bootstrapping/.
+$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/.
        "$(GHC)" $(SRC_HC_OPTS) --make $(GHC_CABAL_DIR)/Main.hs -o $@ \
               -no-user-package-conf \
               -Wall $(WERROR) \
@@ -36,7 +36,7 @@ $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/Main.hs | $
               -ilibraries/filepath \
               -ilibraries/hpc \
               $(utils/ghc-cabal_dist_EXTRA_HC_OPTS)
-       touch $@
+       "$(TOUCH_CMD)" $@
 
 # touch is required, because otherwise if mkdirhier is newer, we
 # repeatedly rebuild ghc-cabal.
index fc9c845..458f80e 100644 (file)
@@ -10,8 +10,9 @@
 #
 # -----------------------------------------------------------------------------
 
-utils/touchy_dist_C_SRCS  = touchy.c
-utils/touchy_dist_PROG    = $(GHC_TOUCHY_PGM)
-utils/touchy_dist_TOPDIR  = YES
-utils/touchy_dist_INSTALL = YES
+utils/touchy_dist_C_SRCS          = touchy.c
+utils/touchy_dist_PROG            = $(GHC_TOUCHY_PGM)
+utils/touchy_dist_TOPDIR          = YES
+utils/touchy_dist_INSTALL         = YES
+utils/touchy_dist_INSTALL_INPLACE = YES
 $(eval $(call build-prog,utils/touchy,dist,0))