Commit af072fc3 authored by's avatar

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.
parent d8684910
......@@ -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
:: 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 ]
(basename, suffix) = case splitExtension file_name of
-- Drop the "." from the extension
......@@ -138,6 +138,11 @@ ifeq "$(findstring v,$(GhcLibWays))" ""
$(error v is not in $$(GhcLibWays), and $$(DYNAMIC_BY_DEFAULT) is not YES)
ifeq "$(GhcProfiled)" "YES"
ifeq "$(findstring p,$(GhcLibWays))" ""
$(error p is not in $$(GhcLibWays), and $$(GhcProfiled) is YES)
ifeq "$(phase)" ""
......@@ -64,7 +64,7 @@ ghc_stage3_MORE_HC_OPTS += -threaded
ifeq "$(GhcProfiled)" "YES"
ghc_stage2_MORE_HC_OPTS += -prof
ghc_stage2_PROGRAM_WAY = p
ghc_stage1_PROG = ghc-stage1$(exeext)
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment