diff options
author | Ian Lynagh <igloo@earth.li> | 2012-07-16 20:53:21 +0100 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2012-07-16 22:40:37 +0100 |
commit | cdf946e45024f76ce4f22462f511a0490fef1dff (patch) | |
tree | 993709cdc4a579e34b056cfb31826cd2b358f340 /compiler/codeGen | |
parent | 5d0fce85fd5c885343196142b15b8a8d2928d3fe (diff) | |
download | haskell-cdf946e45024f76ce4f22462f511a0490fef1dff.tar.gz |
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).
Diffstat (limited to 'compiler/codeGen')
-rw-r--r-- | compiler/codeGen/CgCon.lhs | 17 | ||||
-rw-r--r-- | compiler/codeGen/StgCmmCon.hs | 18 |
2 files changed, 18 insertions, 17 deletions
diff --git a/compiler/codeGen/CgCon.lhs b/compiler/codeGen/CgCon.lhs index aff5e468ca..78c1934869 100644 --- a/compiler/codeGen/CgCon.lhs +++ b/compiler/codeGen/CgCon.lhs @@ -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 diff --git a/compiler/codeGen/StgCmmCon.hs b/compiler/codeGen/StgCmmCon.hs index a7af5662e9..03a659b2cf 100644 --- a/compiler/codeGen/StgCmmCon.hs +++ b/compiler/codeGen/StgCmmCon.hs @@ -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 |