diff options
author | Ian Lynagh <igloo@earth.li> | 2011-10-02 01:03:23 +0100 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2011-10-02 01:03:23 +0100 |
commit | d8d161749c8b13c3db802f348761cff662741c53 (patch) | |
tree | f43031a8378e36c19ddae46df9746b8e13695b1d /compiler | |
parent | 651cd99621e42b10b7caadfb8986547b28222785 (diff) | |
download | haskell-d8d161749c8b13c3db802f348761cff662741c53.tar.gz |
Some CPP removal
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/cmm/CLabel.hs | 55 | ||||
-rw-r--r-- | compiler/nativeGen/PIC.hs | 16 |
2 files changed, 39 insertions, 32 deletions
diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs index e1893836ab..76d5e79a21 100644 --- a/compiler/cmm/CLabel.hs +++ b/compiler/cmm/CLabel.hs @@ -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 diff --git a/compiler/nativeGen/PIC.hs b/compiler/nativeGen/PIC.hs index 439f36d4b3..2762e4ff25 100644 --- a/compiler/nativeGen/PIC.hs +++ b/compiler/nativeGen/PIC.hs @@ -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 |