Commit cdf946e4 authored by Ian Lynagh's avatar Ian Lynagh

Make -fPIC a dynamic flag

Hopefully I've kept the logic the same, and we now generate warnings if
the user does -fno-PIC but we ignore them (e.g. because they're on OS X
amd64).
parent 5d0fce85
......@@ -119,9 +119,10 @@ buildDynCon :: Id -- Name of the thing to which this constr will
-> FCode CgIdInfo -- Return details about how to find it
buildDynCon binder ccs con args
= do dflags <- getDynFlags
buildDynCon' (targetPlatform dflags) binder ccs con args
buildDynCon' dflags (targetPlatform dflags) binder ccs con args
buildDynCon' :: Platform
buildDynCon' :: DynFlags
-> Platform
-> Id
-> CostCentreStack
-> DataCon
......@@ -148,7 +149,7 @@ which have exclusively size-zero (VoidRep) args, we generate no code
at all.
\begin{code}
buildDynCon' _ binder _ con []
buildDynCon' _ _ binder _ con []
= returnFC (taggedStableIdInfo binder
(mkLblExpr (mkClosureLabel (dataConName con)
(idCafInfo binder)))
......@@ -183,9 +184,9 @@ because they don't support cross package data references well.
\begin{code}
buildDynCon' platform binder _ con [arg_amode]
buildDynCon' dflags platform binder _ con [arg_amode]
| maybeIntLikeCon con
, platformOS platform /= OSMinGW32 || not opt_PIC
, platformOS platform /= OSMinGW32 || not (dopt Opt_PIC dflags)
, (_, CmmLit (CmmInt val _)) <- arg_amode
, let val_int = (fromIntegral val) :: Int
, val_int <= mAX_INTLIKE && val_int >= mIN_INTLIKE
......@@ -195,9 +196,9 @@ buildDynCon' platform binder _ con [arg_amode]
intlike_amode = CmmLit (cmmLabelOffW intlike_lbl offsetW)
; returnFC (taggedStableIdInfo binder intlike_amode (mkConLFInfo con) con) }
buildDynCon' platform binder _ con [arg_amode]
buildDynCon' dflags platform binder _ con [arg_amode]
| maybeCharLikeCon con
, platformOS platform /= OSMinGW32 || not opt_PIC
, platformOS platform /= OSMinGW32 || not (dopt Opt_PIC dflags)
, (_, CmmLit (CmmInt val _)) <- arg_amode
, let val_int = (fromIntegral val) :: Int
, val_int <= mAX_CHARLIKE && val_int >= mIN_CHARLIKE
......@@ -212,7 +213,7 @@ buildDynCon' platform binder _ con [arg_amode]
Now the general case.
\begin{code}
buildDynCon' _ binder ccs con args
buildDynCon' _ _ binder ccs con args
= do {
; let
(closure_info, amodes_w_offsets) = layOutDynConstr con args
......
......@@ -40,7 +40,6 @@ import Literal
import PrelInfo
import Outputable
import Platform
import StaticFlags
import Util
import Control.Monad
......@@ -115,9 +114,10 @@ buildDynCon :: Id -- Name of the thing to which this constr will
-- Return details about how to find it and initialization code
buildDynCon binder cc con args
= do dflags <- getDynFlags
buildDynCon' (targetPlatform dflags) binder cc con args
buildDynCon' dflags (targetPlatform dflags) binder cc con args
buildDynCon' :: Platform
buildDynCon' :: DynFlags
-> Platform
-> Id
-> CostCentreStack
-> DataCon
......@@ -145,7 +145,7 @@ premature looking at the args will cause the compiler to black-hole!
-- which have exclusively size-zero (VoidRep) args, we generate no code
-- at all.
buildDynCon' _ binder _cc con []
buildDynCon' _ _ binder _cc con []
= return (litIdInfo binder (mkConLFInfo con)
(CmmLabel (mkClosureLabel (dataConName con) (idCafInfo binder))),
mkNop)
......@@ -176,9 +176,9 @@ We don't support this optimisation when compiling into Windows DLLs yet
because they don't support cross package data references well.
-}
buildDynCon' platform binder _cc con [arg]
buildDynCon' dflags platform binder _cc con [arg]
| maybeIntLikeCon con
, platformOS platform /= OSMinGW32 || not opt_PIC
, platformOS platform /= OSMinGW32 || not (dopt Opt_PIC dflags)
, StgLitArg (MachInt val) <- arg
, val <= fromIntegral mAX_INTLIKE -- Comparisons at type Integer!
, val >= fromIntegral mIN_INTLIKE -- ...ditto...
......@@ -189,9 +189,9 @@ buildDynCon' platform binder _cc con [arg]
intlike_amode = cmmLabelOffW intlike_lbl offsetW
; return (litIdInfo binder (mkConLFInfo con) intlike_amode, mkNop) }
buildDynCon' platform binder _cc con [arg]
buildDynCon' dflags platform binder _cc con [arg]
| maybeCharLikeCon con
, platformOS platform /= OSMinGW32 || not opt_PIC
, platformOS platform /= OSMinGW32 || not (dopt Opt_PIC dflags)
, StgLitArg (MachChar val) <- arg
, let val_int = ord val :: Int
, val_int <= mAX_CHARLIKE
......@@ -203,7 +203,7 @@ buildDynCon' platform binder _cc con [arg]
; return (litIdInfo binder (mkConLFInfo con) charlike_amode, mkNop) }
-------- buildDynCon': the general case -----------
buildDynCon' _ binder ccs con args
buildDynCon' _ _ binder ccs con args
= do { let (tot_wds, ptr_wds, args_w_offsets)
= mkVirtConstrOffsets (addArgReps args)
-- No void args in args_w_offsets
......
......@@ -37,7 +37,7 @@ fingerprintDynFlags dflags@DynFlags{..} this_mod nameio =
IntSet.toList $ extensionFlags)
-- -I, -D and -U flags affect CPP
cpp = (map normalise includePaths, opt_P dflags ++ picPOpts)
cpp = (map normalise includePaths, opt_P dflags ++ picPOpts dflags)
-- normalise: eliminate spurious differences due to "./foo" vs "foo"
-- Note [path flags and recompilation]
......
......@@ -39,7 +39,7 @@ import Module
import UniqFM ( eltsUFM )
import ErrUtils
import DynFlags
import StaticFlags ( v_Ld_inputs, opt_PIC, opt_Static, WayName(..) )
import StaticFlags ( v_Ld_inputs, opt_Static, WayName(..) )
import Config
import Panic
import Util
......@@ -1349,7 +1349,7 @@ runPhase LlvmLlc input_fn dflags
let lc_opts = getOpts dflags opt_lc
opt_lvl = max 0 (min 2 $ optLevel dflags)
rmodel | opt_PIC = "pic"
rmodel | dopt Opt_PIC dflags = "pic"
| not opt_Static = "dynamic-no-pic"
| otherwise = "static"
tbaa | ver < 29 = "" -- no tbaa in 2.8 and earlier
......@@ -2036,7 +2036,7 @@ linkDynLib dflags o_files dep_packages = do
doCpp :: DynFlags -> Bool -> Bool -> FilePath -> FilePath -> IO ()
doCpp dflags raw include_cc_opts input_fn output_fn = do
let hscpp_opts = getOpts dflags opt_P ++ picPOpts
let hscpp_opts = getOpts dflags opt_P ++ picPOpts dflags
let cmdline_include_paths = includePaths dflags
pkg_include_dirs <- getPackageIncludePath dflags []
......
......@@ -317,6 +317,7 @@ data DynFlag
| Opt_DeferTypeErrors
| Opt_Parallel
| Opt_GranMacros
| Opt_PIC
-- output style opts
| Opt_PprCaseAsLet
......@@ -972,7 +973,7 @@ defaultDynFlags mySettings =
dirsToClean = panic "defaultDynFlags: No dirsToClean",
generatedDumps = panic "defaultDynFlags: No generatedDumps",
haddockOptions = Nothing,
flags = IntSet.fromList (map fromEnum defaultFlags),
flags = IntSet.fromList (map fromEnum (defaultFlags (sTargetPlatform mySettings))),
warningFlags = IntSet.fromList (map fromEnum standardWarnings),
ghciScripts = [],
language = Nothing,
......@@ -1840,6 +1841,8 @@ dynamic_flags = [
------ Safe Haskell flags -------------------------------------------
, Flag "fpackage-trust" (NoArg setPackageTrust)
, Flag "fno-safe-infer" (NoArg (setSafeHaskell Sf_None))
, Flag "fPIC" (NoArg setFPIC)
, Flag "fno-PIC" (NoArg unSetFPIC)
]
++ map (mkFlag turnOn "" setDynFlag ) negatableFlags
++ map (mkFlag turnOff "no-" unSetDynFlag) negatableFlags
......@@ -2195,8 +2198,8 @@ xFlags = [
( "PackageImports", Opt_PackageImports, nop )
]
defaultFlags :: [DynFlag]
defaultFlags
defaultFlags :: Platform -> [DynFlag]
defaultFlags platform
= [ Opt_AutoLinkPackages,
Opt_SharedImplib,
......@@ -2217,6 +2220,14 @@ defaultFlags
++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns]
-- The default -O0 options
++ (case platformOS platform of
OSDarwin ->
case platformArch platform of
ArchX86_64 -> [Opt_PIC]
_ | not opt_Static -> [Opt_PIC]
_ -> []
_ -> [])
impliedFlags :: [(ExtensionFlag, TurnOnFlag, ExtensionFlag)]
impliedFlags
= [ (Opt_RankNTypes, turnOn, Opt_ExplicitForAll)
......@@ -2612,7 +2623,7 @@ setObjTarget l = updM set
return dflags
HscLlvm
| not ((arch == ArchX86_64) && (os == OSLinux || os == OSDarwin)) &&
(not opt_Static || opt_PIC)
(not opt_Static || dopt Opt_PIC dflags)
->
do addWarn ("Ignoring " ++ flag ++ " as it is incompatible with -fPIC and -dynamic on this platform")
return dflags
......@@ -2623,6 +2634,37 @@ setObjTarget l = updM set
os = platformOS platform
flag = showHscTargetFlag l
setFPIC :: DynP ()
setFPIC = updM set
where
set dflags
| cGhcWithNativeCodeGen == "YES" || cGhcUnregisterised == "YES"
= let platform = targetPlatform dflags
in case hscTarget dflags of
HscLlvm
| (platformArch platform == ArchX86_64) &&
(platformOS platform `elem` [OSLinux, OSDarwin]) ->
do addWarn "Ignoring -fPIC as it is incompatible with LLVM on this platform"
return dflags
_ -> return $ dopt_set dflags Opt_PIC
| otherwise
= ghcError $ CmdLineError "-fPIC is not supported on this platform"
unSetFPIC :: DynP ()
unSetFPIC = updM set
where
set dflags
= let platform = targetPlatform dflags
in case platformOS platform of
OSDarwin
| platformArch platform == ArchX86_64 ->
do addWarn "Ignoring -fno-PIC on this platform"
return dflags
_ | not opt_Static ->
do addWarn "Ignoring -fno-PIC as -fstatic is off"
return dflags
_ -> return $ dopt_unset dflags Opt_PIC
setOptLevel :: Int -> DynFlags -> DynP DynFlags
setOptLevel n dflags
| hscTarget dflags == HscInterpreted && n > 0
......@@ -2782,24 +2824,24 @@ picCCOpts dflags
-- Don't generate "common" symbols - these are unwanted
-- in dynamic libraries.
| opt_PIC -> ["-fno-common", "-U __PIC__", "-D__PIC__"]
| otherwise -> ["-mdynamic-no-pic"]
| dopt Opt_PIC dflags -> ["-fno-common", "-U __PIC__", "-D__PIC__"]
| otherwise -> ["-mdynamic-no-pic"]
OSMinGW32 -- no -fPIC for Windows
| opt_PIC -> ["-U __PIC__", "-D__PIC__"]
| otherwise -> []
| dopt Opt_PIC dflags -> ["-U __PIC__", "-D__PIC__"]
| otherwise -> []
_
-- we need -fPIC for C files when we are compiling with -dynamic,
-- otherwise things like stub.c files don't get compiled
-- correctly. They need to reference data in the Haskell
-- objects, but can't without -fPIC. See
-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/PositionIndependentCode
| opt_PIC || not opt_Static -> ["-fPIC", "-U __PIC__", "-D__PIC__"]
| otherwise -> []
| dopt Opt_PIC dflags || not opt_Static -> ["-fPIC", "-U __PIC__", "-D__PIC__"]
| otherwise -> []
picPOpts :: [String]
picPOpts
| opt_PIC = ["-U __PIC__", "-D__PIC__"]
| otherwise = []
picPOpts :: DynFlags -> [String]
picPOpts dflags
| dopt Opt_PIC dflags = ["-U __PIC__", "-D__PIC__"]
| otherwise = []
-- -----------------------------------------------------------------------------
-- Splitting
......
......@@ -158,10 +158,6 @@ flagsStatic = [
------ Compiler flags -----------------------------------------------
-- -fPIC requires extra checking: only the NCG supports it.
-- See also DynFlags.parseDynamicFlags.
, Flag "fPIC" (PassFlag setPIC)
-- All other "-fno-<blah>" options cancel out "-f<blah>" on the hsc cmdline
, Flag "fno-"
(PrefixPred (\s -> isStaticFlag ("f"++s)) (\s -> removeOpt ("-f"++s)))
......@@ -171,12 +167,6 @@ flagsStatic = [
, Flag "f" (AnySuffixPred isStaticFlag addOpt)
]
setPIC :: String -> StaticP ()
setPIC | cGhcWithNativeCodeGen == "YES" || cGhcUnregisterised == "YES"
= addOpt
| otherwise
= ghcError $ CmdLineError "-fPIC is not supported on this platform"
isStaticFlag :: String -> Bool
isStaticFlag f =
f `elem` [
......@@ -196,7 +186,6 @@ isStaticFlag f =
"funregisterised",
"fcpr-off",
"ferror-spans",
"fPIC",
"fhpc"
]
|| any (`isPrefixOf` f) [
......
......@@ -70,7 +70,6 @@ module StaticFlags (
opt_Fuel,
-- Related to linking
opt_PIC,
opt_Static,
-- misc opts
......@@ -317,14 +316,6 @@ opt_UF_DearOp = ( 40 :: Int)
-- Related to linking
opt_PIC :: Bool
#if darwin_TARGET_OS && x86_64_TARGET_ARCH
opt_PIC = True
#elif darwin_TARGET_OS
opt_PIC = lookUp (fsLit "-fPIC") || not opt_Static
#else
opt_PIC = lookUp (fsLit "-fPIC")
#endif
opt_Static :: Bool
opt_Static = lookUp (fsLit "-static")
opt_Unregisterised :: Bool
......
......@@ -59,7 +59,6 @@ import UniqFM
import Unique ( Unique, getUnique )
import UniqSupply
import DynFlags
import StaticFlags
import Util
import BasicTypes ( Alignment )
......@@ -135,7 +134,7 @@ The machine-dependent bits break down as follows:
data NcgImpl statics instr jumpDest = NcgImpl {
cmmTopCodeGen :: RawCmmDecl -> NatM [NatCmmDecl statics instr],
generateJumpTableForInstr :: instr -> Maybe (NatCmmDecl statics instr),
generateJumpTableForInstr :: DynFlags -> instr -> Maybe (NatCmmDecl statics instr),
getJumpDestBlockId :: jumpDest -> Maybe BlockId,
canShortcut :: instr -> Maybe jumpDest,
shortcutStatics :: (BlockId -> Maybe jumpDest) -> statics -> statics,
......@@ -494,7 +493,7 @@ cmmNativeGen dflags ncgImpl us cmm count
---- generate jump tables
let tabled =
{-# SCC "generateJumpTables" #-}
generateJumpTables ncgImpl kludged
generateJumpTables dflags ncgImpl kludged
---- shortcut branches
let shorted =
......@@ -572,10 +571,10 @@ makeImportsDoc dflags imports
-- (Hack) sometimes two Labels pretty-print the same, but have
-- different uniques; so we compare their text versions...
dyld_stubs imps
| needImportedSymbols arch os
| needImportedSymbols dflags arch os
= vcat $
(pprGotDeclaration arch os :) $
map ( pprImportedSymbol platform . fst . head) $
(pprGotDeclaration dflags arch os :) $
map ( pprImportedSymbol dflags platform . fst . head) $
groupBy (\(_,a) (_,b) -> a == b) $
sortBy (\(_,a) (_,b) -> compare a b) $
map doPpr $
......@@ -712,12 +711,12 @@ makeFarBranches blocks
-- Analyzes all native code and generates data sections for all jump
-- table instructions.
generateJumpTables
:: NcgImpl statics instr jumpDest
:: DynFlags -> NcgImpl statics instr jumpDest
-> [NatCmmDecl statics instr] -> [NatCmmDecl statics instr]
generateJumpTables ncgImpl xs = concatMap f xs
generateJumpTables dflags ncgImpl xs = concatMap f xs
where f p@(CmmProc _ _ (ListGraph xs)) = p : concatMap g xs
f p = [p]
g (BasicBlock _ xs) = catMaybes (map (generateJumpTableForInstr ncgImpl) xs)
g (BasicBlock _ xs) = catMaybes (map (generateJumpTableForInstr ncgImpl dflags) xs)
-- -----------------------------------------------------------------------------
-- Shortcut branches
......@@ -887,7 +886,7 @@ cmmBlockConFold (BasicBlock id stmts) = do
-- * reg = reg --> nop
-- * if 0 then jump --> nop
-- * if 1 then jump --> jump
-- We might be tempted to skip this step entirely of not opt_PIC, but
-- We might be tempted to skip this step entirely of not Opt_PIC, but
-- there is some PowerPC code for the non-PIC case, which would also
-- have to be separated.
cmmStmtConFold :: CmmStmt -> CmmOptM CmmStmt
......@@ -990,15 +989,15 @@ cmmExprNative referenceKind expr = do
-- to use the register table, so we replace these registers
-- with the corresponding labels:
CmmReg (CmmGlobal EagerBlackholeInfo)
| arch == ArchPPC && not opt_PIC
| arch == ArchPPC && not (dopt Opt_PIC dflags)
-> cmmExprNative referenceKind $
CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "__stg_EAGER_BLACKHOLE_info")))
CmmReg (CmmGlobal GCEnter1)
| arch == ArchPPC && not opt_PIC
| arch == ArchPPC && not (dopt Opt_PIC dflags)
-> cmmExprNative referenceKind $
CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "__stg_gc_enter_1")))
CmmReg (CmmGlobal GCFun)
| arch == ArchPPC && not opt_PIC
| arch == ArchPPC && not (dopt Opt_PIC dflags)
-> cmmExprNative referenceKind $
CmmLit (CmmLabel (mkCmmCodeLabel rtsPackageId (fsLit "__stg_gc_fun")))
......
......@@ -74,7 +74,7 @@ import CLabel ( CLabel, ForeignLabelSource(..), pprCLabel,
import CLabel ( mkForeignLabel )
import StaticFlags ( opt_PIC, opt_Static )
import StaticFlags ( opt_Static )
import BasicTypes
import Outputable
......@@ -160,7 +160,7 @@ cmmMakePicReference dflags lbl
= CmmLit $ CmmLabel lbl
| (opt_PIC || not opt_Static) && absoluteLabel lbl
| (dopt Opt_PIC dflags || not opt_Static) && absoluteLabel lbl
= CmmMachOp (MO_Add wordWidth)
[ CmmReg (CmmGlobal PicBaseReg)
, CmmLit $ picRelative
......@@ -256,7 +256,7 @@ howToAccessLabel dflags arch OSDarwin DataReference lbl
-- we'd need to pass the current Module all the way in to
-- this function.
| arch /= ArchX86_64
, opt_PIC && externallyVisibleCLabel lbl
, dopt Opt_PIC dflags && externallyVisibleCLabel lbl
= AccessViaSymbolPtr
| otherwise
......@@ -301,12 +301,12 @@ howToAccessLabel _ ArchPPC_64 os kind _
-- actually, .label instead of label
else AccessDirectly
howToAccessLabel _ _ os _ _
howToAccessLabel dflags _ os _ _
-- no PIC -> the dynamic linker does everything for us;
-- if we don't dynamically link to Haskell code,
-- it actually manages to do so without messing thins up.
| osElfTarget os
, not opt_PIC && opt_Static
, not (dopt Opt_PIC dflags) && opt_Static
= AccessDirectly
howToAccessLabel dflags arch os DataReference lbl
......@@ -320,7 +320,7 @@ howToAccessLabel dflags arch os DataReference lbl
-- via a symbol pointer (see below for an explanation why
-- PowerPC32 Linux is especially broken).
| arch == ArchPPC
, opt_PIC
, dopt Opt_PIC dflags
-> AccessViaSymbolPtr
| otherwise
......@@ -341,12 +341,12 @@ howToAccessLabel dflags arch os DataReference lbl
howToAccessLabel dflags arch os CallReference lbl
| osElfTarget os
, labelDynamic dflags (thisPackage dflags) lbl && not opt_PIC
, labelDynamic dflags (thisPackage dflags) lbl && not (dopt Opt_PIC dflags)
= AccessDirectly
| osElfTarget os
, arch /= ArchX86
, labelDynamic dflags (thisPackage dflags) lbl && opt_PIC
, labelDynamic dflags (thisPackage dflags) lbl && dopt Opt_PIC dflags
= AccessViaStub
howToAccessLabel dflags _ os _ lbl
......@@ -356,8 +356,8 @@ howToAccessLabel dflags _ os _ lbl
else AccessDirectly
-- all other platforms
howToAccessLabel _ _ _ _ _
| not opt_PIC
howToAccessLabel dflags _ _ _ _
| not (dopt Opt_PIC dflags)
= AccessDirectly
| otherwise
......@@ -419,8 +419,8 @@ picRelative _ _ _
--------------------------------------------------------------------------------
needImportedSymbols :: Arch -> OS -> Bool
needImportedSymbols arch os
needImportedSymbols :: DynFlags -> Arch -> OS -> Bool
needImportedSymbols dflags arch os
| os == OSDarwin
, arch /= ArchX86_64
= True
......@@ -428,12 +428,12 @@ needImportedSymbols arch os
-- PowerPC Linux: -fPIC or -dynamic
| osElfTarget os
, arch == ArchPPC
= opt_PIC || not opt_Static
= dopt Opt_PIC dflags || not opt_Static
-- i386 (and others?): -dynamic but not -fPIC
| osElfTarget os
, arch /= ArchPPC_64
= not opt_Static && not opt_PIC
= not opt_Static && not (dopt Opt_PIC dflags)
| otherwise
= False
......@@ -453,9 +453,9 @@ gotLabel
--------------------------------------------------------------------------------
-- We don't need to declare any offset tables.
-- However, for PIC on x86, we need a small helper function.
pprGotDeclaration :: Arch -> OS -> SDoc
pprGotDeclaration ArchX86 OSDarwin
| opt_PIC
pprGotDeclaration :: DynFlags -> Arch -> OS -> SDoc
pprGotDeclaration dflags ArchX86 OSDarwin
| dopt Opt_PIC dflags
= vcat [
ptext (sLit ".section __TEXT,__textcoal_nt,coalesced,no_toc"),
ptext (sLit ".weak_definition ___i686.get_pc_thunk.ax"),
......@@ -464,7 +464,7 @@ pprGotDeclaration ArchX86 OSDarwin
ptext (sLit "\tmovl (%esp), %eax"),
ptext (sLit "\tret") ]
pprGotDeclaration _ OSDarwin
pprGotDeclaration _ _ OSDarwin
= empty
-- pprGotDeclaration
......@@ -472,10 +472,10 @@ pprGotDeclaration _ OSDarwin
-- The .LCTOC1 label is defined to point 32768 bytes into the table,
-- to make the most of the PPC's 16-bit displacements.
-- Only needed for PIC.
pprGotDeclaration arch os
pprGotDeclaration dflags arch os
| osElfTarget os
, arch /= ArchPPC_64
, not opt_PIC
, not (dopt Opt_PIC dflags)
= empty
| osElfTarget os
......@@ -484,7 +484,7 @@ pprGotDeclaration arch os
ptext (sLit ".section \".got2\",\"aw\""),
ptext (sLit ".LCTOC1 = .+32768") ]
pprGotDeclaration _ _
pprGotDeclaration _ _ _
= panic "pprGotDeclaration: no match"
......@@ -496,10 +496,10 @@ pprGotDeclaration _ _
-- Whenever you change something in this assembler output, make sure
-- the splitter in driver/split/ghc-split.lprl recognizes the new output
pprImportedSymbol :: Platform -> CLabel -> SDoc
pprImportedSymbol platform@(Platform { platformArch = ArchPPC, platformOS = OSDarwin }) importedLbl
pprImportedSymbol :: DynFlags -> Platform -> CLabel -> SDoc
pprImportedSymbol dflags platform@(Platform { platformArch = ArchPPC, platformOS = OSDarwin }) importedLbl
| Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
= case opt_PIC of
= case dopt Opt_PIC dflags of
False ->
vcat [
ptext (sLit ".symbol_stub"),
......@@ -551,9 +551,9 @@ pprImportedSymbol platform@(Platform { platformArch = ArchPPC, platformOS = OSDa
= empty
pprImportedSymbol platform@(Platform { platformArch = ArchX86, platformOS = OSDarwin }) importedLbl
pprImportedSymbol dflags platform@(Platform { platformArch = ArchX86, platformOS = OSDarwin }) importedLbl
| Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
= case opt_PIC of
= case dopt Opt_PIC dflags of
False ->
vcat [
ptext (sLit ".symbol_stub"),
......@@ -586,7 +586,7 @@ pprImportedSymbol platform@(Platform { platformArch = ArchX86, platformOS = OSDa
ptext (sLit "\tjmp dyld_stub_binding_helper")
]
$+$ vcat [ ptext (sLit ".section __DATA, __la_sym_ptr")
<> (if opt_PIC then int 2 else int 3)
<> (if dopt Opt_PIC dflags then int 2 else int 3)
<> ptext (sLit ",lazy_symbol_pointers"),
ptext (sLit "L") <> pprCLabel platform lbl <> ptext (sLit "$lazy_ptr:"),
ptext (sLit "\t.indirect_symbol") <+> pprCLabel platform lbl,
......@@ -604,7 +604,7 @@ pprImportedSymbol platform@(Platform { platformArch = ArchX86, platformOS = OSDa
= empty
pprImportedSymbol (Platform { platformOS = OSDarwin }) _
pprImportedSymbol _ (Platform { platformOS = OSDarwin }) _
= empty
......@@ -622,7 +622,7 @@ pprImportedSymbol (Platform { platformOS = OSDarwin }) _
-- section.
-- The "official" GOT mechanism (label@got) isn't intended to be used
-- in position dependent code, so we have to create our own "fake GOT"
-- when not opt_PIC && not opt_Static.
-- when not Opt_PIC && not opt_Static.
--
-- 2) PowerPC Linux is just plain broken.
-- While it's theoretically possible to use GOT offsets larger
......@@ -637,11 +637,11 @@ pprImportedSymbol (Platform { platformOS = OSDarwin }) _
-- the NCG will keep track of all DynamicLinkerLabels it uses
-- and output each of them using pprImportedSymbol.
pprImportedSymbol platform@(Platform { platformArch = ArchPPC_64 }) _
pprImportedSymbol _ platform@(Platform { platformArch = ArchPPC_64 }) _
| osElfTarget (platformOS platform)
= empty
pprImportedSymbol platform importedLbl
pprImportedSymbol _ platform importedLbl
| osElfTarget (platformOS platform)
= case dynamicLinkerLabelInfo importedLbl of
Just (SymbolPtr, lbl)
......@@ -658,7 +658,7 @@ pprImportedSymbol platform importedLbl
-- PLT code stubs are generated automatically by the dynamic linker.
_ -> empty
pprImportedSymbol _ _
pprImportedSymbol _ _ _
= panic "PIC.pprImportedSymbol: no match"
--------------------------------------------------------------------------------
......
......@@ -45,7 +45,6 @@ import OldCmm
import CLabel
-- The rest:
import StaticFlags ( opt_PIC )
import OrdList
import Outputable
import Unique
......@@ -140,7 +139,8 @@ stmtToInstrs stmt = do
CmmBranch id -> genBranch id
CmmCondBranch arg id -> genCondJump id arg
CmmSwitch arg ids -> genSwitch arg ids
CmmSwitch arg ids -> do dflags <- getDynFlags
genSwitch dflags arg ids
CmmJump arg _ -> genJump arg
CmmReturn ->
panic "stmtToInstrs: return statement should have been cps'd away"
......@@ -1153,9 +1153,9 @@ genCCall' gcp target dest_regs argsAndHints
-- -----------------------------------------------------------------------------
-- Generating a table-branch