[GHC] #11223: Runtime linker performs eager loading of all object files (was: Dynamic linker on Windows is unable to link against libmingwex)

GHC ghc-devs at haskell.org
Sun Jan 17 22:39:54 UTC 2016


#11223: Runtime linker performs eager loading of all object files
-------------------------------------+-------------------------------------
        Reporter:  Phyx-             |                Owner:  Phyx-
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Runtime System    |              Version:  7.10.3
  (Linker)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Compile-time      |  Unknown/Multiple
  crash                              |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #10726            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by Phyx-):

 * os:  Windows => Unknown/Multiple


Comment:

 The Runtime Linker is currently eagerly loading all object files on all
 platforms which do not use the system linker for `GHCi`.

 After talking with @rwbarton I have taken the approach of loading entire
 object files when a symbol is needed instead of doing the dependency
 tracking on a per symbol basis. This is a lot less fragile and a lot less
 complicated to implement.

 The changes come down to the following steps:

 1) modify the linker to keep a list of required symbols. Required symbols
 are any symbols that are passed in from `.o` arguments to `GHCi`.

 2) Change `ObjectCode`'s to be indexed but not initialized or resolved.
 This means we know where we would load the symbols, but haven't actually
 done so.

 3) Mark any `ObjectCode` belonging to `.o` passed as argument as required
 `loadObject`.

 4) During `Resolve` object calls, mark all `ObjectCode` containing the
 required symbols as `loadObject`

 5) During `lookupSymbol` lookups, (which is called from `linkExpr` and
 `linkDecl` in `GHCI.hs`) is the symbol is in a not-yet-loaded `ObjectCode`
 then load the `ObjectCode` on demand and return the address of the symbol.
 Otherwise produce an unresolved symbols error as expected.

 This change affects all platforms and OSes which use the runtime linker.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11223#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list