$ ./inplace/bin/ghc-stage2 --interactive
GHCi, version 6.11.
20090701: http://www.haskell.org/ghc/ :? for help
ghc-stage2: GHCi cannot be used when compiled with -prof
[1] 32473 exit 1 ./inplace/bin/ghc-stage2 --interactive
import Module -- for ModuleEnv
import Name
import SrcLoc
import Module -- for ModuleEnv
import Name
import SrcLoc
-- Other random utilities
import CmdLineParser
-- Other random utilities
import CmdLineParser
import Maybes ( orElse, expectJust )
import FastString
import Encoding
import Maybes ( orElse, expectJust )
import FastString
import Encoding
-
-#if __GLASGOW_HASKELL__ < 611
#ifndef mingw32_HOST_OS
import System.Posix hiding (getEnv)
#ifndef mingw32_HOST_OS
import System.Posix hiding (getEnv)
+foreign import ccall unsafe "rts_isProfiled" isProfiled :: IO CInt
+
interactiveUI :: [(FilePath, Maybe Phase)] -> Maybe [String]
-> Ghc ()
interactiveUI srcs maybe_exprs = do
-- although GHCi compiles with -prof, it is not usable: the byte-code
-- compiler and interpreter don't work with profiling. So we check for
-- this up front and emit a helpful error message (#2197)
interactiveUI :: [(FilePath, Maybe Phase)] -> Maybe [String]
-> Ghc ()
interactiveUI srcs maybe_exprs = do
-- although GHCi compiles with -prof, it is not usable: the byte-code
-- compiler and interpreter don't work with profiling. So we check for
-- this up front and emit a helpful error message (#2197)
- m <- liftIO $ lookupSymbol "PushCostCentre"
- when (isJust m) $
+ i <- liftIO $ isProfiled
+ when (i /= 0) $
ghcError (InstallationError "GHCi cannot be used when compiled with -prof")
-- HACK! If we happen to get into an infinite loop (eg the user
ghcError (InstallationError "GHCi cannot be used when compiled with -prof")
-- HACK! If we happen to get into an infinite loop (eg the user
+// Provides a way for Haskell programs to tell whether they're being
+// profiled or not. GHCi uses it (see #2197).
+int rts_isProfiled(void)
+{
+#ifdef PROFILING
+ return 1;
+#else
+ return 0;
+#endif
+}
+int rts_isProfiled(void);
+