Kill inaccessible-branch complaints in record update
[ghc.git] / compiler / ghc.mk
index 4977e28..ce41eca 100644 (file)
@@ -53,8 +53,9 @@ compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
        @echo                                                               >> $@
        @echo '#include "ghc_boot_platform.h"'                              >> $@
        @echo                                                               >> $@
-       @echo 'data IntegerLibrary = IntegerGMP | IntegerSimple'            >> $@
-       @echo '    deriving Eq'                                             >> $@
+       @echo 'data IntegerLibrary = IntegerGMP'                            >> $@
+       @echo '                    | IntegerSimple'                         >> $@
+       @echo '                    deriving Eq'                             >> $@
        @echo                                                               >> $@
        @echo 'cBuildPlatformString :: String'                              >> $@
        @echo 'cBuildPlatformString = BuildPlatform_NAME'                   >> $@
@@ -65,12 +66,18 @@ compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
        @echo                                                               >> $@
        @echo 'cProjectName          :: String'                             >> $@
        @echo 'cProjectName          = "$(ProjectName)"'                    >> $@
+       @echo 'cProjectGitCommitId   :: String'                             >> $@
+       @echo 'cProjectGitCommitId   = "$(ProjectGitCommitId)"'             >> $@
        @echo 'cProjectVersion       :: String'                             >> $@
        @echo 'cProjectVersion       = "$(ProjectVersion)"'                 >> $@
        @echo 'cProjectVersionInt    :: String'                             >> $@
        @echo 'cProjectVersionInt    = "$(ProjectVersionInt)"'              >> $@
        @echo 'cProjectPatchLevel    :: String'                             >> $@
        @echo 'cProjectPatchLevel    = "$(ProjectPatchLevel)"'              >> $@
+       @echo 'cProjectPatchLevel1   :: String'                             >> $@
+       @echo 'cProjectPatchLevel1   = "$(ProjectPatchLevel1)"'             >> $@
+       @echo 'cProjectPatchLevel2   :: String'                             >> $@
+       @echo 'cProjectPatchLevel2   = "$(ProjectPatchLevel2)"'             >> $@
        @echo 'cBooterVersion        :: String'                             >> $@
        @echo 'cBooterVersion        = "$(GhcVersion)"'                     >> $@
        @echo 'cStage                :: String'                             >> $@
@@ -95,12 +102,16 @@ endif
        @echo 'cGhcWithSMP           = "$(GhcWithSMP)"'                     >> $@
        @echo 'cGhcRTSWays           :: String'                             >> $@
        @echo 'cGhcRTSWays           = "$(GhcRTSWays)"'                     >> $@
+       @echo 'cGhcRtsWithLibdw      :: Bool'                               >> $@
+ifeq "$(GhcRtsWithLibdw)" "YES"
+       @echo 'cGhcRtsWithLibdw      = True'                                >> $@
+else
+       @echo 'cGhcRtsWithLibdw      = False'                               >> $@
+endif
        @echo 'cGhcEnableTablesNextToCode :: String'                        >> $@
        @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
        @echo 'cLeadingUnderscore    :: String'                             >> $@
        @echo 'cLeadingUnderscore    = "$(LeadingUnderscore)"'              >> $@
-       @echo 'cRAWCPP_FLAGS         :: String'                             >> $@
-       @echo 'cRAWCPP_FLAGS         = "$(RAWCPP_FLAGS)"'                   >> $@
        @echo 'cGHC_UNLIT_PGM        :: String'                             >> $@
        @echo 'cGHC_UNLIT_PGM        = "$(utils/unlit_dist_PROG)"'          >> $@
        @echo 'cGHC_SPLIT_PGM        :: String'                             >> $@
@@ -166,11 +177,6 @@ compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
        @echo "#define BUILD_OS \"$(BuildOS_CPP)\""               >> $@
        @echo "#define HOST_OS \"$(HostOS_CPP)\""                 >> $@
        @echo "#define TARGET_OS \"$(TargetOS_CPP)\""             >> $@
-ifeq "$(TargetOS_CPP)" "irix"
-       @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS"                   >> $@
-       @echo "#define $(IRIX_MAJOR)_TARGET_OS 1"                 >> $@
-       @echo "#endif"                                            >> $@
-endif
        @echo                                                     >> $@
        @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1"         >> $@
        @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1"           >> $@
@@ -212,11 +218,6 @@ compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
        @echo "#define BUILD_OS \"$(HostOS_CPP)\""                >> $@
        @echo "#define HOST_OS \"$(TargetOS_CPP)\""               >> $@
        @echo "#define TARGET_OS \"$(TargetOS_CPP)\""             >> $@
-ifeq "$(TargetOS_CPP)" "irix"
-       @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS"                   >> $@
-       @echo "#define $(IRIX_MAJOR)_TARGET_OS 1"                 >> $@
-       @echo "#endif"                                            >> $@
-endif
        @echo                                                     >> $@
        @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1"          >> $@
        @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1"         >> $@
@@ -232,7 +233,7 @@ compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
        "$(CP)" $< $@
 
 # ----------------------------------------------------------------------------
-#              Generate supporting stuff for prelude/PrimOp.lhs
+#              Generate supporting stuff for prelude/PrimOp.hs
 #              from prelude/primops.txt
 
 PRIMOP_BITS_NAMES = primop-data-decl.hs-incl        \
@@ -258,13 +259,15 @@ PRIMOP_BITS_STAGE3 = $(addprefix compiler/stage3/build/,$(PRIMOP_BITS_NAMES))
 compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
 compiler_CPP_OPTS += ${GhcCppOpts}
 
+# We add these paths to the Haskell compiler's #include search path list since
+# we must avoid #including files by paths relative to the source file as Hadrian
+# moves the build artifacts out of the source tree. See #8040.
+compiler_HC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
+
 define preprocessCompilerFiles
 # $0 = stage
-compiler/stage$1/build/Parser.y: compiler/parser/Parser.y.pp
-       $$(CPP) $$(RAWCPP_FLAGS) -P $$(compiler_CPP_OPTS) -x c $$< | grep -v '^#pragma GCC' > $$@
-
 compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
-       $$(CPP) $$(RAWCPP_FLAGS) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
+       $$(HS_CPP) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
 
 compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
        "$$(genprimopcode_INPLACE)" --data-decl          < $$< > $$@
@@ -362,33 +365,27 @@ endif
 # at it, because that takes too long and doesn't buy much, but we do want
 # to inline certain key external functions, so we instruct GHC not to
 # throw away inlinings as it would normally do in -O0 mode.
-compiler/stage1/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas
-# If we're bootstrapping the compiler during stage2, or we're being
-# built by a GHC whose version is > 7.8, we need -fcmm-sink to be
+# Since GHC version 7.8, we need -fcmm-sink to be
 # passed to the compiler. This is required on x86 to avoid the
 # register allocator running out of stack slots when compiling this
 # module with -fPIC -dynamic.
 # See #8182 for all the details
-ifeq "$(CMM_SINK_BOOTSTRAP_IS_NEEDED)" "YES"
-compiler/stage1/build/Parser_HC_OPTS += -fcmm-sink
-endif
-# We also pass -fcmm-sink to every stage != 1
+compiler/stage1/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
 compiler/stage2/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
 compiler/stage3/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
 
-
 ifeq "$(GhcProfiled)" "YES"
 # If we're profiling GHC then we want SCCs.  However, adding -auto-all
 # everywhere tends to give a hard-to-read profile, and adds lots of
 # overhead.  A better approach is to proceed top-down; identify the
 # parts of the compiler of interest, and then add further cost centres
-# as necessary.  Turn on -auto-all for individual modules like this:
+# as necessary.  Turn on -fprof-auto for individual modules like this:
 
-# compiler/main/DriverPipeline_HC_OPTS += -auto-all
-compiler/main/GhcMake_HC_OPTS        += -auto-all
-compiler/main/GHC_HC_OPTS            += -auto-all
+# compiler/main/DriverPipeline_HC_OPTS += -fprof-auto
+compiler/main/GhcMake_HC_OPTS        += -fprof-auto
+compiler/main/GHC_HC_OPTS            += -fprof-auto
 
-# or alternatively add {-# OPTIONS_GHC -auto-all #-} to the top of
+# or alternatively add {-# OPTIONS_GHC -fprof-auto #-} to the top of
 # modules you're interested in.
 
 # We seem to still build the vanilla libraries even if we say
@@ -416,144 +413,96 @@ compiler/stage3/package-data.mk : compiler/ghc.mk
 
 compiler_PACKAGE = ghc
 
-# Note [fiddle-stage1-version]
-# The version of the GHC package changes every day, since the
-# patchlevel is the current date.  We don't want to force
-# recompilation of the entire compiler when this happens, so for stage
-# 1 we omit the patchlevel from the version number.  For stage 2 we
-# have to include the patchlevel since this is the package we install,
-# however.
-#
-# Note: we also have to tweak the version number of the package itself
-# when it gets registered; see Note [munge-stage1-package-config]
-# below.
-# The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
-# then we don't want to remove it
-ifneq "$(CLEANING)" "YES"
-ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
-compiler_stage1_VERSION_MUNGED = YES
-endif
-endif
-
-ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
-compiler_stage1_MUNGED_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
-define compiler_PACKAGE_MAGIC
-compiler_stage1_VERSION = $(compiler_stage1_MUNGED_VERSION)
-endef
-
-# Don't register the non-munged package
-compiler_stage1_REGISTER_PACKAGE = NO
-
-endif
-
 # Don't do splitting for the GHC package, it takes too long and
 # there's not much benefit.
 compiler_stage1_SplitObjs = NO
 compiler_stage2_SplitObjs = NO
 compiler_stage3_SplitObjs = NO
-
-# There are too many symbols in the ghc package for a Windows DLL.
-# We therefore need to split some of the modules off into a separate
-# DLL. This clump are the modules reachable from DynFlags:
+compiler_stage1_SplitSections = NO
+compiler_stage2_SplitSections = NO
+compiler_stage3_SplitSections = NO
+
+# There are too many symbols in the ghc package for a Windows DLL
+# (due to a limitation of bfd ld, see Trac #5987). We therefore need to split
+# some of the modules off into a separate DLL. This clump are the modules
+# reachable from DynFlags:
 compiler_stage2_dll0_START_MODULE = DynFlags
 compiler_stage2_dll0_MODULES = \
        Annotations \
+       ApiAnnotation \
        Avail \
        Bag \
        BasicTypes \
-       BinIface \
        Binary \
-       Bitmap \
-       BlockId \
+       BinFingerprint \
        BooleanFormula \
-       BreakArray \
        BufWrite \
-       BuildTyCl \
-       ByteCodeAsm \
-       ByteCodeInstr \
-       ByteCodeItbls \
-       CLabel \
        Class \
        CmdLineParser \
-       Cmm \
-       CmmCallConv \
-       CmmExpr \
-       CmmInfo \
-       CmmMachOp \
-       CmmNode \
        CmmType \
-       CmmUtils \
        CoAxiom \
        ConLike \
-       CodeGen.Platform \
-       CodeGen.Platform.ARM \
-       CodeGen.Platform.NoRegs \
-       CodeGen.Platform.PPC \
-       CodeGen.Platform.PPC_Darwin \
-       CodeGen.Platform.SPARC \
-       CodeGen.Platform.X86 \
-       CodeGen.Platform.X86_64 \
        Coercion \
        Config \
        Constants \
        CoreArity \
        CoreFVs \
-       CoreLint \
        CoreSubst \
        CoreSyn \
        CoreTidy \
        CoreUnfold \
        CoreUtils \
+       CoreSeq \
+       CoreStats \
        CostCentre \
        DataCon \
        Demand \
        Digraph \
        DriverPhases \
-       DsMonad \
        DynFlags \
        Encoding \
        ErrUtils \
        Exception \
-       ExtsCompat46 \
        FamInstEnv \
-       FastBool \
        FastFunctions \
        FastMutInt \
        FastString \
-       FastTypes \
-       Finder \
+       FastStringEnv \
+       FieldLabel \
        Fingerprint \
        FiniteMap \
        ForeignCall \
+       FV \
        Hooks \
-       Hoopl \
-       Hoopl.Dataflow \
        HsBinds \
        HsDecls \
        HsDoc \
        HsExpr \
        HsImpExp \
        HsLit \
+       PlaceHolder \
+       PmExpr \
        HsPat \
        HsSyn \
        HsTypes \
        HsUtils \
        HscTypes \
        IOEnv \
+  NameCache \
        Id \
        IdInfo \
-       IfaceEnv \
        IfaceSyn \
        IfaceType \
+       Json            \
+       ToIface \
        InstEnv \
-       InteractiveEvalTypes \
        Kind \
+       KnownUniques \
+       Lexeme \
        ListSetOps \
        Literal \
-       LoadIface \
        Maybes \
        MkCore \
-       MkGraph \
        MkId \
        Module \
        MonadUtils \
@@ -573,47 +522,29 @@ compiler_stage2_dll0_MODULES = \
        PipelineMonad \
        Platform \
        PlatformConstants \
-       PprCmm \
-       PprCmmDecl \
-       PprCmmExpr \
        PprCore \
-       PrelInfo \
        PrelNames \
        PrelRules \
        Pretty \
        PrimOp \
+       RepType \
        RdrName \
-       Reg \
-       RegClass \
        Rules \
-       SMRep \
-       Serialized \
        SrcLoc \
-       StaticFlags \
-       StgCmmArgRep \
-       StgCmmClosure \
-       StgCmmEnv \
-       StgCmmLayout \
-       StgCmmMonad \
-       StgCmmProf \
-       StgCmmTicky \
-       StgCmmUtils \
-       StgSyn \
-       Stream \
        StringBuffer \
+       SysTools.Terminal \
        TcEvidence \
-       TcIface \
-       TcRnMonad \
        TcRnTypes \
        TcType \
-       TcTypeNats \
        TrieMap \
        TyCon \
        Type \
-       TypeRep \
+       TyCoRep \
        TysPrim \
        TysWiredIn \
        Unify \
+       UniqDFM \
+       UniqDSet \
        UniqFM \
        UniqSet \
        UniqSupply \
@@ -623,10 +554,19 @@ compiler_stage2_dll0_MODULES = \
        VarEnv \
        VarSet
 
+ifeq "$(GhcWithInterpreter)" "YES"
+# These files are reacheable from DynFlags
+# only by GHCi-enabled code (see #9552)
+compiler_stage2_dll0_MODULES += \
+       ByteCodeTypes \
+       InteractiveEvalTypes
+endif
+
 compiler_stage2_dll0_HS_OBJS = \
     $(patsubst %,compiler/stage2/build/%.$(dyn_osuf),$(subst .,/,$(compiler_stage2_dll0_MODULES)))
 
 # if stage is set to something other than "1" or "", disable stage 1
+# See Note [Stage1Only vs stage=1] in mk/config.mk.in.
 ifneq "$(filter-out 1,$(stage))" ""
 compiler_stage1_NOT_NEEDED = YES
 endif
@@ -648,8 +588,8 @@ $(eval $(call build-package,compiler,stage3,2))
 define keepCAFsForGHCiDynOnly
 # $1 = stage
 # $2 = way
-ifeq "$$(findstring dyn, $1)" ""
-compiler_stage$1_$2_C_OBJS := $$(filter-out %/keepCAFsForGHCi.o,$$(compiler_stage$1_$2_C_OBJS))
+ifeq "$$(findstring dyn, $2)" ""
+compiler_stage$1_$2_C_OBJS := $$(filter-out %/keepCAFsForGHCi.$$($2_osuf),$$(compiler_stage$1_$2_C_OBJS))
 endif
 endef
 $(foreach w,$(compiler_stage1_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,1,$w)))
@@ -667,9 +607,15 @@ compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
 
 # after build-package, because that sets compiler_stage1_HC_OPTS:
-compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
-compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
-compiler_stage3_HC_OPTS += $(GhcStage3HcOpts)
+ifeq "$(V)" "0"
+compiler_stage1_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage1HcOpts)
+compiler_stage2_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage2HcOpts)
+compiler_stage3_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage3HcOpts)
+else
+compiler_stage1_HC_OPTS += $(GhcHcOpts) $(GhcStage1HcOpts)
+compiler_stage2_HC_OPTS += $(GhcHcOpts) $(GhcStage2HcOpts)
+compiler_stage3_HC_OPTS += $(GhcHcOpts) $(GhcStage3HcOpts)
+endif
 
 ifneq "$(BINDIST)" "YES"
 
@@ -708,26 +654,4 @@ ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
 compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
 endif
 
-# LibFFI.hs #includes ffi.h
-ifneq "$(UseSystemLibFFI)" "YES"
-compiler/stage2/build/LibFFI.hs : $(libffi_HEADERS)
-endif
-
-# Note [munge-stage1-package-config]
-# Strip the date/patchlevel from the version of stage1.  See Note
-# [fiddle-stage1-version] above.
-ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
-compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
-       sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
-           -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
-           -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
-         < $< > $@
-       "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
-
-# We need to make sure the munged config is in the database before we
-# try to configure ghc-bin
-ghc/stage1/package-data.mk : compiler/stage1/inplace-pkg-config-munged
 endif
-
-endif
-