summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-11-02 21:42:33 +0000
committerIan Lynagh <ian@well-typed.com>2012-11-02 22:15:20 +0000
commitaf072fc35d8dbe7962e62700da052593e999c0ef (patch)
treee32ca8fbfa251cbd6e6734953183f3833d6b3094
parentd8684910b18203e0d15d3c77374382f5841e991d (diff)
downloadhaskell-af072fc35d8dbe7962e62700da052593e999c0ef.tar.gz
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.
-rw-r--r--compiler/main/DriverMkDepend.hs41
-rw-r--r--ghc.mk5
-rw-r--r--ghc/ghc.mk2
-rw-r--r--rules/build-dependencies.mk12
4 files changed, 31 insertions, 29 deletions
diff --git a/compiler/main/DriverMkDepend.hs b/compiler/main/DriverMkDepend.hs
index 953b2c4568..7355e31593 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 c1544ad6ec..6c0a29a208 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 ac8ce66245..809756e334 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 8442801cbe..4a4f5638e2 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"