Commit d8d16174 authored by Ian Lynagh's avatar Ian Lynagh

Some CPP removal

parent 651cd996
......@@ -128,6 +128,7 @@ import CostCentre
import Outputable
import FastString
import DynFlags
import Platform
import UniqSet
-- -----------------------------------------------------------------------------
......@@ -773,42 +774,48 @@ idInfoLabelType info =
-- @labelDynamic@ returns @True@ if the label is located
-- in a DLL, be it a data reference or not.
labelDynamic :: PackageId -> CLabel -> Bool
labelDynamic this_pkg lbl =
labelDynamic :: DynFlags -> PackageId -> CLabel -> Bool
labelDynamic dflags this_pkg lbl =
case lbl of
-- is the RTS in a DLL or not?
RtsLabel _ -> not opt_Static && (this_pkg /= rtsPackageId)
IdLabel n _ k -> isDllName this_pkg n
#if mingw32_TARGET_OS
-- When compiling in the "dyn" way, eack package is to be linked into its own shared library.
-- When compiling in the "dyn" way, eack package is to be linked into
-- its own shared library.
CmmLabel pkg _ _
-> not opt_Static && (this_pkg /= pkg)
| os == OSMinGW32 ->
not opt_Static && (this_pkg /= pkg)
| otherwise ->
True
ForeignLabel _ _ source _ ->
if os == OSMinGW32
then case source of
-- Foreign label is in some un-named foreign package (or DLL).
ForeignLabelInExternalPackage -> True
-- Foreign label is linked into the same package as the
-- source file currently being compiled.
ForeignLabelInThisPackage -> False
-- Foreign label is in some named package.
-- When compiling in the "dyn" way, each package is to be
-- linked into its own DLL.
ForeignLabelInPackage pkgId ->
(not opt_Static) && (this_pkg /= pkgId)
else -- On Mac OS X and on ELF platforms, false positives are OK,
-- so we claim that all foreign imports come from dynamic
-- libraries
True
-- Foreign label is in some un-named foreign package (or DLL)
ForeignLabel _ _ ForeignLabelInExternalPackage _ -> True
-- Foreign label is linked into the same package as the source file currently being compiled.
ForeignLabel _ _ ForeignLabelInThisPackage _ -> False
-- Foreign label is in some named package.
-- When compiling in the "dyn" way, each package is to be linked into its own DLL.
ForeignLabel _ _ (ForeignLabelInPackage pkgId) _
-> (not opt_Static) && (this_pkg /= pkgId)
#else
-- On Mac OS X and on ELF platforms, false positives are OK,
-- so we claim that all foreign imports come from dynamic libraries
ForeignLabel _ _ _ _ -> True
CmmLabel pkg _ _ -> True
#endif
PlainModuleInitLabel m -> not opt_Static && this_pkg /= (modulePackageId m)
-- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
_ -> False
where os = platformOS (targetPlatform dflags)
{-
OLD?: These GRAN functions are needed for spitting out GRAN_FETCH() at the
......
......@@ -225,7 +225,7 @@ howToAccessLabel dflags _ OSMinGW32 _ lbl
-- If the target symbol is in another PE we need to access it via the
-- appropriate __imp_SYMBOL pointer.
| labelDynamic (thisPackage dflags) lbl
| labelDynamic dflags (thisPackage dflags) lbl
= AccessViaSymbolPtr
-- Target symbol is in the same PE as the caller, so just access it directly.
......@@ -243,7 +243,7 @@ howToAccessLabel dflags _ OSMinGW32 _ lbl
--
howToAccessLabel dflags arch OSDarwin DataReference lbl
-- data access to a dynamic library goes via a symbol pointer
| labelDynamic (thisPackage dflags) lbl
| labelDynamic dflags (thisPackage dflags) lbl
= AccessViaSymbolPtr
-- when generating PIC code, all cross-module data references must
......@@ -267,7 +267,7 @@ howToAccessLabel dflags arch OSDarwin JumpReference lbl
-- stack alignment is only right for regular calls.
-- Therefore, we have to go via a symbol pointer:
| arch == ArchX86 || arch == ArchX86_64
, labelDynamic (thisPackage dflags) lbl
, labelDynamic dflags (thisPackage dflags) lbl
= AccessViaSymbolPtr
......@@ -276,7 +276,7 @@ howToAccessLabel dflags arch OSDarwin _ lbl
-- not needed on x86_64 because Apple's new linker, ld64, generates
-- them automatically.
| arch /= ArchX86_64
, labelDynamic (thisPackage dflags) lbl
, labelDynamic dflags (thisPackage dflags) lbl
= AccessViaStub
| otherwise
......@@ -313,7 +313,7 @@ howToAccessLabel dflags arch os DataReference lbl
| osElfTarget os
= case () of
-- A dynamic label needs to be accessed via a symbol pointer.
_ | labelDynamic (thisPackage dflags) lbl
_ | labelDynamic dflags (thisPackage dflags) lbl
-> AccessViaSymbolPtr
-- For PowerPC32 -fPIC, we have to access even static data
......@@ -341,17 +341,17 @@ howToAccessLabel dflags arch os DataReference lbl
howToAccessLabel dflags arch os CallReference lbl
| osElfTarget os
, labelDynamic (thisPackage dflags) lbl && not opt_PIC
, labelDynamic dflags (thisPackage dflags) lbl && not opt_PIC
= AccessDirectly
| osElfTarget os
, arch /= ArchX86
, labelDynamic (thisPackage dflags) lbl && opt_PIC
, labelDynamic dflags (thisPackage dflags) lbl && opt_PIC
= AccessViaStub
howToAccessLabel dflags _ os _ lbl
| osElfTarget os
= if labelDynamic (thisPackage dflags) lbl
= if labelDynamic dflags (thisPackage dflags) lbl
then AccessViaSymbolPtr
else AccessDirectly
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment