Cheng Shao pushed to branch wip/set-keep-cafs-by-need at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC.hs
    ... ... @@ -463,6 +463,9 @@ import System.Exit ( exitWith, ExitCode(..) )
    463 463
     import System.FilePath
    
    464 464
     import System.IO.Error  ( isDoesNotExistError )
    
    465 465
     
    
    466
    +#if defined(HAVE_INTERNAL_INTERPRETER)
    
    467
    +import Foreign.C
    
    468
    +#endif
    
    466 469
     
    
    467 470
     -- %************************************************************************
    
    468 471
     -- %*                                                                      *
    
    ... ... @@ -597,12 +600,12 @@ withCleanupSession ghc = ghc `MC.finally` cleanup
    597 600
     
    
    598 601
     initGhcMonad :: GhcMonad m => Maybe FilePath -> m ()
    
    599 602
     initGhcMonad mb_top_dir = setSession =<< liftIO ( do
    
    600
    -#if !defined(javascript_HOST_ARCH)
    
    603
    +#if defined(HAVE_INTERNAL_INTERPRETER)
    
    601 604
         -- The call to c_keepCAFsForGHCi must not be optimized away. Even in non-debug builds.
    
    602 605
         -- So we can't use assertM here.
    
    603 606
         -- See Note [keepCAFsForGHCi] in keepCAFsForGHCi.c for details about why.
    
    604 607
         !keep_cafs <- c_keepCAFsForGHCi
    
    605
    -    massert keep_cafs
    
    608
    +    massert $ keep_cafs /= 0
    
    606 609
     #endif
    
    607 610
         initHscEnv mb_top_dir
    
    608 611
       )
    
    ... ... @@ -2092,7 +2095,7 @@ mkApiErr :: DynFlags -> SDoc -> GhcApiError
    2092 2095
     mkApiErr dflags msg = GhcApiError (showSDoc dflags msg)
    
    2093 2096
     
    
    2094 2097
     
    
    2095
    -#if !defined(javascript_HOST_ARCH)
    
    2098
    +#if defined(HAVE_INTERNAL_INTERPRETER)
    
    2096 2099
     foreign import ccall unsafe "keepCAFsForGHCi"
    
    2097
    -    c_keepCAFsForGHCi   :: IO Bool
    
    2100
    +    c_keepCAFsForGHCi   :: IO CBool
    
    2098 2101
     #endif

  • compiler/cbits/keepCAFsForGHCi.c
    ... ... @@ -21,7 +21,7 @@
    21 21
     //   the constructor to be run, allowing the assertion to succeed in the first place
    
    22 22
     //   as keepCAFs will have been set already during initialization of constructors.
    
    23 23
     
    
    24
    -
    
    24
    +#if defined(HAVE_INTERNAL_INTERPRETER)
    
    25 25
     
    
    26 26
     bool keepCAFsForGHCi(void) __attribute__((constructor));
    
    27 27
     
    
    ... ... @@ -32,4 +32,4 @@ bool keepCAFsForGHCi(void)
    32 32
         return was_set;
    
    33 33
     }
    
    34 34
     
    
    35
    -
    35
    +#endif