Ticket #1407: fix_T1407.patch

File fix_T1407.patch, 3.7 KB (added by archblob, 5 years ago)
  • compiler/ghci/Linker.lhs

    From aacbc02cd677a07009a490eed0c658a61b331b8f Mon Sep 17 00:00:00 2001
    From: archblob <fcsernik@gmail.com>
    Date: Tue, 26 Aug 2014 07:52:08 +0300
    Subject: [PATCH] Add the ability to :set -l{foo} in ghci, fix #1407.
    
    ---
     compiler/ghci/Linker.lhs | 29 ++++++++++++++++++++---------
     ghc/InteractiveUI.hs     | 13 ++++++++++++-
     2 files changed, 32 insertions(+), 10 deletions(-)
    
    diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs
    index 86d7b26..ad2f5a5 100644
    a b module Linker ( getHValue, showLinkerState, 
    1717                extendLinkEnv, deleteFromLinkEnv,
    1818                extendLoadedPkgs,
    1919                linkPackages,initDynLinker,linkModule,
     20                linkCmdLineLibs,
    2021
    2122                -- Saving/restoring globals
    2223                PersistentLinkerState, saveLinkerGlobals, restoreLinkerGlobals
    reallyInitDynLinker dflags = 
    285286          -- (b) Load packages from the command-line (Note [preload packages])
    286287        ; pls <- linkPackages' dflags (preloadPackages (pkgState dflags)) pls0
    287288
    288           -- (c) Link libraries from the command-line
    289         ; let cmdline_ld_inputs = ldInputs dflags
     289          -- steps (c), (d) and (e)
     290        ; linkCmdLineLibs' dflags pls
     291        }
     292
     293linkCmdLineLibs :: DynFlags -> IO ()
     294linkCmdLineLibs dflags = do
     295  initDynLinker dflags
     296  modifyPLS_ $ \pls -> do
     297    linkCmdLineLibs' dflags pls
     298
     299linkCmdLineLibs' :: DynFlags -> PersistentLinkerState -> IO PersistentLinkerState
     300linkCmdLineLibs' dflags@(DynFlags { ldInputs     = cmdline_ld_inputs
     301                                  , libraryPaths = lib_paths}) pls =
     302  do  {   -- (c) Link libraries from the command-line
    290303        ; let minus_ls = [ lib | Option ('-':'l':lib) <- cmdline_ld_inputs ]
    291         ; let lib_paths = libraryPaths dflags
    292304        ; libspecs <- mapM (locateLib dflags False lib_paths) minus_ls
    293305
    294306          -- (d) Link .o files from the command-line
    reallyInitDynLinker dflags = 
    297309
    298310          -- (e) Link any MacOS frameworks
    299311        ; let platform = targetPlatform dflags
    300         ; let framework_paths = if platformUsesFrameworks platform
    301                                 then frameworkPaths dflags
    302                                 else []
    303         ; let frameworks = if platformUsesFrameworks platform
    304                            then cmdlineFrameworks dflags
    305                            else []
     312        ; let (framework_paths, frameworks) =
     313                if platformUsesFrameworks platform
     314                 then (frameworkPaths dflags, cmdlineFrameworks dflags)
     315                  else ([],[])
     316         
    306317          -- Finally do (c),(d),(e)
    307318        ; let cmdline_lib_specs = [ l | Just l <- classified_ld_inputs ]
    308319                               ++ libspecs
  • ghc/InteractiveUI.hs

    diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
    index 3d871d9..0431390 100644
    a b newDynFlags interactive_only minus_opts = do 
    21442144          GHC.setInteractiveDynFlags
    21452145              idflags{ pkgState = pkgState dflags2
    21462146                     , pkgDatabase = pkgDatabase dflags2
    2147                      , packageFlags = packageFlags dflags2 }
     2147                     , packageFlags = packageFlags dflags2
     2148
     2149        let ld0length   = length $ ldInputs dflags0
     2150            fmrk0length = length $ cmdlineFrameworks dflags0
     2151
     2152            newLdInputs     = drop ld0length (ldInputs dflags2)
     2153            newCLFrameworks = drop fmrk0length (cmdlineFrameworks dflags2)
     2154         
     2155        when (not (null newLdInputs && null newCLFrameworks)) $
     2156          liftIO $ linkCmdLineLibs $
     2157            dflags2 { ldInputs = newLdInputs
     2158                    , cmdlineFrameworks = newCLFrameworks }
    21482159
    21492160      return ()
    21502161