Commit 0f5e104c authored by Ian Lynagh's avatar Ian Lynagh

More commandline flag improvements

* Allow -ffoo flags to be deprecated
* Mark some -ffoo flags as deprecated
* Avoid using deprecated flags in error messages, in the build system, etc
* Add a flag to en/disable the deprecated flag warning
parent 1363f412
......@@ -96,7 +96,13 @@ SRC_CC_OPTS += -I$(FPTOOLS_TOP)/libraries/base/cbits -I$(FPTOOLS_TOP)/libraries/
# Make the #includes in the stubs independent of the current location
SRC_HC_OPTS += -I$(FPTOOLS_TOP)/libraries
SRC_HC_OPTS += -fglasgow-exts -fforce-recomp
SRC_HC_OPTS += -fglasgow-exts
ifeq "$(ghc_ge_609)" "YES"
SRC_HC_OPTS += -fforce-recomp
else
SRC_HC_OPTS += -no-recomp
endif
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
Compat/Directory_HC_OPTS += -\#include shlobj.h
......
......@@ -568,9 +568,13 @@ SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
# -----------------------------------------------------------------------------
# Haskell compilations
SRC_HC_OPTS += \
-cpp -fglasgow-exts -fno-generics -Rghc-timing \
-I. -Iparser -Iutil
SRC_HC_OPTS += -cpp -fglasgow-exts -Rghc-timing -I. -Iparser -Iutil
ifeq "$(ghc_ge_609)" "NO"
SRC_HC_OPTS += -fno-generics
else
SRC_HC_OPTS += -XNoGenerics
endif
# Omitted: -I$(GHC_INCLUDE_DIR)
# We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS,
......
......@@ -23,7 +23,7 @@ SRC_HC_OPTS += -Wall
SRC_HC_OPTS += -package ghc
SRC_HC_OPTS += -Istage$(stage)
SRC_HC_OPTS += \
-cpp -fglasgow-exts -fno-generics -Rghc-timing \
-cpp -fglasgow-exts -XNoGenerics -Rghc-timing \
-I. -IcodeGen -InativeGen -Iparser
SRC_HC_OPTS += $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
ifeq "$(TargetOS_CPP)" "openbsd"
......
{-# LANGUAGE MultiParamTypeClasses, ScopedTypeVariables #-}
{-# OPTIONS -fno-allow-overlapping-instances -fglasgow-exts #-}
{-# OPTIONS -fglasgow-exts #-}
-- -fglagow-exts for kind signatures
module ZipDataflow
......
......@@ -1406,12 +1406,12 @@ setCmd ""
vcat (text "other dynamic, non-language, flag settings:"
:map (flagSetting dflags) nonLanguageDynFlags)
))
where flagSetting dflags (str,f)
where flagSetting dflags (str, f, _)
| dopt f dflags = text " " <> text "-f" <> text str
| otherwise = text " " <> text "-fno-" <> text str
(ghciFlags,others) = partition (\(_,f)->f `elem` flags)
(ghciFlags,others) = partition (\(_, f, _) -> f `elem` flags)
DynFlags.fFlags
nonLanguageDynFlags = filterOut (\(_,f) -> f `elem` languageOptions)
nonLanguageDynFlags = filterOut (\(_, f, _) -> f `elem` languageOptions)
others
flags = [Opt_PrintExplicitForalls
,Opt_PrintBindResult
......@@ -1689,7 +1689,7 @@ completeWord w start end = do
(s,r') = span isBreak r
in (n,w):words' isBreak (n+length w+length s) r'
-- In a Haskell expression we want to parse 'a-b' as three words
-- where a compiler flag (ie. -fno-monomorphism-restriction) should
-- where a compiler flag (e.g. -ddump-simpl) should
-- only be a single word.
selectWord [] = (0,w)
selectWord ((offset,x):xs)
......
This diff is collapsed.
......@@ -176,8 +176,13 @@ printBagOfWarnings dflags bag_of_warns
GT -> False
handleFlagWarnings :: DynFlags -> [String] -> IO ()
handleFlagWarnings _ [] = return ()
handleFlagWarnings dflags warns
= when (dopt Opt_WarnDeprecatedFlags dflags)
(handleFlagWarnings' dflags warns)
handleFlagWarnings' :: DynFlags -> [String] -> IO ()
handleFlagWarnings' _ [] = return ()
handleFlagWarnings' dflags warns
= do -- It would be nicer if warns :: [Message], but that has circular
-- import problems.
let warns' = map text warns
......
......@@ -649,7 +649,7 @@ way_details =
, "-package concurrent" ]),
(WayNDP, Way "ndp" False "Nested data parallelism"
[ "-fparr"
[ "-XParr"
, "-fvectorise"]),
(WayUser_a, Way "a" False "User way 'a'" ["$WAY_a_REAL_OPTS"]),
......
......@@ -504,8 +504,8 @@ data Token
| ITvocurly
| ITvccurly
| ITobrack
| ITopabrack -- [:, for parallel arrays with -fparr
| ITcpabrack -- :], for parallel arrays with -fparr
| ITopabrack -- [:, for parallel arrays with -XParr
| ITcpabrack -- :], for parallel arrays with -XParr
| ITcbrack
| IToparen
| ITcparen
......@@ -1550,7 +1550,7 @@ getLexState :: P Int
getLexState = P $ \s@PState{ lex_state=ls:_ } -> POk s ls
-- for reasons of efficiency, flags indicating language extensions (eg,
-- -fglasgow-exts or -fparr) are represented by a bitmap stored in an unboxed
-- -fglasgow-exts or -XParr) are represented by a bitmap stored in an unboxed
-- integer
genericsBit, ffiBit, parrBit :: Int
......
......@@ -926,7 +926,7 @@ isModuleExported implicit_prelude mod (GRE { gre_name = name, gre_prov = prov })
-- They just clutter up the environment (esp tuples), and the parser
-- will generate Exact RdrNames for them, so the cluttered
-- envt is no use. To avoid doing this filter all the time,
-- we use -fno-implicit-prelude as a clue that the filter is
-- we use -XNoImplicitPrelude as a clue that the filter is
-- worth while. Really, it's only useful for GHC.Base and GHC.Tuple.
--
-- It's worth doing because it makes the environment smaller for
......@@ -1038,7 +1038,7 @@ a) It might be a WiredInName; in that case we may not load
its interface (although we could).
b) It might be GHC.Real.fromRational, or GHC.Num.fromInteger
These are seen as "used" by the renamer (if -fno-implicit-prelude)
These are seen as "used" by the renamer (if -XNoImplicitPrelude)
is on), but the typechecker may discard their uses
if in fact the in-scope fromRational is GHC.Read.fromRational,
(see tcPat.tcOverloadedLit), and the typechecker sees that the type
......
......@@ -447,7 +447,7 @@ badDotDot str = ptext (sLit "You cannot use `..' in record") <+> text str
badPun :: Located RdrName -> SDoc
badPun fld = vcat [ptext (sLit "Illegal use of punning for field") <+> quotes (ppr fld),
ptext (sLit "Use -XRecordPuns to permit this")]
ptext (sLit "Use -XNamedFieldPuns to permit this")]
-- wrappers
......
......@@ -401,7 +401,7 @@ newMethodFromName :: InstOrigin -> BoxyRhoType -> Name -> TcM TcId
newMethodFromName origin ty name = do
id <- tcLookupId name
-- Use tcLookupId not tcLookupGlobalId; the method is almost
-- always a class op, but with -fno-implicit-prelude GHC is
-- always a class op, but with -XNoImplicitPrelude GHC is
-- meant to find whatever thing is in scope, and that may
-- be an ordinary function.
loc <- getInstLoc origin
......@@ -862,7 +862,7 @@ tcGetInstEnvs = do { eps <- getEps; env <- getGblEnv;
%* *
%************************************************************************
Suppose we are doing the -fno-implicit-prelude thing, and we encounter
Suppose we are doing the -XNoImplicitPrelude thing, and we encounter
a do-expression. We have to find (>>) in the current environment, which is
done by the rename. Then we have to check that it has the same type as
Control.Monad.(>>). Or, more precisely, a compatible type. One 'customer' had
......
......@@ -630,14 +630,14 @@ tcLhs sig_fn (FunBind { fun_id = L nm_loc name, fun_infix = inf, fun_matches = m
tcLhs sig_fn (PatBind { pat_lhs = pat, pat_rhs = grhss })
= do { mb_sigs <- mapM (tcInstSig_maybe sig_fn) names
; mono_pat_binds <- doptM Opt_MonoPatBinds
-- With -fmono-pat-binds, we do no generalisation of pattern bindings
-- With -XMonoPatBinds, we do no generalisation of pattern bindings
-- But the signature can still be polymoprhic!
-- data T = MkT (forall a. a->a)
-- x :: forall a. a->a
-- MkT x = <rhs>
-- The function get_sig_ty decides whether the pattern-bound variables
-- should have exactly the type in the type signature (-fmono-pat-binds),
-- or the instantiated version (-fmono-pat-binds)
-- should have exactly the type in the type signature (-XMonoPatBinds),
-- or the instantiated version (-XMonoPatBinds)
; let nm_sig_prs = names `zip` mb_sigs
get_sig_ty | mono_pat_binds = idType . sig_id
......
......@@ -794,7 +794,7 @@ notSimple inst_tys
notGeneric :: TyCon -> SDoc
notGeneric tycon
= vcat [ptext (sLit "because the instance type constructor") <+> quotes (ppr tycon) <+>
ptext (sLit "was not compiled with -fgenerics")]
ptext (sLit "was not compiled with -XGenerics")]
badGenericInstanceType :: LHsBinds Name -> SDoc
badGenericInstanceType binds
......
......@@ -971,7 +971,7 @@ inferInstanceContexts oflag infer_specs
iterate_deriv :: Int -> [ThetaType] -> TcM [DerivSpec]
iterate_deriv n current_solns
| n > 20 -- Looks as if we are in an infinite loop
-- This can happen if we have -fallow-undecidable-instances
-- This can happen if we have -XUndecidableInstances
-- (See TcSimplify.tcSimplifyDeriv.)
= pprPanic "solveDerivEqns: probable loop"
(vcat (map pprDerivSpec infer_specs) $$ ppr current_solns)
......
......@@ -1595,7 +1595,7 @@ predUndecErr pred msg = sep [msg,
nomoreMsg, smallerMsg, undecidableMsg :: SDoc
nomoreMsg = ptext (sLit "Variable occurs more often in a constraint than in the instance head")
smallerMsg = ptext (sLit "Constraint is no smaller than the instance head")
undecidableMsg = ptext (sLit "Use -fallow-undecidable-instances to permit this")
undecidableMsg = ptext (sLit "Use -XUndecidableInstances to permit this")
\end{code}
......@@ -1635,7 +1635,7 @@ should have only type-variable constraints.
Here is another example:
data Fix f = In (f (Fix f)) deriving( Eq )
Here, if we are prepared to allow -fallow-undecidable-instances we
Here, if we are prepared to allow -XUndecidableInstances we
could derive the instance
instance Eq (f (Fix f)) => Eq (Fix f)
but this is so delicate that I don't think it should happen inside
......@@ -1672,7 +1672,7 @@ validDerivPred _ = False
\begin{code}
-- Check that a "type instance" is well-formed (which includes decidability
-- unless -fallow-undecidable-instances is given).
-- unless -XUndecidableInstances is given).
--
checkValidTypeInst :: [Type] -> Type -> TcM ()
checkValidTypeInst typats rhs
......
......@@ -2670,7 +2670,7 @@ disambiguate doc interactive dflags insts
| extended_defaulting = any isInteractiveClass clss
| otherwise = all is_std_class clss && (any is_num_class clss)
-- In interactive mode, or with -fextended-default-rules,
-- In interactive mode, or with -XExtendedDefaultRules,
-- we default Show a to Show () to avoid graututious errors on "show []"
isInteractiveClass cls
= is_num_class cls || (classKey cls `elem` [showClassKey, eqClassKey, ordClassKey])
......@@ -2736,7 +2736,7 @@ getDefaultTys extended_deflts ovl_strings
Note [Default unitTy]
~~~~~~~~~~~~~~~~~~~~~
In interative mode (or with -fextended-default-rules) we add () as the first type we
In interative mode (or with -XExtendedDefaultRules) we add () as the first type we
try when defaulting. This has very little real impact, except in the following case.
Consider:
Text.Printf.printf "hello"
......@@ -2962,7 +2962,7 @@ report_no_instances tidy_env mb_what insts
ASSERT( not (null unifiers) )
parens (vcat [ptext (sLit "The choice depends on the instantiation of") <+>
quotes (pprWithCommas ppr (varSetElems (tyVarsOfInst dict))),
ptext (sLit "To pick the first instance above, use -fallow-incoherent-instances"),
ptext (sLit "To pick the first instance above, use -XIncoherentInstances"),
ptext (sLit "when compiling the other instance declarations")])]
where
ispecs = [ispec | (ispec, _) <- matches]
......@@ -3061,8 +3061,8 @@ monomorphism_fix dflags
= ptext (sLit "Probable fix:") <+> vcat
[ptext (sLit "give these definition(s) an explicit type signature"),
if dopt Opt_MonomorphismRestriction dflags
then ptext (sLit "or use -fno-monomorphism-restriction")
else empty] -- Only suggest adding "-fno-monomorphism-restriction"
then ptext (sLit "or use -XNoMonomorphismRestriction")
else empty] -- Only suggest adding "-XNoMonomorphismRestriction"
-- if it is not already set!
warnDefault :: [(Inst, Class, Var)] -> Type -> TcM ()
......
......@@ -11,7 +11,8 @@ Basically, the things need to be in class @Uniquable@, and we use the
@getUnique@ method to grab their @Uniques@.
\begin{code}
{-# OPTIONS -Wall -fno-warn-name-shadowing -Werror -fallow-undecidable-instances #-}
{-# OPTIONS -Wall -fno-warn-name-shadowing -Werror #-}
{-# LANGUAGE UndecidableInstances #-}
module LazyUniqFM (
UniqFM, -- abstract type
......
......@@ -32,8 +32,8 @@
<h2>More Sugar: Special Syntax for Array Comprehensions</h2>
<p>
The option <code>-fparr</code>, which is a dynamic hsc option that can
be reversed with <code>-fno-parr</code>, enables special syntax for
The option <code>-XParr</code>, which is a dynamic hsc option that can
be reversed with <code>-XNoParr</code>, enables special syntax for
parallel arrays, which is not essential to using parallel arrays, but
makes for significantly more concise programs. The switch works by
making the lexical analyser (located in <a
......@@ -326,7 +326,7 @@ mapFilterP :: (a -> Maybe b) -> [:a:] -> [:b:]</pre>
flattening (just like profiling does), there is a <em>compiler way</em>
<code>"ndp"</code>, which can be selected using the way option code
<code>-ndp</code>. This option will automagically select
<code>-fparr</code> and <code>-fflatten</code>.
<code>-XParr</code> and <code>-fflatten</code>.
<h4><code>FlattenMonad</code></h4>
<p>
......
......@@ -98,7 +98,7 @@ main = do args &lt;- getArgs
<para>GHC's typechecker makes all pattern bindings monomorphic
by default; this behaviour can be disabled with
<option>-fno-mono-pat-binds</option>. See <xref
<option>-XNoMonoPatBinds</option>. See <xref
linkend="options-language" />.</para>
</sect3>
......
......@@ -9,11 +9,8 @@ Foreign function interface (FFI)
<para>GHC (mostly) conforms to the Haskell 98 Foreign Function Interface
Addendum 1.0, whose definition is available from <ulink url="http://www.haskell.org/"><literal>http://www.haskell.org/</literal></ulink>.</para>
<para>To enable FFI support in GHC, give the <option>-fffi</option><indexterm><primary><option>-fffi</option></primary>
</indexterm> flag, or
the <option>-fglasgow-exts</option><indexterm><primary><option>-fglasgow-exts</option></primary>
</indexterm> flag which implies <option>-fffi</option>
.</para>
<para>To enable FFI support in GHC, give the <option>-XForeignFunctionInterface</option><indexterm><primary><option>-XForeignFunctionInterface</option></primary>
</indexterm> flag.</para>
<para>GHC implements a number of GHC-specific extensions to the FFI
Addendum. These extensions are described in <xref linkend="ffi-ghcexts" />, but please note that programs using
......
......@@ -881,10 +881,10 @@
<entry><option>-XNoRecordWildCards</option></entry>
</row>
<row>
<entry><option>-XRecordPuns</option></entry>
<entry><option>-XNamedFieldPuns</option></entry>
<entry>Enable <link linkend="record-puns">record puns</link>.</entry>
<entry>dynamic</entry>
<entry><option>-XNoRecordPuns</option></entry>
<entry><option>-XNoNamedFieldPuns</option></entry>
</row>
<row>
<entry><option>-XDisambiguateRecordFields</option></entry>
......@@ -1011,6 +1011,13 @@
<entry><option>-fno-warn-deprecations</option></entry>
</row>
<row>
<entry><option>-fwarn-deprecated-flags</option></entry>
<entry>warn about uses of commandline flags that are deprecated</entry>
<entry>dynamic</entry>
<entry><option>-fno-warn-deprecated-flags</option></entry>
</row>
<row>
<entry><option>-fwarn-duplicate-exports</option></entry>
<entry>warn when an entity is exported multiple times</entry>
......
......@@ -1410,7 +1410,7 @@ records from different modules that use the same field name.
</title>
<para>
Record puns are enabled by the flag <literal>-XRecordPuns</literal>.
Record puns are enabled by the flag <literal>-XNamedFieldPuns</literal>.
</para>
<para>
......@@ -3269,7 +3269,7 @@ corresponding type in the instance declaration.
These restrictions ensure that context reduction terminates: each reduction
step makes the problem smaller by at least one
constructor. Both the Paterson Conditions and the Coverage Condition are lifted
if you give the <option>-fallow-undecidable-instances</option>
if you give the <option>-XUndecidableInstances</option>
flag (<xref linkend="undecidable-instances"/>).
You can find lots of background material about the reason for these
restrictions in the paper <ulink
......
......@@ -55,7 +55,7 @@
example, if it picks up a non-standard
<filename>Prelude.hi</filename> file, pretty terrible things
will happen. If you turn on
<option>-fno-implicit-prelude</option><indexterm><primary>-fno-implicit-prelude
<option>-XNoImplicitPrelude</option><indexterm><primary>-XNoImplicitPrelude
option</primary></indexterm>, the compiler will almost
surely die, unless you know what you are doing.</para>
......
......@@ -842,6 +842,7 @@ ghc -c Foo.hs</screen>
program. These are:
<option>-fwarn-overlapping-patterns</option>,
<option>-fwarn-deprecations</option>,
<option>-fwarn-deprecated-flags</option>,
<option>-fwarn-duplicate-exports</option>,
<option>-fwarn-missing-fields</option>, and
<option>-fwarn-missing-methods</option>. The following flags are
......@@ -930,6 +931,19 @@ ghc -c Foo.hs</screen>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-fwarn-deprecated-flags</option>:</term>
<listitem>
<indexterm><primary><option>-fwarn-deprecated-flags</option></primary>
</indexterm>
<indexterm><primary>deprecated-flags</primary></indexterm>
<para>Causes a warning to be emitted when a deprecated
commandline flag is used.</para>
<para>This option is on by default.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-fwarn-dodgy-imports</option>:</term>
<listitem>
......@@ -982,11 +996,11 @@ ghc -c Foo.hs</screen>
imported. This happens unless either the Prelude module is
explicitly imported with an <literal>import ... Prelude ...</literal>
line, or this implicit import is disabled (either by
<option>-fno-implicit-prelude</option> or a
<option>-XNoImplicitPrelude</option> or a
<literal>LANGUAGE NoImplicitPrelude</literal> pragma).</para>
<para>Note that no warning is given for syntax that implicitly
refers to the Prelude, even if <option>-fno-implicit-prelude</option>
refers to the Prelude, even if <option>-XNoImplicitPrelude</option>
would change whether it refers to the Prelude.
For example, no warning is given when
<literal>368</literal> means
......
......@@ -90,6 +90,10 @@ space=$(empty) $(empty)
# -----------------------------------------------------------------------------
ifeq "$(ghc_ge_609)" "YES"
GhcLibHcOpts += -fno-warn-deprecated-flags
endif
ifeq "$(RelocatableBuild)" "YES"
# On Windows we want to make moveable bindists, but we need to tell
# ghc-pkg where the haddock docs are. Therefore we completely ignore
......
......@@ -15,6 +15,8 @@ GHC := $(SAVE_GHC)
AR := $(SAVE_AR)
LD := $(SAVE_LD)
GhcLibHcOpts += -fno-warn-deprecated-flags
# Now add flags from the GHC build system to the Cabal build:
GHC_CC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
GHC_OPTS += $(SRC_HC_OPTS)
......
......@@ -35,7 +35,7 @@ SRC_HC_OPTS = -O -H64m
GhcStage1HcOpts = -O -fasm
GhcStage2HcOpts = -O2 -fasm
GhcHcOpts = -Rghc-timing
GhcLibHcOpts = -O2 -fgenerics
GhcLibHcOpts = -O2 -XGenerics
GhcLibWays = p
endif
......
......@@ -402,12 +402,12 @@ GhcThreaded = $(if $(findstring thr,$(GhcRTSWays)),YES,NO)
# -O(2) is pretty desirable, otherwise no inlining of prelude
# things (incl "+") happens when compiling with this compiler
#
# -fgenerics switches on generation of support code for
# -XGenerics switches on generation of support code for
# derivable type classes. This is now off by default,
# but we switch it on for the libraries so that we generate
# the code in case someone importing wants it
GhcLibHcOpts=-O2 -Rghc-timing -fgenerics
GhcLibHcOpts=-O2 -Rghc-timing -XGenerics
# Win32 only: Enable the RTS and libraries to be built as DLLs
DLLized=@EnableWin32DLLs@
......
......@@ -129,12 +129,12 @@ SRC_HC_OPTS += $(GhcLibHcOpts)
SRC_HC_OPTS += $(patsubst %, -package %, $(PACKAGE_DEPS))
endif
# -fgenerics switches on generation of support code for
# -XGenerics switches on generation of support code for
# derivable type classes. This is now off by default,
# but we switch it on for the libraries so that we generate
# the code in case someone importing wants it.
ifeq "$(NON_HS_PACKAGE)" ""
SRC_HC_OPTS += -fgenerics
SRC_HC_OPTS += -XGenerics
endif
ifndef LIBRARY
......
......@@ -2,7 +2,7 @@
-- Replacement for GHC.Unicode module
{-# OPTIONS -fno-implicit-prelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS -#include "WCsubst.h" #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
......
......@@ -465,9 +465,9 @@ gen_latex_doc (Info defaults entries)
gen_wrappers :: Info -> String
gen_wrappers (Info _ entries)
= "{-# OPTIONS -fno-implicit-prelude #-}\n"
= "{-# LANGUAGE NoImplicitPrelude #-}\n"
-- Dependencies on Prelude must be explicit in libraries/base, but we
-- don't need the Prelude here so we add -fno-implicit-prelude.
-- don't need the Prelude here so we add NoImplicitPrelude.
++ "module GHC.PrimopWrappers where\n"
++ "import qualified GHC.Prim\n"
++ unlines (map f (filter (not.dodgy) (filter is_primop entries)))
......
{-# OPTIONS -fffi -cpp #-}
{-# LANGUAGE CPP, ForeignFunctionInterface #-}
------------------------------------------------------------------------
-- Program for converting .hsc files to .hs files, by converting the
......
{-# OPTIONS -cpp -fffi #-}
{-# LANGUAGE CPP, ForeignFunctionInterface #-}
#if __GLASGOW_HASKELL__ < 603
#include "config.h"
#else
......
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