From 395917a05328e935f40abd080b169aa25546b083 Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 24 Feb 2003 12:39:27 +0000 Subject: [PATCH] [project @ 2003-02-24 12:39:24 by simonpj] Three Template Haskell improvements a) Add type synonyms to THSyntax (and DsMeta, Convert) b) Make Q into a newtype instead of a type synonym c) Eliminate tiresome and error prone argument to DsMeta.wrapGenSyms and similarly addTyVarBinds --- docs/building/building.sgml | 30 ++++++++++++++++++++++++++++++ ghc/compiler/ghci/InteractiveUI.hs | 8 ++++---- ghc/compiler/main/DriverFlags.hs | 4 ++-- ghc/compiler/main/DriverPhases.hs | 4 +++- ghc/compiler/main/SysTools.lhs | 22 +++++++++++----------- ghc/compiler/utils/Panic.lhs | 6 +++--- 6 files changed, 53 insertions(+), 21 deletions(-) diff --git a/docs/building/building.sgml b/docs/building/building.sgml index 0975985..fc342d0 100644 --- a/docs/building/building.sgml +++ b/docs/building/building.sgml @@ -4129,6 +4129,36 @@ that Haskell programs compiled by GHC-cygwin can import the (Haskell) Posix libr +HOST_OS vs TARGET_OS + + +In the source code you'll find various ifdefs looking like: + + #ifdef mingw32_HOST_OS + ...blah blah... + #endif + +and + + #ifdef mingw32_TARGET_OS + ...blah blah... + #endif + +These macros are set by the configure script (via the file config.h). +Which is which? The criterion is this. In the ifdefs in GHC's source code: + + + The "host" system is the one on which GHC itself will be run. + + + The "target" system is the one for which the program compiled by GHC will be run. + + +For a stage-2 compiler, in which GHCi is available, the "host" and "target" systems must be the same. +So then it doesn't really matter whether you use the HOST_OS or TARGET_OS cpp macros. + + + Summary Notice that "GHC-mingw" means "GHC that targets MinGW". It says nothing about diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index ab52f34..b8f75de 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,6 +1,6 @@ {-# OPTIONS -#include "Linker.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.147 2003/02/20 13:12:40 simonpj Exp $ +-- $Id: InteractiveUI.hs,v 1.148 2003/02/24 12:39:26 simonpj Exp $ -- -- GHC Interactive User Interface -- @@ -45,7 +45,7 @@ import CmdLineOpts ( DynFlag(..), DynFlags(..), getDynFlags, saveDynFlags, import Panic hiding ( showException ) import Config -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS import System.Posix #endif @@ -234,7 +234,7 @@ runGHCi paths dflags = do loadModule paths -- enter the interactive loop -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) -- always show prompt, since hIsTerminalDevice returns True for Consoles -- only, which we may or may not be running under (cf. Emacs sub-shells.) interactiveLoop True @@ -274,7 +274,7 @@ interactiveLoop is_tty = do checkPerms :: String -> IO Bool checkPerms name = -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS return True #else DriverUtil.handle (\_ -> return False) $ do diff --git a/ghc/compiler/main/DriverFlags.hs b/ghc/compiler/main/DriverFlags.hs index a015de2..e66f718 100644 --- a/ghc/compiler/main/DriverFlags.hs +++ b/ghc/compiler/main/DriverFlags.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverFlags.hs,v 1.113 2003/02/21 13:26:58 simonpj Exp $ +-- $Id: DriverFlags.hs,v 1.114 2003/02/24 12:39:26 simonpj Exp $ -- -- Driver flags -- @@ -362,7 +362,7 @@ dynamic_flags = [ -- on all other systems, quoting is necessary, to avoid interpretation -- of shell metacharacters in the arguments (e.g. green-card's -- -DBEGIN_GHC_ONLY='}-' trick). -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS , ( "D", Prefix (\s -> addOpt_P ("-D'"++s++"'") ) ) , ( "U", Prefix (\s -> addOpt_P ("-U'"++s++"'") ) ) #else diff --git a/ghc/compiler/main/DriverPhases.hs b/ghc/compiler/main/DriverPhases.hs index 4632bab..e85bbe7 100644 --- a/ghc/compiler/main/DriverPhases.hs +++ b/ghc/compiler/main/DriverPhases.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverPhases.hs,v 1.22 2002/09/13 15:02:34 simonpj Exp $ +-- $Id: DriverPhases.hs,v 1.23 2003/02/24 12:39:27 simonpj Exp $ -- -- GHC Driver -- @@ -106,6 +106,8 @@ cish_suffix = (`elem` [ "c", "cpp", "C", "cc", "cxx", "s", "S" ]) hsbootish_suffix = (`elem` [ "hs-boot" ]) extcoreish_suffix = (`elem` [ "hcr" ]) +-- Use the appropriate suffix for the system on which +-- the GHC-compiled code will run #if mingw32_TARGET_OS || cygwin32_TARGET_OS objish_suffix = (`elem` [ "o", "O", "obj", "OBJ" ]) #else diff --git a/ghc/compiler/main/SysTools.lhs b/ghc/compiler/main/SysTools.lhs index 15d5c88..71b7298 100644 --- a/ghc/compiler/main/SysTools.lhs +++ b/ghc/compiler/main/SysTools.lhs @@ -86,11 +86,11 @@ import Directory ( doesFileExist, removeFile ) -- GHC <= 4.08 didn't have rawSystem, and runs into problems with long command -- lines on mingw32, so we disallow it now. -#if defined(mingw32_TARGET_OS) && (__GLASGOW_HASKELL__ <= 408) +#if defined(mingw32_HOST_OS) && (__GLASGOW_HASKELL__ <= 408) #error GHC <= 4.08 is not supported for bootstrapping GHC on i386-unknown-mingw32 #endif -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS #if __GLASGOW_HASKELL__ > 504 import qualified GHC.Posix #else @@ -103,7 +103,7 @@ import Foreign import CString ( CString, peekCString ) #endif -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS #if __GLASGOW_HASKELL__ > 504 import System.Cmd ( rawSystem ) #else @@ -272,7 +272,7 @@ initSysTools minusB_args | am_installed = installed_bin cGHC_MANGLER_PGM | otherwise = inplace cGHC_MANGLER_DIR_REL cGHC_MANGLER_PGM -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS -- check whether TMPDIR is set in the environment ; IO.try (do dir <- getEnv "TMPDIR" -- fails if not set setTmpDir dir @@ -314,7 +314,7 @@ initSysTools minusB_args throwDyn (InstallationError ("Can't find package.conf as " ++ pkgconfig_path)) -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) -- WINDOWS-SPECIFIC STUFF -- On Windows, gcc and friends are distributed with GHC, -- so when "installed" we look in TopDir/bin @@ -417,7 +417,7 @@ initSysTools minusB_args ; return () } -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) foreign import stdcall "GetTempPathA" unsafe getTempPath :: Int -> CString -> IO Int32 #endif \end{code} @@ -701,7 +701,7 @@ runSomething :: String -- For -v message runSomething phase_name pgm args = traceCmd phase_name cmd_line $ do { -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS exit_code <- system cmd_line #else exit_code <- rawSystem cmd_line @@ -772,7 +772,7 @@ pgmPath :: String -- Directory string in Unix format -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) --------------------- Windows version ------------------ dosifyPaths xs = map dosifyPath xs @@ -832,7 +832,7 @@ slash s1 s2 = s1 ++ ('/' : s2) ----------------------------------------------------------------------------- -- Define getExecDir :: IO (Maybe String) -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) getExecDir :: IO (Maybe String) getExecDir = do let len = (2048::Int) -- plenty, PATH_MAX is 512 under Win32. buf <- mallocArray len @@ -849,7 +849,7 @@ foreign import stdcall "GetModuleFileNameA" unsafe getExecDir :: IO (Maybe String) = do return Nothing #endif -#ifdef mingw32_TARGET_OS +#ifdef mingw32_HOST_OS foreign import ccall "_getpid" unsafe getProcessID :: IO Int -- relies on Int == Int32 on Windows #elif __GLASGOW_HASKELL__ > 504 getProcessID :: IO Int @@ -860,7 +860,7 @@ getProcessID = Posix.getProcessID #endif quote :: String -> String -#if defined(mingw32_TARGET_OS) +#if defined(mingw32_HOST_OS) quote "" = "" quote s = "\"" ++ s ++ "\"" #else diff --git a/ghc/compiler/utils/Panic.lhs b/ghc/compiler/utils/Panic.lhs index f07f7f1..29e99e9 100644 --- a/ghc/compiler/utils/Panic.lhs +++ b/ghc/compiler/utils/Panic.lhs @@ -27,7 +27,7 @@ module Panic import Config import FastTypes -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS # if __GLASGOW_HASKELL__ > 504 import System.Posix.Signals # else @@ -41,7 +41,7 @@ import EXCEPTION ( raiseInThread ) # else import EXCEPTION ( throwTo ) # endif /* GHC < 500 */ -#endif /* mingw32_TARGET_OS */ +#endif /* mingw32_HOST_OS */ import DYNAMIC import qualified EXCEPTION as Exception @@ -185,7 +185,7 @@ thread. \begin{code} installSignalHandlers :: IO () installSignalHandlers = do -#ifndef mingw32_TARGET_OS +#ifndef mingw32_HOST_OS main_thread <- myThreadId let sig_handler = Catch (throwTo main_thread (Exception.DynException (toDyn Interrupted))) -- 1.7.10.4