[GHC] #9709: Make restarts itself sometimes, and that's OK

#9709: Make restarts itself sometimes, and that's OK -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.9 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- I fairly frequently get the message that `make` has restarted itself {{{ ghc.mk:100: *** Make has restarted itself 2 times; is there a makefile bug? See http://ghc.haskell.org/trac/ghc/wiki/Building/Troubleshooting#Makehasrestart... for details. Stop. }}} but then when I say `make` again, things proceed just fine. In particular, this always (I think) happens after I `make clean` in the `libraries` directory. If it matters, I always use the `-j` flag to `make`, sometimes with 2 cores and sometimes with 4. I'm on Mac OS 10.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9709 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9709: Make restarts itself sometimes, and that's OK -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Build System | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by thomie): I can reproduce this by running the following with recent HEAD (25d1a716395e349736994759d1fcbb3721f3ee9f): {{{ ./boot ./configure make touch -r inplace/bin/ghc-cabal -d '-1 day' compiler/stage1/package-data.mk make -j2 }}} Below are my notes. {{{ # Don't put stage=2 in your build.mk file. cd ghc-build # Make sure compiler/stage1/package-data.mk is out of date, so that # `inplace/stage1/ghc-cabal configure ...` is run, which updates # compiler/stage1/inplace-pkg-config, which *should* trigger `make` to update # compiler/stage1/inplace-pkg-config-munged. touch -r inplace/bin/ghc-cabal -d '-1 day' compiler/stage1/package-data.mk make -j2 # This fails with: # # "Make has restarted itself 2 times; is there a makefile bug? ..." # # Analysis: # For some reason, make *does* update inplace-pkg-config-munged before # restarting itself when running with `-j1`, but it *doesn't* when running # with `-j2`. # This can be seen more clearly when deleting the following line from the # toplevel ghc.mk: # # else ifeq "$(MAKE_RESTARTS)" "1" # # Make will fail with both `-j1` as with `-j2`, but in the former case # inplace-pkg-config-munged is updated (you'll see the sed command in the # output), whereas in the latter it isn't. Using `-j2 -d` does seem to work, # which is very confusing. # In build-package-data.mk, we have the following two (expanded) rules. # # compiler/stage1/package-data.mk : inplace/bin/ghc-cabal # # inplace/bin/ghc-cabal configure ... (which is effectively): # touch compiler/stage1/inplace-pkg-config # touch "$@" # # compiler/stage1/inplace-pkg-config : compiler/stage1/package-data.mk # # And in compiler/ghc.mk: # # compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg- config # sed ... "$@" # # What seems to work as a fix is changing the rule for inplace-pkg-config to: # # compiler/stage1/inplace-pkg-config : compiler/stage1/package-data.mk ; # # Note the semicolon, which turns this into an empty recipe [1]. No recipe is # not the same as an empty recipe. I don't quite understand why this works # though, or how robust this fix is. # See also [2] for why the original rule might be flawed (it should have # failed for `-j1` as well). It doesn't follow best practice number 2 from # [3], from the GNU make maintainer's blog: # # "Every non-.PHONY rule *must* update a file with the exact name of its target." # # TODO: can we find all such flawed rules in the ghc build system? # (using some sort of makelint). # # References: # [1] https://www.gnu.org/software/make/manual/html_node/Empty- Recipes.html # [2] https://stackoverflow.com/questions/12724137/why-does-make-not- consider-a-target-without-recipe-out-of-date-when-updated-by-a # [3] http://make.mad-scientist.net/papers/rules-of-makefiles/ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9709#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC