summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/main/DynFlags.hs11
-rw-r--r--compiler/main/HscMain.lhs6
2 files changed, 15 insertions, 2 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 3261e34a24..866301376d 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -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
diff --git a/compiler/main/HscMain.lhs b/compiler/main/HscMain.lhs
index 48cca7bc1f..b8874b1a9f 100644
--- a/compiler/main/HscMain.lhs
+++ b/compiler/main/HscMain.lhs
@@ -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)