[commit: ghc] master: Change how dependency generation works; fixes #7381 (af072fc)
David Terei
davidterei at gmail.com
Mon Mar 4 08:59:29 CET 2013
Ian,
I think this patch or one related to it may have broken the expected behaviour.
Previously I could do:
$ ghc -M Main.hs
but now executing the above gives the error "You must specify at least
one -dep-suffix". I can get the old behaviour by doing:
$ ghc -M Main.hs -dep-suffix=''
If the new behaviour is the expected one, then the userguide is now out of date.
Cheers,
David
On 2 November 2012 16:38, Ian Lynagh <igloo at earth.li> wrote:
> Repository : ssh://darcs.haskell.org//srv/darcs/ghc
>
> On branch : master
>
> http://hackage.haskell.org/trac/ghc/changeset/af072fc35d8dbe7962e62700da052593e999c0ef
>
>>---------------------------------------------------------------
>
> commit af072fc35d8dbe7962e62700da052593e999c0ef
> Author: Ian Lynagh <ian at well-typed.com>
> Date: Fri Nov 2 21:42:33 2012 +0000
>
> Change how dependency generation works; fixes #7381
>
> We now do the initial dependency generation for the vanilla way
> regardless of what way flags and hisuf/osuf flags are given. This
> makes it easier to generate the right dependency info in the end.
>
>>---------------------------------------------------------------
>
> compiler/main/DriverMkDepend.hs | 41 ++++++++++++++++++++++----------------
> ghc.mk | 5 ++++
> ghc/ghc.mk | 2 +-
> rules/build-dependencies.mk | 12 +----------
> 4 files changed, 31 insertions(+), 29 deletions(-)
>
> diff --git a/compiler/main/DriverMkDepend.hs b/compiler/main/DriverMkDepend.hs
> index 953b2c4..7355e31 100644
> --- a/compiler/main/DriverMkDepend.hs
> +++ b/compiler/main/DriverMkDepend.hs
> @@ -51,7 +51,25 @@ import Data.Maybe ( isJust )
> doMkDependHS :: GhcMonad m => [FilePath] -> m ()
> doMkDependHS srcs = do
> -- Initialisation
> - dflags <- GHC.getSessionDynFlags
> + dflags0 <- GHC.getSessionDynFlags
> +
> + -- We kludge things a bit for dependency generation. Rather than
> + -- generating dependencies for each way separately, we generate
> + -- them once and then duplicate them for each way's osuf/hisuf.
> + -- We therefore do the initial dependency generation with an empty
> + -- way and .o/.hi extensions, regardless of any flags that might
> + -- be specified.
> + let dflags = dflags0 {
> + ways = [],
> + buildTag = mkBuildTag [],
> + hiSuf = "hi",
> + objectSuf = "o"
> + }
> + _ <- GHC.setSessionDynFlags dflags
> +
> + when (null (depSuffixes dflags)) $
> + ghcError (ProgramError "You must specify at least one -dep-suffix")
> +
> files <- liftIO $ beginMkDependHS dflags
>
> -- Do the downsweep to find all the modules
> @@ -263,24 +281,13 @@ writeDependency root hdl targets dep
> -----------------------------
> insertSuffixes
> :: FilePath -- Original filename; e.g. "foo.o"
> - -> [String] -- Extra suffices e.g. ["x","y"]
> - -> [FilePath] -- Zapped filenames e.g. ["foo.o", "foo.x_o", "foo.y_o"]
> + -> [String] -- Suffix prefixes e.g. ["x_", "y_"]
> + -> [FilePath] -- Zapped filenames e.g. ["foo.x_o", "foo.y_o"]
> -- Note that that the extra bit gets inserted *before* the old suffix
> - -- We assume the old suffix contains no dots, so we can strip it with removeSuffix
> -
> - -- NOTE: we used to have this comment
> - -- In order to construct hi files with alternate suffixes, we
> - -- now have to find the "basename" of the hi file. This is
> - -- difficult because we can't just split the hi filename
> - -- at the last dot - the hisuf might have dots in it. So we
> - -- check whether the hi filename ends in hisuf, and if it does,
> - -- we strip off hisuf, otherwise we strip everything after the
> - -- last dot.
> - -- But I'm not sure we care about hisufs with dots in them.
> - -- Lots of other things will break first!
> -
> + -- We assume the old suffix contains no dots, so we know where to
> + -- split it
> insertSuffixes file_name extras
> - = file_name : [ basename <.> (extra ++ "_" ++ suffix) | extra <- extras ]
> + = [ basename <.> (extra ++ suffix) | extra <- extras ]
> where
> (basename, suffix) = case splitExtension file_name of
> -- Drop the "." from the extension
> diff --git a/ghc.mk b/ghc.mk
> index c1544ad..6c0a29a 100644
> --- a/ghc.mk
> +++ b/ghc.mk
> @@ -138,6 +138,11 @@ ifeq "$(findstring v,$(GhcLibWays))" ""
> $(error v is not in $$(GhcLibWays), and $$(DYNAMIC_BY_DEFAULT) is not YES)
> endif
> endif
> +ifeq "$(GhcProfiled)" "YES"
> +ifeq "$(findstring p,$(GhcLibWays))" ""
> +$(error p is not in $$(GhcLibWays), and $$(GhcProfiled) is YES)
> +endif
> +endif
> endif
>
> ifeq "$(phase)" ""
> diff --git a/ghc/ghc.mk b/ghc/ghc.mk
> index ac8ce66..809756e 100644
> --- a/ghc/ghc.mk
> +++ b/ghc/ghc.mk
> @@ -64,7 +64,7 @@ ghc_stage3_MORE_HC_OPTS += -threaded
> endif
>
> ifeq "$(GhcProfiled)" "YES"
> -ghc_stage2_MORE_HC_OPTS += -prof
> +ghc_stage2_PROGRAM_WAY = p
> endif
>
> ghc_stage1_PROG = ghc-stage1$(exeext)
> diff --git a/rules/build-dependencies.mk b/rules/build-dependencies.mk
> index 8442801..4a4f563 100644
> --- a/rules/build-dependencies.mk
> +++ b/rules/build-dependencies.mk
> @@ -22,18 +22,8 @@ $1_$2_depfile_c_asm = $$($1_$2_depfile_base).c_asm
>
> $1_$2_C_FILES_DEPS = $$(filter-out $$($1_$2_C_FILES_NODEPS),$$($1_$2_C_FILES))
>
> -$1_$2_MKDEPENDHS_FLAGS = -dep-makefile $$($1_$2_depfile_haskell).tmp $$(foreach way,$$(filter-out v,$$($1_$2_WAYS)),-dep-suffix $$(way))
> +$1_$2_MKDEPENDHS_FLAGS = -dep-makefile $$($1_$2_depfile_haskell).tmp $$(foreach way,$$($1_$2_WAYS),-dep-suffix "$$(patsubst %o,%,$$($$(way)_osuf))")
> $1_$2_MKDEPENDHS_FLAGS += -include-pkg-deps
> -# Setting hisuf/osuf is a kludge. If DYNAMIC_BY_DEFAULT is on, dyn is
> -# the first way, and p is another way, then without this kludge we run
> -# ghc -M -hisuf dyn_hi -osuf dyn_o -dep-suffix dyn -dep-suffix p
> -# which means we get dependencies for .dyn_hi/.dyn_o and .p_dyn_hi/.p_dyn_o
> -# rather than .dyn_hi/.dyn_o and .p_hi/.p_o.
> -# With the kludge we also get .hi/.o dependencies that we don't need, but
> -# they don't do any harm.
> -# We also specify -static, as otherwise we end up with some dependencies
> -# on .dyn_dyn_hi files
> -$1_$2_MKDEPENDHS_FLAGS += -static -hisuf hi -osuf o
>
> ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES"
>
>
>
>
> _______________________________________________
> Cvs-ghc mailing list
> Cvs-ghc at haskell.org
> http://www.haskell.org/mailman/listinfo/cvs-ghc
More information about the ghc-devs
mailing list