Commit 2615b581 authored by dterei's avatar dterei

Add -fpackage-trust flag to Safe Haskell.

parent c726526a
......@@ -41,6 +41,7 @@ module DynFlags (
SafeHaskellMode(..),
safeHaskellOn, safeLanguageOn,
safeDirectImpsReq, safeImplicitImpsReq,
packageTrustOn,
-- ** System tool settings and locations
Settings(..),
......@@ -296,6 +297,9 @@ data DynFlag
| Opt_KeepRawTokenStream
| Opt_KeepLlvmFiles
-- safe haskell flags
| Opt_PackageTrust
deriving (Eq, Show)
data WarningFlag =
......@@ -1012,6 +1016,10 @@ setLanguage l = upd f
dynFlagDependencies :: DynFlags -> [ModuleName]
dynFlagDependencies = pluginModNames
-- | Is the -fpackage-trust mode on
packageTrustOn :: DynFlags -> Bool
packageTrustOn = dopt Opt_PackageTrust
-- | Is the Safe Haskell safe language in use
safeLanguageOn :: DynFlags -> Bool
safeLanguageOn dflags = safeHaskell dflags == Sf_Safe
......@@ -1601,6 +1609,9 @@ dynamic_flags = [
, Flag "fobject-code" (NoArg (setTarget defaultHscTarget))
, Flag "fglasgow-exts" (NoArg (enableGlasgowExts >> deprecate "Use individual extensions instead"))
, Flag "fno-glasgow-exts" (NoArg (disableGlasgowExts >> deprecate "Use individual extensions instead"))
------ Safe Haskell flags -------------------------------------------
, Flag "fpackage-trust" (NoArg (setDynFlag Opt_PackageTrust))
]
++ map (mkFlag turnOn "f" setDynFlag ) fFlags
++ map (mkFlag turnOff "fno-" unSetDynFlag) fFlags
......
......@@ -890,7 +890,7 @@ checkSafeImports dflags hsc_env tcg_env
= do
imps <- mapM condense imports'
pkgs <- mapM checkSafe imps
checkPkgTrust pkg_reqs
when (packageTrustOn dflags) $ checkPkgTrust pkg_reqs
-- add in trusted package requirements for this module
let new_trust = emptyImportAvails { imp_trust_pkgs = catMaybes pkgs }
......@@ -936,7 +936,9 @@ checkSafeImports dflags hsc_env tcg_env
-- modules in the home package are trusted but otherwise
-- we check the package trust flag.
packageTrusted :: SafeHaskellMode -> Bool -> Module -> Bool
packageTrusted Sf_Safe False _ = True
packageTrusted _ _ _
| not (packageTrustOn dflags) = True
packageTrusted Sf_Safe False _ = True
packageTrusted _ _ m
| isHomePkg m = True
| otherwise = trusted $ getPackageDetails (pkgState dflags)
......
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