Commit 5cd20c40 authored by simonpj@microsoft.com's avatar simonpj@microsoft.com
Browse files

The templateHaskellOk check should only run in stage2

Because rtsIsProfiled is only available in stage2
parent fd316eba
...@@ -61,7 +61,12 @@ module DynFlags ( ...@@ -61,7 +61,12 @@ module DynFlags (
-- * Compiler configuration suitable for display to the user -- * Compiler configuration suitable for display to the user
Printable(..), Printable(..),
compilerInfo, rtsIsProfiled compilerInfo
#ifdef GHCI
-- Only in stage 2 can we be sure that the RTS
-- exposes the appropriate runtime boolean
, rtsIsProfiled
#endif
) where ) where
#include "HsVersions.h" #include "HsVersions.h"
...@@ -1810,12 +1815,13 @@ glasgowExtsFlags = [ ...@@ -1810,12 +1815,13 @@ glasgowExtsFlags = [
, Opt_GeneralizedNewtypeDeriving , Opt_GeneralizedNewtypeDeriving
, Opt_TypeFamilies ] , Opt_TypeFamilies ]
#ifdef GHCI
-- Consult the RTS to find whether GHC itself has been built profiled -- Consult the RTS to find whether GHC itself has been built profiled
-- If so, you can't use Template Haskell -- If so, you can't use Template Haskell
foreign import ccall unsafe "rts_isProfiled" rtsIsProfiledIO :: IO CInt foreign import ccall unsafe "rts_isProfiled" rtsIsProfiledIO :: IO CInt
rtsIsProfiled :: Bool rtsIsProfiled :: Bool
rtsIsProfiled = False -- unsafePerformIO rtsIsProfiledIO /= 0 rtsIsProfiled = unsafePerformIO rtsIsProfiledIO /= 0
checkTemplateHaskellOk :: Bool -> DynP () checkTemplateHaskellOk :: Bool -> DynP ()
checkTemplateHaskellOk turn_on checkTemplateHaskellOk turn_on
...@@ -1823,6 +1829,12 @@ checkTemplateHaskellOk turn_on ...@@ -1823,6 +1829,12 @@ checkTemplateHaskellOk turn_on
= addErr "You can't use Template Haskell with a profiled compiler" = addErr "You can't use Template Haskell with a profiled compiler"
| otherwise | otherwise
= return () = return ()
#else
-- In stage 1 we don't know that the RTS has rts_isProfiled,
-- so we simply say "ok". It doesn't matter because TH isn't
-- available in stage 1 anyway.
checkTemplateHaskellOk turn_on = return ()
#endif
{- ********************************************************************** {- **********************************************************************
%* * %* *
......
Supports Markdown
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