X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FMakefile;h=769a673a6fb4b2e5ad8ff5f4d80f38ac9c8e28a6;hb=dd313897eb9a14bcc7b81f97e4f2292c30039efd;hp=4cff048ed20cfdf26ddd553654962ab4b559c8d8;hpb=e64cdcd1c11f896085923860d67e1b9d02090b3d;p=ghc-hetmet.git diff --git a/ghc/compiler/Makefile b/ghc/compiler/Makefile index 4cff048..769a673 100644 --- a/ghc/compiler/Makefile +++ b/ghc/compiler/Makefile @@ -90,11 +90,24 @@ ifeq "$(stage)" "" stage=1 endif -boot :: +.DUMMY: stage_dir +stage_dirs : $(MKDIRHIER) stage$(stage) for i in $(ALL_DIRS); do \ $(MKDIRHIER) stage$(stage)/$$i; \ done + +ifeq "$(stage) $(ghc_ge_603)" "1 YES" +UsingHsBoot = YES +else +ifneq "$(findstring $(stage), 2 3)" "" +UsingHsBoot = YES +else +UsingHsBoot = NO +endif +endif + +boot :: stage_dirs # On Windows, we can't use symbolic links for the -hi-boot files # because GHC itself is a Mingw program and does not understand # symbolic links. So we have to copy the files instead of link them. @@ -104,8 +117,7 @@ boot :: # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz' # whereas 'cp foo baz' treats the two paths independently. # Hence the "../.." in the ln command line -ifeq "$(stage)" "1" -ifeq "$(ghc_ge_603)" "NO" +ifeq "$(UsingHsBoot)" "NO" ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" for i in */*hi-boot*; do \ cp -u -f $$i stage$(stage)/$$i; \ @@ -116,7 +128,6 @@ else done endif endif -endif ifeq "$(stage)" "1" HC=$(GHC) @@ -146,8 +157,15 @@ SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS)) HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS)))) C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS)))) +# Our standard cleaning rules don't know that we're doing our output into $(odir), so +# we have to augment CLEAN_FILES appropriateliy. + CLEAN_FILES += $(odir)/*/*.hi +ifeq "$(UsingHsBoot)" "YES" +CLEAN_FILES += $(odir)/*/*.hi-boot $(odir)/*/*.o-boot +endif + ifeq "$(stage)" "1" mostlyclean clean distclean maintainer-clean :: $(MAKE) $@ stage=2 @@ -163,7 +181,6 @@ endif # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the # equivalent of `env' if it doesn't exist locally). # -ifneq "$(BuildPackageGHC)" "YES" ifneq "$(way)" "dll" ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32" HS_PROG=$(odir)/ghc$(_way)-$(ProjectVersion) @@ -173,7 +190,6 @@ endif else HS_PROG=$(odir)/ghc-$(ProjectVersion) endif -endif # ----------------------------------------------------------------------------- # Create compiler configuration @@ -237,7 +253,7 @@ CLEAN_FILES += $(CONFIG_HS) PLATFORM_H = ghc_boot_platform.h -stage1/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk Makefile +stage1/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk Makefile @echo "Creating $@..." @$(RM) $@ @echo "#ifndef __PLATFORM_H__" >$@ @@ -283,7 +299,7 @@ endif # For stage2 and above, the BUILD platform is the HOST of stage1, and # the HOST platform is the TARGET of stage1. The TARGET remains the same # (stage1 is the cross-compiler, not stage2). -stage2/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk Makefile +stage2/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk Makefile @echo "Creating $@..." @$(RM) $@ @echo "#ifndef __PLATFORM_H__" >$@ @@ -326,10 +342,12 @@ endif @echo "#endif /* __PLATFORM_H__ */" >> $@ @echo "Done." -stage3/$(PLATFORM_H) : stage2/$(PLATFORM_H) +stage3/$(PLATFORM_H) : stage_dirs stage2/$(PLATFORM_H) $(CP) stage2/$(PLATFORM_H) stage3/$(PLATFORM_H) -boot :: stage$(stage)/$(PLATFORM_H) +STAGE_PLATFORM_H = stage$(stage)/$(PLATFORM_H) + +boot :: $(STAGE_PLATFORM_H) SRC_HC_OPTS += -Istage$(stage) @@ -387,9 +405,20 @@ ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES" # Yes, include the interepreter, readline, and Template Haskell extensions SRC_HC_OPTS += -DGHCI -package template-haskell +PKG_DEPENDS += template-haskell ALL_DIRS += ghci +# If we are going to use dynamic libraries instead of .o files for ghci, +# we will need to always retain CAFs in the compiler. +# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor)) +# function which sets the keepCAFs flag for the RTS before any Haskell +# code is run. +ifeq "$(GhcBuildDylibs)" "YES" +else +EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c +endif + # Enable readline if either: # - we're building stage 1 and $(GhcHasReadline)="YES" # - we're building stage 2/3, and we have built the readline package @@ -401,10 +430,12 @@ ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32" ifeq "$(stage)" "1" ifeq "$(GhcHasReadline)" "YES" SRC_HC_OPTS += -package readline -DUSE_READLINE +PKG_DEPENDS += readline endif else ifeq "$(GhcLibsWithReadline)" "YES" SRC_HC_OPTS += -package readline -DUSE_READLINE +PKG_DEPENDS += readline endif endif # stage=1 endif # not windows @@ -456,11 +487,13 @@ ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO" SRC_HC_OPTS += -package posix else SRC_HC_OPTS += -package unix +PKG_DEPENDS += unix endif endif ifneq "$(findstring YES, $(bootstrapped) $(ghc_ge_603))" "" SRC_HC_OPTS += -package Cabal +PKG_DEPENDS += Cabal endif SRC_CC_OPTS += -Iparser -I. -O @@ -515,6 +548,11 @@ utils/Binary_HC_OPTS += -O utils/FastMutInt_HC_OPTS += -O +# ---- Profiling ---- +#simplCore/Simplify_HC_OPTS = -auto-all +#simplCore/SimplEnv_HC_OPTS = -auto-all +#simplCore/SimplUtils_HC_OPTS = -auto-all + # CSE interacts badly with top-level IORefs (reportedly in DriverState and # DriverMkDepend), causing some of them to be commoned up. We have a fix for # this in 5.00+, but earlier versions of the compiler will need CSE turned off. @@ -522,13 +560,11 @@ utils/FastMutInt_HC_OPTS += -O compMan/CompManager_HC_OPTS = -fno-cse ghci/InteractiveUI_HC_OPTS = -fno-cse main/CmdLineOpts_HC_OPTS = -fno-cse -main/DriverFlags_HC_OPTS = -fno-cse main/DriverMkDepend_HC_OPTS = -fno-cse main/DriverPipeline_HC_OPTS = -fno-cse -main/DriverState_HC_OPTS = -fno-cse -main/DriverUtil_HC_OPTS = -fno-cse main/Finder_HC_OPTS = -fno-cse main/SysTools_HC_OPTS = -fno-cse +main/StaticFlags_HC_OPTS = -fno-cse # The #include is vital for the via-C route, else the C # compiler doesn't realise that the stcall foreign imports are indeed @@ -709,14 +745,36 @@ endif coreSyn/CorePrep_HC_OPTS += -auto-all #----------------------------------------------------------------------------- -# Building GHC package +# Building the GHC package -ifeq "$(BuildPackageGHC)" "YES" +# The GHC package is made from the stage 2 build. Fortunately the +# package build system framework more or less does the right thing for +# us here. +ifeq "$(stage)" "2" PACKAGE = ghc -STANDALONE_PACKAGE = YES -PACKAGE_DEPS = +HIERARCHICAL_LIB = NO +VERSION = $(ProjectVersion) +PKG_DEPENDS += base haskell98 +PACKAGE_CPP_OPTS += -DPKG_DEPENDS='$(PKG_DEPENDS)' + +# disable splitting: it won't really help with GHC, and the specialised +# build system for ghc/compiler isn't set up to handle it. +SplitObjs = NO + +# the package build system likes to set WAYS=$(GhcLibWays), but we don't +# really want to build the whole of GHC multiple ways... if you do, +# set GhcCompilerWays instead. +GhcLibWays = $(GhcCompilerWays) + +# override $(GhcLibHcOpts): we want GhcStage2HcOpts to take precedence +GhcLibHcOpts = + +# override default definition of HS_IFACES so we can add $(odir) +HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_OBJS))) +# Haddock can't handle recursive modules currently, so we disable it for now. +NO_HADDOCK_DOCS = YES endif #----------------------------------------------------------------------------- @@ -755,7 +813,7 @@ MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS)) MKDEPENDHS=$(HC) # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet. -depend :: $(HS_SRCS) $(C_SRCS) +depend :: $(STAGE_PLATFORM_H) $(HS_SRCS) $(C_SRCS) touch .depend-BASE ifneq "$(BootingFromHc)" "YES" $(MKDEPENDHS) -M -optdep-f -optdep.depend-BASE $(foreach way,$(WAYS),-optdep-s -optdep$(way)) $(foreach obj,$(MKDEPENDHS_OBJ_SUFFICES),-osuf $(obj)) $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(MKDEPENDHS_HC_OPTS)) $(HS_SRCS)