gitlab-ci: Update bootstrap compiled used for Darwin builds
[ghc.git] / compiler / ghc.mk
index a2a123c..441b698 100644 (file)
@@ -5,8 +5,8 @@
 # This file is part of the GHC build system.
 #
 # To understand how the build system works and how to modify it, see
-#      http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
-#      http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
+#      https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture
+#      https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying
 #
 # -----------------------------------------------------------------------------
 
@@ -49,95 +49,35 @@ compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
        $(call removeFiles,$@)
        @echo 'Creating $@ ... '
        @echo '{-# LANGUAGE CPP #-}'                                        >> $@
-       @echo 'module Config where'                                         >> $@
+       @echo 'module Config'                                               >> $@
+       @echo '  ( module GHC.Version'                                      >> $@
+       @echo '  , cBuildPlatformString'                                    >> $@
+       @echo '  , cHostPlatformString'                                     >> $@
+       @echo '  , cProjectName'                                            >> $@
+       @echo '  , cBooterVersion'                                          >> $@
+       @echo '  , cStage'                                                  >> $@
+       @echo '  ) where'                                                   >> $@
        @echo                                                               >> $@
-       @echo '#include "ghc_boot_platform.h"'                              >> $@
+       @echo 'import GhcPrelude'                                           >> $@
+       @echo                                                               >> $@
+       @echo 'import GHC.Version'                                          >> $@
        @echo                                                               >> $@
-       @echo 'data IntegerLibrary = IntegerGMP'                            >> $@
-       @echo '                    | IntegerSimple'                         >> $@
-       @echo '                    deriving Eq'                             >> $@
+       @echo '#include "ghc_boot_platform.h"'                              >> $@
        @echo                                                               >> $@
        @echo 'cBuildPlatformString :: String'                              >> $@
        @echo 'cBuildPlatformString = BuildPlatform_NAME'                   >> $@
+       @echo                                                               >> $@
        @echo 'cHostPlatformString :: String'                               >> $@
        @echo 'cHostPlatformString = HostPlatform_NAME'                     >> $@
-       @echo 'cTargetPlatformString :: String'                             >> $@
-       @echo 'cTargetPlatformString = TargetPlatform_NAME'                 >> $@
        @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                                                               >> $@
        @echo 'cBooterVersion        :: String'                             >> $@
        @echo 'cBooterVersion        = "$(GhcVersion)"'                     >> $@
+       @echo                                                               >> $@
        @echo 'cStage                :: String'                             >> $@
        @echo 'cStage                = show (STAGE :: Int)'                 >> $@
-       @echo 'cIntegerLibrary       :: String'                             >> $@
-       @echo 'cIntegerLibrary       = "$(INTEGER_LIBRARY)"'                >> $@
-       @echo 'cIntegerLibraryType   :: IntegerLibrary'                     >> $@
-ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
-       @echo 'cIntegerLibraryType   = IntegerGMP'                          >> $@
-else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
-       @echo 'cIntegerLibraryType   = IntegerSimple'                       >> $@
-else ifneq "$(CLEANING)" "YES"
-$(error Unknown integer library)
-endif
-       @echo 'cSupportsSplitObjs    :: String'                             >> $@
-       @echo 'cSupportsSplitObjs    = "$(SupportsSplitObjs)"'              >> $@
-       @echo 'cGhcWithInterpreter   :: String'                             >> $@
-       @echo 'cGhcWithInterpreter   = "$(GhcWithInterpreter)"'             >> $@
-       @echo 'cGhcWithNativeCodeGen :: String'                             >> $@
-       @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"'           >> $@
-       @echo 'cGhcWithSMP           :: String'                             >> $@
-       @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 'cGHC_UNLIT_PGM        :: String'                             >> $@
-       @echo 'cGHC_UNLIT_PGM        = "$(utils/unlit_dist_PROG)"'          >> $@
-       @echo 'cGHC_SPLIT_PGM        :: String'                             >> $@
-       @echo 'cGHC_SPLIT_PGM        = "$(driver/split_dist_PROG)"'         >> $@
-       @echo 'cLibFFI               :: Bool'                               >> $@
-ifeq "$(UseLibFFIForAdjustors)" "YES"
-       @echo 'cLibFFI               = True'                                >> $@
-else
-       @echo 'cLibFFI               = False'                               >> $@
-endif
-# Note that GhcThreaded just reflects the Makefile variable setting.
-# In particular, the stage1 compiler is never actually compiled with
-# -threaded, but it will nevertheless have cGhcThreaded = True.
-# The "+RTS --info" output will show what RTS GHC is really using.
-       @echo 'cGhcThreaded :: Bool'                                        >> $@
-ifeq "$(GhcThreaded)" "YES"
-       @echo 'cGhcThreaded = True'                                         >> $@
-else
-       @echo 'cGhcThreaded = False'                                        >> $@
-endif
-       @echo 'cGhcDebugged :: Bool'                                        >> $@
-ifeq "$(GhcDebugged)" "YES"
-       @echo 'cGhcDebugged = True'                                         >> $@
-else
-       @echo 'cGhcDebugged = False'                                        >> $@
-endif
        @echo done.
 
 # -----------------------------------------------------------------------------
@@ -153,38 +93,29 @@ PLATFORM_H = ghc_boot_platform.h
 compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
        $(call removeFiles,$@)
        @echo "Creating $@..."
-       @echo "#ifndef __PLATFORM_H__"                           >> $@
+       @echo "#if !defined(__PLATFORM_H__)"                     >> $@
        @echo "#define __PLATFORM_H__"                           >> $@
        @echo                                                    >> $@
        @echo "#define BuildPlatform_NAME  \"$(BUILDPLATFORM)\""  >> $@
        @echo "#define HostPlatform_NAME   \"$(HOSTPLATFORM)\""   >> $@
-       @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
        @echo                                                     >> $@
        @echo "#define $(BuildPlatform_CPP)_BUILD 1"              >> $@
        @echo "#define $(HostPlatform_CPP)_HOST 1"                >> $@
-       @echo "#define $(TargetPlatform_CPP)_TARGET 1"            >> $@
        @echo                                                     >> $@
        @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1"             >> $@
        @echo "#define $(HostArch_CPP)_HOST_ARCH 1"               >> $@
-       @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1"           >> $@
        @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\""           >> $@
        @echo "#define HOST_ARCH \"$(HostArch_CPP)\""             >> $@
-       @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\""         >> $@
-       @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\""         >> $@
        @echo                                                     >> $@
        @echo "#define $(BuildOS_CPP)_BUILD_OS 1"                 >> $@
        @echo "#define $(HostOS_CPP)_HOST_OS 1"                   >> $@
-       @echo "#define $(TargetOS_CPP)_TARGET_OS 1"               >> $@
        @echo "#define BUILD_OS \"$(BuildOS_CPP)\""               >> $@
        @echo "#define HOST_OS \"$(HostOS_CPP)\""                 >> $@
-       @echo "#define TARGET_OS \"$(TargetOS_CPP)\""             >> $@
        @echo                                                     >> $@
        @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1"         >> $@
        @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1"           >> $@
-       @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1"      >> $@
        @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\""       >> $@
        @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\""         >> $@
-       @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\""     >> $@
        @echo                                                     >> $@
        @echo "#endif /* __PLATFORM_H__ */"                       >> $@
        @echo "Done."
@@ -195,38 +126,29 @@ compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
 compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
        $(call removeFiles,$@)
        @echo "Creating $@..."
-       @echo "#ifndef __PLATFORM_H__"                            >> $@
+       @echo "#if !defined(__PLATFORM_H__)"                      >> $@
        @echo "#define __PLATFORM_H__"                            >> $@
        @echo                                                     >> $@
        @echo "#define BuildPlatform_NAME  \"$(HOSTPLATFORM)\""   >> $@
        @echo "#define HostPlatform_NAME   \"$(TARGETPLATFORM)\"" >> $@
-       @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
        @echo                                                     >> $@
        @echo "#define $(HostPlatform_CPP)_BUILD 1"               >> $@
        @echo "#define $(TargetPlatform_CPP)_HOST 1"              >> $@
-       @echo "#define $(TargetPlatform_CPP)_TARGET 1"            >> $@
        @echo                                                     >> $@
        @echo "#define $(HostArch_CPP)_BUILD_ARCH 1"              >> $@
        @echo "#define $(TargetArch_CPP)_HOST_ARCH 1"             >> $@
-       @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1"           >> $@
        @echo "#define BUILD_ARCH \"$(HostArch_CPP)\""            >> $@
        @echo "#define HOST_ARCH \"$(TargetArch_CPP)\""           >> $@
-       @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\""         >> $@
-       @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\""         >> $@
        @echo                                                     >> $@
        @echo "#define $(HostOS_CPP)_BUILD_OS 1"                  >> $@
        @echo "#define $(TargetOS_CPP)_HOST_OS 1"                 >> $@
-       @echo "#define $(TargetOS_CPP)_TARGET_OS 1"               >> $@
        @echo "#define BUILD_OS \"$(HostOS_CPP)\""                >> $@
        @echo "#define HOST_OS \"$(TargetOS_CPP)\""               >> $@
-       @echo "#define TARGET_OS \"$(TargetOS_CPP)\""             >> $@
        @echo                                                     >> $@
        @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1"          >> $@
        @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1"         >> $@
-       @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1"      >> $@
        @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\""        >> $@
        @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\""       >> $@
-       @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\""     >> $@
        @echo                                                     >> $@
        @echo "#endif /* __PLATFORM_H__ */"                       >> $@
        @echo "Done."
@@ -268,7 +190,7 @@ compiler_HC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
 
 define preprocessCompilerFiles
 # $0 = stage
-compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
+compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp
        $$(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)
@@ -334,7 +256,7 @@ endif
 ifeq "$(GhcWithInterpreter)" "YES"
 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
 
-ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
+ifeq "$(TablesNextToCode)" "YES"
 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
 # or not?
 # XXX This should logically be a CPP option, but there doesn't seem to
@@ -421,160 +343,10 @@ compiler_PACKAGE = ghc
 
 # 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
 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 \
-       Binary \
-       BinFingerprint \
-       BooleanFormula \
-       BufWrite \
-       ByteCodeTypes \
-       Class \
-       CmdLineParser \
-       CmmType \
-       CoAxiom \
-       ConLike \
-       Coercion \
-       Config \
-       Constants \
-       CoreArity \
-       CoreFVs \
-       CoreSubst \
-       CoreOpt \
-       CoreSyn \
-       CoreTidy \
-       CoreUnfold \
-       CoreUtils \
-       CoreSeq \
-       CoreStats \
-       CostCentre \
-       DataCon \
-       Demand \
-       Digraph \
-       DriverPhases \
-       DynFlags \
-       Encoding \
-       EnumSet \
-       ErrUtils \
-       Exception \
-       FamInstEnv \
-       FastFunctions \
-       FastMutInt \
-       FastString \
-       FastStringEnv \
-       FieldLabel \
-       Fingerprint \
-       FiniteMap \
-       ForeignCall \
-       FV \
-       Hooks \
-       HsBinds \
-       HsDecls \
-       HsDoc \
-       HsExpr \
-       HsImpExp \
-       HsLit \
-       PlaceHolder \
-       HsExtension \
-       PmExpr \
-       HsPat \
-       HsSyn \
-       HsTypes \
-       HsUtils \
-       HscTypes \
-       IOEnv \
-       NameCache \
-       Id \
-       IdInfo \
-       IfaceSyn \
-       IfaceType \
-       InteractiveEvalTypes \
-       Json \
-       ToIface \
-       InstEnv \
-       Kind \
-       KnownUniques \
-       Lexeme \
-       ListSetOps \
-       Literal \
-       Maybes \
-       MkCore \
-       MkId \
-       Module \
-       MonadUtils \
-       Name \
-       NameEnv \
-       NameSet \
-       OccName \
-       OccurAnal \
-       OptCoercion \
-       OrdList \
-       Outputable \
-       PackageConfig \
-       Packages \
-       Pair \
-       Panic \
-       PatSyn \
-       PipelineMonad \
-       Platform \
-       PlatformConstants \
-       PprColour \
-       PprCore \
-       PrelNames \
-       PrelRules \
-       Pretty \
-       PrimOp \
-       RepType \
-       RdrName \
-       Rules \
-       SrcLoc \
-       StringBuffer \
-       SysTools.Terminal \
-       TcEvidence \
-       TcRnTypes \
-       TcType \
-       TrieMap \
-       TyCon \
-       Type \
-       TyCoRep \
-       TysPrim \
-       TysWiredIn \
-       Unify \
-       UniqDFM \
-       UniqDSet \
-       UniqFM \
-       UniqSet \
-       UniqSupply \
-       Unique \
-       Util \
-       Var \
-       VarEnv \
-       VarSet
-
-ifeq "$(GhcWithInterpreter)" "YES"
-# These files are reacheable from DynFlags
-# only by GHCi-enabled code (see #9552)
-compiler_stage2_dll0_MODULES += # none
-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))" ""
@@ -629,9 +401,6 @@ endif
 
 ifneq "$(BINDIST)" "YES"
 
-compiler_stage2_TAGS_HC_OPTS = -package ghc
-$(eval $(call tags-package,compiler,stage2))
-
 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)