[Git][ghc/ghc][master] Move isDynLinkName into GHC.Types.Name
Marge Bot
gitlab at gitlab.haskell.org
Thu May 21 16:24:56 UTC 2020
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00
Move isDynLinkName into GHC.Types.Name
It doesn't belong into GHC.Unit.State
- - - - -
4 changed files:
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Stg/Syntax.hs
- compiler/GHC/Types/Name.hs
- compiler/GHC/Unit/State.hs
Changes:
=====================================
compiler/GHC/Cmm/CLabel.hs
=====================================
@@ -119,7 +119,6 @@ import GHC.Prelude
import GHC.Types.Id.Info
import GHC.Types.Basic
import {-# SOURCE #-} GHC.Cmm.BlockId (BlockId, mkBlockId)
-import GHC.Unit.State
import GHC.Unit
import GHC.Types.Name
import GHC.Types.Unique
=====================================
compiler/GHC/Stg/Syntax.hs
=====================================
@@ -72,11 +72,11 @@ import GHC.Core.DataCon
import GHC.Driver.Session
import GHC.Types.ForeignCall ( ForeignCall )
import GHC.Types.Id
+import GHC.Types.Name ( isDynLinkName )
import GHC.Types.Var.Set
import GHC.Types.Literal ( Literal, literalType )
import GHC.Unit.Module ( Module )
import GHC.Utils.Outputable
-import GHC.Unit.State ( isDynLinkName )
import GHC.Platform
import GHC.Core.Ppr( {- instances -} )
import GHC.Builtin.PrimOps ( PrimOp, PrimCall )
=====================================
compiler/GHC/Types/Name.hs
=====================================
@@ -60,7 +60,7 @@ module GHC.Types.Name (
-- ** Predicates on 'Name's
isSystemName, isInternalName, isExternalName,
isTyVarName, isTyConName, isDataConName,
- isValName, isVarName,
+ isValName, isVarName, isDynLinkName,
isWiredInName, isWiredIn, isBuiltInSyntax,
isHoleName,
wiredInNameTyThing_maybe,
@@ -83,6 +83,7 @@ import GHC.Prelude
import {-# SOURCE #-} GHC.Core.TyCo.Rep( TyThing )
+import GHC.Platform
import GHC.Types.Name.Occurrence
import GHC.Unit.Module
import GHC.Types.SrcLoc
@@ -242,6 +243,39 @@ isInternalName name = not (isExternalName name)
isHoleName :: Name -> Bool
isHoleName = isHoleModule . nameModule
+-- | Will the 'Name' come from a dynamically linked package?
+isDynLinkName :: Platform -> Module -> Name -> Bool
+isDynLinkName platform this_mod name
+ | Just mod <- nameModule_maybe name
+ -- Issue #8696 - when GHC is dynamically linked, it will attempt
+ -- to load the dynamic dependencies of object files at compile
+ -- time for things like QuasiQuotes or
+ -- TemplateHaskell. Unfortunately, this interacts badly with
+ -- intra-package linking, because we don't generate indirect
+ -- (dynamic) symbols for intra-package calls. This means that if a
+ -- module with an intra-package call is loaded without its
+ -- dependencies, then GHC fails to link.
+ --
+ -- In the mean time, always force dynamic indirections to be
+ -- generated: when the module name isn't the module being
+ -- compiled, references are dynamic.
+ = case platformOS platform of
+ -- On Windows the hack for #8696 makes it unlinkable.
+ -- As the entire setup of the code from Cmm down to the RTS expects
+ -- the use of trampolines for the imported functions only when
+ -- doing intra-package linking, e.g. referring to a symbol defined in the same
+ -- package should not use a trampoline.
+ -- I much rather have dynamic TH not supported than the entire Dynamic linking
+ -- not due to a hack.
+ -- Also not sure this would break on Windows anyway.
+ OSMinGW32 -> moduleUnit mod /= moduleUnit this_mod
+
+ -- For the other platforms, still perform the hack
+ _ -> mod /= this_mod
+
+ | otherwise = False -- no, it is not even an external name
+
+
nameModule name =
nameModule_maybe name `orElse`
pprPanic "nameModule" (ppr (n_sort name) <+> ppr name)
=====================================
compiler/GHC/Unit/State.hs
=====================================
@@ -60,7 +60,6 @@ module GHC.Unit.State (
pprPackagesSimple,
pprModuleMap,
isIndefinite,
- isDynLinkName
)
where
@@ -75,13 +74,11 @@ import GHC.Unit.Module
import GHC.Unit.Subst
import GHC.Driver.Session
import GHC.Driver.Ways
-import GHC.Types.Name ( Name, nameModule_maybe )
import GHC.Types.Unique.FM
import GHC.Types.Unique.DFM
import GHC.Types.Unique.Set
import GHC.Utils.Misc
import GHC.Utils.Panic
-import GHC.Platform
import GHC.Utils.Outputable as Outputable
import GHC.Data.Maybe
@@ -2088,38 +2085,6 @@ displayUnitId :: PackageState -> UnitId -> Maybe String
displayUnitId pkgstate uid =
fmap unitPackageIdString (lookupInstalledPackage pkgstate uid)
--- | Will the 'Name' come from a dynamically linked package?
-isDynLinkName :: Platform -> Module -> Name -> Bool
-isDynLinkName platform this_mod name
- | Just mod <- nameModule_maybe name
- -- Issue #8696 - when GHC is dynamically linked, it will attempt
- -- to load the dynamic dependencies of object files at compile
- -- time for things like QuasiQuotes or
- -- TemplateHaskell. Unfortunately, this interacts badly with
- -- intra-package linking, because we don't generate indirect
- -- (dynamic) symbols for intra-package calls. This means that if a
- -- module with an intra-package call is loaded without its
- -- dependencies, then GHC fails to link.
- --
- -- In the mean time, always force dynamic indirections to be
- -- generated: when the module name isn't the module being
- -- compiled, references are dynamic.
- = case platformOS platform of
- -- On Windows the hack for #8696 makes it unlinkable.
- -- As the entire setup of the code from Cmm down to the RTS expects
- -- the use of trampolines for the imported functions only when
- -- doing intra-package linking, e.g. referring to a symbol defined in the same
- -- package should not use a trampoline.
- -- I much rather have dynamic TH not supported than the entire Dynamic linking
- -- not due to a hack.
- -- Also not sure this would break on Windows anyway.
- OSMinGW32 -> moduleUnit mod /= moduleUnit this_mod
-
- -- For the other platforms, still perform the hack
- _ -> mod /= this_mod
-
- | otherwise = False -- no, it is not even an external name
-
-- -----------------------------------------------------------------------------
-- Displaying packages
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/566cc73f46d67e2b36fda95d0253067bb0ecc12f
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/566cc73f46d67e2b36fda95d0253067bb0ecc12f
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200521/96dd20a1/attachment-0001.html>
More information about the ghc-commits
mailing list