X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FStaticFlags.hs;h=9378c0afa9500cb5111ec7978dba06465456b75d;hb=d5934bbb856aa0aa620c9b2e0fa51c90a1a5a048;hp=9e1d8ad7a8df11c7aa2bdd7e63212187efff47bb;hpb=95731e19939a07410877371bac8fcb5a259c17eb;p=ghc-hetmet.git diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs index 9e1d8ad..9378c0a 100644 --- a/compiler/main/StaticFlags.hs +++ b/compiler/main/StaticFlags.hs @@ -64,23 +64,23 @@ module StaticFlags ( opt_EmitExternalCore, opt_PIC, v_Ld_inputs, + tablesNextToCode ) where #include "HsVersions.h" import CmdLineParser -import Config ( cProjectVersionInt, cProjectPatchLevel, - cGhcUnregisterised ) +import Config import FastString ( FastString, mkFastString ) import Util import Maybes ( firstJust ) import Panic ( GhcException(..), ghcError ) -import EXCEPTION ( throwDyn ) -import DATA_IOREF -import UNSAFE_IO ( unsafePerformIO ) -import Monad ( when ) -import Char ( isDigit ) +import Control.Exception ( throwDyn ) +import Data.IORef +import System.IO.Unsafe ( unsafePerformIO ) +import Control.Monad ( when ) +import Data.Char ( isDigit ) import Data.List ( sort, intersperse, nub ) ----------------------------------------------------------------------------- @@ -100,8 +100,16 @@ parseStaticFlags args = do | otherwise = [] (more_leftover, errs) <- processArgs static_flags (unreg_flags ++ way_flags) + + -- TABLES_NEXT_TO_CODE affects the info table layout. + -- Be careful to do this *after* all processArgs, + -- because evaluating tablesNextToCode involves looking at the global + -- static flags. Those pesky global variables... + let cg_flags | tablesNextToCode = ["-optc-DTABLES_NEXT_TO_CODE"] + | otherwise = [] + when (not (null errs)) $ ghcError (UsageError (unlines errs)) - return (more_leftover++leftover) + return (cg_flags++more_leftover++leftover) -- note that ordering is important in the following list: any flag which @@ -284,6 +292,14 @@ opt_UF_DearOp = ( 4 :: Int) opt_Static = lookUp FSLIT("-static") opt_Unregisterised = lookUp FSLIT("-funregisterised") + +-- Derived, not a real option. Determines whether we will be compiling +-- info tables that reside just before the entry code, or with an +-- indirection to the entry code. See TABLES_NEXT_TO_CODE in +-- includes/InfoTables.h. +tablesNextToCode = not opt_Unregisterised + && cGhcEnableTablesNextToCode == "YES" + opt_EmitExternalCore = lookUp FSLIT("-fext-core") -- Include full span info in error messages, instead of just the start position.