From: Simon Marlow Date: Wed, 1 Jul 2009 12:23:54 +0000 (+0000) Subject: Fix #2197 (properly this time) X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=2fb511a805af6fc2932e3577139513b0d0992070 Fix #2197 (properly this time) $ ./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 --- diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 0e9efb6..8eb94f1 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -39,7 +39,6 @@ import Outputable hiding (printForUser, printForUserPartWay) import Module -- for ModuleEnv import Name import SrcLoc -import ObjLink -- Other random utilities import CmdLineParser @@ -54,11 +53,7 @@ import NameSet import Maybes ( orElse, expectJust ) import FastString import Encoding - -#if __GLASGOW_HASKELL__ < 611 import Foreign.C -import Encoding -#endif #ifndef mingw32_HOST_OS import System.Posix hiding (getEnv) @@ -296,14 +291,16 @@ findEditor = do return "" #endif +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) - 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 diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c index dda9660..3091aa1 100644 --- a/rts/RtsUtils.c +++ b/rts/RtsUtils.c @@ -465,3 +465,13 @@ void printRtsInfo(void) { printf(" ]\n"); } +// 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 +} diff --git a/rts/RtsUtils.h b/rts/RtsUtils.h index fea1d41..11a2826 100644 --- a/rts/RtsUtils.h +++ b/rts/RtsUtils.h @@ -49,4 +49,6 @@ extern void __hscore_set_saved_termios(int fd, void* ts); void printRtsInfo(void); +int rts_isProfiled(void); + #endif /* RTSUTILS_H */