diff options
author | Ian Lynagh <igloo@earth.li> | 2009-04-26 11:42:15 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2009-04-26 11:42:15 +0000 |
commit | 34cc75e1a62638f2833815746ebce0a9114dc26b (patch) | |
tree | ef21e8fd7af1356beea9cce7d6efb8a65374e24c /compiler | |
parent | 74e1368d4688ee16f6decdf2cd3ebe27506b26ba (diff) | |
download | haskell-34cc75e1a62638f2833815746ebce0a9114dc26b.tar.gz |
GHC new build system megapatch
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/LICENSE | 31 | ||||
-rw-r--r-- | compiler/Makefile | 507 | ||||
-rw-r--r-- | compiler/ghc.cabal.in | 19 | ||||
-rw-r--r-- | compiler/ghc.mk | 432 | ||||
-rw-r--r-- | compiler/main/DriverMkDepend.hs | 28 | ||||
-rw-r--r-- | compiler/main/SysTools.lhs | 200 | ||||
-rw-r--r-- | compiler/rename/RnNames.lhs | 10 |
7 files changed, 575 insertions, 652 deletions
diff --git a/compiler/LICENSE b/compiler/LICENSE new file mode 100644 index 0000000000..b5059b71f6 --- /dev/null +++ b/compiler/LICENSE @@ -0,0 +1,31 @@ +The Glasgow Haskell Compiler License + +Copyright 2002, The University Court of the University of Glasgow. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +- Neither name of the University nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF +GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. diff --git a/compiler/Makefile b/compiler/Makefile index 18701532ca..f85e1c893c 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -1,503 +1,16 @@ -# ----------------------------------------------------------------------------- -# Main compiler Makefile - -# Targets: -# -# all builds stage1 compiler -# -# boot stage=N generate build dirs and dependencies for stage N. -# NB. Must be done before 'make stageN'. -# NB. Cannot 'make boot stage=2' until stage1 has -# been built (similarly for stage3). -# -# stage1 (or stage=1) builds stage1 compiler -# stage2 (or stage=2) builds stage2 compiler -# stage3 (or stage=3) builds stage3 compiler -# - +dir = compiler TOP = .. +SPEC_TARGETS = 1 2 3 +include $(TOP)/mk/sub-makefile.mk -ifeq "$(stage)" "" -stage=1 -endif - -include $(TOP)/mk/boilerplate.mk -include $(TOP)/mk/cabal-flags.mk - -ifeq "$(GhcThreaded) $(GhcProfiled)" "YES YES" -$(error Cannot make GHC both threaded and profiled) -endif - -CONFIG_HS = main/Config.hs -PRIMOP_BITS = primop-data-decl.hs-incl \ - primop-tag.hs-incl \ - primop-list.hs-incl \ - primop-has-side-effects.hs-incl \ - primop-out-of-line.hs-incl \ - primop-commutable.hs-incl \ - primop-needs-wrapper.hs-incl \ - primop-can-fail.hs-incl \ - primop-strictness.hs-incl \ - primop-primop-info.hs-incl - -boot:: boot.stage.$(stage) - -all:: build.stage.$(stage) - -doc:: doc.stage.$(stage) - -stage1 :: - $(MAKE) stage=1 - -stage2 :: - $(MAKE) stage=2 - -stage3 :: - $(MAKE) stage=3 - -ifeq "$(CLEAN_ALL_STAGES)" "YES" -clean distclean maintainer-clean:: - $(RM) -f prelude/primops.txt - $(RM) -f $(PRIMOP_BITS) - $(RM) -f $(CONFIG_HS) - $(RM) -f parser/Parser.y - $(RM) -rf stage1 stage2plus - $(RM) -f $(STAGE3_PACKAGE_CONF) -endif - -ifeq "$(CLEAN_ALL_STAGES)" "YES" -clean distclean maintainer-clean:: clean.stage.1 clean.stage.2 clean.stage.3 -else -clean distclean maintainer-clean:: clean.stage.$(stage) -endif - -ifeq "$(CLEAN_ALL_STAGES)" "YES" -distclean maintainer-clean:: - $(RM) -f ghc.cabal -endif - -clean.stage.%: - $(RM) -f Makefile-stage$* -# This is a bit naughty. We ought to use: -# -$(CABAL) clean --distpref dist-stage$* -# but that won't work if the Cabal file (a generated file) doesn't -# exist. So we do this instead: - $(RM) -rf dist-stage$* - -CONFIGURE_FLAGS_STAGE1 += --flags=stage1 -CONFIGURE_FLAGS_STAGE2 += --flags=-stage1 - -ifeq "$(GhcWithNativeCodeGen)" "YES" -CONFIGURE_FLAGS_STAGE1 += --flags=ncg -CONFIGURE_FLAGS_STAGE2 += --flags=ncg -endif - -ifeq "$(GhcWithInterpreter)" "YES" -CONFIGURE_FLAGS_STAGE2 += --flags=ghci - -ifeq "$(BuildSharedLibs)" "YES" -CONFIGURE_FLAGS_STAGE2 += --enable-shared -# 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. -CONFIGURE_FLAGS_STAGE2 += --flags=dynlibs -endif - -ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO" -# 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 -# be a flag for that -CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE -endif - -# Should the debugger commands be enabled? -ifeq "$(GhciWithDebugger)" "YES" -CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DDEBUGGER -endif - -# Enable editline if: -# - we're building stage 2/3, and we have built the editline package -# -# But we don't enable editline on Windows, as Windows terminals have -# editline-like support builtin. -# -ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32" -ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/editline/unbuildable)" "" -CONFIGURE_FLAGS_STAGE2 += --flags=editline -endif -endif -endif - -ifeq "$(GhcWithNativeCodeGen)" "NO" -# XXX This should logically be a CPP option, but there doesn't seem to -# be a flag for that -COMMON_CONFIGURE_FLAGS += --ghc-option=-DOMIT_NATIVE_CODEGEN -endif - -ifeq "$(TargetOS_CPP)" "openbsd" -COMMON_CONFIGURE_FLAGS += --ld-options=-E -endif - -ifeq "$(GhcUnregisterised)" "NO" -ifeq "$(HOSTPLATFORM)" "ia64-unknown-linux" -# needed for generating proper relocation in large binaries: trac #856 -COMMON_CONFIGURE_FLAGS += --ld-option=-Wl,--relax -endif -endif - -# We need to turn on profiling either if we have been asked to -# (GhcLibProfiled = YES) or if we want GHC itself to be compiled with -# profiling enabled (GhcProfiled = YES). -ifneq "$(GhcLibProfiled) $(GhcProfiled)" "NO NO" -CONFIGURE_FLAGS_STAGE2 += --enable-library-profiling -# And if we're profiling GHC then we want lots of SCCs. -# We also don't want to waste time building the non-profiling library, -# either normally or for ghci. Unfortunately this means that we have to -# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't -# exist. -ifeq "$(GhcProfiled)" "YES" -CONFIGURE_FLAGS_STAGE2 += --ghc-option=-auto-all -CONFIGURE_FLAGS_STAGE2 += --disable-library-vanilla -CONFIGURE_FLAGS_STAGE2 += --disable-library-for-ghci -CONFIGURE_FLAGS_STAGE2 += --ghc-pkg-option=--force -endif -endif - -ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -# The #include is vital for the via-C route with older compilers, else the C -# compiler doesn't realise that the stcall foreign imports are indeed -# stdcall, and doesn't generate the Foo@8 name for them -# As it's only important for older compilers we don't need to do anything -# for stage2+. -CONFIGURE_FLAGS_STAGE1 += --ghc-option='-\#include' \ - --ghc-option='"<windows.h>"' \ - --ghc-option='-\#include' \ - --ghc-option='"<process.h>"' -endif - -# ghc_strlen percolates through so many modules that it is easier to get its -# prototype via a global option instead of a myriad of per-file OPTIONS. -# Again, this is only important for older compilers, so we don't do it in -# stage 2+. -CONFIGURE_FLAGS_STAGE1 += --ghc-options='-\#include "cutils.h"' - -CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2) -CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS) -CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS) -CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS) -CONFIGURE_FLAGS_STAGE3 += --package-db $(STAGE3_PACKAGE_CONF) - -# In a source dist we don't need to worry about Parser.y(.pp) as we have -# the .hs file pre-generated -ifneq "$(wildcard parser/Parser.y.pp)" "" -PARSER_Y = parser/Parser.y -endif - -boot.stage.%: $(PRIMOP_BITS) $(CONFIG_HS) $(PARSER_Y) - test -f $(STAGE3_PACKAGE_CONF) || echo "[]" > $(STAGE3_PACKAGE_CONF) - $(CABAL) configure --distpref dist-stage$* \ - $(CONFIGURE_FLAGS_STAGE$*) \ - $(INSTALL_DIRS_CONFIGURE_FLAGS) \ - $(COMMON_CONFIGURE_FLAGS) \ - --ghc-option=-DSTAGE=$* - $(RM) -f Makefile-stage$* - $(CABAL) makefile --distpref dist-stage$* -f Makefile-stage$* - -build.stage.%: - $(MAKE) -f Makefile-stage$* stage=$* - $(CABAL) register --distpref dist-stage$* --inplace - $(MAKE) -C ../ghc stage=$* - -doc.stage.%: - $(CABAL) haddock --distpref dist-stage$* \ - --html-location='../$$pkg' \ - --haddock-option=--optghc=-DSTAGE=$* \ - --haddock-option=+RTS --haddock-option=-s --haddock-option=-c --haddock-option=-RTS \ - --with-haddock=$(FPTOOLS_TOP_ABS)/utils/haddock/install-inplace/bin/haddock - -install: - $(INSTALL_PACKAGE) install '$(GHC_PKG_INSTALL_PROG)' '$(DESTDIR)$(datadir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' --distpref dist-stage2 - -# ----------------------------------------------------------------------------- -# Create compiler configuration -# -# The 'echo' commands simply spit the values of various make variables -# into Config.hs, whence they can be compiled and used by GHC itself - -$(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk - @$(RM) -f $(CONFIG_HS) - @echo "Creating $(CONFIG_HS) ... " - @echo "module Config where" >>$(CONFIG_HS) - @echo "cProjectName :: String" >> $(CONFIG_HS) - @echo "cProjectName = \"$(ProjectName)\"" >> $(CONFIG_HS) - @echo "cProjectVersion :: String" >> $(CONFIG_HS) - @echo "cProjectVersion = \"$(ProjectVersion)\"" >> $(CONFIG_HS) - @echo "cProjectVersionInt :: String" >> $(CONFIG_HS) - @echo "cProjectVersionInt = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS) - @echo "cProjectPatchLevel :: String" >> $(CONFIG_HS) - @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS) - @echo "cBooterVersion :: String" >> $(CONFIG_HS) - @echo "cBooterVersion = \"$(GhcVersion)\"" >> $(CONFIG_HS) - @echo "cStage :: String" >> $(CONFIG_HS) - @echo "cStage = show (STAGE :: Int)" >> $(CONFIG_HS) - @echo "cHscIfaceFileVersion :: String" >> $(CONFIG_HS) - @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS) - @echo "cSplitObjs :: String" >> $(CONFIG_HS) - @echo "cSplitObjs = \"$(SupportsSplitObjs)\"" >> $(CONFIG_HS) - @echo "cGhcWithInterpreter :: String" >> $(CONFIG_HS) - @echo "cGhcWithInterpreter = \"$(GhcWithInterpreter)\"" >> $(CONFIG_HS) - @echo "cGhcWithNativeCodeGen :: String" >> $(CONFIG_HS) - @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS) - @echo "cGhcWithSMP :: String" >> $(CONFIG_HS) - @echo "cGhcWithSMP = \"$(GhcWithSMP)\"" >> $(CONFIG_HS) - @echo "cGhcRTSWays :: String" >> $(CONFIG_HS) - @echo "cGhcRTSWays = \"$(GhcRTSWays)\"" >> $(CONFIG_HS) - @echo "cGhcUnregisterised :: String" >> $(CONFIG_HS) - @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS) - @echo "cGhcEnableTablesNextToCode :: String" >> $(CONFIG_HS) - @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $(CONFIG_HS) - @echo "cLeadingUnderscore :: String" >> $(CONFIG_HS) - @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS) - @echo "cRAWCPP_FLAGS :: String" >> $(CONFIG_HS) - @echo "cRAWCPP_FLAGS = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS) - @echo "cGCC :: String" >> $(CONFIG_HS) - @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS) - @echo "cMKDLL :: String" >> $(CONFIG_HS) - @echo "cMKDLL = \"$(BLD_DLL)\"" >> $(CONFIG_HS) - @echo "cLdIsGNULd :: String" >> $(CONFIG_HS) - @echo "cLdIsGNULd = \"$(LdIsGNULd)\"" >> $(CONFIG_HS) - @echo "cLD_X :: String" >> $(CONFIG_HS) - @echo "cLD_X = \"$(LD_X)\"" >> $(CONFIG_HS) - @echo "cGHC_DRIVER_DIR_REL :: String" >> $(CONFIG_HS) - @echo "cGHC_DRIVER_DIR_REL = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS) - @echo "cGHC_TOUCHY_PGM :: String" >> $(CONFIG_HS) - @echo "cGHC_TOUCHY_PGM = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS) - @echo "cGHC_TOUCHY_DIR_REL :: String" >> $(CONFIG_HS) - @echo "cGHC_TOUCHY_DIR_REL = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS) - @echo "cGHC_UNLIT_PGM :: String" >> $(CONFIG_HS) - @echo "cGHC_UNLIT_PGM = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS) - @echo "cGHC_UNLIT_DIR_REL :: String" >> $(CONFIG_HS) - @echo "cGHC_UNLIT_DIR_REL = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS) - @echo "cGHC_MANGLER_PGM :: String" >> $(CONFIG_HS) - @echo "cGHC_MANGLER_PGM = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS) - @echo "cGHC_MANGLER_DIR_REL :: String" >> $(CONFIG_HS) - @echo "cGHC_MANGLER_DIR_REL = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS) - @echo "cGHC_SPLIT_PGM :: String" >> $(CONFIG_HS) - @echo "cGHC_SPLIT_PGM = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS) - @echo "cGHC_SPLIT_DIR_REL :: String" >> $(CONFIG_HS) - @echo "cGHC_SPLIT_DIR_REL = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS) - @echo "cGHC_SYSMAN_PGM :: String" >> $(CONFIG_HS) - @echo "cGHC_SYSMAN_PGM = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS) - @echo "cGHC_SYSMAN_DIR_REL :: String" >> $(CONFIG_HS) - @echo "cGHC_SYSMAN_DIR_REL = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS) - @echo "cGHC_CP :: String" >> $(CONFIG_HS) - @echo "cGHC_CP = \"$(GHC_CP)\"" >> $(CONFIG_HS) - @echo "cGHC_PERL :: String" >> $(CONFIG_HS) - @echo "cGHC_PERL = \"$(GHC_PERL)\"" >> $(CONFIG_HS) - @echo "cEnableWin32DLLs :: String" >> $(CONFIG_HS) - @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS) - @echo "cCONTEXT_DIFF :: String" >> $(CONFIG_HS) - @echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS) - @echo "cUSER_WAY_NAMES :: String" >> $(CONFIG_HS) - @echo "cUSER_WAY_NAMES = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS) - @echo "cUSER_WAY_OPTS :: String" >> $(CONFIG_HS) - @echo "cUSER_WAY_OPTS = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS) - @echo "cDEFAULT_TMPDIR :: String" >> $(CONFIG_HS) - @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS) - @echo "cRelocatableBuild :: Bool" >> $(CONFIG_HS) -ifeq "$(RelocatableBuild)" "YES" - @echo "cRelocatableBuild = True" >> $(CONFIG_HS) -else - @echo "cRelocatableBuild = False" >> $(CONFIG_HS) -endif - @echo "cLibFFI :: Bool" >> $(CONFIG_HS) -ifeq "$(UseLibFFIForAdjustors)" "YES" - @echo "cLibFFI = True" >> $(CONFIG_HS) -else - @echo "cLibFFI = False" >> $(CONFIG_HS) -endif - @echo done. - -# ----------------------------------------------------------------------------- -# Create platform includes - -# Here we generate a little header file containing CPP symbols that GHC -# uses to determine which platform it is building on/for. The platforms -# can differ between stage1 and stage2 if we're cross-compiling, so we -# need one of these header files per stage. - -PLATFORM_H = ghc_boot_platform.h - -stage1/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk - $(MKDIRHIER) stage1 - @echo "Creating $@..." - @$(RM) $@ - @echo "#ifndef __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 >> $@ - @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)\"" >> $@ -ifeq "$(HostOS_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" >> $@ - @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." - -# 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). -stage2plus/$(PLATFORM_H) : $(FPTOOLS_TOP)/mk/config.mk - $(MKDIRHIER) stage2plus - @echo "Creating $@..." - @$(RM) $@ - @echo "#ifndef __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 >> $@ - @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)\"" >> $@ -ifeq "$(HostOS_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" >> $@ - @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." - -ifeq "$(stage)" "1" -STAGE_PLATFORM_H = stage1/$(PLATFORM_H) -else -STAGE_PLATFORM_H = stage2plus/$(PLATFORM_H) -endif - -boot :: $(STAGE_PLATFORM_H) - -# ---------------------------------------------------------------------------- -# Generate supporting stuff for prelude/PrimOp.lhs -# from prelude/primops.txt - -SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR) -SRC_CPP_OPTS += ${GhcCppOpts} - -prelude/primops.txt parser/Parser.y: %: %.pp stage1/$(PLATFORM_H) - $(CPP) $(RAWCPP_FLAGS) -P $(CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@ - -primop-data-decl.hs-incl: prelude/primops.txt - $(GENPRIMOP) --data-decl < $< > $@ -primop-tag.hs-incl: prelude/primops.txt - $(GENPRIMOP) --primop-tag < $< > $@ -primop-list.hs-incl: prelude/primops.txt - $(GENPRIMOP) --primop-list < $< > $@ -primop-has-side-effects.hs-incl: prelude/primops.txt - $(GENPRIMOP) --has-side-effects < $< > $@ -primop-out-of-line.hs-incl: prelude/primops.txt - $(GENPRIMOP) --out-of-line < $< > $@ -primop-commutable.hs-incl: prelude/primops.txt - $(GENPRIMOP) --commutable < $< > $@ -primop-needs-wrapper.hs-incl: prelude/primops.txt - $(GENPRIMOP) --needs-wrapper < $< > $@ -primop-can-fail.hs-incl: prelude/primops.txt - $(GENPRIMOP) --can-fail < $< > $@ -primop-strictness.hs-incl: prelude/primops.txt - $(GENPRIMOP) --strictness < $< > $@ -primop-primop-info.hs-incl: prelude/primops.txt - $(GENPRIMOP) --primop-primop-info < $< > $@ - -# Usages aren't used any more; but the generator -# can still generate them if we want them back -primop-usage.hs-incl: prelude/primops.txt - $(GENPRIMOP) --usage < $< > $@ - -html: - $(MAKE) doc stage=2 - -install-docs: - @: - -#----------------------------------------------------------------------------- -# binary-dist -# +.PHONY: 1 2 3 -# Ideally we'd get these from the Cabal file's Install-Includes: -BINDIST_EXTRAS += HsVersions.h -ifeq "$(stage)" "1" -BINDIST_EXTRAS += stage1/ghc_boot_platform.h -else -BINDIST_EXTRAS += stage2plus/ghc_boot_platform.h -endif +1: + +$(TOPMAKE) stage=1 all_ghc_stage1 compiler_stage1_NO_BUILD_DEPS=YES -include $(TOP)/mk/bindist.mk -LIB_DIST_DIR = dist-stage2 +2: + +$(TOPMAKE) stage=2 all_ghc_stage2 compiler_stage2_NO_BUILD_DEPS=YES -#----------------------------------------------------------------------------- -# etags generation -ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -GHCTAGS = $(TOP)/utils/ghctags/ghctags.exe -else -GHCTAGS = $(TOP)/utils/ghctags/ghctags-inplace -endif -GHCTAGS_ROOT = main/GHC.hs ghci/InteractiveUI.hs main/PprTyThing.hs +3: + +$(TOPMAKE) stage=3 all_ghc_stage3 compiler_stage3_NO_BUILD_DEPS=YES -# etags for stage2 is actually broken since it requires building -# ghctags against an older ghc api -etags: etags.stage.2 -etags.stage.%: - $(GHCTAGS) --topdir $(FPTOOLS_TOP_ABS) --etags --use-cabal-config=./dist-stage$* -- -DSTAGE=$* -- $(GHCTAGS_ROOT) diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in index b37165805a..55f235a298 100644 --- a/compiler/ghc.cabal.in +++ b/compiler/ghc.cabal.in @@ -1,3 +1,6 @@ +-- WARNING: ghc.cabal is automatically generated from ghc.cabal.in by +-- ./configure. Make sure you are editing ghc.cabal.in, not ghc.cabal. + Name: ghc Version: @ProjectVersion@ License: BSD3 @@ -45,6 +48,15 @@ Flag ncg Flag stage1 Description: Is this stage 1? + Default: False + +Flag stage2 + Description: Is this stage 2? + Default: False + +Flag stage3 + Description: Is this stage 3? + Default: False Library Exposed: False @@ -103,7 +115,12 @@ Library Build-Depends: extensible-exceptions Extensions: PatternSignatures else - Include-Dirs: stage2plus + if flag(stage2) + Include-Dirs: stage2 + else + if flag(stage3) + Include-Dirs: stage2 + Install-Includes: HsVersions.h, ghc_boot_platform.h c-sources: diff --git a/compiler/ghc.mk b/compiler/ghc.mk new file mode 100644 index 0000000000..a1969e8f98 --- /dev/null +++ b/compiler/ghc.mk @@ -0,0 +1,432 @@ +# ----------------------------------------------------------------------------- +# For expressing extra dependencies on source files + +define compiler-hs-dependency # args: $1 = module, $2 = dependency + +$$(foreach stage,1 2 3,\ + $$(foreach way,$$(compiler_stage$$(stage)_WAYS),\ + compiler/stage$$(stage)/build/$1.$($(way)_osuf))) : $2 + +endef + +# ----------------------------------------------------------------------------- +# Create compiler configuration +# +# The 'echo' commands simply spit the values of various make variables +# into Config.hs, whence they can be compiled and used by GHC itself + +compiler_CONFIG_HS = compiler/main/Config.hs + +ifneq "$(BINDIST)" "YES" +compiler/stage1/package-data.mk : $(compiler_CONFIG_HS) +compiler/stage2/package-data.mk : $(compiler_CONFIG_HS) +compiler/stage3/package-data.mk : $(compiler_CONFIG_HS) +endif + +$(compiler_CONFIG_HS) : mk/config.mk + $(RM) -f $@ + @echo "Creating $@ ... " + @echo "module Config where" >>$@ + @echo "cProjectName :: String" >> $@ + @echo "cProjectName = \"$(ProjectName)\"" >> $@ + @echo "cProjectVersion :: String" >> $@ + @echo "cProjectVersion = \"$(ProjectVersion)\"" >> $@ + @echo "cProjectVersionInt :: String" >> $@ + @echo "cProjectVersionInt = \"$(ProjectVersionInt)\"" >> $@ + @echo "cProjectPatchLevel :: String" >> $@ + @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $@ + @echo "cBooterVersion :: String" >> $@ + @echo "cBooterVersion = \"$(GhcVersion)\"" >> $@ + @echo "cStage :: String" >> $@ + @echo "cStage = show (STAGE :: Int)" >> $@ + @echo "cHscIfaceFileVersion :: String" >> $@ + @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $@ + @echo "cSplitObjs :: String" >> $@ + @echo "cSplitObjs = \"$(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 "cGhcUnregisterised :: String" >> $@ + @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $@ + @echo "cGhcEnableTablesNextToCode :: String" >> $@ + @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $@ + @echo "cLeadingUnderscore :: String" >> $@ + @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $@ + @echo "cRAWCPP_FLAGS :: String" >> $@ + @echo "cRAWCPP_FLAGS = \"$(RAWCPP_FLAGS)\"" >> $@ + @echo "cGCC :: String" >> $@ + @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $@ + @echo "cMKDLL :: String" >> $@ + @echo "cMKDLL = \"$(BLD_DLL)\"" >> $@ + @echo "cLdIsGNULd :: String" >> $@ + @echo "cLdIsGNULd = \"$(LdIsGNULd)\"" >> $@ + @echo "cLD_X :: String" >> $@ + @echo "cLD_X = \"$(LD_X)\"" >> $@ + @echo "cGHC_DRIVER_DIR :: String" >> $@ + @echo "cGHC_DRIVER_DIR = \"$(GHC_DRIVER_DIR)\"" >> $@ + @echo "cGHC_TOUCHY_PGM :: String" >> $@ + @echo "cGHC_TOUCHY_PGM = \"$(GHC_TOUCHY_PGM)\"" >> $@ + @echo "cGHC_TOUCHY_DIR :: String" >> $@ + @echo "cGHC_TOUCHY_DIR = \"$(GHC_TOUCHY_DIR)\"" >> $@ + @echo "cGHC_UNLIT_PGM :: String" >> $@ + @echo "cGHC_UNLIT_PGM = \"$(GHC_UNLIT_PGM)\"" >> $@ + @echo "cGHC_UNLIT_DIR :: String" >> $@ + @echo "cGHC_UNLIT_DIR = \"$(GHC_UNLIT_DIR)\"" >> $@ + @echo "cGHC_MANGLER_PGM :: String" >> $@ + @echo "cGHC_MANGLER_PGM = \"$(GHC_MANGLER_PGM)\"" >> $@ + @echo "cGHC_MANGLER_DIR :: String" >> $@ + @echo "cGHC_MANGLER_DIR = \"$(GHC_MANGLER_DIR)\"" >> $@ + @echo "cGHC_SPLIT_PGM :: String" >> $@ + @echo "cGHC_SPLIT_PGM = \"$(GHC_SPLIT_PGM)\"" >> $@ + @echo "cGHC_SPLIT_DIR :: String" >> $@ + @echo "cGHC_SPLIT_DIR = \"$(GHC_SPLIT_DIR)\"" >> $@ + @echo "cGHC_SYSMAN_PGM :: String" >> $@ + @echo "cGHC_SYSMAN_PGM = \"$(GHC_SYSMAN)\"" >> $@ + @echo "cGHC_SYSMAN_DIR :: String" >> $@ + @echo "cGHC_SYSMAN_DIR = \"$(GHC_SYSMAN_DIR)\"" >> $@ + @echo "cGHC_CP :: String" >> $@ + @echo "cGHC_CP = \"$(GHC_CP)\"" >> $@ + @echo "cGHC_PERL :: String" >> $@ + @echo "cGHC_PERL = \"$(GHC_PERL)\"" >> $@ + @echo "cEnableWin32DLLs :: String" >> $@ + @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> $@ + @echo "cCONTEXT_DIFF :: String" >> $@ + @echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> $@ + @echo "cUSER_WAY_NAMES :: String" >> $@ + @echo "cUSER_WAY_NAMES = \"$(USER_WAY_NAMES)\"" >> $@ + @echo "cUSER_WAY_OPTS :: String" >> $@ + @echo "cUSER_WAY_OPTS = \"$(USER_WAY_OPTS)\"" >> $@ + @echo "cDEFAULT_TMPDIR :: String" >> $@ + @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $@ + @echo "cRelocatableBuild :: Bool" >> $@ +ifeq "$(RelocatableBuild)" "YES" + @echo "cRelocatableBuild = True" >> $@ +else + @echo "cRelocatableBuild = False" >> $@ +endif + @echo "cLibFFI :: Bool" >> $@ +ifeq "$(UseLibFFIForAdjustors)" "YES" + @echo "cLibFFI = True" >> $@ +else + @echo "cLibFFI = False" >> $@ +endif + @echo done. + +$(eval $(call clean-target,compiler,config_hs,$(compiler_CONFIG_HS))) + +# ----------------------------------------------------------------------------- +# Create platform includes + +# Here we generate a little header file containing CPP symbols that GHC +# uses to determine which platform it is building on/for. The platforms +# can differ between stage1 and stage2 if we're cross-compiling, so we +# need one of these header files per stage. + +PLATFORM_H = ghc_boot_platform.h + +compiler/stage1/$(PLATFORM_H) : mk/config.mk + $(MKDIRHIER) $(dir $@) + $(RM) $@ + @echo "Creating $@..." + @echo "#ifndef __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 >> $@ + @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)\"" >> $@ +ifeq "$(HostOS_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" >> $@ + @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." + +# 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). +compiler/stage2/$(PLATFORM_H) : mk/config.mk + $(MKDIRHIER) $(dir $@) + $(RM) $@ + @echo "Creating $@..." + @echo "#ifndef __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 >> $@ + @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)\"" >> $@ +ifeq "$(HostOS_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" >> $@ + @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." + +compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H) + $(CP) $< $@ + +# Every Constants.o object file depends on includes/GHCConstants.h: +$(eval $(call compiler-hs-dependency,Constants,$(includes_GHCCONSTANTS))) + +# ---------------------------------------------------------------------------- +# Generate supporting stuff for prelude/PrimOp.lhs +# from prelude/primops.txt + +# XXX: these should go in stage1/stage2/stage3 +PRIMOP_BITS = compiler/primop-data-decl.hs-incl \ + compiler/primop-tag.hs-incl \ + compiler/primop-list.hs-incl \ + compiler/primop-has-side-effects.hs-incl \ + compiler/primop-out-of-line.hs-incl \ + compiler/primop-commutable.hs-incl \ + compiler/primop-needs-wrapper.hs-incl \ + compiler/primop-can-fail.hs-incl \ + compiler/primop-strictness.hs-incl \ + compiler/primop-primop-info.hs-incl + +compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR) +compiler_CPP_OPTS += ${GhcCppOpts} + +$(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H) + $(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@ + +$(eval $(call clean-target,compiler,primop, $(PRIMOPS_TXT) compiler/parser/Parser.y $(PRIMOP_BITS))) + +compiler/primop-data-decl.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --data-decl < $< > $@ +compiler/primop-tag.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --primop-tag < $< > $@ +compiler/primop-list.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --primop-list < $< > $@ +compiler/primop-has-side-effects.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --has-side-effects < $< > $@ +compiler/primop-out-of-line.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --out-of-line < $< > $@ +compiler/primop-commutable.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --commutable < $< > $@ +compiler/primop-needs-wrapper.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --needs-wrapper < $< > $@ +compiler/primop-can-fail.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --can-fail < $< > $@ +compiler/primop-strictness.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --strictness < $< > $@ +compiler/primop-primop-info.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) + $(GENPRIMOP_INPLACE) --primop-primop-info < $< > $@ + +# Every PrimOp.o object file depends on $(PRIMOP_BITS): +$(eval $(call compiler-hs-dependency,PrimOp,$(PRIMOP_BITS))) + +# Usages aren't used any more; but the generator +# can still generate them if we want them back +compiler/primop-usage.hs-incl: $(PRIMOPS_TXT) + $(GENPRIMOP_INPLACE) --usage < $< > $@ + +# ----------------------------------------------------------------------------- +# Configuration + +compiler_stage1_CONFIGURE_OPTS += --flags=stage1 +compiler_stage2_CONFIGURE_OPTS += --flags=stage2 +compiler_stage3_CONFIGURE_OPTS += --flags=stage3 + +ifeq "$(GhcWithNativeCodeGen)" "YES" +compiler_stage1_CONFIGURE_OPTS += --flags=ncg +compiler_stage2_CONFIGURE_OPTS += --flags=ncg +endif + +ifeq "$(GhcWithInterpreter)" "YES" +compiler_stage2_CONFIGURE_OPTS += --flags=ghci + +ifeq "$(BuildSharedLibs)" "YES" +compiler_stage2_CONFIGURE_OPTS += --enable-shared +# 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. +compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs +endif + +ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO" +# 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 +# be a flag for that +compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE +endif + +# Should the debugger commands be enabled? +ifeq "$(GhciWithDebugger)" "YES" +compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER +endif + +endif + +ifeq "$(GhcWithNativeCodeGen)" "NO" +# XXX This should logically be a CPP option, but there doesn't seem to +# be a flag for that +compiler_CONFIGURE_OPTS += --ghc-option=-DOMIT_NATIVE_CODEGEN +endif + +ifeq "$(TargetOS_CPP)" "openbsd" +compiler_CONFIGURE_OPTS += --ld-options=-E +endif + +ifeq "$(GhcUnregisterised)" "NO" +ifeq "$(HOSTPLATFORM)" "ia64-unknown-linux" +# needed for generating proper relocation in large binaries: trac #856 +compiler_CONFIGURE_OPTS += --ld-option=-Wl,--relax +endif +endif + +# We need to turn on profiling either if we have been asked to +# (GhcLibProfiled = YES) or if we want GHC itself to be compiled with +# profiling enabled (GhcProfiled = YES). +ifneq "$(GhcLibProfiled) $(GhcProfiled)" "NO NO" +compiler_stage2_CONFIGURE_OPTS += --enable-library-profiling +# And if we're profiling GHC then we want lots of SCCs. +# We also don't want to waste time building the non-profiling library, +# either normally or for ghci. Unfortunately this means that we have to +# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't +# exist. +ifeq "$(GhcProfiled)" "YES" +compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all +compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla +compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci +compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force +endif +endif + +ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" +# The #include is vital for the via-C route with older compilers, else the C +# compiler doesn't realise that the stcall foreign imports are indeed +# stdcall, and doesn't generate the Foo@8 name for them +# As it's only important for older compilers we don't need to do anything +# for stage2+. +compiler_stage1_CONFIGURE_OPTS += --ghc-option='-\#include' \ + --ghc-option='"<windows.h>"' \ + --ghc-option='-\#include' \ + --ghc-option='"<process.h>"' +endif + +# ghc_strlen percolates through so many modules that it is easier to get its +# prototype via a global option instead of a myriad of per-file OPTIONS. +# Again, this is only important for older compilers, so we don't do it in +# stage 2+. +compiler_stage1_CONFIGURE_OPTS += --ghc-options='-\#include "cutils.h"' + +compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS) + +compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1 +compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2 +compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3 +compiler_stage2_HADDOCK_OPTS += --haddock-option=--optghc=-DSTAGE=2 + +compiler_stage1_CONFIGURE_OPTS += --ghc-options='$(GhcStage1HcOpts)' +compiler_stage2_CONFIGURE_OPTS += --ghc-options='$(GhcStage2HcOpts)' +compiler_stage3_CONFIGURE_OPTS += --ghc-options='$(GhcStage3HcOpts)' + +compiler/stage1/package-data.mk : compiler/ghc.mk +compiler/stage2/package-data.mk : compiler/ghc.mk +compiler/stage3/package-data.mk : compiler/ghc.mk + +# ----------------------------------------------------------------------------- +# And build the package + +compiler_PACKAGE = ghc + +# haddocking only happens for stage2 +compiler_stage1_DO_HADDOCK = NO +compiler_stage3_DO_HADDOCK = NO + +# 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 + +# For now, bindists always use stage 2 +ifneq "$(BINDIST)" "YES" +# stage 1 is enabled unless $(stage) is set to something other than 1 +ifeq "$(filter-out 1,$(stage))" "" +$(eval $(call build-package,compiler,stage1,0)) +endif +endif + +# stage 2 is enabled unless $(stage) is set to something other than 2 +ifeq "$(filter-out 2,$(stage))" "" +$(eval $(call build-package,compiler,stage2,1)) +endif + +ifneq "$(BINDIST)" "YES" +# stage 3 has to be requested explicitly with stage=3 +ifeq "$(stage)" "3" +$(eval $(call build-package,compiler,stage3,2)) +endif + +$(compiler_stage1_depfile) : compiler/stage1/$(PLATFORM_H) +$(compiler_stage2_depfile) : compiler/stage2/$(PLATFORM_H) +$(compiler_stage3_depfile) : compiler/stage3/$(PLATFORM_H) + +$(compiler_stage1_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS) +$(compiler_stage2_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS) +$(compiler_stage3_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS) +endif + diff --git a/compiler/main/DriverMkDepend.hs b/compiler/main/DriverMkDepend.hs index 7451cef95e..400f8bdf0b 100644 --- a/compiler/main/DriverMkDepend.hs +++ b/compiler/main/DriverMkDepend.hs @@ -72,7 +72,8 @@ doMkDependHS srcs = do -- Prcess them one by one, dumping results into makefile -- and complaining about cycles hsc_env <- getSession - mapM (liftIO . processDeps dflags hsc_env excl_mods (mkd_tmp_hdl files)) sorted + root <- liftIO getCurrentDirectory + mapM (liftIO . processDeps dflags hsc_env excl_mods root (mkd_tmp_hdl files)) sorted -- If -ddump-mod-cycles, show cycles in the module graph liftIO $ dumpModCycles dflags mod_summaries @@ -158,6 +159,7 @@ beginMkDependHS dflags = do processDeps :: DynFlags -> HscEnv -> [ModuleName] + -> FilePath -> Handle -- Write dependencies to here -> SCC ModSummary -> IO () @@ -176,11 +178,11 @@ processDeps :: DynFlags -- -- For {-# SOURCE #-} imports the "hi" will be "hi-boot". -processDeps _ _ _ _ (CyclicSCC nodes) +processDeps _ _ _ _ _ (CyclicSCC nodes) = -- There shouldn't be any cycles; report them ghcError (ProgramError (showSDoc $ GHC.cyclicModuleErr nodes)) -processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node) +processDeps dflags hsc_env excl_mods root hdl (AcyclicSCC node) = do { let extra_suffixes = depSuffixes dflags include_pkg_deps = depIncludePkgDeps dflags src_file = msHsFilePath node @@ -194,7 +196,7 @@ processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node) Nothing -> return () ; Just hi_file -> do { let hi_files = insertSuffixes hi_file extra_suffixes - write_dep (obj,hi) = writeDependency hdl [obj] hi + write_dep (obj,hi) = writeDependency root hdl [obj] hi -- Add one dependency for each suffix; -- e.g. A.o : B.hi @@ -204,7 +206,7 @@ processDeps dflags hsc_env excl_mods hdl (AcyclicSCC node) -- Emit std dependency of the object(s) on the source file -- Something like A.o : A.hs - ; writeDependency hdl obj_files src_file + ; writeDependency root hdl obj_files src_file -- Emit a dependency for each import @@ -248,12 +250,18 @@ findDependency hsc_env srcloc pkg imp is_boot include_pkg_deps } ----------------------------- -writeDependency :: Handle -> [FilePath] -> FilePath -> IO () --- (writeDependency h [t1,t2] dep) writes to handle h the dependency +writeDependency :: FilePath -> Handle -> [FilePath] -> FilePath -> IO () +-- (writeDependency r h [t1,t2] dep) writes to handle h the dependency -- t1 t2 : dep -writeDependency hdl targets dep - = hPutStrLn hdl (unwords (map forOutput targets) ++ " : " ++ forOutput dep) - where forOutput = escapeSpaces . reslash Forwards . normalise +writeDependency root hdl targets dep + = do let -- We need to avoid making deps on + -- c:/foo/... + -- on cygwin as make gets confused by the : + -- Making relative deps avoids some instances of this. + dep' = makeRelative root dep + forOutput = escapeSpaces . reslash Forwards . normalise + output = unwords (map forOutput targets) ++ " : " ++ forOutput dep' + hPutStrLn hdl output ----------------------------- insertSuffixes diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index 49dd4275bc..a64d73e11c 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -77,27 +77,20 @@ How GHC finds its files [Note topdir] GHC needs various support files (library packages, RTS etc), plus -various auxiliary programs (cp, gcc, etc). It starts by finding topdir: - - for "installed" topdir is the root of GHC's support files ($libdir) - for "in-place" topdir is the root of the build tree +various auxiliary programs (cp, gcc, etc). It starts by finding topdir, +the root of GHC's support files On Unix: - ghc always has a shell wrapper that passes a -B<dir> option - - in an installation, <dir> is $libdir - - in a build tree, <dir> is $TOP/inplace-datadir - - so we detect the build-tree case and add ".." to get us back to $TOP On Windows: - ghc never has a shell wrapper. - we can find the location of the ghc binary, which is - $topdir/bin/ghc.exe in an installation, or - $topdir/ghc/stage1-inplace/ghc.exe in a build tree. - - we detect which one of these we have, and calculate $topdir. - + $topdir/bin/<something>.exe + where <something> may be "ghc", "ghc-stage2", or similar + - we strip off the "bin/<something>.exe" to leave $topdir. -from topdir we can find package.conf, which contains the locations of -almost everything else, whether we're in a build tree or installed. +from topdir we can find package.conf, ghc-asm, etc. SysTools.initSysProgs figures out exactly where all the auxiliary programs @@ -113,8 +106,8 @@ Config.hs contains two sorts of things etc They do *not* include paths - cUNLIT_DIR_REL The *path* to the directory containing unlit, split etc - cSPLIT_DIR_REL *relative* to the root of the build tree, + cUNLIT_DIR The *path* to the directory containing unlit, split etc + cSPLIT_DIR *relative* to the root of the build tree, for use when running *in-place* in a build tree (only) @@ -159,46 +152,28 @@ initSysTools :: Maybe String -- Maybe TopDir path (without the '-B' prefix) initSysTools mbMinusB dflags0 - = do { (am_installed, top_dir) <- findTopDir mbMinusB + = do { top_dir <- findTopDir mbMinusB -- see [Note topdir] -- NB: top_dir is assumed to be in standard Unix -- format, '/' separated - ; let installed, installed_bin :: FilePath -> FilePath - installed_bin pgm = top_dir </> pgm - installed file = top_dir </> file - inplace dir pgm = top_dir </> dir </> pgm - - ; let pkgconfig_path - | am_installed = installed "package.conf" - | otherwise = inplace "inplace-datadir" "package.conf" - - ghc_usage_msg_path - | am_installed = installed "ghc-usage.txt" - | otherwise = inplace cGHC_DRIVER_DIR_REL "ghc-usage.txt" + ; let installed :: FilePath -> FilePath + installed file = top_dir </> file + installed_mingw_bin file = top_dir </> ".." </> "mingw" </> "bin" </> file - ghci_usage_msg_path - | am_installed = installed "ghci-usage.txt" - | otherwise = inplace cGHC_DRIVER_DIR_REL "ghci-usage.txt" + ; let pkgconfig_path = installed "package.conf" + ghc_usage_msg_path = installed "ghc-usage.txt" + ghci_usage_msg_path = installed "ghci-usage.txt" -- For all systems, unlit, split, mangle are GHC utilities -- architecture-specific stuff is done when building Config.hs - unlit_path - | am_installed = installed_bin cGHC_UNLIT_PGM - | otherwise = inplace cGHC_UNLIT_DIR_REL cGHC_UNLIT_PGM + unlit_path = installed cGHC_UNLIT_PGM -- split and mangle are Perl scripts - split_script - | am_installed = installed_bin cGHC_SPLIT_PGM - | otherwise = inplace cGHC_SPLIT_DIR_REL cGHC_SPLIT_PGM + split_script = installed cGHC_SPLIT_PGM + mangle_script = installed cGHC_MANGLER_PGM - mangle_script - | am_installed = installed_bin cGHC_MANGLER_PGM - | otherwise = inplace cGHC_MANGLER_DIR_REL cGHC_MANGLER_PGM - - windres_path - | am_installed = installed_bin "bin/windres" - | otherwise = "windres" + windres_path = installed_mingw_bin "windres" ; tmpdir <- getTemporaryDirectory ; let dflags1 = setTmpDir tmpdir dflags0 @@ -209,43 +184,19 @@ initSysTools mbMinusB dflags0 ghcError (InstallationError ("Can't find package.conf as " ++ pkgconfig_path)) - -- On Windows, gcc and friends are distributed with GHC, - -- so when "installed" we look in TopDir/bin - -- When "in-place", or when not on Windows, we look wherever - -- the build-time configure script found them + -- On Windows, mingw is distributed with GHC, + -- so we look in TopDir/../mingw/bin ; let - -- The trailing "/" is absolutely essential; gcc seems - -- to construct file names simply by concatenating to - -- this -B path with no extra slash We use "/" rather - -- than "\\" because otherwise "\\\" is mangled - -- later on; although gcc_args are in NATIVE format, - -- gcc can cope - -- (see comments with declarations of global variables) - gcc_b_arg = Option ("-B" ++ installed "gcc-lib/") - gcc_mingw_include_arg = Option ("-I" ++ installed "include/mingw") - (gcc_prog,gcc_args) - | isWindowsHost && am_installed - -- We tell gcc where its specs file + exes are (-B) - -- and also some places to pick up include files. We need - -- to be careful to put all necessary exes in the -B place - -- (as, ld, cc1, etc) since if they don't get found there, - -- gcc then tries to run unadorned "as", "ld", etc, and - -- will pick up whatever happens to be lying around in - -- the path, possibly including those from a cygwin - -- install on the target, which is exactly what we're - -- trying to avoid. - = (installed_bin "gcc", [gcc_b_arg, gcc_mingw_include_arg]) - | otherwise = (cGCC, []) + gcc_prog + | isWindowsHost = installed_mingw_bin "gcc" + | otherwise = cGCC perl_path - | isWindowsHost && am_installed = installed_bin cGHC_PERL - | otherwise = cGHC_PERL + | isWindowsHost = installed cGHC_PERL + | otherwise = cGHC_PERL -- 'touch' is a GHC util for Windows touch_path - | isWindowsHost - = if am_installed - then installed_bin cGHC_TOUCHY_PGM - else inplace cGHC_TOUCHY_DIR_REL cGHC_TOUCHY_PGM - | otherwise = "touch" + | isWindowsHost = installed cGHC_TOUCHY_PGM + | otherwise = "touch" -- On Win32 we don't want to rely on #!/bin/perl, so we prepend -- a call to Perl to get the invocation of split and mangle. -- On Unix, scripts are invoked using the '#!' method. Binary @@ -261,23 +212,18 @@ initSysTools mbMinusB dflags0 (mkdll_prog, mkdll_args) | not isWindowsHost = panic "Can't build DLLs on a non-Win32 system" - | am_installed = - (installed "gcc-lib/" </> cMKDLL, - [ Option "--dlltool-name", - Option (installed "gcc-lib/" </> "dlltool"), - Option "--driver-name", - Option gcc_prog, gcc_b_arg, gcc_mingw_include_arg ]) - | otherwise = (cMKDLL, []) + | otherwise = + (installed_mingw_bin cMKDLL, []) -- cpp is derived from gcc on all platforms -- HACK, see setPgmP below. We keep 'words' here to remember to fix -- Config.hs one day. - ; let cpp_path = (gcc_prog, gcc_args ++ + ; let cpp_path = (gcc_prog, (Option "-E"):(map Option (words cRAWCPP_FLAGS))) -- Other things being equal, as and ld are simply gcc - ; let (as_prog,as_args) = (gcc_prog,gcc_args) - (ld_prog,ld_args) = (gcc_prog,gcc_args) + ; let as_prog = gcc_prog + ld_prog = gcc_prog ; return dflags1{ ghcUsagePath = ghc_usage_msg_path, @@ -287,11 +233,11 @@ initSysTools mbMinusB dflags0 pgm_L = unlit_path, pgm_P = cpp_path, pgm_F = "", - pgm_c = (gcc_prog,gcc_args), + pgm_c = (gcc_prog,[]), pgm_m = (mangle_prog,mangle_args), pgm_s = (split_prog,split_args), - pgm_a = (as_prog,as_args), - pgm_l = (ld_prog,ld_args), + pgm_a = (as_prog,[]), + pgm_l = (ld_prog,[]), pgm_dll = (mkdll_prog,mkdll_args), pgm_T = touch_path, pgm_sysman = top_dir ++ "/ghc/rts/parallel/SysMan", @@ -303,33 +249,17 @@ initSysTools mbMinusB dflags0 \end{code} \begin{code} -findTopDir :: Maybe String -- Maybe TopDir path (without the '-B' prefix). - -> IO (Bool, -- True <=> am installed, False <=> in-place - String) -- TopDir (in Unix format '/' separated) - -findTopDir mbMinusB - = do { top_dir <- get_proto - ; exists1 <- doesFileExist (top_dir </> "package.conf") - ; exists2 <- doesFileExist (top_dir </> "inplace") - ; let amInplace = not exists1 -- On Windows, package.conf doesn't exist - -- when we are inplace - || exists2 -- On Linux, the presence of inplace signals - -- that we are inplace - - ; let real_top = if exists2 then top_dir </> ".." else top_dir - - ; return (not amInplace, real_top) - } - where - -- get_proto returns a Unix-format path (relying on getBaseDir to do so too) - get_proto = case mbMinusB of - Just minusb -> return (normalise minusb) - Nothing - -> do maybe_exec_dir <- getBaseDir -- Get directory of executable - case maybe_exec_dir of -- (only works on Windows; - -- returns Nothing on Unix) - Nothing -> ghcError (InstallationError "missing -B<dir> option") - Just dir -> return dir +-- returns a Unix-format path (relying on getBaseDir to do so too) +findTopDir :: Maybe String -- Maybe TopDir path (without the '-B' prefix). + -> IO String -- TopDir (in Unix format '/' separated) +findTopDir (Just minusb) = return (normalise minusb) +findTopDir Nothing + = do -- Get directory of executable + maybe_exec_dir <- getBaseDir + case maybe_exec_dir of + -- "Just" on Windows, "Nothing" on unix + Nothing -> ghcError (InstallationError "missing -B<dir> option") + Just dir -> return dir \end{code} @@ -473,25 +403,10 @@ runMkDLL dflags args = do runWindres :: DynFlags -> [Option] -> IO () runWindres dflags args = do - let (gcc,gcc_args) = pgm_c dflags + let (_gcc,gcc_args) = pgm_c dflags windres = pgm_windres dflags mb_env <- getGccEnv gcc_args - runSomethingFiltered dflags id "Windres" windres - -- we must tell windres where to find gcc: it might not be on PATH - (Option ("--preprocessor=" ++ - unwords (map quote (gcc : map showOpt gcc_args ++ - ["-E", "-xc", "-DRC_INVOKED"]))) - -- -- use-temp-file is required for windres to interpret the - -- quoting in the preprocessor arg above correctly. Without - -- this, windres calls the preprocessor with popen, which gets - -- the quoting wrong (discovered by experimentation and - -- reading the windres sources). See #1828. - : Option "--use-temp-file" - : args) - -- we must use the PATH workaround here too, since windres invokes gcc - mb_env - where - quote x = '\"' : x ++ "\"" + runSomethingFiltered dflags id "Windres" windres args mb_env touch :: DynFlags -> String -> String -> IO () touch dflags purpose arg = @@ -833,8 +748,8 @@ traceCmd dflags phase_name cmd_line action getBaseDir :: IO (Maybe String) #if defined(mingw32_HOST_OS) --- Assuming we are running ghc, accessed by path $()/bin/ghc.exe, --- return the path $(stuff). Note that we drop the "bin/" directory too. +-- Assuming we are running ghc, accessed by path $(stuff)/bin/ghc.exe, +-- return the path $(stuff)/lib. getBaseDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32. buf <- mallocArray len ret <- getModuleFileName nullPtr buf len @@ -844,13 +759,14 @@ getBaseDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32. return (Just (rootDir s)) where rootDir s = case splitFileName $ normalise s of - (d, ghc_exe) | lower ghc_exe == "ghc.exe" -> + (d, ghc_exe) + | lower ghc_exe `elem` ["ghc.exe", + "ghc-stage1.exe", + "ghc-stage2.exe", + "ghc-stage3.exe"] -> case splitFileName $ takeDirectory d of - -- installed ghc.exe is in $topdir/bin/ghc.exe - (d', bin) | lower bin == "bin" -> takeDirectory d' - -- inplace ghc.exe is in $topdir/ghc/stage1-inplace/ghc.exe - (d', x) | "-inplace" `isSuffixOf` lower x -> - takeDirectory d' </> ".." + -- ghc is in $topdir/bin/ghc.exe + (d', bin) | lower bin == "bin" -> takeDirectory d' </> "lib" _ -> fail _ -> fail where fail = panic ("can't decompose ghc.exe path: " ++ show s) diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs index d2add1f7be..a7b84ebdef 100644 --- a/compiler/rename/RnNames.lhs +++ b/compiler/rename/RnNames.lhs @@ -143,8 +143,14 @@ rnImportDecl this_mod (L loc (ImportDecl loc_imp_mod_name mb_pkg want_boot -- Issue a user warning for a redundant {- SOURCE -} import -- NB that we arrange to read all the ordinary imports before - -- any of the {- SOURCE -} imports - warnIf (want_boot && not (mi_boot iface)) + -- any of the {- SOURCE -} imports. + -- + -- in --make and GHCi, the compilation manager checks for this, + -- and indeed we shouldn't do it here because the existence of + -- the non-boot module depends on the compilation order, which + -- is not deterministic. The hs-boot test can show this up. + dflags <- getDOpts + warnIf (want_boot && not (mi_boot iface) && isOneShot (ghcMode dflags)) (warnRedundantSourceImport imp_mod_name) let |