From 50027272414438955dbc41696541cbd25da55883 Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 23 Mar 2001 16:36:23 +0000 Subject: [PATCH] [project @ 2001-03-23 16:36:20 by simonmar] Changes to support bootstrapping the compiler from .hc files. It's not quite working yet, but it's not far off. - the biggest change is that any injected #includes are now placed in the .hc file at generation time, rather than compilation time. I can't see any reason not to do this - it makes it clear by looking at the .hc file which files are being #included, it means one less temporary file at compilation time, and it means the .hc file is more standalone. - all the gruesomeness is in mk/bootstrap.mk, which handles building .hc files without a ghc driver. --- Makefile | 10 +++--- ghc/Makefile | 8 ++--- ghc/compiler/main/CodeOutput.lhs | 10 ++++-- ghc/compiler/main/DriverPipeline.hs | 57 +++++++++++++++---------------- ghc/compiler/main/DriverState.hs | 4 ++- ghc/compiler/main/Finder.lhs | 4 +-- ghc/driver/mangler/Makefile | 7 +++- ghc/lib/std/Makefile | 11 +++--- ghc/mk/paths.mk | 14 +------- ghc/rts/Exception.hc | 3 +- ghc/rts/HeapStackCheck.hc | 3 +- ghc/rts/Makefile | 25 ++++++++++---- ghc/rts/PrimOps.hc | 3 +- ghc/rts/Schedule.c | 4 +-- ghc/rts/StgMiscClosures.hc | 3 +- ghc/rts/StgStartup.hc | 3 +- ghc/rts/StgStdThunks.hc | 3 +- ghc/rts/Updates.hc | 3 +- ghc/rts/parallel/FetchMe.hc | 3 +- ghc/utils/genprimopcode/Makefile | 4 ++- ghc/utils/hsc2hs/Makefile | 5 +-- mk/boilerplate.mk | 4 +++ mk/bootstrap.mk | 64 +++++++++++++++++++++++++++++++++++ mk/config.mk.in | 25 +++++++++----- mk/paths.mk | 17 ++++++++-- mk/suffix.mk | 10 ++++++ mk/target.mk | 26 +++++++++----- 27 files changed, 229 insertions(+), 104 deletions(-) create mode 100644 mk/bootstrap.mk diff --git a/Makefile b/Makefile index 0c93680..4a999c6 100644 --- a/Makefile +++ b/Makefile @@ -9,12 +9,6 @@ TOP=. include $(TOP)/mk/boilerplate.mk -# -# Totally evil hack to make the setting of SUBDIRS be dependent -# on whether we do `make install' or not. Having a $(ifeq ... ) would -# be preferable.. -CURRENT_TARGET = $(MAKECMDGOALS) - # find the projects that actually exist... SUBDIRS = $(filter $(patsubst %/, %, $(wildcard */)), $(AllProjects)) @@ -29,6 +23,10 @@ ifneq "$(Project)" "" include $(shell echo $(Project) | tr A-Z a-z)/mk/config.mk endif +# ----------------------------------------------------------------------------- +# Certain targets require that Project is set from the command line. + +CURRENT_TARGET = $(MAKECMDGOALS) project-check : @if [ "$(Project)" = "" ]; then \ echo " You need to set \"Project\" in order to make $(CURRENT_TARGET)"; \ diff --git a/ghc/Makefile b/ghc/Makefile index 68541ab..c62f588 100644 --- a/ghc/Makefile +++ b/ghc/Makefile @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# $Id: Makefile,v 1.14 2000/11/06 13:14:52 simonmar Exp $ +# $Id: Makefile,v 1.15 2001/03/23 16:36:20 simonmar Exp $ # TOP=. @@ -20,10 +20,10 @@ include $(TOP)/mk/boilerplate.mk # If we're booting from .hc files, swap the order # we descend into compiler/ and lib/ # -ifeq "$(GhcWithHscBuiltViaC)" "NO" -SUBDIRS = includes utils driver docs compiler rts lib +ifeq "$(BootingFromHc)" "YES" +SUBDIRS = includes driver rts docs lib compiler else -SUBDIRS = includes utils driver rts docs lib compiler +SUBDIRS = includes utils driver docs compiler rts lib endif # Easier to copy diff --git a/ghc/compiler/main/CodeOutput.lhs b/ghc/compiler/main/CodeOutput.lhs index c320964..3ff665e 100644 --- a/ghc/compiler/main/CodeOutput.lhs +++ b/ghc/compiler/main/CodeOutput.lhs @@ -20,6 +20,7 @@ import IlxGen ( ilxGen ) import JavaGen ( javaGen ) import qualified PrintJava +import DriverState ( v_HCHeader ) import TyCon ( TyCon ) import Id ( Id ) import CoreSyn ( CoreBind ) @@ -34,8 +35,8 @@ import Outputable import CmdLineOpts ( DynFlags, HscLang(..), dopt_OutName ) import TmpFiles ( newTempName ) -import IO ( IOMode(..), hClose, openFile, Handle ) -import IO ( hPutStr, stderr) -- Debugging +import IOExts +import IO \end{code} @@ -99,7 +100,10 @@ doOutput filenm io_action \begin{code} outputC dflags filenm flat_absC = do dumpIfSet_dyn dflags Opt_D_dump_realC "Real C" (dumpRealC flat_absC) - doOutput filenm (\ h -> writeRealC h flat_absC) + header <- readIORef v_HCHeader + doOutput filenm $ \ h -> do + hPutStr h header + writeRealC h flat_absC \end{code} diff --git a/ghc/compiler/main/DriverPipeline.hs b/ghc/compiler/main/DriverPipeline.hs index 91e195a..c81294c 100644 --- a/ghc/compiler/main/DriverPipeline.hs +++ b/ghc/compiler/main/DriverPipeline.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverPipeline.hs,v 1.56 2001/03/22 03:51:08 hwloidl Exp $ +-- $Id: DriverPipeline.hs,v 1.57 2001/03/23 16:36:20 simonmar Exp $ -- -- GHC Driver -- @@ -322,12 +322,7 @@ run_phase Unlit _basename _suff input_fn output_fn run_phase Cpp basename suff input_fn output_fn = do src_opts <- getOptionsFromSource input_fn unhandled_flags <- processArgs dynamic_flags src_opts [] - - when (not (null unhandled_flags)) - (throwDyn (OtherError ( - basename ++ "." ++ suff - ++ ": static flags are not allowed in {-# OPTIONS #-} pragmas:\n\t" - ++ unwords unhandled_flags)) (ExitFailure 1)) + checkProcessArgsResult unhandled_flags basename suff do_cpp <- dynFlag cppFlag if do_cpp @@ -443,6 +438,20 @@ run_phase Hsc basename suff input_fn output_fn Nothing -> basename ++ '.':hisuf Just fn -> fn + -- figure out which header files to #include in a generated .hc file + c_includes <- getPackageCIncludes + cmdline_includes <- dynFlag cmdlineHcIncludes -- -#include options + + let cc_injects = unlines (map mk_include + (c_includes ++ reverse cmdline_includes)) + mk_include h_file = + case h_file of + '"':_{-"-} -> "#include "++h_file + '<':_ -> "#include "++h_file + _ -> "#include \""++h_file++"\"" + + writeIORef v_HCHeader cc_injects + -- figure out if the source has changed, for recompilation avoidance. -- only do this if we're eventually going to generate a .o file. -- (ToDo: do when generating .hc files too?) @@ -519,7 +528,7 @@ run_phase Hsc basename suff input_fn output_fn -- we don't support preprocessing .c files (with -E) now. Doing so introduces -- way too many hacks, and I can't say I've ever used it anyway. -run_phase cc_phase _basename _suff input_fn output_fn +run_phase cc_phase basename suff input_fn output_fn | cc_phase == Cc || cc_phase == HCc = do cc <- readIORef v_Pgm_c cc_opts <- (getOpts opt_c) @@ -534,26 +543,6 @@ run_phase cc_phase _basename _suff input_fn output_fn let include_paths = map (\p -> "-I"++p) (cmdline_include_dirs ++ pkg_include_dirs) - c_includes <- getPackageCIncludes - cmdline_includes <- dynFlag cmdlineHcIncludes -- -#include options - - let cc_injects | hcc = unlines (map mk_include - (c_includes ++ reverse cmdline_includes)) - | otherwise = "" - mk_include h_file = - case h_file of - '"':_{-"-} -> "#include "++h_file - '<':_ -> "#include "++h_file - _ -> "#include \""++h_file++"\"" - - cc_help <- newTempName "c" - h <- openFile cc_help WriteMode - hPutStr h cc_injects - hPutStrLn h ("#include \"" ++ input_fn ++ "\"\n") - hClose h - - ccout <- newTempName "ccout" - mangle <- readIORef v_Do_asm_mangling (md_c_flags, md_regd_c_flags) <- machdepCCOpts @@ -572,7 +561,7 @@ run_phase cc_phase _basename _suff input_fn output_fn excessPrecision <- readIORef v_Excess_precision runSomething "C Compiler" - (unwords ([ cc, "-x", "c", cc_help, "-o", output_fn ] + (unwords ([ cc, "-x", "c", input_fn, "-o", output_fn ] ++ md_c_flags ++ (if cc_phase == HCc && mangle then md_regd_c_flags @@ -584,7 +573,6 @@ run_phase cc_phase _basename _suff input_fn output_fn ++ (if excessPrecision then [] else [ "-ffloat-store" ]) ++ include_paths ++ pkg_extra_cc_opts --- ++ [">", ccout] )) return True @@ -765,6 +753,15 @@ mk_pvm_wrapper_script pvm_executable pvm_executable_base sysMan = unlines $ ] ----------------------------------------------------------------------------- +-- Complain about non-dynamic flags in OPTIONS pragmas + +checkProcessArgsResult flags basename suff + = do when (not (null flags)) (throwDyn (OtherError ( + basename ++ "." ++ suff + ++ ": static flags are not allowed in {-# OPTIONS #-} pragmas:\n\t" + ++ unwords flags)) (ExitFailure 1)) + +----------------------------------------------------------------------------- -- Linking doLink :: [String] -> IO () diff --git a/ghc/compiler/main/DriverState.hs b/ghc/compiler/main/DriverState.hs index 62a7976..0500b66 100644 --- a/ghc/compiler/main/DriverState.hs +++ b/ghc/compiler/main/DriverState.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverState.hs,v 1.34 2001/03/22 03:51:08 hwloidl Exp $ +-- $Id: DriverState.hs,v 1.35 2001/03/23 16:36:20 simonmar Exp $ -- -- Settings for the driver -- @@ -322,6 +322,8 @@ addToDirList ref path = do paths <- readIORef ref writeIORef ref (paths ++ split split_marker path) +GLOBAL_VAR(v_HCHeader, "", String) + ----------------------------------------------------------------------------- -- Packages diff --git a/ghc/compiler/main/Finder.lhs b/ghc/compiler/main/Finder.lhs index 70aa69c..4e4844d 100644 --- a/ghc/compiler/main/Finder.lhs +++ b/ghc/compiler/main/Finder.lhs @@ -30,7 +30,7 @@ import Directory import List import IO import Monad -import Outputable ( showSDoc, ppr ) -- debugging only +import Outputable \end{code} The Finder provides a thin filesystem abstraction to the rest of the @@ -211,5 +211,5 @@ getDirectoryContents' d ("WARNING: error while reading directory " ++ d) return [] ) - + \end{code} diff --git a/ghc/driver/mangler/Makefile b/ghc/driver/mangler/Makefile index 062213f..7b482e1 100644 --- a/ghc/driver/mangler/Makefile +++ b/ghc/driver/mangler/Makefile @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# $Id: Makefile,v 1.2 2000/11/03 16:54:52 simonmar Exp $ +# $Id: Makefile,v 1.3 2001/03/23 16:36:21 simonmar Exp $ TOP=../.. include $(TOP)/mk/boilerplate.mk @@ -14,4 +14,9 @@ INSTALL_LIBEXEC_SCRIPTS += $(SCRIPT_PROG) CLEAN_FILES += $(SCRIPT_OBJS) +# needed for bootstrapping with HC files +ifeq "$(BootingFromHc)" "YES" +boot :: all +endif + include $(TOP)/mk/target.mk diff --git a/ghc/lib/std/Makefile b/ghc/lib/std/Makefile index 0857f53..4a7b2c2 100644 --- a/ghc/lib/std/Makefile +++ b/ghc/lib/std/Makefile @@ -22,8 +22,7 @@ endif # Setting the standard variables # -HC = $(GHC_INPLACE) -CC = $(GHC_INPLACE) +HC = $(GHC_INPLACE) ifneq "$(DLLized)" "YES" PACKAGE = -package-name std @@ -72,8 +71,12 @@ PrelPrimopWrappers.hs: ../../compiler/prelude/primops.txt PrelGHC.$(way_)hi : PrelGHC.hi-boot cp $< $@ -boot :: PrelPrimopWrappers.hs PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi) -all :: PrelPrimopWrappers.hs +boot :: PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi) + +ifneq "$(BootingFromHc)" "YES" +boot :: PrelPrimopWrappers.hs +all :: PrelPrimopWrappers.hs +endif DLL_DESCRIPTION="GHC-compiled Haskell Prelude" diff --git a/ghc/mk/paths.mk b/ghc/mk/paths.mk index 40ade63..51d5ebc 100644 --- a/ghc/mk/paths.mk +++ b/ghc/mk/paths.mk @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: paths.mk,v 1.29 2001/03/05 10:29:00 simonmar Exp $ +# $Id: paths.mk,v 1.30 2001/03/23 16:36:22 simonmar Exp $ # # ghc project specific make variables # @@ -35,15 +35,3 @@ GHC_SPLIT = $(GHC_SPLIT_DIR)/ghc-split GHC_SYSMAN = $(GHC_RUNTIME_DIR)/parallel/SysMan GHC_SYSMAN_DIR = $(GHC_RUNTIME_DIR)/parallel - -#----------------------------------------------------------------------------- -# Stuff for the C-compiling phase in particular... - -# -# There's no need to compute dependencies when booting from .hc files -# -ifneq "$(GhcWithHscBuiltViaC)" "YES" -MKDEPENDHS_SRCS = $(HS_SRCS) -else -MKDEPENDHS_SRCS = -endif diff --git a/ghc/rts/Exception.hc b/ghc/rts/Exception.hc index d647013..31a1ae2 100644 --- a/ghc/rts/Exception.hc +++ b/ghc/rts/Exception.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Exception.hc,v 1.19 2001/03/22 03:51:10 hwloidl Exp $ + * $Id: Exception.hc,v 1.20 2001/03/23 16:36:21 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -7,6 +7,7 @@ * * ---------------------------------------------------------------------------*/ +#include "Stg.h" #include "Rts.h" #include "Exception.h" #include "Schedule.h" diff --git a/ghc/rts/HeapStackCheck.hc b/ghc/rts/HeapStackCheck.hc index 36c6090..8d0c46a 100644 --- a/ghc/rts/HeapStackCheck.hc +++ b/ghc/rts/HeapStackCheck.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: HeapStackCheck.hc,v 1.15 2000/12/14 15:19:48 sewardj Exp $ + * $Id: HeapStackCheck.hc,v 1.16 2001/03/23 16:36:21 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -7,6 +7,7 @@ * * ---------------------------------------------------------------------------*/ +#include "Stg.h" #include "Rts.h" #include "Storage.h" /* for CurrentTSO */ #include "StgRun.h" /* for StgReturn and register saving */ diff --git a/ghc/rts/Makefile b/ghc/rts/Makefile index 8feddbf..6cb4e0a 100644 --- a/ghc/rts/Makefile +++ b/ghc/rts/Makefile @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# $Id: Makefile,v 1.43 2001/01/26 14:40:18 simonmar Exp $ +# $Id: Makefile,v 1.44 2001/03/23 16:36:21 simonmar Exp $ # # This is the Makefile for the runtime-system stuff. # This stuff is written in C (and cannot be written in Haskell). @@ -32,13 +32,13 @@ else SRCS_RTS_C := $(filter-out Main.c, $(SRCS_RTS_C)) endif -#----------------------------------------------------------------------------- -# creating and installing libHSrts.a (in its many flavors) -# LIBOBJS = $(patsubst %.c,%.$(way_)o,$(SRCS_RTS_C)) \ $(patsubst %.hc,%.$(way_)o,$(SRCS_RTS_HC)) \ $(patsubst %.S,%.$(way_)o,$(SRCS_RTS_S)) +#----------------------------------------------------------------------------- +# Flags for compiling RTS .c and .hc files + # gcc provides lots of useful warnings if you ask it. # This is a pretty good list to start with - use a # to comment out # any you don't like. @@ -60,7 +60,6 @@ WARNING_OPTS += -optc-Wbad-function-cast #WARNING_OPTS += -optc-Wconversion SRC_HC_OPTS += -I../includes -I. -Iparallel $(WARNING_OPTS) $(GhcRtsHcOpts) -optc-DCOMPILING_RTS -SRC_CC_OPTS = $(GhcRtsCcOpts) ifneq "$(DLLized)" "YES" SRC_HC_OPTS += -static @@ -71,6 +70,11 @@ ifeq "$(way)" "mp" SRC_HC_OPTS += -I$$PVM_ROOT/include endif +# compiling straight C files: use all the HC_OPTS, plus any extra options in +# $(GhcRtsCcOpts). +SRC_CC_OPTS += $(GhcRtsCcOpts) +SRC_CC_OPTS += $(HC_OPTS) + #----------------------------------------------------------------------------- # Include the Front panel code? @@ -100,7 +104,16 @@ SRC_MKDEPENDC_OPTS += -I. -I../includes # ../driver/ghc (a better C compiler :-) to compile the # different RTS pieces # -CC=$(GHC_INPLACE) $(HC_OPTS) $($*_HC_OPTS) + +ifeq "$(BootingFromHc)" "YES" +# use the normal $(CC) when booting from .hc files +SRC_CC_OPTS := $(patsubst -optc%,%,$(SRC_CC_OPTS)) +SRC_CC_OPTS += $(PLATFORM_CC_OPTS) +else +# otherwise, use $(GHC_INPLACE) as the C compiler. +CC=$(GHC_INPLACE) +endif + HC=$(GHC_INPLACE) # prevent this value from leaking into the GMP makefile diff --git a/ghc/rts/PrimOps.hc b/ghc/rts/PrimOps.hc index 99d1dab..8c5c55e 100644 --- a/ghc/rts/PrimOps.hc +++ b/ghc/rts/PrimOps.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: PrimOps.hc,v 1.74 2001/03/22 03:51:10 hwloidl Exp $ + * $Id: PrimOps.hc,v 1.75 2001/03/23 16:36:21 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -7,6 +7,7 @@ * * ---------------------------------------------------------------------------*/ +#include "Stg.h" #include "Rts.h" #include "RtsFlags.h" diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index c0b4720..5451cc5 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.94 2001/03/22 03:51:10 hwloidl Exp $ + * $Id: Schedule.c,v 1.95 2001/03/23 16:36:21 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -1478,7 +1478,6 @@ createThread_(nat size, rtsBool have_lock) tso->why_blocked = NotBlocked; tso->blocked_exceptions = NULL; - //tso->splim = (P_)&(tso->stack) + RESERVED_STACK_WORDS; tso->stack_size = stack_size; tso->max_stack_size = round_to_mblocks(RtsFlags.GcFlags.maxStkSize) - TSO_STRUCT_SIZEW; @@ -2245,7 +2244,6 @@ threadStackOverflow(StgTSO *tso) diff = (P_)new_sp - (P_)tso->sp; /* In *words* */ dest->su = (StgUpdateFrame *) ((P_)dest->su + diff); dest->sp = new_sp; - //dest->splim = (P_)dest->splim + (nat)((P_)dest - (P_)tso); dest->stack_size = new_stack_size; /* and relocate the update frame list */ diff --git a/ghc/rts/StgMiscClosures.hc b/ghc/rts/StgMiscClosures.hc index eadb097..9fced45 100644 --- a/ghc/rts/StgMiscClosures.hc +++ b/ghc/rts/StgMiscClosures.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgMiscClosures.hc,v 1.65 2001/02/15 14:30:07 sewardj Exp $ + * $Id: StgMiscClosures.hc,v 1.66 2001/03/23 16:36:21 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -7,6 +7,7 @@ * * ---------------------------------------------------------------------------*/ +#include "Stg.h" #include "Rts.h" #include "RtsUtils.h" #include "RtsFlags.h" diff --git a/ghc/rts/StgStartup.hc b/ghc/rts/StgStartup.hc index f4e5683..bed2312 100644 --- a/ghc/rts/StgStartup.hc +++ b/ghc/rts/StgStartup.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgStartup.hc,v 1.14 2001/02/09 13:09:16 simonmar Exp $ + * $Id: StgStartup.hc,v 1.15 2001/03/23 16:36:21 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -7,6 +7,7 @@ * * ---------------------------------------------------------------------------*/ +#include "Stg.h" #include "Rts.h" #include "StgRun.h" /* StgReturn */ #include "StgStartup.h" diff --git a/ghc/rts/StgStdThunks.hc b/ghc/rts/StgStdThunks.hc index befa414..9bc1a21 100644 --- a/ghc/rts/StgStdThunks.hc +++ b/ghc/rts/StgStdThunks.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgStdThunks.hc,v 1.14 2000/12/04 12:31:21 simonmar Exp $ + * $Id: StgStdThunks.hc,v 1.15 2001/03/23 16:36:21 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -7,6 +7,7 @@ * * ---------------------------------------------------------------------------*/ +#include "Stg.h" #include "Rts.h" #include "StoragePriv.h" #include "HeapStackCheck.h" diff --git a/ghc/rts/Updates.hc b/ghc/rts/Updates.hc index dac564e..0e36791 100644 --- a/ghc/rts/Updates.hc +++ b/ghc/rts/Updates.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Updates.hc,v 1.32 2001/03/02 14:26:40 simonmar Exp $ + * $Id: Updates.hc,v 1.33 2001/03/23 16:36:21 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -7,6 +7,7 @@ * * ---------------------------------------------------------------------------*/ +#include "Stg.h" #include "Rts.h" #include "RtsUtils.h" #include "RtsFlags.h" diff --git a/ghc/rts/parallel/FetchMe.hc b/ghc/rts/parallel/FetchMe.hc index b25d6e5..799f126 100644 --- a/ghc/rts/parallel/FetchMe.hc +++ b/ghc/rts/parallel/FetchMe.hc @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- Time-stamp: - $Id: FetchMe.hc,v 1.6 2001/03/22 03:51:11 hwloidl Exp $ + $Id: FetchMe.hc,v 1.7 2001/03/23 16:36:21 simonmar Exp $ Entry code for a FETCH_ME closure @@ -21,6 +21,7 @@ //@node Includes, Info tables //@subsection Includes +#include "Stg.h" #include "Rts.h" #include "RtsFlags.h" #include "RtsUtils.h" diff --git a/ghc/utils/genprimopcode/Makefile b/ghc/utils/genprimopcode/Makefile index 3d9dbcd..753fd94 100644 --- a/ghc/utils/genprimopcode/Makefile +++ b/ghc/utils/genprimopcode/Makefile @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Makefile,v 1.4 2000/12/30 20:42:03 panne Exp $ +# $Id: Makefile,v 1.5 2001/03/23 16:36:22 simonmar Exp $ TOP=../.. include $(TOP)/mk/boilerplate.mk @@ -8,6 +8,8 @@ HS_PROG = genprimopcode SRC_HC_OPTS += -syslib text # genprimopcode is needed to boot in ghc/compiler... +ifneq "$(BootingFromHc)" "YES" boot :: all +endif include $(TOP)/mk/target.mk diff --git a/ghc/utils/hsc2hs/Makefile b/ghc/utils/hsc2hs/Makefile index 9ff860c..64ef719 100644 --- a/ghc/utils/hsc2hs/Makefile +++ b/ghc/utils/hsc2hs/Makefile @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Makefile,v 1.12 2001/03/16 09:07:41 qrczak Exp $ +# $Id: Makefile,v 1.13 2001/03/23 16:36:22 simonmar Exp $ TOP=../.. include $(TOP)/mk/boilerplate.mk @@ -57,7 +57,6 @@ INSTALL_DATAS += template-hsc.h # ----------------------------------------------------------------------------- # Create driver configuration -CURRENT_DIR=ghc/utils/hsc2hs CONFIG_HS = Config.hs boot :: $(CONFIG_HS) @@ -78,6 +77,8 @@ all clean veryclean maintainer-clean :: endif # hsc2hs-inplace is needed to boot in ghc/lib/std... +ifneq "$(BootingFromHc)" "YES" boot :: all +endif include $(TOP)/mk/target.mk diff --git a/mk/boilerplate.mk b/mk/boilerplate.mk index 0f78b67..d20d167 100644 --- a/mk/boilerplate.mk +++ b/mk/boilerplate.mk @@ -49,6 +49,10 @@ include $(TOP)/mk/opts.mk include $(TOP)/mk/suffix.mk # Suffix rules for Haskell, C and literate +ifeq "$(BootingFromHc)" "YES" +include $(TOP)/mk/bootstrap.mk +endif + -include $(TOP)/mk/build.mk # (Optional) build-specific configuration # diff --git a/mk/bootstrap.mk b/mk/bootstrap.mk new file mode 100644 index 0000000..7e7e44e --- /dev/null +++ b/mk/bootstrap.mk @@ -0,0 +1,64 @@ +# ----------------------------------------------------------------------------- +# $Id: bootstrap.mk,v 1.1 2001/03/23 16:36:23 simonmar Exp $ +# +# Makefile rules for booting from .hc files without a driver. +# + +TOP_SAVED := $(TOP) +TOP:=$(TOP)/ghc + +include $(FPTOOLS_TOP_ABS)/ghc/mk/version.mk +include $(FPTOOLS_TOP_ABS)/ghc/mk/paths.mk + +# Reset TOP +TOP:=$(TOP_SAVED) + +# ----------------------------------------------------------------------------- +# Set the platform-specific options to send to the C compiler. These should +# match the list in machdepCCOpts in ghc/compiler/DriverFlags.hs. +# + +PLATFORM_CC_OPTS = +PLATFORM_HC_BOOT_CC_OPTS = + +ifeq "$(i386_TARGET_ARCH)" "1" +PLATFORM_CC_OPTS += -DDONT_WANT_WIN32_DLL_SUPPORT +PLATFORM_HC_BOOT_CC_OPTS += -fno-defer-pop -fomit-frame-pointer +# ToDo: +STOLEN_X86_REGS = 4 +endif + +ifeq "$(hppa_TARGET_ARCH)" "1" +PLATFORM_CC_OPTS += -static -D_HPUX_SOURCE +endif + +ifeq "$(powerpc_TARGET_ARCH)" "1" +PLATFORM_CC_OPTS += -static +PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive +endif + +ifeq "$(rs6000_TARGET_ARCH)" "1" +PLATFORM_CC_OPTS += -static +PLATFORM_HC_BOOT_CC_OPTS += -static -finhibit-size-directive +endif + +ifeq "$(mingw32_TARGET_OS)" "1" +PLATFORM_CC_OPTS += -mno-cygwin +endif + +PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) + +HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) + +# ----------------------------------------------------------------------------- +# suffix rules for building a .o from a .hc file. The normal build system +# should be able to take care of the rest. + +%.raw_s : %.hc + $(CC) -x c $< -o $@ -S -O $(HC_BOOT_CC_OPTS) -I. -I$(FPTOOLS_TOP_ABS)/ghc/includes -I$(FPTOOLS_TOP_ABS)/ghc/lib/std/cbits + +%.s : %.raw_s + $(GHC_MANGLER) $< $@ $(STOLEN_X86_REGS) + +%.o : %.s + $(CC) -c -o $@ $< diff --git a/mk/config.mk.in b/mk/config.mk.in index 2ef7c4d..3bffb6a 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -97,8 +97,11 @@ exeext=@exeext@ # ################################################################################ +# BootingFromHc - build GHC and the libraries from .hc files? +BootingFromHc = @BootingFromHc@ + # build the libs first if we're bootstrapping from .hc files -ifeq "$(GhcWithHscBuiltViaC)" "YES" +ifeq "$(BootingFromHc)" "YES" AllProjects = glafp-utils hslibs ghc green-card happy hdirect hood nofib else AllProjects = glafp-utils ghc hslibs green-card happy hdirect hood nofib @@ -156,9 +159,6 @@ GhcCompilerWays= # a pretty strong internal check GhcHcOpts=-O -Rghc-timing -# GhcWithHscBuiltViaC - build GHC compiler proper (\`hsc') from .hc files? -GhcWithHscBuiltViaC=@BootingFromHc@ - # Build a compiler that will build *unregisterised* libraries and # binaries by default. Unregisterised code is supposed to compile and # run without any support for architecture-specific assembly mangling, @@ -214,7 +214,7 @@ BuildingGranSim=$(subst mg,YES,$(filter mg,$(WAYS))) # In addition to the normal sequential way, the default is to also build # profiled prelude libraries. # When booting from .hc files, turn this off. -ifeq "$(GhcWithHscBuiltViaC)" "YES" +ifeq "$(BootingFromHc)" "YES" GhcLibWays= else GhcLibWays=p @@ -231,14 +231,18 @@ endif GhcLibHcOpts=-O -Rghc-timing # Win32 only: Enable the RTS and libraries to be built as DLLs -# Don't split object files for libs if we're building DLLs DLLized=@EnableWin32DLLs@ + +# Don't split object files for libs if we're building DLLs, or booting from +# .hc files. +SplitObjs=YES + ifeq "$(DLLized)" "YES" SplitObjs=NO -else -SplitObjs=YES endif - +ifeq "$(BootingFromHc)" "YES" +SplitObjs=NO +endif # Strip local symbols from libraries? This can make the libraries smaller, # but makes debugging somewhat more difficult. Doesn't work with all ld's. @@ -575,6 +579,9 @@ else endif endif +# default C compiler flags +SRC_CC_OPTS = -O + #----------------------------------------------------------------------------- # GMP Library (version 2.0.x or above) # diff --git a/mk/paths.mk b/mk/paths.mk index 83a76b8..0cb1e2d 100644 --- a/mk/paths.mk +++ b/mk/paths.mk @@ -97,7 +97,7 @@ INSTALL_DIR = $(FPTOOLS_TOP)/glafp-utils/mkdirhier/mkdirhier # (caveat: assuming no funny use of -hisuf and that # file name and module name match) -SRCS=$(wildcard *.lhs *.hs *.c *.lc *.prl *.lprl *.lit *.verb) +SRCS=$(wildcard *.lhs *.hs *.c *.prl *.lprl *.lit *.verb) HS_SRCS=$(filter %.lhs %.hs %.hc,$(sort $(SRCS) $(BOOT_SRCS))) HS_OBJS=$(addsuffix .$(way_)o,$(basename $(HS_SRCS))) @@ -105,7 +105,7 @@ HS_HCS=$(addsuffix .$(way_)hc,$(basename $(HS_SRCS))) HS_SS=$(addsuffix .$(way_)s,$(basename $(HS_SRCS))) HS_IFACES=$(addsuffix .$(way_)hi,$(basename $(HS_SRCS))) -C_SRCS=$(filter %.lc %.c,$(SRCS)) +C_SRCS=$(filter %.c,$(SRCS)) C_OBJS=$(addsuffix .$(way_)o,$(basename $(C_SRCS))) # SCRIPT_SRCS: list of raw script files (in literate form) @@ -129,7 +129,13 @@ OBJS=$(HS_OBJS) $(C_OBJS) $(SCRIPT_OBJS) # The default set of files for the dependency generators to work on # is just their source equivalents. # + +ifneq "$(BootingFromHc)" "YES" MKDEPENDHS_SRCS=$(HS_SRCS) +else +MKDEPENDHS_SRCS= +endif + MKDEPENDC_SRCS=$(C_SRCS) #------------------------------------------------------------------ @@ -159,9 +165,14 @@ TAGS_C_SRCS=$(C_SRCS) # MOSTLY_CLEAN_FILES += $(HS_OBJS) $(C_OBJS) CLEAN_FILES += $(HS_PROG) $(C_PROG) $(SCRIPT_PROG) $(SCRIPT_LINK) \ - $(PROG) $(LIBRARY) $(HS_IFACES) $(HS_HCS) $(HS_SS) \ + $(PROG) $(LIBRARY) $(HS_IFACES) $(HS_SS) \ a.out +# Don't clean the .hc files if we're bootstrapping +ifneq "$(BootingFromHc)" "YES" +CLEAN_FILES += $(HS_HCS) +endif + DIST_CLEAN_FILES += .depend MAINTAINER_CLEAN_FILES += $(BOOT_SRCS) diff --git a/mk/suffix.mk b/mk/suffix.mk index e954345..5f67ad6 100644 --- a/mk/suffix.mk +++ b/mk/suffix.mk @@ -30,6 +30,11 @@ endif #----------------------------------------------------------------------------- # Haskell Suffix Rules +# Turn off all the Haskell suffix rules if we're booting from .hc +# files. The file bootstrap.mk contains alternative suffix rules in +# this case. +ifneq "$(BootingFromHc)" "YES" + %.$(way_)o : %.hs $(HC_PRE_OPTS) $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@)) @@ -91,6 +96,8 @@ endif else exit 0 ; \ fi +endif # BootingViaC + #----------------------------------------------------------------------------- # Happy Suffix Rules # @@ -214,6 +221,9 @@ endif %.html : %.sgml @$(RM) $@ +# $(PERL) $(COLLATEINDEX) -N -o index.sgml +# $(JADE) -t sgml -V html-index -d $(SGMLSTYLESHEET) -c $(DOCBOOK_CATALOG) $< +# $(PERL) $(COLLATEINDEX) -N -o index.sgml $(SGML2HTML) $(SGML2HTML_OPTS) $< %.html : %.tex diff --git a/mk/target.mk b/mk/target.mk index b6060ca..81ac73b 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -318,29 +318,39 @@ endif #---------------------------------------- -# Libraries/archives +# Building HsLibs libraries. + +ifneq "$(HSLIB)" "" ifeq "$(IS_CBITS_LIB)" "YES" _cbits := _cbits endif -ifneq "$(HSLIB)" "" LIBRARY = libHS$(HSLIB)$(_cbits)$(_way).a GHCI_LIBRARY = HS$(HSLIB)$(_cbits)$(_way).o + +ifneq "$(IS_CBITS_LIB)" "YES" +WAYS=$(GhcLibWays) +endif + ifeq "$(LIBOBJS)" "" - ifneq "$(IS_CBITS_LIB)" "YES" - LIBOBJS = $(HS_OBJS) - else + ifeq "$(IS_CBITS_LIB)" "YES" LIBOBJS = $(C_OBJS) + else + LIBOBJS = $(HS_OBJS) endif endif -ifneq "$(IS_CBITS_LIB)" "" -CC = $(HC) + +ifeq "$(IS_CBITS_LIB)" "YES" override datadir:=$(libdir)/includes INSTALL_DATAS += Hs$(shell perl -e 'print ucfirst "$(HSLIB)"').h SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR) endif -endif + +endif # HSLIB + +#---------------------------------------- +# Libraries/archives ifneq "$(LIBRARY)" "" all :: $(LIBRARY) -- 1.7.10.4