addCmdlineHCInclude,
buildStaticHscOpts,
machdepCCOpts,
+ picCCOpts,
processArgs, OptKind(..), -- for DriverMkDepend only
) where
#include "HsVersions.h"
-#include "../includes/ghcconfig.h"
import MkIface ( showIface )
import DriverState
, ( "S" , PassFlag (setMode (StopBefore As)))
, ( "-make" , PassFlag (setMode DoMake))
, ( "-interactive" , PassFlag (setMode DoInteractive))
- , ( "-mk-dll" , PassFlag (setMode DoMkDLL))
+ , ( "-mk-dll" , NoArg (writeIORef v_GhcLink NoLink))
, ( "e" , HasArg (\s -> setMode (DoEval s) "-e"))
-- -fno-code says to stop after Hsc but don't generate any code.
, ( "ignore-dot-ghci", NoArg (writeIORef v_Read_DotGHCi False) )
, ( "read-dot-ghci" , NoArg (writeIORef v_Read_DotGHCi True) )
- ------- recompilation checker --------------------------------------
- , ( "recomp" , NoArg (setRecompFlag True) )
- , ( "no-recomp" , NoArg (setRecompFlag False) )
-
------- ways --------------------------------------------------------
, ( "prof" , NoArg (addNoDups v_Ways WayProf) )
, ( "unreg" , NoArg (addNoDups v_Ways WayUnreg) )
, ( "optdll" , HasArg (add v_Opt_dll) )
----- Linker --------------------------------------------------------
- , ( "c" , NoArg (writeIORef v_NoLink True) )
- , ( "no-link" , NoArg (writeIORef v_NoLink True) ) -- Deprecated
+ , ( "c" , NoArg (writeIORef v_GhcLink NoLink) )
+ , ( "no-link" , NoArg (writeIORef v_GhcLink NoLink) ) -- Deprecated
, ( "static" , NoArg (writeIORef v_Static True) )
, ( "dynamic" , NoArg (writeIORef v_Static False) )
, ( "rdynamic" , NoArg (return ()) ) -- ignored for compat w/ gcc
, ( "opti", HasArg (addOpt_i) )
#endif
+ ------- recompilation checker --------------------------------------
+ , ( "recomp" , NoArg (setRecompFlag True) )
+ , ( "no-recomp" , NoArg (setRecompFlag False) )
+
------- Packages ----------------------------------------------------
, ( "package-conf" , HasArg extraPkgConf_ )
, ( "no-user-package-conf", NoArg noUserPkgConf_ )
-- )
machdepCCOpts dflags
- | prefixMatch "alpha" cTARGETPLATFORM
+#if alpha_TARGET_ARCH
= return ( ["-w", "-mieee"
#ifdef HAVE_THREADED_RTS_SUPPORT
, "-D_REENTRANT"
-- register used for global register variable", we simply
-- disable all warnings altogether using the -w flag. Oh well.
- | prefixMatch "hppa" cTARGETPLATFORM
+#elif hppa_TARGET_ARCH
-- ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi!
-- (very nice, but too bad the HP /usr/include files don't agree.)
= return ( ["-D_HPUX_SOURCE"], [] )
- | prefixMatch "m68k" cTARGETPLATFORM
+#elif m68k_TARGET_ARCH
-- -fno-defer-pop : for the .hc files, we want all the pushing/
-- popping of args to routines to be explicit; if we let things
-- be deferred 'til after an STGJUMP, imminent death is certain!
-- as on iX86, where we *do* steal the frame pointer [%ebp].)
= return ( [], ["-fno-defer-pop", "-fno-omit-frame-pointer"] )
- | prefixMatch "i386" cTARGETPLATFORM
+#elif i386_TARGET_ARCH
-- -fno-defer-pop : basically the same game as for m68k
--
-- -fomit-frame-pointer : *must* in .hc files; because we're stealing
"-DSTOLEN_X86_REGS="++show n_regs ]
)
- | prefixMatch "ia64" cTARGETPLATFORM
+#elif ia64_TARGET_ARCH
= return ( [], ["-fomit-frame-pointer", "-G0"] )
- | prefixMatch "x86_64" cTARGETPLATFORM
+#elif x86_64_TARGET_ARCH
= return ( [], ["-fomit-frame-pointer"] )
- | prefixMatch "mips" cTARGETPLATFORM
+#elif mips_TARGET_ARCH
= return ( ["-static"], [] )
- | prefixMatch "sparc" cTARGETPLATFORM
+#elif sparc_TARGET_ARCH
= return ( [], ["-w"] )
-- For now, to suppress the gcc warning "call-clobbered
-- register used for global register variable", we simply
-- disable all warnings altogether using the -w flag. Oh well.
- | prefixMatch "powerpc-apple-darwin" cTARGETPLATFORM
+#elif powerpc_apple_darwin_TARGET
-- -no-cpp-precomp:
-- Disable Apple's precompiling preprocessor. It's a great thing
-- for "normal" programs, but it doesn't support register variable
-- declarations.
+ = return ( [], ["-no-cpp-precomp"] )
+#else
+ = return ( [], [] )
+#endif
+
+picCCOpts dflags
+#if darwin_TARGET_OS
+ -- Apple prefers to do things the other way round.
+ -- PIC is on by default.
-- -mdynamic-no-pic:
- -- Turn off PIC code generation to save space and time.
+ -- Turn off PIC code generation.
-- -fno-common:
-- Don't generate "common" symbols - these are unwanted
-- in dynamic libraries.
- = if opt_PIC
- then return ( ["-no-cpp-precomp", "-fno-common"],
- ["-fno-common"] )
- else return ( ["-no-cpp-precomp", "-mdynamic-no-pic"],
- ["-mdynamic-no-pic"] )
-
- | prefixMatch "powerpc" cTARGETPLATFORM && opt_PIC
- = return ( ["-fPIC"], ["-fPIC"] )
-
- | otherwise
- = return ( [], [] )
+ | opt_PIC
+ = return ["-fno-common"]
+ | otherwise
+ = return ["-mdynamic-no-pic"]
+#elif mingw32_TARGET_OS
+ -- no -fPIC for Windows
+ = return []
+#else
+ | opt_PIC
+ = return ["-fPIC"]
+ | otherwise
+ = return []
+#endif
-----------------------------------------------------------------------------
-- local utils