</para>
</sect3>
+<sect3><title>HOST_OS vs TARGET_OS</title>
+
+<para>
+In the source code you'll find various ifdefs looking like:
+<programlisting>
+ #ifdef mingw32_HOST_OS
+ ...blah blah...
+ #endif
+</programlisting>
+and
+<programlisting>
+ #ifdef mingw32_TARGET_OS
+ ...blah blah...
+ #endif
+</programlisting>
+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:
+<itemizedlist>
+ <listitem> <para>
+ The "host" system is the one on which GHC itself will be run.
+ </para> </listitem>
+ <listitem> <para>
+ The "target" system is the one for which the program compiled by GHC will be run.
+ </para> </listitem>
+</itemizedlist>
+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.
+</para>
+</sect3>
+
<sect3><title>Summary</title>
<para>Notice that "GHC-mingw" means "GHC that <emphasis>targets</emphasis> MinGW". It says nothing about
{-# 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
--
import Panic hiding ( showException )
import Config
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
import System.Posix
#endif
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
checkPerms :: String -> IO Bool
checkPerms name =
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
return True
#else
DriverUtil.handle (\_ -> return False) $ do
-----------------------------------------------------------------------------
--- $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
--
-- 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
-----------------------------------------------------------------------------
--- $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
--
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
-- 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
import CString ( CString, peekCString )
#endif
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
#if __GLASGOW_HASKELL__ > 504
import System.Cmd ( rawSystem )
#else
| 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
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
; return ()
}
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
foreign import stdcall "GetTempPathA" unsafe getTempPath :: Int -> CString -> IO Int32
#endif
\end{code}
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
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
--------------------- Windows version ------------------
dosifyPaths xs = map dosifyPath xs
-----------------------------------------------------------------------------
-- 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
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
#endif
quote :: String -> String
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
quote "" = ""
quote s = "\"" ++ s ++ "\""
#else
import Config
import FastTypes
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
# if __GLASGOW_HASKELL__ > 504
import System.Posix.Signals
# else
# else
import EXCEPTION ( throwTo )
# endif /* GHC < 500 */
-#endif /* mingw32_TARGET_OS */
+#endif /* mingw32_HOST_OS */
import DYNAMIC
import qualified EXCEPTION as Exception
\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)))